Preserve old widget opacity, locale format pct

pull/390/head
Alex Baker 8 years ago
parent 0f92ee41f1
commit 89b3b93361

@ -27,7 +27,8 @@ public abstract class BaseWidgetConfigActivity extends InjectingAppCompatActivit
@Deprecated public static final String PREF_DARK_THEME = "widget-dark-theme-";
public static final String PREF_THEME = "widget-theme-";
public static final String PREF_HIDE_HEADER = "widget-hide-header-";
public static final String PREF_WIDGET_OPACITY = "widget-opacity-";
@Deprecated public static final String PREF_WIDGET_OPACITY = "widget-opacity-";
public static final String PREF_WIDGET_OPACITY_V2 = "widget-opacity-v2";
@Inject Tracker tracker;
@Inject DialogBuilder dialogBuilder;

@ -101,7 +101,9 @@ public class TasksWidget extends InjectingAppWidgetProvider {
if (preferences.getBoolean(WidgetConfigActivity.PREF_HIDE_HEADER + id, false)) {
remoteViews.setViewVisibility(R.id.widget_header, View.GONE);
}
int opacity = preferences.getInt(WidgetConfigActivity.PREF_WIDGET_OPACITY + id, WidgetConfigActivity.DEFAULT_OPACITY);
int legacyOpacity = preferences.getInt(WidgetConfigActivity.PREF_WIDGET_OPACITY + id, 100);
int defaultOpacity = legacyOpacity < 100 ? legacyOpacity : WidgetConfigActivity.DEFAULT_OPACITY;
int opacity = preferences.getInt(WidgetConfigActivity.PREF_WIDGET_OPACITY_V2 + id, defaultOpacity);
remoteViews.setImageViewBitmap(R.id.widget_background,
getSolidBackground(theme.getContentBackground()));
remoteViews.setImageViewBitmap(R.id.widget_header_background,

@ -27,6 +27,8 @@ import org.tasks.preferences.Preferences;
import org.tasks.preferences.Theme;
import org.tasks.preferences.ThemeManager;
import java.text.NumberFormat;
import javax.inject.Inject;
import butterknife.Bind;
@ -156,7 +158,7 @@ public class WidgetConfigDialog extends InjectingDialogFragment implements SeekB
}
private void updateOpacity() {
opacityValue.setText(Integer.toString(opacitySeekbar.getProgress()*100/255)+"%");
opacityValue.setText(NumberFormat.getPercentInstance().format(opacitySeekbar.getProgress() / 255));
}
private void updateTheme() {
@ -201,7 +203,7 @@ public class WidgetConfigDialog extends InjectingDialogFragment implements SeekB
preferences.setBoolean(WidgetConfigActivity.PREF_HIDE_CHECKBOXES + appWidgetId, hideCheckBoxes.isChecked());
preferences.setBoolean(WidgetConfigActivity.PREF_HIDE_HEADER + appWidgetId, hideHeader.isChecked());
preferences.setInt(WidgetConfigActivity.PREF_THEME + appWidgetId, theme);
preferences.setInt(WidgetConfigActivity.PREF_WIDGET_OPACITY + appWidgetId, opacitySeekbar.getProgress());
preferences.setInt(WidgetConfigActivity.PREF_WIDGET_OPACITY_V2 + appWidgetId, opacitySeekbar.getProgress());
// force update after setting preferences
context.sendBroadcast(new Intent(context, TasksWidget.class) {{

Loading…
Cancel
Save