33import static android .provider .Settings .ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS ;
44import static android .provider .Settings .ACTION_REQUEST_SCHEDULE_EXACT_ALARM ;
55
6+ import android .annotation .SuppressLint ;
67import android .app .AlarmManager ;
78import android .app .AlertDialog ;
89import android .app .PendingIntent ;
2425import android .text .method .LinkMovementMethod ;
2526import android .util .Log ;
2627import android .view .View ;
27- import android .widget .AdapterView ;
28- import android .widget .ArrayAdapter ;
29- import android .widget .Spinner ;
3028import android .widget .TextView ;
3129import 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 );
0 commit comments