Added setting to enable full notification text

pull/174/head
M66B 5 years ago
parent fe35cc0c1e
commit c6f0ae6dad

@ -2862,6 +2862,7 @@ class Core {
boolean name_email = prefs.getBoolean("name_email", false);
boolean flags = prefs.getBoolean("flags", true);
boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_preview_all = prefs.getBoolean("notify_preview_all", false);
boolean wearable_preview = prefs.getBoolean("wearable_preview", false);
boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro);
boolean notify_junk = (prefs.getBoolean("notify_junk", false) && pro);
@ -3210,14 +3211,14 @@ class Core {
if (message.content && notify_preview) {
// Android will truncate the text
String text = null;
try {
String html = Helper.readText(message.getFile(context));
text = HtmlHelper.getPreviewText(html);
} catch (Throwable ex) {
Log.e(ex);
text = message.preview;
}
String preview = message.preview;
if (notify_preview_all)
try {
String html = Helper.readText(message.getFile(context));
preview = HtmlHelper.getPreviewText(html);
} catch (Throwable ex) {
Log.e(ex);
}
// Wearables
StringBuilder sb = new StringBuilder();
@ -3226,8 +3227,8 @@ class Core {
if (wearable_preview) {
if (sb.length() != 0)
sb.append(" - ");
if (!TextUtils.isEmpty(text))
sb.append(text);
if (!TextUtils.isEmpty(preview))
sb.append(preview);
}
if (sb.length() > 0)
mbuilder.setContentText(sb.toString());
@ -3237,8 +3238,8 @@ class Core {
if (!TextUtils.isEmpty(message.subject))
sbm.append("<em>").append(message.subject).append("</em>").append("<br>");
if (!TextUtils.isEmpty(text))
sbm.append(text);
if (!TextUtils.isEmpty(preview))
sbm.append(preview);
if (sbm.length() > 0) {
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()

@ -58,6 +58,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swNotifyRemove;
private SwitchCompat swNotifyClear;
private SwitchCompat swNotifyPreview;
private SwitchCompat swNotifyPreviewAll;
private SwitchCompat swWearablePreview;
private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionJunk;
@ -81,7 +82,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private final static String[] RESET_OPTIONS = new String[]{
"badge", "unseen_ignored",
"notify_summary", "notify_remove", "notify_clear", "notify_preview", "wearable_preview",
"notify_summary", "notify_remove", "notify_clear", "notify_preview", "notify_preview_all", "wearable_preview",
"notify_trash", "notify_junk", "notify_archive", "notify_move",
"notify_reply", "notify_reply_direct",
"notify_flag", "notify_seen", "notify_snooze",
@ -108,6 +109,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swNotifyClear = view.findViewById(R.id.swNotifyClear);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll);
swWearablePreview = view.findViewById(R.id.swWearablePreview);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk);
@ -217,6 +219,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifyPreviewAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_preview_all", checked).apply();
}
});
swWearablePreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -390,6 +399,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true));
swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false));
swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false));
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro);
@ -415,6 +425,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
boolean summary = swNotifySummary.isChecked();
swNotifyPreview.setEnabled(!summary);
swNotifyPreviewAll.setEnabled(!summary && swNotifyPreview.isChecked());
swWearablePreview.setEnabled(!summary && swNotifyPreview.isChecked());
cbNotifyActionTrash.setEnabled(pro && !summary);
cbNotifyActionJunk.setEnabled(pro && !summary);

@ -191,6 +191,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreview" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreviewAll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_notify_preview_all"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvNotifyPreviewAllHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_notify_preview_all_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreviewAll" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWearablePreview"
android:layout_width="0dp"
@ -199,7 +222,7 @@
android:text="@string/title_advanced_wearable_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewHint"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewAllHint"
app:switchPadding="12dp" />
<TextView

@ -360,6 +360,7 @@
<string name="title_advanced_unseen_ignored">Let the number of new messages match the number of notifications</string>
<string name="title_advanced_notify_summary">Show summary notification only</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_notify_preview_all">Preview all text</string>
<string name="title_advanced_notify_actions">Notification actions</string>
<string name="title_advanced_notify_action_trash">Trash</string>
<string name="title_advanced_notify_action_junk">Spam</string>
@ -465,6 +466,7 @@
<string name="title_advanced_notify_manage_hint">Tap on the channel name to set the channel properties</string>
<string name="title_advanced_notify_manage_default_hint">To set the default sound, etc</string>
<string name="title_advanced_notify_manage_service_hint">To disable the permanent notification</string>
<string name="title_advanced_notify_preview_all_hint">For wearables that can show the full text (up to 5,000 characters)</string>
<string name="title_advanced_wearable_hint">Notifications are only sent to a wearable after the message text has been downloaded</string>
<string name="title_advanced_move_hint">The target folder can be configured in the account settings</string>
<string name="title_advanced_notify_no_grouping">This Android version does not support notification grouping</string>

Loading…
Cancel
Save