Added option to disable text reply suggestion

pull/177/head
M66B 5 years ago
parent 9ca688b35f
commit 0c7c894ccc

@ -2041,6 +2041,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ConversationActions getConversationActions(TupleMessageEx message, Document document) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean conversation_actions = prefs.getBoolean("conversation_actions", true);
boolean conversation_actions_replies = prefs.getBoolean("conversation_actions_replies", true);
if (!conversation_actions)
return null;
@ -2065,27 +2066,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.setText(document.text())
.build());
Set<String> included = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(
ConversationAction.TYPE_TEXT_REPLY
)));
Set<String> excluded = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(
ConversationAction.TYPE_OPEN_URL,
ConversationAction.TYPE_SEND_EMAIL
)));
Set<String> excluded = new HashSet<>(Arrays.asList(
ConversationAction.TYPE_OPEN_URL,
ConversationAction.TYPE_SEND_EMAIL
));
if (!conversation_actions_replies)
excluded.add(ConversationAction.TYPE_TEXT_REPLY);
TextClassifier.EntityConfig config =
new TextClassifier.EntityConfig.Builder()
//.setIncludedTypes(included)
.setExcludedTypes(excluded)
//.includeTypesFromTextClassifier(false)
//.setHints(included)
.build();
List<String> hints = Collections.unmodifiableList(Arrays.asList(
ConversationActions.Request.HINT_FOR_IN_APP
));
ConversationActions.Request crequest =
new ConversationActions.Request.Builder(input)
.setTypeConfig(config)

@ -55,6 +55,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swExternalSearch;
private SwitchCompat swShortcuts;
private SwitchCompat swConversationActions;
private SwitchCompat swConversationActionsReplies;
private SwitchCompat swFts;
private TextView tvFtsIndexed;
private TextView tvFtsPro;
@ -77,10 +78,12 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvStorageSpace;
private TextView tvFingerprint;
private Group grpConversationActions;
private Group grpDebug;
private final static String[] RESET_OPTIONS = new String[]{
"shortcuts", "conversation_actions", "fts", "english", "watchdog", "auto_optimize", "updates", "experiments", "crash_reports", "debug"
"shortcuts", "conversation_actions", "conversation_actions_replies",
"fts", "english", "watchdog", "auto_optimize", "updates", "experiments", "crash_reports", "debug"
};
private final static String[] RESET_QUESTIONS = new String[]{
@ -103,6 +106,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swExternalSearch = view.findViewById(R.id.swExternalSearch);
swShortcuts = view.findViewById(R.id.swShortcuts);
swConversationActions = view.findViewById(R.id.swConversationActions);
swConversationActionsReplies = view.findViewById(R.id.swConversationActionsReplies);
swFts = view.findViewById(R.id.swFts);
tvFtsIndexed = view.findViewById(R.id.tvFtsIndexed);
tvFtsPro = view.findViewById(R.id.tvFtsPro);
@ -125,6 +129,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvStorageSpace = view.findViewById(R.id.tvStorageSpace);
tvFingerprint = view.findViewById(R.id.tvFingerprint);
grpConversationActions = view.findViewById(R.id.grpConversationActions);
grpDebug = view.findViewById(R.id.grpDebug);
setOptions();
@ -158,6 +163,14 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("conversation_actions", checked).apply();
swConversationActionsReplies.setEnabled(checked);
}
});
swConversationActionsReplies.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("conversation_actions_replies", checked).apply();
}
});
@ -401,7 +414,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swExternalSearch.setChecked(state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
swShortcuts.setChecked(prefs.getBoolean("shortcuts", true));
swConversationActions.setChecked(prefs.getBoolean("conversation_actions", true));
swConversationActions.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ? View.VISIBLE : View.GONE);
swConversationActionsReplies.setChecked(prefs.getBoolean("conversation_actions_replies", true));
swConversationActionsReplies.setEnabled(swConversationActions.isChecked());
swFts.setChecked(prefs.getBoolean("fts", false));
swEnglish.setChecked(prefs.getBoolean("english", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
@ -426,6 +440,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
Helper.humanReadableByteCount(Helper.getTotalStorageSpace(), true)));
tvFingerprint.setText(Helper.getFingerprint(getContext()));
grpConversationActions.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ? View.VISIBLE : View.GONE);
grpDebug.setVisibility(swDebug.isChecked() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
}

@ -69,13 +69,25 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:checked="true"
android:text="@string/title_advanced_conversation_actions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvShortcutsHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swConversationActionsReplies"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_conversation_actions_replies"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swConversationActions"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFts"
android:layout_width="0dp"
@ -84,7 +96,7 @@
android:text="@string/title_advanced_fts"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swConversationActions"
app:layout_constraintTop_toBottomOf="@id/swConversationActionsReplies"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
@ -352,6 +364,12 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvStorageSpace" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpConversationActions"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="swConversationActions,swConversationActionsReplies" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpDebug"
android:layout_width="0dp"

@ -427,7 +427,8 @@
<string name="title_advanced_external_search">Allow other apps to search in messages</string>
<string name="title_advanced_shortcuts">Show frequently used contacts in Android share menu</string>
<string name="title_advanced_conversation_actions">Show quick actions</string>
<string name="title_advanced_conversation_actions">Suggest actions</string>
<string name="title_advanced_conversation_actions_replies">Suggest reply texts</string>
<string name="title_advanced_fts">Build search index</string>
<string name="title_advanced_fts_indexed">%1$d / %2$d messages indexed (%3$s)</string>
<string name="title_advanced_english">Force English language</string>
@ -1127,8 +1128,8 @@
<string name="title_set">Set</string>
<string name="title_fetching_again">Fetching message again from the server</string>
<string name="title_conversation_actions">Quick actions</string>
<string name="title_conversation_action_reply">Start reply with: \'%1$s\'</string>
<string name="title_conversation_actions">Actions</string>
<string name="title_conversation_action_reply">Reply with: \'%1$s\'</string>
<string name="title_icalendar_accept">Accept</string>
<string name="title_icalendar_decline">Decline</string>

Loading…
Cancel
Save