|
|
|
@ -82,6 +82,16 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
appWidgetId = extras.getInt(
|
|
|
|
|
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
|
long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
|
|
|
|
|
long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
|
|
|
|
|
boolean unseen = prefs.getBoolean("widget." + appWidgetId + ".unseen", false);
|
|
|
|
|
boolean flagged = prefs.getBoolean("widget." + appWidgetId + ".flagged", false);
|
|
|
|
|
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
|
|
|
|
|
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
|
|
|
|
int font = prefs.getInt("widget." + appWidgetId + ".font", 0);
|
|
|
|
|
int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
|
|
|
|
|
|
|
|
|
|
getSupportActionBar().setSubtitle(R.string.title_widget_title_list);
|
|
|
|
|
setContentView(R.layout.activity_widget_unified);
|
|
|
|
|
|
|
|
|
@ -151,16 +161,6 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
int font = spFontSize.getSelectedItemPosition();
|
|
|
|
|
int padding = spPadding.getSelectedItemPosition();
|
|
|
|
|
|
|
|
|
|
if (font == 1) // tiny
|
|
|
|
|
font = 4;
|
|
|
|
|
else if (font > 1)
|
|
|
|
|
font--;
|
|
|
|
|
|
|
|
|
|
if (padding == 1) // tiny
|
|
|
|
|
padding = 4;
|
|
|
|
|
else if (padding > 1)
|
|
|
|
|
padding--;
|
|
|
|
|
|
|
|
|
|
editor.putLong("widget." + appWidgetId + ".account", account == null ? -1L : account.id);
|
|
|
|
|
editor.putLong("widget." + appWidgetId + ".folder", folder == null ? -1L : folder.id);
|
|
|
|
|
editor.putString("widget." + appWidgetId + ".type", folder == null ? null : folder.type);
|
|
|
|
@ -168,8 +168,8 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
editor.putBoolean("widget." + appWidgetId + ".flagged", cbFlagged.isChecked());
|
|
|
|
|
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
|
|
|
|
|
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
|
|
|
|
|
editor.putInt("widget." + appWidgetId + ".font", font);
|
|
|
|
|
editor.putInt("widget." + appWidgetId + ".padding", padding);
|
|
|
|
|
editor.putInt("widget." + appWidgetId + ".font", tinyOut(font));
|
|
|
|
|
editor.putInt("widget." + appWidgetId + ".padding", tinyOut(padding));
|
|
|
|
|
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
|
|
|
|
|
|
|
|
|
editor.apply();
|
|
|
|
@ -250,7 +250,14 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
adapterFolder.clear();
|
|
|
|
|
adapterFolder.addAll(folders);
|
|
|
|
|
|
|
|
|
|
spFolder.setSelection(0);
|
|
|
|
|
int select = 0;
|
|
|
|
|
for (int i = 0; i < folders.size(); i++)
|
|
|
|
|
if (folders.get(i).id.equals(folder)) {
|
|
|
|
|
select = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spFolder.setSelection(select);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -273,13 +280,21 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
adapterPadding.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
|
|
|
|
spPadding.setAdapter(adapterPadding);
|
|
|
|
|
|
|
|
|
|
btnColor.setColor(Color.TRANSPARENT);
|
|
|
|
|
// Initialize
|
|
|
|
|
cbUnseen.setChecked(unseen);
|
|
|
|
|
cbFlagged.setChecked(flagged);
|
|
|
|
|
cbSemiTransparent.setChecked(semi);
|
|
|
|
|
btnColor.setColor(background);
|
|
|
|
|
spFontSize.setSelection(tinyIn(font));
|
|
|
|
|
spPadding.setSelection(tinyIn(padding));
|
|
|
|
|
|
|
|
|
|
grpReady.setVisibility(View.GONE);
|
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
setResult(RESULT_CANCELED, resultValue);
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
|
|
new SimpleTask<List<EntityAccount>>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected List<EntityAccount> onExecute(Context context, Bundle args) {
|
|
|
|
@ -301,6 +316,12 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
|
|
|
|
|
adapterAccount.addAll(accounts);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < accounts.size(); i++)
|
|
|
|
|
if (accounts.get(i).id.equals(account)) {
|
|
|
|
|
spAccount.setSelection(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grpReady.setVisibility(View.VISIBLE);
|
|
|
|
|
pbWait.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
@ -309,6 +330,24 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getSupportFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(this, new Bundle(), "widget:accounts");
|
|
|
|
|
}.execute(this, args, "widget:accounts");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int tinyOut(int value) {
|
|
|
|
|
if (value == 1) // tiny
|
|
|
|
|
return 4;
|
|
|
|
|
else if (value > 1)
|
|
|
|
|
return value - 1;
|
|
|
|
|
else
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int tinyIn(int value) {
|
|
|
|
|
if (value == 4)
|
|
|
|
|
return 1;
|
|
|
|
|
else if (value >= 1)
|
|
|
|
|
return value + 1;
|
|
|
|
|
else
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|