mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-09 18:43:23 +02:00
Added AI template option
This commit is contained in:
@@ -79,10 +79,13 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
||||
private View vwColor;
|
||||
private TextView tvName;
|
||||
private ImageView ivExternal;
|
||||
private ImageView ivStandard;
|
||||
private ImageView ivHide;
|
||||
private ImageView ivSnippet;
|
||||
private ImageView ivFavorite;
|
||||
private ImageView ivAi;
|
||||
private ImageView ivReceipt;
|
||||
private ImageView ivStandard;
|
||||
|
||||
private TextView tvLastApplied;
|
||||
private TextView tvApplied;
|
||||
|
||||
@@ -95,10 +98,12 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
||||
vwColor = itemView.findViewById(R.id.vwColor);
|
||||
tvName = itemView.findViewById(R.id.tvName);
|
||||
ivExternal = itemView.findViewById(R.id.ivExternal);
|
||||
ivStandard = itemView.findViewById(R.id.ivStandard);
|
||||
ivHide = itemView.findViewById(R.id.ivHide);
|
||||
ivSnippet = itemView.findViewById(R.id.ivSnippet);
|
||||
ivFavorite = itemView.findViewById(R.id.ivFavorite);
|
||||
ivAi = itemView.findViewById(R.id.ivAi);
|
||||
ivReceipt = itemView.findViewById(R.id.ivReceipt);
|
||||
ivStandard = itemView.findViewById(R.id.ivStandard);
|
||||
tvLastApplied = itemView.findViewById(R.id.tvLastApplied);
|
||||
tvApplied = itemView.findViewById(R.id.tvApplied);
|
||||
}
|
||||
@@ -118,10 +123,12 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
||||
vwColor.setBackgroundColor(answer.color == null ? Color.TRANSPARENT : answer.color);
|
||||
tvName.setText(answer.name);
|
||||
ivExternal.setVisibility(answer.external ? View.VISIBLE : View.GONE);
|
||||
ivStandard.setVisibility(answer.standard ? View.VISIBLE : View.GONE);
|
||||
ivHide.setVisibility(answer.hide ? View.VISIBLE : View.GONE);
|
||||
ivSnippet.setVisibility(answer.snippet ? View.VISIBLE : View.GONE);
|
||||
ivFavorite.setVisibility(answer.favorite ? View.VISIBLE : View.GONE);
|
||||
ivAi.setVisibility(answer.ai ? View.VISIBLE : View.GONE);
|
||||
ivReceipt.setVisibility(answer.receipt ? View.VISIBLE : View.GONE);
|
||||
ivStandard.setVisibility(answer.standard ? View.VISIBLE : View.GONE);
|
||||
tvLastApplied.setText(answer.last_applied == null ? null : DF.format(answer.last_applied));
|
||||
tvApplied.setText(NF.format(answer.applied));
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ import javax.mail.internet.InternetAddress;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 294,
|
||||
version = 295,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -3010,6 +3010,12 @@ public abstract class DB extends RoomDatabase {
|
||||
logMigration(startVersion, endVersion);
|
||||
db.execSQL("ALTER TABLE `identity` ADD COLUMN `login` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
}).addMigrations(new Migration(294, 295) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
logMigration(startVersion, endVersion);
|
||||
db.execSQL("ALTER TABLE `answer` ADD COLUMN `ai` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
}).addMigrations(new Migration(998, 999) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
|
||||
@@ -34,6 +34,12 @@ public interface DaoAnswer {
|
||||
" ORDER BY -favorite, name COLLATE NOCASE")
|
||||
List<EntityAnswer> getAnswers(boolean all);
|
||||
|
||||
@Query("SELECT * FROM answer" +
|
||||
" WHERE ai" +
|
||||
" AND NOT hide" +
|
||||
" ORDER BY name COLLATE NOCASE")
|
||||
List<EntityAnswer> getAiPrompts();
|
||||
|
||||
@Query("SELECT * FROM answer" +
|
||||
" WHERE favorite = :favorite" +
|
||||
" AND NOT hide" +
|
||||
|
||||
@@ -91,6 +91,8 @@ public class EntityAnswer implements Serializable {
|
||||
@NonNull
|
||||
public Boolean receipt;
|
||||
@NonNull
|
||||
public Boolean ai;
|
||||
@NonNull
|
||||
public Boolean favorite;
|
||||
@NonNull
|
||||
public Boolean snippet;
|
||||
|
||||
@@ -71,6 +71,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
private AutoCompleteTextView etGroup;
|
||||
private CheckBox cbStandard;
|
||||
private CheckBox cbReceipt;
|
||||
private CheckBox cbAI;
|
||||
private CheckBox cbFavorite;
|
||||
private CheckBox cbSnippet;
|
||||
private CheckBox cbHide;
|
||||
@@ -127,6 +128,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
etGroup = view.findViewById(R.id.etGroup);
|
||||
cbStandard = view.findViewById(R.id.cbStandard);
|
||||
cbReceipt = view.findViewById(R.id.cbReceipt);
|
||||
cbAI = view.findViewById(R.id.cbAI);
|
||||
cbFavorite = view.findViewById(R.id.cbFavorite);
|
||||
cbSnippet = view.findViewById(R.id.cbSnippet);
|
||||
cbHide = view.findViewById(R.id.cbHide);
|
||||
@@ -199,6 +201,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
|
||||
// Initialize
|
||||
etLabel.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
cbAI.setVisibility(View.GONE);
|
||||
cbExternal.setVisibility(View.GONE);
|
||||
cbSnippet.setVisibility(View.GONE);
|
||||
grpReady.setVisibility(View.GONE);
|
||||
@@ -277,6 +280,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
etGroup.setText(answer == null ? null : answer.group);
|
||||
cbStandard.setChecked(answer == null ? false : answer.standard);
|
||||
cbReceipt.setChecked(answer == null ? false : answer.receipt);
|
||||
cbAI.setChecked(answer == null ? false : answer.ai);
|
||||
cbFavorite.setChecked(answer == null ? false : answer.favorite);
|
||||
cbSnippet.setChecked(answer == null ? false : answer.snippet);
|
||||
cbHide.setChecked(answer == null ? false : answer.hide);
|
||||
@@ -293,6 +297,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
|
||||
if (ActivityAnswer.canAnswer(context))
|
||||
cbExternal.setVisibility(View.VISIBLE);
|
||||
cbAI.setVisibility(AI.isAvailable(context) ? View.VISIBLE : View.GONE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
cbSnippet.setVisibility(View.VISIBLE);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
@@ -442,6 +447,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
args.putString("group", etGroup.getText().toString().trim());
|
||||
args.putBoolean("standard", cbStandard.isChecked());
|
||||
args.putBoolean("receipt", cbReceipt.isChecked());
|
||||
args.putBoolean("ai", cbAI.isChecked());
|
||||
args.putBoolean("favorite", cbFavorite.isChecked());
|
||||
args.putBoolean("snippet", cbSnippet.isChecked());
|
||||
args.putBoolean("hide", cbHide.isChecked());
|
||||
@@ -468,6 +474,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
String group = args.getString("group");
|
||||
boolean standard = args.getBoolean("standard");
|
||||
boolean receipt = args.getBoolean("receipt");
|
||||
boolean ai = args.getBoolean("ai");
|
||||
boolean favorite = args.getBoolean("favorite");
|
||||
boolean snippet = args.getBoolean("snippet");
|
||||
boolean hide = args.getBoolean("hide");
|
||||
@@ -506,6 +513,7 @@ public class FragmentAnswer extends FragmentBase {
|
||||
answer.group = group;
|
||||
answer.standard = standard;
|
||||
answer.receipt = receipt;
|
||||
answer.ai = ai;
|
||||
answer.favorite = favorite;
|
||||
answer.snippet = snippet;
|
||||
answer.hide = hide;
|
||||
|
||||
Reference in New Issue
Block a user