Added global keywords

pull/209/head
M66B 2 years ago
parent 10dd18a16a
commit d2fb3b154c

@ -8206,16 +8206,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final long id = getArguments().getLong("id");
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_keyword_manage, null);
final Context context = getContext();
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_keyword_manage, null);
final RecyclerView rvKeyword = dview.findViewById(R.id.rvKeyword);
final FloatingActionButton fabAdd = dview.findViewById(R.id.fabAdd);
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
rvKeyword.setHasFixedSize(false);
final LinearLayoutManager llm = new LinearLayoutManager(getContext());
final LinearLayoutManager llm = new LinearLayoutManager(context);
rvKeyword.setLayoutManager(llm);
final AdapterKeyword adapter = new AdapterKeyword(getContext(), getViewLifecycleOwner());
final AdapterKeyword adapter = new AdapterKeyword(context, getViewLifecycleOwner());
rvKeyword.setAdapter(adapter);
fabAdd.setOnClickListener(new View.OnClickListener() {
@ -8232,16 +8233,26 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbWait.setVisibility(View.VISIBLE);
DB db = DB.getInstance(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
DB db = DB.getInstance(context);
db.message().liveMessageKeywords(id).observe(getViewLifecycleOwner(), new Observer<TupleKeyword.Persisted>() {
@Override
public void onChanged(TupleKeyword.Persisted data) {
String global = prefs.getString("global_keywords", null);
if (global != null) {
List<String> available = new ArrayList<>();
available.addAll(Arrays.asList(global.split(" ")));
if (data != null && data.available != null)
available.addAll(Arrays.asList(data.available));
data.available = available.toArray(new String[0]);
}
pbWait.setVisibility(View.GONE);
adapter.set(id, TupleKeyword.from(getContext(), data));
adapter.set(id, TupleKeyword.from(context, data));
}
});
return new AlertDialog.Builder(getContext())
return new AlertDialog.Builder(context)
.setIcon(R.drawable.twotone_label_important_24)
.setTitle(R.string.title_manage_keywords)
.setView(dview)

@ -197,6 +197,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swExactAlarms;
private SwitchCompat swInfra;
private SwitchCompat swDupMsgId;
private EditText etKeywords;
private SwitchCompat swTestIab;
private Button btnImportProviders;
private TextView tvProcessors;
@ -243,7 +244,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"use_modseq", "uid_command", "perform_expunge", "uid_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "auth_apop", "use_top",
"keep_alive_poll", "empty_pool", "idle_done", "logarithmic_backoff",
"exact_alarms", "infra", "dkim_verify", "dup_msgids", "test_iab"
"exact_alarms", "infra", "dkim_verify", "dup_msgids", "global_keywords", "test_iab"
};
private final static String[] RESET_QUESTIONS = new String[]{
@ -392,6 +393,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swExactAlarms = view.findViewById(R.id.swExactAlarms);
swInfra = view.findViewById(R.id.swInfra);
swDupMsgId = view.findViewById(R.id.swDupMsgId);
etKeywords = view.findViewById(R.id.etKeywords);
swTestIab = view.findViewById(R.id.swTestIab);
btnImportProviders = view.findViewById(R.id.btnImportProviders);
tvProcessors = view.findViewById(R.id.tvProcessors);
@ -1347,6 +1349,32 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
etKeywords.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
}
@Override
public void afterTextChanged(Editable s) {
String keywords = s.toString().trim();
String[] keyword = keywords.replaceAll("\\s+", " ").split(" ");
for (int i = 0; i < keyword.length; i++)
keyword[i] = MessageHelper.sanitizeKeyword(keyword[i]);
keywords = String.join(" ", keyword);
if (TextUtils.isEmpty(keywords))
prefs.edit().remove("global_keywords").apply();
else
prefs.edit().putString("global_keywords", keywords).apply();
}
});
swTestIab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1754,6 +1782,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
if ("vt_apikey".equals(key) || "send_host".equals(key))
return;
if ("global_keywords".equals(key))
return;
setOptions();
}
@ -1974,6 +2005,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
swInfra.setChecked(prefs.getBoolean("infra", false));
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
etKeywords.setText(prefs.getString("global_keywords", null));
swTestIab.setChecked(prefs.getBoolean("test_iab", false));
tvProcessors.setText(getString(R.string.title_advanced_processors, Runtime.getRuntime().availableProcessors()));

@ -322,10 +322,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
app:drawableTint="?attr/colorWarning"
android:text="@string/title_advanced_privacy_risk"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
app:drawableTint="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLanguageTool" />
@ -336,10 +336,10 @@
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLanguageToolHint" />
@ -372,10 +372,10 @@
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDeepL" />
@ -408,10 +408,10 @@
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swVirusTotal" />
@ -620,10 +620,10 @@
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:text="@string/title_advanced_sdcard"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLastCleanup" />
@ -672,12 +672,12 @@
android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_warning_24"
android:drawablePadding="6dp"
app:drawableTint="?attr/colorWarning"
android:gravity="center"
android:text="@string/title_setup_advanced"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="?attr/colorWarning"
android:textStyle="bold"
app:drawableTint="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -716,10 +716,10 @@
android:layout_marginTop="6dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:text="@string/title_advanced_experiments_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swExperiments" />
@ -910,11 +910,11 @@
android:drawableStart="@drawable/twotone_warning_24"
android:drawableEnd="@drawable/twotone_warning_24"
android:drawablePadding="6dp"
app:drawableTint="?attr/colorWarning"
android:gravity="center"
android:text="@string/title_advanced_caption_debug"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textStyle="bold"
app:drawableTint="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -962,8 +962,8 @@
android:layout_marginTop="12dp"
android:drawableStart="@drawable/twotone_warning_24"
android:drawablePadding="6dp"
app:drawableTint="?attr/colorWarning"
android:text="@string/title_advanced_external_storage"
app:drawableTint="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swWorkManager"
@ -1648,6 +1648,7 @@
android:id="@+id/tvDkimVerifyHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_usage_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
@ -1668,6 +1669,18 @@
app:layout_constraintTop_toBottomOf="@id/tvDkimVerifyHint"
app:switchPadding="12dp" />
<EditText
android:id="@+id/etKeywords"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="Global keywords"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDupMsgId" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swTestIab"
android:layout_width="0dp"
@ -1676,7 +1689,7 @@
android:text="@string/title_advanced_test_iab"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDupMsgId"
app:layout_constraintTop_toBottomOf="@id/etKeywords"
app:switchPadding="12dp" />
<Button

Loading…
Cancel
Save