Bug fixes
Clock synchronization, fixed problem with SettingsActivity and Widgets
This commit is contained in:
parent
af70bcc0f3
commit
711f956872
6 changed files with 134 additions and 117 deletions
|
|
@ -13,6 +13,7 @@
|
|||
<activity
|
||||
android:name=".BreakReminder"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
|
|
|||
|
|
@ -40,27 +40,16 @@ public class BreakReminder extends AppCompatActivity
|
|||
private CountDownTimer ct;
|
||||
private String stopTime = "";
|
||||
private int oldTime = 0;
|
||||
private boolean addNewProfile = false;
|
||||
private Spinner profileSpinner;
|
||||
private SharedPreferences sharedPrefs;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean onPause = sharedPrefs.getBoolean("onPause", false);
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
if (onPause) {
|
||||
System.out.println("ON PAUSE WAS TRUE!!!!");
|
||||
editor.putBoolean("onPause", false);
|
||||
editor.apply();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
System.out.println("WELCOME TO THE MOTHER FUCKING JUNGLE BIIIIIIIIIIIIIIIIIIIIIIIIIIITCH");
|
||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
|
||||
setContentView(R.layout.activity_break_reminder);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
|
|
@ -79,7 +68,9 @@ public class BreakReminder extends AppCompatActivity
|
|||
String allProfiles = sharedPrefs.getString("profiles", "");
|
||||
if (allProfiles.equals("")) {
|
||||
System.out.println("Es gibt noch keine Profile!!");
|
||||
editor.putString("profiles", "Sport,5,1,false;Exams,90,15,false;Pomodoro,30,5,false;");
|
||||
allProfiles = "Sport,5,1,false;Exams,90,15,false;Pomodoro,30,5,false;";
|
||||
editor.putString("profiles", allProfiles);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
|
|
@ -90,15 +81,16 @@ public class BreakReminder extends AppCompatActivity
|
|||
|
||||
if (stayOn)
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
else
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
int mins = sharedPrefs.getInt("work_value", 50);
|
||||
int mins = sharedPrefs.getInt("work_value", 5);
|
||||
String bufferZeroMinute = "";
|
||||
|
||||
if (mins < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
ct_text = (TextView)
|
||||
|
||||
findViewById(R.id.textView);
|
||||
|
||||
ct_text.setText(bufferZeroMinute + mins + ":00");
|
||||
|
|
@ -115,6 +107,7 @@ public class BreakReminder extends AppCompatActivity
|
|||
String[] fillProfileNames = allProfiles.split(";");
|
||||
for (int i = 0; i < profileNames.length - 1; i++) {
|
||||
profileNames[i] = fillProfileNames[i].split(",")[0];
|
||||
System.out.println("Profile name:" + profileNames[i]);
|
||||
}
|
||||
profileNames[profileNames.length - 1] = "New Profile...";
|
||||
ArrayAdapter<String> adapter = new
|
||||
|
|
@ -122,12 +115,8 @@ public class BreakReminder extends AppCompatActivity
|
|||
profileSpinner.setAdapter(adapter);
|
||||
|
||||
//Set the ClickListener for Spinner
|
||||
profileSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||
|
||||
{
|
||||
|
||||
profileSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
System.out.println("Selected item: " + parent.getItemAtPosition(position) + " with id: " + id);
|
||||
|
||||
String profileSelected = (String) parent.getItemAtPosition(position);
|
||||
if (profileSelected.equals("New Profile...")) {
|
||||
|
|
@ -144,7 +133,6 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void updatePreference(String profileSelected) {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
String allProfiles = sharedPrefs.getString("profiles", "");
|
||||
|
||||
|
|
@ -153,6 +141,11 @@ public class BreakReminder extends AppCompatActivity
|
|||
if (allProfiles.contains(currentProfile) && profileSelected.equals(sharedPrefs.getString("name_text", ""))) {
|
||||
System.out.println("Profile didn´t change");
|
||||
} else {
|
||||
if (ct != null) {
|
||||
ct.cancel();
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
String[] profileNames = allProfiles.split(";");
|
||||
for (int i = 0; i < profileNames.length; i++) {
|
||||
String profileName = profileNames[i].split(",")[0];
|
||||
|
|
@ -160,7 +153,7 @@ public class BreakReminder extends AppCompatActivity
|
|||
int break_time = Integer.parseInt(profileNames[i].split(",")[2]);
|
||||
if (profileName.equals(profileSelected)) {
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
editor.putString("current_profile", ""+i);
|
||||
editor.putString("current_profile", "" + i);
|
||||
editor.putString("name_text", profileName);
|
||||
editor.putInt("work_value", interval);
|
||||
editor.putInt("break_value", break_time);
|
||||
|
|
@ -183,7 +176,12 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void fillProfiles() {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if (ct != null) {
|
||||
ct.cancel();
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
String allProfiles = sharedPrefs.getString("profiles", "");
|
||||
|
||||
String[] profileNames = new String[allProfiles.split(";").length + 1];
|
||||
|
|
@ -197,9 +195,10 @@ public class BreakReminder extends AppCompatActivity
|
|||
profileSpinner.setAdapter(adapter);
|
||||
|
||||
//Set Spinner on the current Profile
|
||||
String currentProfile = sharedPrefs.getString("name_text", "Sport");
|
||||
//String currentProfile = sharedPrefs.getString("name_text", "Sport");
|
||||
int interval = sharedPrefs.getInt("work_value", 1);
|
||||
profileSpinner.setSelection(Arrays.asList(profileNames).indexOf(currentProfile));
|
||||
//profileSpinner.setSelection(Arrays.asList(profileNames).indexOf(currentProfile));
|
||||
profileSpinner.setSelection(Integer.parseInt(sharedPrefs.getString("current_profile", "-1")));
|
||||
|
||||
//Update clock
|
||||
String bufferZeroMinute = "";
|
||||
|
|
@ -210,13 +209,8 @@ public class BreakReminder extends AppCompatActivity
|
|||
ct_text.setText(bufferZeroMinute + time / 1000 / 60 + ":00");
|
||||
|
||||
//Set the ClickListener for Spinner
|
||||
profileSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||
|
||||
{
|
||||
|
||||
profileSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
System.out.println("Selected item: " + parent.getItemAtPosition(position) + " with id: " + id);
|
||||
|
||||
String profileSelected = (String) parent.getItemAtPosition(position);
|
||||
if (profileSelected.equals("New Profile...")) {
|
||||
createNewProfile();
|
||||
|
|
@ -231,44 +225,32 @@ public class BreakReminder extends AppCompatActivity
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean("onPause", true);
|
||||
editor.apply();
|
||||
System.out.println("IM ON PAUSE BITCH 1111111");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
// If chosen, set screen to "stay on"
|
||||
boolean stayOn = sharedPrefs.getBoolean("notifications_stayOn", false);
|
||||
|
||||
if (stayOn)
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
else
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
System.out.println("Activity resumed!!");
|
||||
|
||||
//FIXME Add flag if New Profile or Resume
|
||||
//if (addNewProfile) {
|
||||
if (sharedPrefs.getBoolean("change_profiles", false)) {
|
||||
System.out.println("Change Profiles is true!");
|
||||
fillProfiles();
|
||||
profileSpinner = (Spinner) findViewById(R.id.spinner);
|
||||
// addNewProfile = false;
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
System.out.println("ON PAUSE CALLED!");
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean("onPause", false);
|
||||
editor.apply();
|
||||
//profileSpinner = (Spinner) findViewById(R.id.spinner);
|
||||
|
||||
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
editor.putBoolean("change_profiles", false);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -311,7 +293,6 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
int mins = sharedPrefs.getInt("work_value", 50);
|
||||
String bufferZeroMinute = "";
|
||||
String bufferZeroSecond = "";
|
||||
|
|
@ -321,7 +302,7 @@ public class BreakReminder extends AppCompatActivity
|
|||
stopTime = (String) ct_text.getText();
|
||||
oldTime = time;
|
||||
|
||||
if (stopTime == "" && !isRunning) {
|
||||
if (stopTime.equals("") && !isRunning) {
|
||||
if (time / 1000 / 60 < 10)
|
||||
bufferZeroMinute = "0";
|
||||
|
||||
|
|
@ -332,7 +313,6 @@ public class BreakReminder extends AppCompatActivity
|
|||
String[] timef = stringTime.split(":");
|
||||
int minute = Integer.parseInt(timef[0]);
|
||||
int second = Integer.parseInt(timef[1]);
|
||||
System.out.println("Minute: " + minute + " Second: " + second);
|
||||
time = (1000 * (minute * 60)) + (1000 * second);
|
||||
|
||||
if (minute < 10)
|
||||
|
|
@ -344,9 +324,6 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
|
||||
|
||||
System.out.println(time + " " + ct_text.getText());
|
||||
|
||||
|
||||
switch (v.getId()) {
|
||||
|
||||
case R.id.textView:
|
||||
|
|
@ -376,8 +353,7 @@ public class BreakReminder extends AppCompatActivity
|
|||
updateWidgets(bufferZeroMinute + (millisUntilFinished / 1000) / 60 + ":" + bufferZeroSecond + millisUntilFinished / 1000 % 60);
|
||||
|
||||
//Show how much time is left
|
||||
//String timeLeft = bufferZeroMinute + (millisUntilFinished / 1000) / 60 + ":" + bufferZeroSecond + millisUntilFinished / 1000 % 60;
|
||||
//System.out.println("Time left: " + timeLeft);
|
||||
|
||||
timeLeft = sharedPrefs.getBoolean("notifications_new_message_timeLeft", false);
|
||||
if (timeLeft) {
|
||||
Notification notification = new NotificationCompat.Builder(getApplicationContext()).setCategory(Notification.CATEGORY_MESSAGE)
|
||||
|
|
@ -399,11 +375,9 @@ public class BreakReminder extends AppCompatActivity
|
|||
updateWidgets("00:00");
|
||||
|
||||
//trigger the alarm
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
String ringPref = sharedPrefs.getString("notifications_new_message_ringtone", "");
|
||||
System.out.println("Sound: " + ringPref);
|
||||
|
||||
if (!ringPref.equals("")) {
|
||||
System.out.println("-----------------PLAY NOTIFICATION SOUND----------------");
|
||||
// Get the current ringtone
|
||||
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), Uri.parse(ringPref));
|
||||
|
||||
|
|
@ -412,7 +386,6 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
//FIXME Test Vibration
|
||||
boolean vibrateChecked = sharedPrefs.getBoolean("notifications_new_message_vibrate", false);
|
||||
System.out.println("Vibrate is : " + vibrateChecked);
|
||||
if (vibrateChecked) {
|
||||
// Get instance of Vibrator from current Context
|
||||
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
|
@ -420,9 +393,8 @@ public class BreakReminder extends AppCompatActivity
|
|||
if (v == null) {
|
||||
System.out.println("No vibrator! :D");
|
||||
} else {
|
||||
// Vibrate for 3000 milliseconds
|
||||
System.out.println("Vibrate for 3000 ms");
|
||||
v.vibrate(3000);
|
||||
// Vibrate for 1500 milliseconds
|
||||
v.vibrate(1500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -453,6 +425,8 @@ public class BreakReminder extends AppCompatActivity
|
|||
ct_text.setText(bufferZeroMinute + time / 1000 / 60 + ":00");
|
||||
stopTime = (String) ct_text.getText();
|
||||
isRunning = false;
|
||||
|
||||
updateWidgets(stopTime);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -468,24 +442,25 @@ public class BreakReminder extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void createNewProfile() {
|
||||
addNewProfile = true;
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
editor.putBoolean("change_profiles", true);
|
||||
editor.apply();
|
||||
Intent intent = new Intent(this, ProfileActivity.class);
|
||||
this.startActivity(intent);
|
||||
}
|
||||
|
||||
private void updateWidgets(String time) {
|
||||
System.out.println("UPDATING THE WIDGET -------");
|
||||
Intent intent = new Intent(this, AppWidget.class);
|
||||
intent.putExtra("time", time);
|
||||
int ids[] = AppWidgetManager.getInstance(getApplication()).getAppWidgetIds(new ComponentName(this.getApplicationContext(), AppWidget.class));
|
||||
System.out.println("Number of WIDGETS : " + ids.length);
|
||||
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
|
||||
sendBroadcast(intent);
|
||||
if (ids.length != 0) {
|
||||
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public void startBreak() {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String allProfiles = sharedPrefs.getString("profiles", "");
|
||||
String[] profiles = allProfiles.split(";");
|
||||
String currentProfile = sharedPrefs.getString("name_text", "");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
|
||||
|
||||
|
||||
public class Exercise {
|
||||
private int id, imageID;
|
||||
private String section, execution, description;
|
||||
|
||||
public Exercise(int id, String description, String section, int imageID, String execution) {
|
||||
this.id = id;
|
||||
this.imageID = imageID;
|
||||
this.section = section;
|
||||
this.execution = execution;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getExecution() {
|
||||
return execution;
|
||||
}
|
||||
|
||||
public void setExecution(String execution) {
|
||||
this.execution = execution;
|
||||
}
|
||||
|
||||
public int getImageID() {
|
||||
return imageID;
|
||||
}
|
||||
|
||||
public void setImageID(int imageID) {
|
||||
this.imageID = imageID;
|
||||
}
|
||||
|
||||
public String getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ public class ProfileActivity extends AppCompatActivity implements View.OnClickLi
|
|||
editor.putString("name_text", name);
|
||||
editor.putInt("work_value", interval_seekbar.getProgress());
|
||||
editor.putInt("break_value", break_seekbar.getProgress());
|
||||
System.out.println("BoolValue: "+cont);
|
||||
editor.putString("current_profile", "" + (sharedPrefs.getString("profiles", "").split(";").length));
|
||||
editor.putString("profiles", sharedPrefs.getString("profiles", "") + name + "," + interval_seekbar.getProgress() + "," + break_seekbar.getProgress() + "," + cont + ";");
|
||||
editor.apply();
|
||||
finish();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
|
|||
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
|
@ -15,7 +14,6 @@ import android.os.Bundle;
|
|||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
|
@ -25,10 +23,7 @@ import android.view.MenuItem;
|
|||
import android.support.v4.app.NavUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A {@link PreferenceActivity} that presents a set of application settings. On
|
||||
|
|
@ -181,8 +176,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This fragment shows general preferences only. It is used when the
|
||||
* activity is showing a two-pane settings UI.
|
||||
|
|
@ -196,8 +189,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
private DynamicListPreference dlp;
|
||||
|
||||
private String currentProfile = "";
|
||||
|
||||
private Bundle bundle;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
bundle = savedInstanceState;
|
||||
|
|
@ -245,26 +238,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
|
||||
|
||||
if(key.equals("current_profile")){
|
||||
System.out.println("HOOOOOOOOOOOOOLY SHIIIIIIIIIIIIT");
|
||||
|
||||
if (key.equals("current_profile")) {
|
||||
ListPreference listPref = (ListPreference) findPreference("current_profile");
|
||||
int i = Integer.parseInt(listPref.getValue());
|
||||
|
||||
System.out.println("!!!!!! "+i);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("current_profile", ""+i);
|
||||
|
||||
editor.putString("current_profile", "" + i);
|
||||
editor.putBoolean("change_profiles", true);
|
||||
String[] allProfile = sharedPreferences.getString("profiles", "").split(";");
|
||||
|
||||
//FIXME Deactivate the onPrefListener in SettingsActivity
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
editor.putString("name_text",allProfile[i].split(",")[0]);
|
||||
editor.putInt("work_value",Integer.parseInt(allProfile[i].split(",")[1]));
|
||||
editor.putInt("break_value",Integer.parseInt(allProfile[i].split(",")[2]));
|
||||
editor.putString("name_text", allProfile[i].split(",")[0]);
|
||||
editor.putInt("work_value", Integer.parseInt(allProfile[i].split(",")[1]));
|
||||
editor.putInt("break_value", Integer.parseInt(allProfile[i].split(",")[2]));
|
||||
editor.apply();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
onDestroy();
|
||||
|
|
@ -272,13 +260,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("--------We change something!!!!! Key: " + key);
|
||||
|
||||
// Set seekbar summary :
|
||||
int radius = PreferenceManager.getDefaultSharedPreferences(this.getActivity()).getInt("work_value", 50);
|
||||
_seekBarWork.setSummary(this.getString(R.string.settings_summary).replace("$1", "" + radius));
|
||||
|
|
@ -286,8 +267,12 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
_seekBarBreak.setSummary(this.getString(R.string.settings_summary).replace("$1", "" + radius));
|
||||
|
||||
//FIXME Update the preferences of the selected profile
|
||||
if (!key.equals("profiles"))
|
||||
|
||||
if (!key.equals("profiles")) {
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
updateProfilesPreference();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -295,9 +280,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
@Override
|
||||
public void onPause() {
|
||||
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
updateProfilesPreference();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
|
@ -307,8 +289,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
String newProfileName = PreferenceManager.getDefaultSharedPreferences(this.getActivity()).getString("name_text", "");
|
||||
String allProfiles = PreferenceManager.getDefaultSharedPreferences(this.getActivity()).getString("profiles", "");
|
||||
|
||||
System.out.println("SETTINGS ACTIVITY0: " + newProfileName + "," + work_radius + "," + break_radius);
|
||||
System.out.println("SETTING ACTIVITY1: " + allProfiles);
|
||||
if (allProfiles.contains(newProfileName + "," + work_radius + "," + break_radius) && newProfileName.equals(currentProfile)) {
|
||||
//Nothing changes
|
||||
System.out.println("No changes for a profile in general settings");
|
||||
|
|
@ -333,9 +313,10 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
} else {
|
||||
|
||||
String[] profiles = allProfiles.split(";");
|
||||
|
||||
for (int i = 0; i < profiles.length; i++) {
|
||||
if (profiles[i].split(",")[0].equals(currentProfile)) {
|
||||
profiles[i] = newProfileName + "," + work_radius + "," + break_radius;
|
||||
profiles[i] = newProfileName + "," + work_radius + "," + break_radius + "," + profiles[i].split(",")[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -343,10 +324,14 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
for (String s : profiles) {
|
||||
builder.append(s + ";");
|
||||
}
|
||||
|
||||
System.out.println("All Profiles: " + builder.toString());
|
||||
editor.putBoolean("change_profiles", true);
|
||||
editor.putString("profiles", builder.toString());
|
||||
editor.apply();
|
||||
|
||||
currentProfile = newProfileName;
|
||||
findPreference("name_text").setSummary(currentProfile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,21 +19,21 @@
|
|||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:defaultValue="false"
|
||||
android:dependency="notifications_new_message"
|
||||
android:key="notifications_new_message_vibrate"
|
||||
android:title="@string/pref_title_vibrate" />
|
||||
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:defaultValue="false"
|
||||
android:dependency="notifications_new_message"
|
||||
android:key="notifications_new_message_timeLeft"
|
||||
android:title="@string/pref_title_timeLeft" />
|
||||
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:defaultValue="false"
|
||||
android:key="notifications_stayOn"
|
||||
android:title="@string/pref_title_stayOn" />
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue