Added AI template option

pull/215/head
M66B 7 months ago
parent 2fa388d109
commit f0ba5953e0

File diff suppressed because it is too large Load Diff

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

@ -87,6 +87,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cbStandard" />
<CheckBox
android:id="@+id/cbAI"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:text="@string/title_answer_ai"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cbReceipt" />
<CheckBox
android:id="@+id/cbFavorite"
android:layout_width="wrap_content"
@ -95,7 +105,7 @@
android:layout_marginTop="6dp"
android:text="@string/title_answer_favorite"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cbReceipt" />
app:layout_constraintTop_toBottomOf="@+id/cbAI" />
<CheckBox
android:id="@+id/cbSnippet"

@ -65,45 +65,63 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toStartOf="@id/ivReceipt"
app:layout_constraintEnd_toStartOf="@id/ivHide"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_open_in_new_24" />
<ImageView
android:id="@+id/ivReceipt"
android:id="@+id/ivHide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toStartOf="@id/ivStandard"
app:layout_constraintEnd_toStartOf="@id/ivSnippet"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_playlist_add_check_24" />
app:srcCompat="@drawable/twotone_visibility_off_24" />
<ImageView
android:id="@+id/ivStandard"
android:id="@+id/ivSnippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toStartOf="@id/ivSnippet"
app:layout_constraintEnd_toStartOf="@id/ivFavorite"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_quickreply_24" />
app:srcCompat="@drawable/twotone_text_snippet_24" />
<ImageView
android:id="@+id/ivSnippet"
android:id="@+id/ivFavorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toStartOf="@id/ivFavorite"
app:layout_constraintEnd_toStartOf="@id/ivAi"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_text_snippet_24" />
app:srcCompat="@drawable/twotone_star_24" />
<ImageView
android:id="@+id/ivFavorite"
android:id="@+id/ivAi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toStartOf="@id/ivReceipt"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_smart_toy_24" />
<ImageView
android:id="@+id/ivReceipt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toStartOf="@id/ivStandard"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_playlist_add_check_24" />
<ImageView
android:id="@+id/ivStandard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_star_24" />
app:srcCompat="@drawable/twotone_quickreply_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ViewCardOptional>
</FrameLayout>

@ -2009,6 +2009,7 @@
<string name="title_answer_favorite">Favorite</string>
<string name="title_answer_snippet">Snippet</string>
<string name="title_answer_receipt">Use as read receipt</string>
<string name="title_answer_ai">Use as AI prompt</string>
<string name="title_answer_hide">Hide from menus</string>
<string name="title_answer_external" translatable="false">External</string>
<string name="title_answer_text">Template text</string>

Loading…
Cancel
Save