|
|
@ -76,6 +76,12 @@ public class ActivityWidget extends ActivityBase {
|
|
|
|
appWidgetId = extras.getInt(
|
|
|
|
appWidgetId = extras.getInt(
|
|
|
|
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
|
|
|
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityWidget.this);
|
|
|
|
|
|
|
|
long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
|
|
|
|
|
|
|
|
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
|
|
|
|
|
|
|
|
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
|
|
|
|
|
|
|
int layout = prefs.getInt("widget." + appWidgetId + ".layout", 1 /* new */);
|
|
|
|
|
|
|
|
|
|
|
|
getSupportActionBar().setSubtitle(R.string.title_widget_title_count);
|
|
|
|
getSupportActionBar().setSubtitle(R.string.title_widget_title_count);
|
|
|
|
setContentView(R.layout.activity_widget);
|
|
|
|
setContentView(R.layout.activity_widget);
|
|
|
|
|
|
|
|
|
|
|
@ -154,7 +160,6 @@ public class ActivityWidget extends ActivityBase {
|
|
|
|
public void onClick(View view) {
|
|
|
|
public void onClick(View view) {
|
|
|
|
EntityAccount account = (EntityAccount) spAccount.getSelectedItem();
|
|
|
|
EntityAccount account = (EntityAccount) spAccount.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityWidget.this);
|
|
|
|
|
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
if (account != null && account.id > 0)
|
|
|
|
if (account != null && account.id > 0)
|
|
|
|
editor.putString("widget." + appWidgetId + ".name", account.name);
|
|
|
|
editor.putString("widget." + appWidgetId + ".name", account.name);
|
|
|
@ -178,10 +183,14 @@ public class ActivityWidget extends ActivityBase {
|
|
|
|
adapterAccount.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
|
|
|
adapterAccount.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
|
|
|
spAccount.setAdapter(adapterAccount);
|
|
|
|
spAccount.setAdapter(adapterAccount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
((TextView) inOld.findViewById(R.id.tvCount)).setText("12");
|
|
|
|
((TextView) inOld.findViewById(R.id.tvCount)).setText("12");
|
|
|
|
((TextView) inNew.findViewById(R.id.tvCount)).setText("12");
|
|
|
|
((TextView) inNew.findViewById(R.id.tvCount)).setText("12");
|
|
|
|
|
|
|
|
|
|
|
|
btnColor.setColor(Color.TRANSPARENT);
|
|
|
|
cbSemiTransparent.setChecked(semi);
|
|
|
|
|
|
|
|
btnColor.setColor(background);
|
|
|
|
|
|
|
|
rbOld.setChecked(layout != 1);
|
|
|
|
|
|
|
|
rbNew.setChecked(layout == 1);
|
|
|
|
setBackground();
|
|
|
|
setBackground();
|
|
|
|
|
|
|
|
|
|
|
|
grpReady.setVisibility(View.GONE);
|
|
|
|
grpReady.setVisibility(View.GONE);
|
|
|
@ -189,6 +198,8 @@ public class ActivityWidget extends ActivityBase {
|
|
|
|
|
|
|
|
|
|
|
|
setResult(RESULT_CANCELED, resultValue);
|
|
|
|
setResult(RESULT_CANCELED, resultValue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<List<EntityAccount>>() {
|
|
|
|
new SimpleTask<List<EntityAccount>>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected List<EntityAccount> onExecute(Context context, Bundle args) {
|
|
|
|
protected List<EntityAccount> onExecute(Context context, Bundle args) {
|
|
|
@ -210,6 +221,12 @@ public class ActivityWidget extends ActivityBase {
|
|
|
|
|
|
|
|
|
|
|
|
adapterAccount.addAll(accounts);
|
|
|
|
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);
|
|
|
|
grpReady.setVisibility(View.VISIBLE);
|
|
|
|
pbWait.setVisibility(View.GONE);
|
|
|
|
pbWait.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -218,7 +235,7 @@ public class ActivityWidget extends ActivityBase {
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
Log.unexpectedError(getSupportFragmentManager(), ex);
|
|
|
|
Log.unexpectedError(getSupportFragmentManager(), ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.execute(this, new Bundle(), "widget:accounts");
|
|
|
|
}.execute(this, args, "widget:accounts");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setBackground() {
|
|
|
|
private void setBackground() {
|
|
|
|