mirror of https://github.com/M66B/FairEmail.git
Improved keyword management
This commit is contained in:
parent
cb3e9ecea9
commit
52b103ceba
|
@ -22,8 +22,10 @@ package eu.faircode.email;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -53,6 +55,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
private Context context;
|
||||
private LifecycleOwner owner;
|
||||
private String accountState = null;
|
||||
private boolean debug;
|
||||
|
||||
private List<TupleFolderEx> all = new ArrayList<>();
|
||||
private List<TupleFolderEx> filtered = new ArrayList<>();
|
||||
|
@ -146,7 +149,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
|
||||
tvKeywords.setText(TextUtils.join(" ", folder.keywords));
|
||||
tvKeywords.setVisibility(folder.keywords.length > 0 ? View.VISIBLE : View.GONE);
|
||||
tvKeywords.setVisibility(debug && folder.keywords.length > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvError.setText(folder.error);
|
||||
tvError.setVisibility(folder.error != null && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
|
@ -322,6 +325,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
AdapterFolder(Context context, LifecycleOwner owner) {
|
||||
this.context = context;
|
||||
this.owner = owner;
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1158,6 +1158,12 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
}
|
||||
|
||||
private void onManageKeywords(ActionData data) {
|
||||
if (!Helper.isPro(context)) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable("message", data.message);
|
||||
|
||||
|
@ -1235,10 +1241,11 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
.setNeutralButton(R.string.title_add, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final EditText etKeyword = new EditText(context);
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dialog_keyword, null);
|
||||
final EditText etKeyword = view.findViewById(R.id.etKeyword);
|
||||
etKeyword.setText(null);
|
||||
new DialogBuilderLifecycle(context, owner)
|
||||
.setTitle(R.string.title_add)
|
||||
.setView(etKeyword)
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvKeyword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_add_keyword"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etKeyword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Keyword"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvKeyword" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -211,6 +211,7 @@
|
|||
<string name="title_reply_all">Reply to all</string>
|
||||
<string name="title_show_headers">Show headers</string>
|
||||
<string name="title_manage_keywords">Manage keywords</string>
|
||||
<string name="title_add_keyword">Add keyword</string>
|
||||
<string name="title_show_html">Show original</string>
|
||||
|
||||
<string name="title_trash">Trash</string>
|
||||
|
|
Loading…
Reference in New Issue