Added option to disable text reply suggestion

This commit is contained in:
M66B
2020-03-20 11:23:44 +01:00
parent 9ca688b35f
commit 0c7c894ccc
4 changed files with 48 additions and 20 deletions

View File

@@ -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)

View File

@@ -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);
}