Skip to content

Commit

Permalink
fixed widget using settings from previous widgets
Browse files Browse the repository at this point in the history
a widget created with same id had used the settings from previous widget if the previous widget had a setting modified but the new widget hadn't
  • Loading branch information
programminghoch10 committed Sep 19, 2019
1 parent 6dd5819 commit 6d2b081
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/main/java/com/JJ/hangoverclock/ConfigureWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ public void onClick(View v) {
boolean twelvehours = ((Switch) findViewById(R.id.hourselector)).isChecked();
boolean enabledate = ((Switch) findViewById(R.id.dateselector)).isChecked();
boolean as = context.getResources().getBoolean(R.bool.alwayssavepreference); //wether preferences should always be saved
int[] flushkeys = {
R.string.keyenableseconds,
R.string.keyfont,
R.string.keyfontscale,
R.string.keyhouroverhang,
R.string.keyminuteoverhang,
R.string.keysecondoverhang,
R.string.keydayoverhang,
R.string.keymonthoverhang,
R.string.keycolor,
R.string.keytwelvehour,
R.string.keyenabledate,
};
for (int key:flushkeys) {
editor.remove(context.getResources().getString(key) + appWidgetID);
}
if (as | context.getResources().getBoolean(R.bool.defaultenableseconds) != enableseconds)
editor.putBoolean(context.getResources().getString(R.string.keyenableseconds) + appWidgetID, enableseconds);
if (as | !context.getResources().getString(R.string.defaultfonttext).equals(font))
Expand Down Expand Up @@ -254,7 +270,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
((Switch) findViewById(R.id.dateselector)).setOnCheckedChangeListener(updatepreviewlistener);
((Switch) findViewById(R.id.secondsselector)).setOnCheckedChangeListener(updatepreviewlistener);
((Switch) findViewById(R.id.autohourselector)).setOnCheckedChangeListener(updatepreviewlistener);
//TODO: replace spinner with recyclerview (big project ._.)
Spinner fontspinner = findViewById(R.id.fontspinner);
ArrayList<RowItem> rowItems = new ArrayList<RowItem>();
ArrayList<String> fonts = ClockWidgetProvider.fonts;
Expand Down

0 comments on commit 6d2b081

Please sign in to comment.