| 
						
					 | 
					 | 
					@@ -21,7 +21,7 @@ import java.util.Map;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					public class MainActivity extends AppCompatActivity {
 | 
					 | 
					 | 
					 | 
					public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    String TAG,
 | 
					 | 
					 | 
					 | 
					    String TAG = "MainActivity.",
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            keySharedPreferences, keyDebug, keyChronometerTime, keyLoopInterval,
 | 
					 | 
					 | 
					 | 
					            keySharedPreferences, keyDebug, keyChronometerTime, keyLoopInterval,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            keyStartStop, keyAppOpen, keyServiceRunning,
 | 
					 | 
					 | 
					 | 
					            keyStartStop, keyAppOpen, keyServiceRunning,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            stringChronometerDefault, stringChronometerTime, stringLoopInterval;
 | 
					 | 
					 | 
					 | 
					            stringChronometerDefault, stringChronometerTime, stringLoopInterval;
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -48,6 +48,9 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override
 | 
					 | 
					 | 
					 | 
					    @Override
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
					 | 
					 | 
					 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        String tag = "onCreate";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        super.onCreate(savedInstanceState);
 | 
					 | 
					 | 
					 | 
					        super.onCreate(savedInstanceState);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setContentView(R.layout.activity_main);
 | 
					 | 
					 | 
					 | 
					        setContentView(R.layout.activity_main);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -55,7 +58,6 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
 | 
					 | 
					 | 
					 | 
					        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        /***** Get Strings *****/
 | 
					 | 
					 | 
					 | 
					        /***** Get Strings *****/
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        TAG = getString(R.string.TAG);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        keySharedPreferences = getString(R.string.keySharedPreferences);
 | 
					 | 
					 | 
					 | 
					        keySharedPreferences = getString(R.string.keySharedPreferences);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        keyDebug = getString(R.string.keyDebug);
 | 
					 | 
					 | 
					 | 
					        keyDebug = getString(R.string.keyDebug);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        keyChronometerTime = getString(R.string.keyChronometerTime);
 | 
					 | 
					 | 
					 | 
					        keyChronometerTime = getString(R.string.keyChronometerTime);
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -68,34 +70,33 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        /***** Shared Preferences *****/
 | 
					 | 
					 | 
					 | 
					        /***** Shared Preferences *****/
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sharedPreferences = getSharedPreferences(keySharedPreferences, MODE_PRIVATE);
 | 
					 | 
					 | 
					 | 
					        sharedPreferences = getSharedPreferences(keySharedPreferences, MODE_PRIVATE);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // TODO: Comment these lines!
 | 
					 | 
					 | 
					 | 
					        DEBUG = sharedPreferences.getBoolean(keyDebug, true);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //sharedPreferences.edit().putBoolean(keyDebug, true).apply();
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //sharedPreferences.edit().putString(keyLoopInterval, stringChronometerDefault).apply();
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //sharedPreferences.edit().putString(keyChronometerTime, stringChronometerDefault).apply();
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // TODO: Keep these!
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        DEBUG = sharedPreferences.getBoolean(keyDebug, false);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        appOpen = sharedPreferences.getBoolean(keyAppOpen, false);
 | 
					 | 
					 | 
					 | 
					        appOpen = sharedPreferences.getBoolean(keyAppOpen, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        /*
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!appOpen && !serviceRunning) {
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        */
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Sound
 | 
					 | 
					 | 
					 | 
					        // Sound
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 | 
					 | 
					 | 
					 | 
					        ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mediaPlayer = MediaPlayer.create(this, ringtoneUri);
 | 
					 | 
					 | 
					 | 
					        mediaPlayer = MediaPlayer.create(this, ringtoneUri);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.onCreate!  Got strings.");
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Got strings.");
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG){
 | 
					 | 
					 | 
					 | 
					        if (DEBUG){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // Print all preferences
 | 
					 | 
					 | 
					 | 
					            // Print all preferences
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            Map<String, ?> sharedPreferencesAll = sharedPreferences.getAll();
 | 
					 | 
					 | 
					 | 
					            Map<String, ?> sharedPreferencesAll = sharedPreferences.getAll();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            for (String key : sharedPreferencesAll.keySet()){
 | 
					 | 
					 | 
					 | 
					            for (String key : sharedPreferencesAll.keySet()){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                Log.d(TAG, "MainActivity.onCreate!  key=" + key + " value=" + sharedPreferencesAll.get(key));
 | 
					 | 
					 | 
					 | 
					                String value = sharedPreferencesAll.get(key).toString();
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                Log.d(tag, "key=" + key + " value=" + value);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                // If app crashed, ensure buttons are correct.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (key.equals(keyStartStop) && value.equals("true")) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    if (DEBUG) Log.d(tag, "Shutting off improper START value");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    // Ensure START is always off if we are creating (not resuming).
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    Log.d(tag, "key=" + key + " value=" + sharedPreferencesAll.get(key));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -152,18 +153,22 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
 | 
					 | 
					 | 
					 | 
					        //sharedPreferences.edit().putBoolean(keyStartStop, false).apply();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        recoverScreen();
 | 
					 | 
					 | 
					 | 
					        recoverScreen();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.onCreate!  Finished.");
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void doTimeChooser(){
 | 
					 | 
					 | 
					 | 
					    private void doTimeChooser(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.openTimeChooser!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "doTimeChooser";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //stringLoopInterval = "00:00:07";
 | 
					 | 
					 | 
					 | 
					        //stringLoopInterval = "00:00:07";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //setEditTexts(stringLoopInterval);
 | 
					 | 
					 | 
					 | 
					        //setEditTexts(stringLoopInterval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void setEditTexts(String interval){
 | 
					 | 
					 | 
					 | 
					    private void setEditTexts(String interval){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setEditTexts! interval=" + interval);
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "setEditTexts";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting, interval=" + interval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!interval.equals(stringChronometerDefault)) {
 | 
					 | 
					 | 
					 | 
					        if (!interval.equals(stringChronometerDefault)) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            String[] time = interval.split(":");
 | 
					 | 
					 | 
					 | 
					            String[] time = interval.split(":");
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -187,23 +192,59 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setLoopInterval();
 | 
					 | 
					 | 
					 | 
					        setLoopInterval();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void setLoopInterval(){
 | 
					 | 
					 | 
					 | 
					    private void setLoopInterval(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setLoopInterval!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "setLoopInterval";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int hours = Integer.parseInt("0"+etHours.getText().toString());
 | 
					 | 
					 | 
					 | 
					        int hours = 0, minutes = 0, seconds = 0;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int minutes = Integer.parseInt("0"+etMinutes.getText().toString());
 | 
					 | 
					 | 
					 | 
					        try {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int seconds = Integer.parseInt("0"+etSeconds.getText().toString());
 | 
					 | 
					 | 
					 | 
					            hours = Integer.parseInt("0" + etHours.getText().toString());
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } catch (NumberFormatException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            etHours.setText("");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        longLoopInterval = (((hours*60*60) + (minutes*60) + seconds) * 1000);
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setLoopInterval!  longLoopInterval=" + longLoopInterval);
 | 
					 | 
					 | 
					 | 
					        try {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            minutes = Integer.parseInt("0" + etMinutes.getText().toString());
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } catch (NumberFormatException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            etMinutes.setText("");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        try {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            seconds = Integer.parseInt("0" + etSeconds.getText().toString());
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } catch (NumberFormatException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            etSeconds.setText("");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // TODO: Properly handle hours being set to 999, which casues a negative.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // TODO: Properly handle time being greater than current time, such as
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        longLoopInterval = (long) (((hours*60*60) + (minutes*60) + seconds) * 1000);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (longLoopInterval > System.currentTimeMillis() || longLoopInterval < 0) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "Got a number larger than current time");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "Setting to current time value");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            longLoopInterval = System.currentTimeMillis();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            /* Not quite doing what we want yet.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            String sHours = "" + longLoopInterval/1000;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            String sMinutes = "" + longLoopInterval/1000/60 % 60;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            String sSeconds = "" + longLoopInterval/1000/60/60 % 60;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            etHours.setText(sHours);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            etMinutes.setText(sMinutes);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            etSeconds.setText(sSeconds);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            */
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "longLoopInterval=" + longLoopInterval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setChronometer(longLoopInterval);
 | 
					 | 
					 | 
					 | 
					        setChronometer(longLoopInterval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void setChronometer(long milliseconds){
 | 
					 | 
					 | 
					 | 
					    private void setChronometer(long milliseconds){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setChronometer!  milliseconds=" + milliseconds);
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "setChronometer";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting, milliseconds=" + milliseconds);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //chronometer = (TextView) findViewById(R.id.chronometer);
 | 
					 | 
					 | 
					 | 
					        //chronometer = (TextView) findViewById(R.id.chronometer);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -230,16 +271,18 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                doTimeChooser();
 | 
					 | 
					 | 
					 | 
					                doTimeChooser();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });*/
 | 
					 | 
					 | 
					 | 
					        });*/
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setChronometer!  display=" + display);
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "display=" + display);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sharedPreferences.edit().putString(keyChronometerTime, display).apply();
 | 
					 | 
					 | 
					 | 
					        sharedPreferences.edit().putString(keyChronometerTime, display).apply();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setChronometer!  Before=" + chronometer.getText());
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Before=" + chronometer.getText());
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        chronometer.setText(display);
 | 
					 | 
					 | 
					 | 
					        chronometer.setText(display);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setChronometer!  After=" + chronometer.getText());
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "After=" + chronometer.getText());
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void startStopChronometer(String buttonText){
 | 
					 | 
					 | 
					 | 
					    private void startStopChronometer(String buttonText){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.startStopChronometer!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "startStopChronometer";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        start = !start;
 | 
					 | 
					 | 
					 | 
					        start = !start;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        SharedPreferences.Editor editor = sharedPreferences.edit();
 | 
					 | 
					 | 
					 | 
					        SharedPreferences.Editor editor = sharedPreferences.edit();
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -275,10 +318,13 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        flipStartStopButton();
 | 
					 | 
					 | 
					 | 
					        flipStartStopButton();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        flipResetPauseButton();
 | 
					 | 
					 | 
					 | 
					        flipResetPauseButton();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void recoverScreen(){
 | 
					 | 
					 | 
					 | 
					    private void recoverScreen(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.recoverScreen!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "recoverScreen";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        /***** Retrieve the last settings *****/
 | 
					 | 
					 | 
					 | 
					        /***** Retrieve the last settings *****/
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Chronometer
 | 
					 | 
					 | 
					 | 
					        // Chronometer
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -291,6 +337,7 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Start/Stop Button
 | 
					 | 
					 | 
					 | 
					        // Start/Stop Button
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "start=" + start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        flipStartStopButton();
 | 
					 | 
					 | 
					 | 
					        flipStartStopButton();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        flipResetPauseButton();
 | 
					 | 
					 | 
					 | 
					        flipResetPauseButton();
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -302,10 +349,13 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //startStopChronometer(stringChronometerTime);
 | 
					 | 
					 | 
					 | 
					        //startStopChronometer(stringChronometerTime);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //incrementTime.sendEmptyMessage(0);
 | 
					 | 
					 | 
					 | 
					        //incrementTime.sendEmptyMessage(0);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void flipStartStopButton(){
 | 
					 | 
					 | 
					 | 
					    private void flipStartStopButton(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.flipStartStopButton!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "flipStartStopButton";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -320,10 +370,13 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            btnStartStop.setBackgroundColor(Color.GREEN);
 | 
					 | 
					 | 
					 | 
					            btnStartStop.setBackgroundColor(Color.GREEN);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void resetPauseChronometer(){
 | 
					 | 
					 | 
					 | 
					    private void resetPauseChronometer(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.resetPauseChronometer!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "resetPauseChronometer";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -334,10 +387,13 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        else{
 | 
					 | 
					 | 
					 | 
					        else{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            setEditTexts(stringChronometerDefault);
 | 
					 | 
					 | 
					 | 
					            setEditTexts(stringChronometerDefault);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void flipResetPauseButton(){
 | 
					 | 
					 | 
					 | 
					    private void flipResetPauseButton(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.flipResetPauseButton!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "flipResetPauseButton";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
					 | 
					 | 
					 | 
					        start = sharedPreferences.getBoolean(keyStartStop, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
					 | 
					 | 
					 | 
					        serviceRunning = sharedPreferences.getBoolean(keyServiceRunning, false);
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -350,13 +406,17 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            btnResetPause.setText(getString(R.string.btnReset));
 | 
					 | 
					 | 
					 | 
					            btnResetPause.setText(getString(R.string.btnReset));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            btnResetPause.setBackgroundColor(Color.RED);
 | 
					 | 
					 | 
					 | 
					            btnResetPause.setBackgroundColor(Color.RED);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final Handler incrementTime = new Handler(){
 | 
					 | 
					 | 
					 | 
					    private final Handler incrementTime = new Handler(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        @Override
 | 
					 | 
					 | 
					 | 
					        @Override
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        public void handleMessage(Message msg) {
 | 
					 | 
					 | 
					 | 
					        public void handleMessage(Message msg) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            String tag = TAG + "handleMessage";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            super.handleMessage(msg);
 | 
					 | 
					 | 
					 | 
					            super.handleMessage(msg);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.incrementTime.handleMessage!");
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            appOpen = sharedPreferences.getBoolean(keyAppOpen, true);
 | 
					 | 
					 | 
					 | 
					            appOpen = sharedPreferences.getBoolean(keyAppOpen, true);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (appOpen) {
 | 
					 | 
					 | 
					 | 
					            if (appOpen) {
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -373,7 +433,7 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                // Calculate new time and text
 | 
					 | 
					 | 
					 | 
					                // Calculate new time and text
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                setTimeLeft();
 | 
					 | 
					 | 
					 | 
					                setTimeLeft();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (DEBUG) Log.d(TAG, "MainActivity.incrementTime.handleMessage!  longTimeLeft=" + longTimeLeft);
 | 
					 | 
					 | 
					 | 
					                if (DEBUG) Log.d(tag, "longTimeLeft=" + longTimeLeft);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                // Check if we need to beep
 | 
					 | 
					 | 
					 | 
					                // Check if we need to beep
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (longTimeLeft < 1000){
 | 
					 | 
					 | 
					 | 
					                if (longTimeLeft < 1000){
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -382,12 +442,12 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    setStartTime();
 | 
					 | 
					 | 
					 | 
					                    setStartTime();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if (DEBUG) {
 | 
					 | 
					 | 
					 | 
					                    if (DEBUG) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Log.d(TAG, "MainActivity.incrementTime.handleMessage!C  longLoopInterval=" + longLoopInterval);
 | 
					 | 
					 | 
					 | 
					                        Log.d(tag, "longLoopInterval=" + longLoopInterval);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Log.d(TAG, "MainActivity.incrementTime.handleMessage!C  longStartTime=" + longStartTime);
 | 
					 | 
					 | 
					 | 
					                        Log.d(tag, "longStartTime=" + longStartTime);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Log.d(TAG, "MainActivity.incrementTime.handleMessage!C  longEndTime=" + longEndTime);
 | 
					 | 
					 | 
					 | 
					                        Log.d(tag, "longEndTime=" + longEndTime);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Log.d(TAG, "MainActivity.incrementTime.handleMessage!C  longTimeLeft=" + longTimeLeft);
 | 
					 | 
					 | 
					 | 
					                        Log.d(tag, "longTimeLeft=" + longTimeLeft);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Log.d(TAG, "MainActivity.incrementTime.handleMessage!C  waitInterval=" + waitInterval);
 | 
					 | 
					 | 
					 | 
					                        Log.d(tag, "waitInterval=" + waitInterval);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Log.d(TAG, "MainActivity.incrementTime.handleMessage!C  start=" + start);
 | 
					 | 
					 | 
					 | 
					                        Log.d(tag, "start=" + start);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        //chronometer.setText("Test");
 | 
					 | 
					 | 
					 | 
					                        //chronometer.setText("Test");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        //setChronometer(200);
 | 
					 | 
					 | 
					 | 
					                        //setChronometer(200);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        /*
 | 
					 | 
					 | 
					 | 
					                        /*
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -405,11 +465,11 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        synchronized (this){
 | 
					 | 
					 | 
					 | 
					                        synchronized (this){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            try{
 | 
					 | 
					 | 
					 | 
					                            try{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                wait(waitInterval);
 | 
					 | 
					 | 
					 | 
					                                wait(waitInterval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                if (DEBUG) Log.d(TAG, "MainActivity.incrementTime.handleMessage!  Done waiting.");
 | 
					 | 
					 | 
					 | 
					                                if (DEBUG) Log.d(tag, "Done waiting.");
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            }
 | 
					 | 
					 | 
					 | 
					                            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            catch (Exception e){
 | 
					 | 
					 | 
					 | 
					                            catch (Exception e){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                e.printStackTrace();
 | 
					 | 
					 | 
					 | 
					                                e.printStackTrace();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                if (DEBUG) Log.d(TAG, "MainActivity.incrementTime.handleMessage!  Failed to wait.");
 | 
					 | 
					 | 
					 | 
					                                if (DEBUG) Log.d(tag, "Failed to wait.");
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            }
 | 
					 | 
					 | 
					 | 
					                            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        }
 | 
					 | 
					 | 
					 | 
					                        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        //sharedPreferences.edit().putBoolean(keyStartStop, true).apply();
 | 
					 | 
					 | 
					 | 
					                        //sharedPreferences.edit().putBoolean(keyStartStop, true).apply();
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -420,45 +480,57 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                Thread t = new Thread(task);
 | 
					 | 
					 | 
					 | 
					                Thread t = new Thread(task);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                t.start();
 | 
					 | 
					 | 
					 | 
					                t.start();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    };
 | 
					 | 
					 | 
					 | 
					    };
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void setStartTime(){
 | 
					 | 
					 | 
					 | 
					    private void setStartTime(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "setStartTime";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "System.currentTimeMillis()=" + System.currentTimeMillis());
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (longTimeLeft == 0) {
 | 
					 | 
					 | 
					 | 
					        if (longTimeLeft == 0) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!  longTimeLeft==" + longTimeLeft);
 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "longTimeLeft=" + longTimeLeft);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // Add extra 1000 so timer starts on interval and beeps after 1
 | 
					 | 
					 | 
					 | 
					            // Add extra 1000 so timer starts on interval and beeps after 1
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            longStartTime = System.currentTimeMillis() + 1000 - waitInterval;
 | 
					 | 
					 | 
					 | 
					            longStartTime = System.currentTimeMillis() + 1000 - waitInterval;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!  longStartTime=" + longStartTime);
 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "longStartTime=" + longStartTime);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            longEndTime = longStartTime + longLoopInterval;
 | 
					 | 
					 | 
					 | 
					            longEndTime = longStartTime + longLoopInterval;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!  longEndTime=" + longEndTime);
 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "longEndTime=" + longEndTime);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        else{
 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "longTimeLeft=" + longTimeLeft);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!  longTimeLeft==" + longTimeLeft);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            longStartTime = System.currentTimeMillis() - waitInterval;
 | 
					 | 
					 | 
					 | 
					            longStartTime = System.currentTimeMillis() - waitInterval;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!  longStartTime=" + longStartTime);
 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "longStartTime=" + longStartTime);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            longEndTime = longStartTime + longTimeLeft;
 | 
					 | 
					 | 
					 | 
					            longEndTime = longStartTime + longTimeLeft;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(TAG, "MainActivity.setStartTime!  longEndTime=" + longEndTime);
 | 
					 | 
					 | 
					 | 
					            if (DEBUG) Log.d(tag, "longEndTime=" + longEndTime);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void setTimeLeft(){
 | 
					 | 
					 | 
					 | 
					    private void setTimeLeft(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setTimeLeft!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "setTimeLeft";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        longTimeLeft = longEndTime - System.currentTimeMillis() + waitInterval;
 | 
					 | 
					 | 
					 | 
					        longTimeLeft = longEndTime - System.currentTimeMillis() + waitInterval;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.setTimeLeft!  longTimeLeft=" + longTimeLeft);
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "longTimeLeft=" + longTimeLeft);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setChronometer(longTimeLeft);
 | 
					 | 
					 | 
					 | 
					        setChronometer(longTimeLeft);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void resetTimeLeft(){
 | 
					 | 
					 | 
					 | 
					    private void resetTimeLeft(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.resetTimeLeft!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "resetTimeLeft";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        longTimeLeft = 0;
 | 
					 | 
					 | 
					 | 
					        longTimeLeft = 0;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setChronometer(longLoopInterval);
 | 
					 | 
					 | 
					 | 
					        setChronometer(longLoopInterval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void playSound(){
 | 
					 | 
					 | 
					 | 
					    private void playSound(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.playSound!");
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "playSound";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        /* Original code, did not work on Nexus 7 with CM 12.1-20151117 (Android 5.1.1)
 | 
					 | 
					 | 
					 | 
					        /* Original code, did not work on Nexus 7 with CM 12.1-20151117 (Android 5.1.1)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
 | 
					 | 
					 | 
					 | 
					        Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -467,28 +539,40 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        //mediaPlayer.reset();
 | 
					 | 
					 | 
					 | 
					        //mediaPlayer.reset();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mediaPlayer.start();
 | 
					 | 
					 | 
					 | 
					        mediaPlayer.start();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // TODO: use this to fix bug when app is closed during a countdown, it opens
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // back up with a 0 count but timer is enabled and needs Stopped before the
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // edit texts can be used.
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void resetAll() {
 | 
					 | 
					 | 
					 | 
					    private void resetAll() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "resetAll";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Resetting screen values...");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setChronometer(0);
 | 
					 | 
					 | 
					 | 
					        setChronometer(0);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setEditTexts("");
 | 
					 | 
					 | 
					 | 
					        setEditTexts("");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setLoopInterval();
 | 
					 | 
					 | 
					 | 
					        setLoopInterval();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Values reset");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Resetting SharedPreferences...");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        start = false;
 | 
					 | 
					 | 
					 | 
					        start = false;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        SharedPreferences.Editor editor = sharedPreferences.edit();
 | 
					 | 
					 | 
					 | 
					        SharedPreferences.Editor editor = sharedPreferences.edit();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.putBoolean(keyStartStop, start);
 | 
					 | 
					 | 
					 | 
					        editor.putBoolean(keyStartStop, start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.putBoolean(keyAppOpen, start);
 | 
					 | 
					 | 
					 | 
					        editor.putBoolean(keyAppOpen, start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.putBoolean(keyServiceRunning, start);
 | 
					 | 
					 | 
					 | 
					        editor.putBoolean(keyServiceRunning, start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.apply();
 | 
					 | 
					 | 
					 | 
					        int count = 0;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        while (!editor.commit() && count < 50) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            Log.i(tag, "Failed! Reattempting commit... count=" + count);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            count++;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        };
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "SharedPreferences reset");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override
 | 
					 | 
					 | 
					 | 
					    @Override
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    protected void onPause() {
 | 
					 | 
					 | 
					 | 
					    protected void onPause() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        super.onPause();
 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "onPause";
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.onPause!");
 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        stringLoopInterval =
 | 
					 | 
					 | 
					 | 
					        stringLoopInterval =
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                etHours.getText().toString() + ":" +
 | 
					 | 
					 | 
					 | 
					                etHours.getText().toString() + ":" +
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -500,29 +584,51 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.putString(keyLoopInterval, stringLoopInterval);
 | 
					 | 
					 | 
					 | 
					        editor.putString(keyLoopInterval, stringLoopInterval);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.putBoolean(keyAppOpen, false);
 | 
					 | 
					 | 
					 | 
					        editor.putBoolean(keyAppOpen, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        editor.apply();
 | 
					 | 
					 | 
					 | 
					        editor.apply();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Done with local code, calling super.");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        super.onPause();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override
 | 
					 | 
					 | 
					 | 
					    @Override
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    protected void onResume() {
 | 
					 | 
					 | 
					 | 
					    protected void onResume() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        super.onResume();
 | 
					 | 
					 | 
					 | 
					        super.onResume();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(TAG, "MainActivity.onResume!");
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "onResume";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        sharedPreferences.edit().putBoolean(keyServiceRunning, false).apply();
 | 
					 | 
					 | 
					 | 
					        sharedPreferences.edit().putBoolean(keyServiceRunning, false).apply();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        recoverScreen();
 | 
					 | 
					 | 
					 | 
					        recoverScreen();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override
 | 
					 | 
					 | 
					 | 
					    @Override
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    protected void onDestroy() {
 | 
					 | 
					 | 
					 | 
					    protected void onDestroy() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "onDestroy";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        resetAll();
 | 
					 | 
					 | 
					 | 
					        resetAll();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Done with local code, calling super..");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        super.onDestroy();
 | 
					 | 
					 | 
					 | 
					        super.onDestroy();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void flipInputTexts() {
 | 
					 | 
					 | 
					 | 
					    private void flipInputTexts() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        String tag = TAG + "flipInputTexts";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Starting");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        etHours.setEnabled(!start);
 | 
					 | 
					 | 
					 | 
					        etHours.setEnabled(!start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        etMinutes.setEnabled(!start);
 | 
					 | 
					 | 
					 | 
					        etMinutes.setEnabled(!start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        etSeconds.setEnabled(!start);
 | 
					 | 
					 | 
					 | 
					        etSeconds.setEnabled(!start);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (DEBUG) Log.d(tag, "Finished");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						 
						
						
						
						 
					 | 
					 | 
					 
 |