mirror of https://github.com/M66B/FairEmail.git
Added rule action icons
This commit is contained in:
parent
c9e7248453
commit
71db19e4e4
|
@ -529,7 +529,32 @@ public class FragmentRule extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
adapterAction = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList<Action>());
|
||||
int dp6 = Helper.dp2pixels(getContext(), 6);
|
||||
adapterAction = new ArrayAdapter<Action>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList<>()) {
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
return getView(position, super.getView(position, convertView, parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
return getView(position, super.getDropDownView(position, convertView, parent));
|
||||
}
|
||||
|
||||
private View getView(int position, View view) {
|
||||
Action action = getItem(position);
|
||||
if (action != null) {
|
||||
TextView tv = view.findViewById(android.R.id.text1);
|
||||
if (tv != null) {
|
||||
tv.setText(action.name);
|
||||
tv.setCompoundDrawablePadding(dp6);
|
||||
tv.setCompoundDrawablesRelativeWithIntrinsicBounds(action.icon, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
};
|
||||
adapterAction.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
||||
spAction.setAdapter(adapterAction);
|
||||
|
||||
|
@ -654,31 +679,31 @@ public class FragmentRule extends FragmentBase {
|
|||
});
|
||||
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(new Action(EntityRule.TYPE_NOOP, getString(R.string.title_rule_noop)));
|
||||
actions.add(new Action(EntityRule.TYPE_SEEN, getString(R.string.title_rule_seen)));
|
||||
actions.add(new Action(EntityRule.TYPE_UNSEEN, getString(R.string.title_rule_unseen)));
|
||||
actions.add(new Action(EntityRule.TYPE_HIDE, getString(R.string.title_rule_hide)));
|
||||
actions.add(new Action(EntityRule.TYPE_IGNORE, getString(R.string.title_rule_ignore)));
|
||||
actions.add(new Action(EntityRule.TYPE_SILENT, getString(R.string.title_rule_silent)));
|
||||
actions.add(new Action(EntityRule.TYPE_NOOP, getString(R.string.title_rule_noop), R.drawable.twotone_close_24));
|
||||
actions.add(new Action(EntityRule.TYPE_SEEN, getString(R.string.title_rule_seen), R.drawable.twotone_drafts_24));
|
||||
actions.add(new Action(EntityRule.TYPE_UNSEEN, getString(R.string.title_rule_unseen), R.drawable.twotone_mail_24));
|
||||
actions.add(new Action(EntityRule.TYPE_HIDE, getString(R.string.title_rule_hide), R.drawable.twotone_visibility_off_24));
|
||||
actions.add(new Action(EntityRule.TYPE_IGNORE, getString(R.string.title_rule_ignore), R.drawable.twotone_notifications_off_24));
|
||||
actions.add(new Action(EntityRule.TYPE_SILENT, getString(R.string.title_rule_silent), R.drawable.twotone_volume_off_24));
|
||||
if (BuildConfig.DEBUG)
|
||||
actions.add(new Action(EntityRule.TYPE_LOCAL_ONLY, getString(R.string.title_rule_local_only)));
|
||||
actions.add(new Action(EntityRule.TYPE_SNOOZE, getString(R.string.title_rule_snooze)));
|
||||
actions.add(new Action(EntityRule.TYPE_FLAG, getString(R.string.title_rule_flag)));
|
||||
actions.add(new Action(EntityRule.TYPE_IMPORTANCE, getString(R.string.title_rule_importance)));
|
||||
actions.add(new Action(EntityRule.TYPE_LOCAL_ONLY, getString(R.string.title_rule_local_only), R.drawable.twotone_android_24));
|
||||
actions.add(new Action(EntityRule.TYPE_SNOOZE, getString(R.string.title_rule_snooze), R.drawable.twotone_timelapse_24));
|
||||
actions.add(new Action(EntityRule.TYPE_FLAG, getString(R.string.title_rule_flag), R.drawable.twotone_star_24));
|
||||
actions.add(new Action(EntityRule.TYPE_IMPORTANCE, getString(R.string.title_rule_importance), R.drawable.twotone_north_24));
|
||||
if (protocol == EntityAccount.TYPE_IMAP)
|
||||
actions.add(new Action(EntityRule.TYPE_KEYWORD, getString(R.string.title_rule_keyword)));
|
||||
actions.add(new Action(EntityRule.TYPE_NOTES, getString(R.string.title_rule_notes)));
|
||||
actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_rule_move)));
|
||||
actions.add(new Action(EntityRule.TYPE_KEYWORD, getString(R.string.title_rule_keyword), R.drawable.twotone_label_important_24));
|
||||
actions.add(new Action(EntityRule.TYPE_NOTES, getString(R.string.title_rule_notes), R.drawable.twotone_sticky_note_2_24));
|
||||
actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_rule_move), R.drawable.twotone_drive_file_move_24));
|
||||
if (protocol == EntityAccount.TYPE_IMAP)
|
||||
actions.add(new Action(EntityRule.TYPE_COPY, getString(R.string.title_rule_copy)));
|
||||
actions.add(new Action(EntityRule.TYPE_DELETE, getString(R.string.title_rule_delete)));
|
||||
actions.add(new Action(EntityRule.TYPE_ANSWER, getString(R.string.title_rule_answer)));
|
||||
actions.add(new Action(EntityRule.TYPE_COPY, getString(R.string.title_rule_copy), R.drawable.twotone_file_copy_24));
|
||||
actions.add(new Action(EntityRule.TYPE_DELETE, getString(R.string.title_rule_delete), R.drawable.twotone_delete_forever_24));
|
||||
actions.add(new Action(EntityRule.TYPE_ANSWER, getString(R.string.title_rule_answer), R.drawable.twotone_reply_24));
|
||||
if (AI.isAvailable(getContext()))
|
||||
actions.add(new Action(EntityRule.TYPE_SUMMARIZE, getString(R.string.title_rule_summarize)));
|
||||
actions.add(new Action(EntityRule.TYPE_TTS, getString(R.string.title_rule_tts)));
|
||||
actions.add(new Action(EntityRule.TYPE_SOUND, getString(R.string.title_rule_sound)));
|
||||
actions.add(new Action(EntityRule.TYPE_AUTOMATION, getString(R.string.title_rule_automation)));
|
||||
actions.add(new Action(EntityRule.TYPE_URL, getString(R.string.title_rule_url)));
|
||||
actions.add(new Action(EntityRule.TYPE_SUMMARIZE, getString(R.string.title_rule_summarize), R.drawable.twotone_smart_toy_24));
|
||||
actions.add(new Action(EntityRule.TYPE_TTS, getString(R.string.title_rule_tts), R.drawable.twotone_record_voice_over_24));
|
||||
actions.add(new Action(EntityRule.TYPE_SOUND, getString(R.string.title_rule_sound), R.drawable.twotone_play_arrow_24));
|
||||
actions.add(new Action(EntityRule.TYPE_AUTOMATION, getString(R.string.title_rule_automation), R.drawable.twotone_auto_awesome_24));
|
||||
actions.add(new Action(EntityRule.TYPE_URL, getString(R.string.title_rule_url), R.drawable.twotone_insert_link_45_24));
|
||||
adapterAction.addAll(actions);
|
||||
|
||||
spAction.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
@ -1897,10 +1922,12 @@ public class FragmentRule extends FragmentBase {
|
|||
private static class Action {
|
||||
int type;
|
||||
String name;
|
||||
int icon;
|
||||
|
||||
Action(int type, String name) {
|
||||
Action(int type, String name, int icon) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:autoMirrored="true">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7.83,11H5v2h2.83L10,15.17v-3.76l-1.29,-1.29z"
|
||||
android:strokeAlpha="0.3"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4.34,2.93L2.93,4.34 7.29,8.7 7,9L3,9v6h4l5,5v-6.59l4.18,4.18c-0.65,0.49 -1.38,0.88 -2.18,1.11v2.06c1.34,-0.3 2.57,-0.92 3.61,-1.75l2.05,2.05 1.41,-1.41L4.34,2.93zM10,15.17L7.83,13L5,13v-2h2.83l0.88,-0.88L10,11.41v3.76zM19,12c0,0.82 -0.15,1.61 -0.41,2.34l1.53,1.53c0.56,-1.17 0.88,-2.48 0.88,-3.87 0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM12,4l-1.88,1.88L12,7.76zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v1.79l2.48,2.48c0.01,-0.08 0.02,-0.16 0.02,-0.24z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue