Added option to disable account name in message list widget

pull/213/head
M66B 1 year ago
parent 479aa72faa
commit e635d90cf3

@ -71,6 +71,7 @@ public class ActivityWidgetUnified extends ActivityBase {
private Spinner spSubjectLines;
private TextView tvSubjectLinesHint;
private CheckBox cbAvatars;
private CheckBox cbAccountName;
private CheckBox cbRefresh;
private CheckBox cbCompose;
private Button btnSave;
@ -112,6 +113,7 @@ public class ActivityWidgetUnified extends ActivityBase {
int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
int subject_lines = prefs.getInt("widget." + appWidgetId + ".subject_lines", 1);
boolean avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false);
boolean account_name = prefs.getBoolean("widget." + appWidgetId + ".account_name", true);
boolean refresh = prefs.getBoolean("widget." + appWidgetId + ".refresh", false);
boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false);
@ -136,6 +138,7 @@ public class ActivityWidgetUnified extends ActivityBase {
spSubjectLines = findViewById(R.id.spSubjectLines);
tvSubjectLinesHint = findViewById(R.id.tvSubjectLinesHint);
cbAvatars = findViewById(R.id.cbAvatars);
cbAccountName = findViewById(R.id.cbAccountName);
cbRefresh = findViewById(R.id.cbRefresh);
cbCompose = findViewById(R.id.cbCompose);
btnSave = findViewById(R.id.btnSave);
@ -278,6 +281,7 @@ public class ActivityWidgetUnified extends ActivityBase {
editor.putInt("widget." + appWidgetId + ".padding", tinyOut(padding));
editor.putInt("widget." + appWidgetId + ".subject_lines", spSubjectLines.getSelectedItemPosition() + 1);
editor.putBoolean("widget." + appWidgetId + ".avatars", cbAvatars.isChecked());
editor.putBoolean("widget." + appWidgetId + ".account_name", cbAccountName.isChecked());
editor.putBoolean("widget." + appWidgetId + ".refresh", cbRefresh.isChecked());
editor.putBoolean("widget." + appWidgetId + ".compose", cbCompose.isChecked());
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
@ -324,6 +328,7 @@ public class ActivityWidgetUnified extends ActivityBase {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
EntityAccount account = (EntityAccount) spAccount.getAdapter().getItem(position);
setFolders(account.id);
cbAccountName.setEnabled(account.id < 0);
}
@Override
@ -408,6 +413,7 @@ public class ActivityWidgetUnified extends ActivityBase {
spFontSize.setSelection(tinyIn(font));
spPadding.setSelection(tinyIn(padding));
cbAvatars.setChecked(avatars);
cbAccountName.setChecked(account_name);
spSubjectLines.setSelection(subject_lines - 1);
tvSubjectLinesHint.setText(getString(R.string.title_advanced_preview_lines_hint, NF.format(HtmlHelper.PREVIEW_SIZE)));
cbRefresh.setChecked(refresh);

@ -66,6 +66,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private int font;
private int padding;
private boolean avatars;
private boolean account_name;
private int subject_lines;
private boolean prefer_contact;
private boolean only_contact;
@ -117,6 +118,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
font = prefs.getInt("widget." + appWidgetId + ".font", 0);
padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false);
account_name = prefs.getBoolean("widget." + appWidgetId + ".account_name", true);
subject_lines = prefs.getInt("widget." + appWidgetId + ".subject_lines", 1);
prefer_contact = prefs.getBoolean("prefer_contact", false);
@ -293,7 +295,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
views.setViewVisibility(R.id.separator, separators ? View.VISIBLE : View.GONE);
views.setViewVisibility(idAccount, account < 0 && !allColors ? View.VISIBLE : View.GONE);
views.setViewVisibility(idAccount, account < 0 && !allColors && account_name ? View.VISIBLE : View.GONE);
} catch (Throwable ex) {
Log.e(ex);

@ -213,6 +213,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSubjectLinesHint" />
<CheckBox
android:id="@+id/cbAccountName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_widget_account_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
<CheckBox
android:id="@+id/cbRefresh"
android:layout_width="wrap_content"
@ -221,7 +231,7 @@
android:checked="true"
android:text="@string/title_widget_refresh"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
app:layout_constraintTop_toBottomOf="@id/cbAccountName" />
<CheckBox
android:id="@+id/cbCompose"

@ -2260,6 +2260,7 @@
<string name="title_widget_count_top">Show unread count at the top</string>
<string name="title_widget_subject_lines">Maximum number of subject lines</string>
<string name="title_widget_avatars">Show contact avatars</string>
<string name="title_widget_account_name">Show account name</string>
<string name="title_widget_refresh">Show refresh messages button</string>
<string name="title_widget_compose">Show compose new message button</string>
<string name="title_widget_background">Background color</string>

Loading…
Cancel
Save