Skip to content

Commit 763ece1

Browse files
committed
Remove old interval code
1 parent 29ebc3c commit 763ece1

File tree

3 files changed

+8
-78
lines changed

3 files changed

+8
-78
lines changed

app/src/main/java/com/arks_layer/pso2_alert/MainActivity.java

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS;
44
import static android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM;
55

6+
import android.annotation.SuppressLint;
67
import android.app.AlarmManager;
78
import android.app.AlertDialog;
89
import android.app.PendingIntent;
@@ -24,9 +25,6 @@
2425
import android.text.method.LinkMovementMethod;
2526
import android.util.Log;
2627
import android.view.View;
27-
import android.widget.AdapterView;
28-
import android.widget.ArrayAdapter;
29-
import android.widget.Spinner;
3028
import android.widget.TextView;
3129
import android.widget.Toast;
3230

@@ -181,7 +179,7 @@ private void configureUnoptimised()
181179
alert.setNeutralButton("Ok", (dialog, whichButton) -> {
182180
showToast(context, getString(R.string.toast_message_battery), Toast.LENGTH_LONG);
183181

184-
Intent requestIntent = new Intent(ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
182+
@SuppressLint("BatteryLife") Intent requestIntent = new Intent(ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
185183
requestIntent.setData(Uri.parse("package:" + packageName));
186184
startActivity(requestIntent);
187185
});
@@ -293,7 +291,7 @@ private void getAlertList()
293291
Log.d("MainActivity", "Using the following server URL at " + serverURL);
294292

295293
//Download data from server
296-
String apiData = null;
294+
String apiData;
297295
try {
298296
apiData = WebHelper.getStringData(new URL(serverURL));
299297
} catch (Exception e) {
@@ -303,7 +301,6 @@ private void getAlertList()
303301
return;
304302
}
305303
//Split by newline
306-
//String[] apiEntries = apiData.split("\\R");
307304
String[] apiEntries = apiData.split("<br>");
308305
Log.d("MainActivity", "Received " + apiEntries.length + " alert titles from the Resources API");
309306

@@ -352,7 +349,7 @@ private void getAppMessage()
352349
});
353350

354351
//Download data from server
355-
String apiData = null;
352+
String apiData;
356353
try {
357354
apiData = WebHelper.getStringData(new URL(serverURL));
358355
} catch (Exception e) {
@@ -398,32 +395,6 @@ private void configureUserSettings()
398395
lblServersFail.setVisibility(View.VISIBLE);
399396
lblAlertsFail.setVisibility(View.VISIBLE);
400397
}
401-
402-
Spinner settingInterval = findViewById(R.id.settingInterval);
403-
ArrayAdapter adapterInterval = ArrayAdapter.createFromResource(this, R.array.intervals, R.layout.spinner_item);
404-
adapterInterval.setDropDownViewResource(R.layout.spinner_item_dropdown);
405-
settingInterval.setAdapter(adapterInterval);
406-
settingInterval.setSelection(adapterInterval.getPosition(String.valueOf(sharedPref.getInt(getString(R.string.setting_interval), 10))), false);
407-
408-
settingInterval.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
409-
@Override
410-
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
411-
try
412-
{
413-
Integer newInterval = Integer.valueOf(String.valueOf(parent.getItemAtPosition(position)));
414-
sharedPref.putInt(getString(R.string.setting_interval), newInterval);
415-
showToast(MainActivity.this, "Check interval has been set to " + newInterval + " minutes!", Toast.LENGTH_LONG);
416-
Log.i("MainActivity", "Check interval has been set to " + newInterval + " minutes");
417-
}
418-
catch (Exception e)
419-
{
420-
Log.e("MainActivity", "Setting Interval: " + e.getMessage());
421-
e.printStackTrace();
422-
}
423-
}
424-
@Override
425-
public void onNothingSelected(AdapterView<?> arg0) { }
426-
});
427398
}
428399

429400
@Override
@@ -439,6 +410,7 @@ protected void onResume() {
439410
}
440411
}
441412

413+
@SuppressLint("SetTextI18n")
442414
@Override
443415
protected void onCreate(Bundle savedInstanceState) {
444416
super.onCreate(savedInstanceState);

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
android:layout_height="0dp"
3232
android:layout_marginBottom="2dp"
3333
android:clickable="true"
34+
android:contentDescription="@string/desc_exit_button"
3435
app:layout_constraintBottom_toBottomOf="@id/materialToolbar"
3536
app:layout_constraintEnd_toEndOf="@id/materialToolbar"
3637
app:layout_constraintHeight="match_constraint"
@@ -110,51 +111,6 @@
110111
app:layout_constraintStart_toStartOf="parent"
111112
app:layout_constraintTop_toBottomOf="@+id/materialToolbar" />
112113

113-
<LinearLayout
114-
android:id="@+id/layout_interval"
115-
android:layout_width="match_parent"
116-
android:layout_height="match_parent"
117-
android:orientation="horizontal">
118-
119-
<TextView
120-
android:id="@+id/lblSettingTimer2"
121-
android:layout_width="wrap_content"
122-
android:layout_height="48dp"
123-
android:layout_weight="1"
124-
android:duplicateParentState="false"
125-
android:editable="false"
126-
android:gravity="center|left"
127-
android:text="Check Interval:"
128-
android:textAllCaps="false"
129-
android:textColor="@color/general_text"
130-
android:textSize="20sp"
131-
android:visibility="gone" />
132-
133-
<Spinner
134-
android:id="@+id/settingInterval"
135-
android:layout_width="wrap_content"
136-
android:layout_height="match_parent"
137-
android:layout_weight="1"
138-
android:backgroundTint="@color/general_text"
139-
android:visibility="gone" />
140-
141-
<TextView
142-
android:id="@+id/lblSettingMinutes"
143-
android:layout_width="100sp"
144-
android:layout_height="48dp"
145-
android:duplicateParentState="false"
146-
android:editable="false"
147-
android:gravity="center|left"
148-
android:text="minutes"
149-
android:textAlignment="gravity"
150-
android:textAllCaps="false"
151-
android:textColor="#99E3FF"
152-
android:textIsSelectable="false"
153-
android:textSize="20sp"
154-
android:visibility="gone" />
155-
156-
</LinearLayout>
157-
158114
<TextView
159115
android:id="@+id/lblHeaderServers"
160116
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@
6767
<string name="toast_message_alert_list_failed">Failed to download the list of Alerts: %1$s</string>
6868
<string name="toast_message_manual_check">Manually checking for alerts.</string>
6969
<string name="toast_message_exit">&appname; will now exit.</string>
70+
71+
<string name="desc_exit_button">The letter X inside a box</string>
7072
</resources>

0 commit comments

Comments
 (0)