From a39ae1be0ccc778bcf5ba887e0555eea66adcf01 Mon Sep 17 00:00:00 2001 From: Maria Seiser Date: Mon, 19 Jul 2021 19:23:59 +0200 Subject: [PATCH] CATROID-1163 Add Icons to Menus Created new ArrayAdapter for AlertDialogs to view Icons and added Icons to all options menus --- .../catrobat/catroid/ui/MainMenuActivity.java | 8 +++ .../catrobat/catroid/ui/NfcTagsActivity.kt | 6 ++ .../catrobat/catroid/ui/ProjectActivity.java | 7 ++ .../catroid/ui/ProjectListActivity.java | 7 ++ .../catrobat/catroid/ui/SpriteActivity.java | 8 +++ .../recyclerview/fragment/DataListFragment.kt | 6 ++ .../fragment/ListSelectorFragment.kt | 30 +++++---- .../fragment/LookListFragment.java | 3 + .../fragment/NfcTagListFragment.java | 3 + .../fragment/ProjectListFragment.java | 3 + .../fragment/SceneListFragment.java | 4 ++ .../recyclerview/fragment/ScriptFragment.java | 66 +++++++++++++++++-- .../fragment/SoundListFragment.kt | 7 +- .../fragment/SpriteListFragment.java | 3 + .../src/main/res/drawable/ic_content_copy.xml | 31 +++++++++ .../main/res/drawable/ic_content_paste.xml | 32 +++++++++ catroid/src/main/res/drawable/ic_delete.xml | 31 +++++++++ catroid/src/main/res/drawable/ic_edit.xml | 31 +++++++++ .../main/res/drawable/ic_import_project.xml | 31 +++++++++ catroid/src/main/res/drawable/ic_info.xml | 31 +++++++++ catroid/src/main/res/drawable/ic_login.xml | 31 +++++++++ catroid/src/main/res/drawable/ic_logout.xml | 31 +++++++++ catroid/src/main/res/drawable/ic_merge.xml | 31 +++++++++ .../src/main/res/drawable/ic_placeholder.xml | 32 +++++++++ catroid/src/main/res/drawable/ic_policy.xml | 34 ++++++++++ catroid/src/main/res/drawable/ic_settings.xml | 31 +++++++++ catroid/src/main/res/drawable/ic_sort.xml | 31 +++++++++ .../src/main/res/drawable/ic_star_rate.xml | 31 +++++++++ .../main/res/layout/alert_dialog_layout.xml | 35 ++++++++++ .../main/res/menu/menu_backpack_activity.xml | 10 ++- .../src/main/res/menu/menu_formulaeditor.xml | 1 + catroid/src/main/res/menu/menu_main_menu.xml | 25 ++++--- .../main/res/menu/menu_project_activity.xml | 28 +++++--- .../main/res/menu/menu_projects_activity.xml | 22 +++++-- .../main/res/menu/menu_scratch_projects.xml | 1 + .../main/res/menu/menu_script_activity.xml | 10 +++ 36 files changed, 687 insertions(+), 45 deletions(-) create mode 100644 catroid/src/main/res/drawable/ic_content_copy.xml create mode 100644 catroid/src/main/res/drawable/ic_content_paste.xml create mode 100644 catroid/src/main/res/drawable/ic_delete.xml create mode 100644 catroid/src/main/res/drawable/ic_edit.xml create mode 100644 catroid/src/main/res/drawable/ic_import_project.xml create mode 100644 catroid/src/main/res/drawable/ic_info.xml create mode 100644 catroid/src/main/res/drawable/ic_login.xml create mode 100644 catroid/src/main/res/drawable/ic_logout.xml create mode 100644 catroid/src/main/res/drawable/ic_merge.xml create mode 100644 catroid/src/main/res/drawable/ic_placeholder.xml create mode 100644 catroid/src/main/res/drawable/ic_policy.xml create mode 100644 catroid/src/main/res/drawable/ic_settings.xml create mode 100644 catroid/src/main/res/drawable/ic_sort.xml create mode 100644 catroid/src/main/res/drawable/ic_star_rate.xml create mode 100644 catroid/src/main/res/layout/alert_dialog_layout.xml diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/MainMenuActivity.java b/catroid/src/main/java/org/catrobat/catroid/ui/MainMenuActivity.java index a79e8356e46..867f105fa6e 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/MainMenuActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/MainMenuActivity.java @@ -22,6 +22,7 @@ */ package org.catrobat.catroid.ui; +import android.annotation.SuppressLint; import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; @@ -64,6 +65,7 @@ import java.io.InputStream; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.view.menu.MenuBuilder; import kotlin.Lazy; import static org.catrobat.catroid.common.FlavoredConstants.CATROBAT_HELP_URL; @@ -244,6 +246,7 @@ public void onPause() { } } + @SuppressLint("RestrictedApi") @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main_menu, menu); @@ -257,6 +260,11 @@ public boolean onCreateOptionsMenu(Menu menu) { scratchConverter.length(), scratchConverterBeta.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); menu.findItem(R.id.menu_scratch_converter).setTitle(scratchConverterBeta); + + if (menu instanceof MenuBuilder) { + MenuBuilder m = (MenuBuilder) menu; + m.setOptionalIconsVisible(true); + } return true; } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/NfcTagsActivity.kt b/catroid/src/main/java/org/catrobat/catroid/ui/NfcTagsActivity.kt index de06d90cff5..48fa47004db 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/NfcTagsActivity.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/NfcTagsActivity.kt @@ -23,9 +23,11 @@ package org.catrobat.catroid.ui +import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle import android.view.Menu +import androidx.appcompat.view.menu.MenuBuilder import org.catrobat.catroid.R import org.catrobat.catroid.ui.recyclerview.fragment.NfcTagListFragment @@ -50,8 +52,12 @@ class NfcTagsActivity : BaseActivity() { } } + @SuppressLint("RestrictedApi") override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_script_activity, menu) + if (menu is MenuBuilder) { + menu.setOptionalIconsVisible(true) + } return super.onCreateOptionsMenu(menu) } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/ProjectActivity.java b/catroid/src/main/java/org/catrobat/catroid/ui/ProjectActivity.java index 3466ae4b234..d4df57bd0da 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/ProjectActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/ProjectActivity.java @@ -22,6 +22,7 @@ */ package org.catrobat.catroid.ui; +import android.annotation.SuppressLint; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Intent; @@ -63,6 +64,7 @@ import java.io.File; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.view.menu.MenuBuilder; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -148,9 +150,14 @@ public void setShowProgressBar(boolean show) { findViewById(R.id.fragment_container).setVisibility(show ? View.GONE : View.VISIBLE); } + @SuppressLint("RestrictedApi") @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_project_activity, menu); + if (menu instanceof MenuBuilder) { + MenuBuilder m = (MenuBuilder) menu; + m.setOptionalIconsVisible(true); + } return super.onCreateOptionsMenu(menu); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/ProjectListActivity.java b/catroid/src/main/java/org/catrobat/catroid/ui/ProjectListActivity.java index acd1b22e4be..64c071f138d 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/ProjectListActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/ProjectListActivity.java @@ -22,6 +22,7 @@ */ package org.catrobat.catroid.ui; +import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.util.Log; @@ -33,6 +34,7 @@ import org.catrobat.catroid.ui.recyclerview.dialog.NewProjectDialogFragment; import org.catrobat.catroid.ui.recyclerview.fragment.ProjectListFragment; +import androidx.appcompat.view.menu.MenuBuilder; import androidx.fragment.app.Fragment; public class ProjectListActivity extends BaseCastActivity { @@ -71,10 +73,15 @@ private void loadFragment(Fragment fragment) { .commit(); } + @SuppressLint("RestrictedApi") @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_projects_activity, menu); menu.findItem(R.id.merge).setVisible(BuildConfig.FEATURE_MERGE_ENABLED); + if (menu instanceof MenuBuilder) { + MenuBuilder m = (MenuBuilder) menu; + m.setOptionalIconsVisible(true); + } return super.onCreateOptionsMenu(menu); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java b/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java index 6deeda7b147..56c028aeafc 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java @@ -22,6 +22,7 @@ */ package org.catrobat.catroid.ui; +import android.annotation.SuppressLint; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Intent; @@ -80,6 +81,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.view.menu.MenuBuilder; import androidx.fragment.app.Fragment; import static org.catrobat.catroid.common.Constants.DEFAULT_IMAGE_EXTENSION; @@ -202,10 +204,16 @@ Fragment getCurrentFragment() { return getSupportFragmentManager().findFragmentById(R.id.fragment_container); } + @SuppressLint("RestrictedApi") @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_script_activity, menu); currentMenu = menu; + + if (menu instanceof MenuBuilder) { + MenuBuilder m = (MenuBuilder) menu; + m.setOptionalIconsVisible(true); + } return super.onCreateOptionsMenu(menu); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/DataListFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/DataListFragment.kt index e5f56a1f96b..efd03017dcf 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/DataListFragment.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/DataListFragment.kt @@ -23,6 +23,7 @@ package org.catrobat.catroid.ui.recyclerview.fragment +import android.annotation.SuppressLint import android.content.DialogInterface import android.os.Bundle import android.view.ActionMode @@ -36,6 +37,7 @@ import android.widget.TextView import androidx.annotation.IntDef import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.view.menu.MenuBuilder import androidx.fragment.app.Fragment import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver @@ -76,6 +78,7 @@ class DataListFragment : Fragment(), this.formulaEditorDataInterface = formulaEditorDataInterface } + @SuppressLint("RestrictedApi") override fun onCreateActionMode( mode: ActionMode, menu: Menu @@ -86,6 +89,9 @@ class DataListFragment : Fragment(), } val inflater = mode.menuInflater inflater.inflate(R.menu.context_menu, menu) + if (menu is MenuBuilder) { + menu.setOptionalIconsVisible(true) + } adapter?.showCheckBoxes(true) adapter?.updateDataSet() return true diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ListSelectorFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ListSelectorFragment.kt index fc94b707e04..f5487a723ca 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ListSelectorFragment.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ListSelectorFragment.kt @@ -25,6 +25,7 @@ package org.catrobat.catroid.ui.recyclerview.fragment import android.content.Context import android.content.DialogInterface +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.Menu @@ -47,11 +48,11 @@ import org.catrobat.catroid.ui.UiUtils import org.catrobat.catroid.ui.recyclerview.adapter.DataListAdapter import org.catrobat.catroid.ui.recyclerview.adapter.RVAdapter import org.catrobat.catroid.ui.recyclerview.dialog.TextInputDialog +import org.catrobat.catroid.ui.recyclerview.dialog.textwatcher.DuplicateInputTextWatcher import org.catrobat.catroid.ui.recyclerview.viewholder.CheckableVH import org.catrobat.catroid.utils.ToastUtil -import java.util.ArrayList -import org.catrobat.catroid.ui.recyclerview.dialog.textwatcher.DuplicateInputTextWatcher import org.catrobat.catroid.utils.UserDataUtil +import java.util.ArrayList class ListSelectorFragment : Fragment(), RVAdapter.SelectionListener, RVAdapter.OnItemClickListener> { @@ -270,20 +271,27 @@ class ListSelectorFragment : Fragment(), RVAdapter.SelectionListener, } override fun onSettingsClick(item: UserData<*>, view: View?) { - val elementList = arrayOf(getString(R.string.delete), getString(R.string.rename)) val popupMenu = PopupMenu(context, view) - for (element: CharSequence in elementList) popupMenu.menu.add(element) + val itemList: MutableList> = ArrayList() + itemList.add(item) + + popupMenu.menuInflater.inflate(R.menu.menu_project_activity, popupMenu.menu) popupMenu.setOnMenuItemClickListener { menuItem -> - when (menuItem.title) { - getString(R.string.rename) -> showRenameDialog( - listOf(item) - ) - getString(R.string.delete) -> showDeleteAlert( - listOf(item) - ) + when (menuItem.itemId) { + R.id.rename -> showRenameDialog(listOf(item)) + R.id.delete -> showDeleteAlert(listOf(item)) } true } + popupMenu.menu.findItem(R.id.backpack).isVisible = false + popupMenu.menu.findItem(R.id.copy).isVisible = false + popupMenu.menu.findItem(R.id.new_group).isVisible = false + popupMenu.menu.findItem(R.id.new_scene).isVisible = false + popupMenu.menu.findItem(R.id.show_details).isVisible = false + popupMenu.menu.findItem(R.id.project_options).isVisible = false + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + popupMenu.setForceShowIcon(true) + } popupMenu.show() } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.java index bb067d9593c..0205874bb2c 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/LookListFragment.java @@ -308,6 +308,9 @@ public boolean onMenuItemClick(MenuItem menuItem) { popupMenu.getMenu().findItem(R.id.new_scene).setVisible(false); popupMenu.getMenu().findItem(R.id.show_details).setVisible(false); popupMenu.getMenu().findItem(R.id.project_options).setVisible(false); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { + popupMenu.setForceShowIcon(true); + } popupMenu.show(); } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/NfcTagListFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/NfcTagListFragment.java index 5ca9e37ce4e..38749602197 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/NfcTagListFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/NfcTagListFragment.java @@ -231,6 +231,9 @@ public boolean onMenuItemClick(MenuItem menuItem) { popupMenu.getMenu().findItem(R.id.new_scene).setVisible(false); popupMenu.getMenu().findItem(R.id.show_details).setVisible(false); popupMenu.getMenu().findItem(R.id.project_options).setVisible(false); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { + popupMenu.setForceShowIcon(true); + } popupMenu.show(); } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.java index 0698fa8b176..4507012440d 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.java @@ -464,6 +464,9 @@ public boolean onMenuItemClick(MenuItem menuItem) { popupMenu.getMenu().findItem(R.id.new_group).setVisible(false); popupMenu.getMenu().findItem(R.id.new_scene).setVisible(false); popupMenu.getMenu().findItem(R.id.show_details).setVisible(false); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { + popupMenu.setForceShowIcon(true); + } popupMenu.show(); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SceneListFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SceneListFragment.java index e4a67a49fec..7eb7bf187eb 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SceneListFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SceneListFragment.java @@ -24,6 +24,7 @@ package org.catrobat.catroid.ui.recyclerview.fragment; import android.content.Intent; +import android.os.Build; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -49,6 +50,7 @@ import java.util.List; import androidx.annotation.PluralsRes; +import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import static org.catrobat.catroid.common.Constants.Z_INDEX_BACKGROUND; @@ -248,6 +250,7 @@ public void onItemClick(Scene item) { } } + @RequiresApi(api = Build.VERSION_CODES.Q) @Override public void onSettingsClick(Scene item, View view) { PopupMenu popupMenu = new PopupMenu(getContext(), view); @@ -283,6 +286,7 @@ public boolean onMenuItemClick(MenuItem menuItem) { popupMenu.getMenu().findItem(R.id.new_scene).setVisible(false); popupMenu.getMenu().findItem(R.id.show_details).setVisible(false); popupMenu.getMenu().findItem(R.id.project_options).setVisible(false); + popupMenu.setForceShowIcon(true); popupMenu.show(); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ScriptFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ScriptFragment.java index d61d9592d60..6cc4a5b4f3f 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ScriptFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ScriptFragment.java @@ -23,6 +23,7 @@ package org.catrobat.catroid.ui.recyclerview.fragment; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -36,6 +37,9 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; +import android.widget.TextView; import org.catrobat.catroid.BuildConfig; import org.catrobat.catroid.ProjectManager; @@ -641,20 +645,72 @@ public void onItemClick(Brick brick, int position) { listView.cancelHighlighting(); return; } + List options = getContextMenuItems(brick); - CharSequence[] items = new CharSequence[options.size()]; + CharSequence[] names = new CharSequence[options.size()]; + int[] icons = new int[options.size()]; for (int i = 0; i < options.size(); i++) { - items[i] = getString(options.get(i)); + names[i] = getString(options.get(i)); + icons[i] = getIconForItem(options.get(i)); } View brickView = brick.getView(getContext()); brick.disableSpinners(); + ListAdapter arrayAdapter = new ArrayAdapter(getContext(), + R.layout.alert_dialog_layout, R.id.title_option_item, options) { + TextView item; + + public View getView(int position, View convertView, ViewGroup parent) { + final LayoutInflater inflater = (LayoutInflater) getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + if (convertView == null) { + convertView = inflater.inflate( + R.layout.alert_dialog_layout, parent, false); + + item = (TextView) convertView + .findViewById(R.id.title_option_item); + convertView.setTag(item); + } else { + // view already defined, retrieve view holder + item = (TextView) convertView.getTag(); + } + + item.setText(names[position]); + item.setCompoundDrawablesWithIntrinsicBounds(icons[position], 0, 0, 0); + return convertView; + } + }; + new AlertDialog.Builder(getContext()) - .setCustomTitle(brickView) - .setItems(items, (dialog, which) -> handleContextMenuItemClick(options.get(which), brick, position)) - .show(); + .setCustomTitle(brickView) + .setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + handleContextMenuItemClick(options.get(which), brick, position); + } + }).show(); + } + + private int getIconForItem(int itemId) { + switch (itemId) { + case R.string.backpack_add: + return R.drawable.ic_content_paste; + case R.string.brick_context_dialog_copy_brick: + case R.string.brick_context_dialog_copy_script: + return R.drawable.ic_content_copy; + case R.string.brick_context_dialog_delete_brick: + case R.string.brick_context_dialog_delete_script: + return R.drawable.ic_delete; + case R.string.brick_context_dialog_formula_edit_brick: + return R.drawable.ic_edit; + case R.string.brick_context_dialog_help: + return R.drawable.ic_main_menu_help; + default: + return R.drawable.ic_placeholder; + } } private List getContextMenuItems(Brick brick) { diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SoundListFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SoundListFragment.kt index 645d5e95850..f8cb94f36d7 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SoundListFragment.kt +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SoundListFragment.kt @@ -23,11 +23,13 @@ package org.catrobat.catroid.ui.recyclerview.fragment import android.content.Intent +import android.os.Build import android.util.Log import android.view.Menu import android.view.View import android.widget.PopupMenu import androidx.annotation.PluralsRes +import androidx.annotation.RequiresApi import org.catrobat.catroid.BuildConfig import org.catrobat.catroid.ProjectManager import org.catrobat.catroid.R @@ -199,8 +201,6 @@ class SoundListFragment : RecyclerViewFragment() { R.id.copy -> copyItems(itemList) R.id.rename -> showRenameDialog(item) R.id.delete -> deleteItems(itemList) - else -> { - } } true } @@ -209,6 +209,9 @@ class SoundListFragment : RecyclerViewFragment() { popupMenu.menu.findItem(R.id.new_scene).isVisible = false popupMenu.menu.findItem(R.id.show_details).isVisible = false popupMenu.menu.findItem(R.id.project_options).isVisible = false + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + popupMenu.setForceShowIcon(true) + } popupMenu.show() } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SpriteListFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SpriteListFragment.java index f71cbd94cce..42303542695 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SpriteListFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/SpriteListFragment.java @@ -356,6 +356,9 @@ public boolean onMenuItemClick(MenuItem menuItem) { popupMenu.getMenu().findItem(R.id.new_scene).setVisible(false); popupMenu.getMenu().findItem(R.id.show_details).setVisible(false); popupMenu.getMenu().findItem(R.id.project_options).setVisible(false); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { + popupMenu.setForceShowIcon(true); + } popupMenu.show(); } diff --git a/catroid/src/main/res/drawable/ic_content_copy.xml b/catroid/src/main/res/drawable/ic_content_copy.xml new file mode 100644 index 00000000000..88a7d0cf9ce --- /dev/null +++ b/catroid/src/main/res/drawable/ic_content_copy.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_content_paste.xml b/catroid/src/main/res/drawable/ic_content_paste.xml new file mode 100644 index 00000000000..557ad7e34ad --- /dev/null +++ b/catroid/src/main/res/drawable/ic_content_paste.xml @@ -0,0 +1,32 @@ + + + + + diff --git a/catroid/src/main/res/drawable/ic_delete.xml b/catroid/src/main/res/drawable/ic_delete.xml new file mode 100644 index 00000000000..46af5e632f4 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_delete.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_edit.xml b/catroid/src/main/res/drawable/ic_edit.xml new file mode 100644 index 00000000000..0460b599c2f --- /dev/null +++ b/catroid/src/main/res/drawable/ic_edit.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_import_project.xml b/catroid/src/main/res/drawable/ic_import_project.xml new file mode 100644 index 00000000000..f845add52c9 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_import_project.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_info.xml b/catroid/src/main/res/drawable/ic_info.xml new file mode 100644 index 00000000000..ef11755b32a --- /dev/null +++ b/catroid/src/main/res/drawable/ic_info.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_login.xml b/catroid/src/main/res/drawable/ic_login.xml new file mode 100644 index 00000000000..aeb82f4a89b --- /dev/null +++ b/catroid/src/main/res/drawable/ic_login.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_logout.xml b/catroid/src/main/res/drawable/ic_logout.xml new file mode 100644 index 00000000000..a77709ce5a9 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_logout.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_merge.xml b/catroid/src/main/res/drawable/ic_merge.xml new file mode 100644 index 00000000000..fc52e447a63 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_merge.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_placeholder.xml b/catroid/src/main/res/drawable/ic_placeholder.xml new file mode 100644 index 00000000000..f3466ecc8ee --- /dev/null +++ b/catroid/src/main/res/drawable/ic_placeholder.xml @@ -0,0 +1,32 @@ + + + + + diff --git a/catroid/src/main/res/drawable/ic_policy.xml b/catroid/src/main/res/drawable/ic_policy.xml new file mode 100644 index 00000000000..62da1f184c6 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_policy.xml @@ -0,0 +1,34 @@ + + + + + diff --git a/catroid/src/main/res/drawable/ic_settings.xml b/catroid/src/main/res/drawable/ic_settings.xml new file mode 100644 index 00000000000..6a6474dc1c2 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_settings.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_sort.xml b/catroid/src/main/res/drawable/ic_sort.xml new file mode 100644 index 00000000000..3177bf6fbfd --- /dev/null +++ b/catroid/src/main/res/drawable/ic_sort.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/drawable/ic_star_rate.xml b/catroid/src/main/res/drawable/ic_star_rate.xml new file mode 100644 index 00000000000..ce38b4e3783 --- /dev/null +++ b/catroid/src/main/res/drawable/ic_star_rate.xml @@ -0,0 +1,31 @@ + + + + diff --git a/catroid/src/main/res/layout/alert_dialog_layout.xml b/catroid/src/main/res/layout/alert_dialog_layout.xml new file mode 100644 index 00000000000..94dd877bba5 --- /dev/null +++ b/catroid/src/main/res/layout/alert_dialog_layout.xml @@ -0,0 +1,35 @@ + + + + diff --git a/catroid/src/main/res/menu/menu_backpack_activity.xml b/catroid/src/main/res/menu/menu_backpack_activity.xml index 6b5007e2f28..1d692d67ee1 100644 --- a/catroid/src/main/res/menu/menu_backpack_activity.xml +++ b/catroid/src/main/res/menu/menu_backpack_activity.xml @@ -21,6 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> + @@ -28,16 +29,19 @@ + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> + app:showAsAction="never" + android:icon="@drawable/ic_delete"/> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> diff --git a/catroid/src/main/res/menu/menu_formulaeditor.xml b/catroid/src/main/res/menu/menu_formulaeditor.xml index 07a49dca9aa..5b10a164928 100644 --- a/catroid/src/main/res/menu/menu_formulaeditor.xml +++ b/catroid/src/main/res/menu/menu_formulaeditor.xml @@ -21,6 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> + diff --git a/catroid/src/main/res/menu/menu_main_menu.xml b/catroid/src/main/res/menu/menu_main_menu.xml index f6673800eea..52106569428 100644 --- a/catroid/src/main/res/menu/menu_main_menu.xml +++ b/catroid/src/main/res/menu/menu_main_menu.xml @@ -21,6 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> + @@ -34,35 +35,43 @@ + app:showAsAction="never" + android:icon="@drawable/ic_star_rate" /> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> + app:showAsAction="never" + android:icon="@drawable/ic_policy"/> + app:showAsAction="never" + android:icon="@drawable/ic_info"/> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> + app:showAsAction="never" + android:icon="@drawable/ic_settings" /> + app:showAsAction="never" + android:icon="@drawable/ic_login"/> + app:showAsAction="never" + android:icon="@drawable/ic_logout"/> + app:showAsAction="never" + android:icon="@drawable/ic_content_paste"/> + app:showAsAction="never" + android:icon="@drawable/ic_content_copy"/> + android:icon="@drawable/ic_delete" + app:showAsAction="never" + /> + android:icon="@drawable/ic_edit" + app:showAsAction="never" + /> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder" + /> - + app:showAsAction="never" + android:icon="@drawable/ic_settings"/> diff --git a/catroid/src/main/res/menu/menu_projects_activity.xml b/catroid/src/main/res/menu/menu_projects_activity.xml index 86ca8b3d74c..4d880477623 100644 --- a/catroid/src/main/res/menu/menu_projects_activity.xml +++ b/catroid/src/main/res/menu/menu_projects_activity.xml @@ -21,6 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> + @@ -28,23 +29,28 @@ + app:showAsAction="never" + android:icon="@drawable/ic_import_project"/> + app:showAsAction="never" + android:icon="@drawable/ic_content_copy"/> + app:showAsAction="never" + android:icon="@drawable/ic_delete"/> + app:showAsAction="never" + android:icon="@drawable/ic_edit"/> + app:showAsAction="never" + android:icon="@drawable/ic_placeholder"/> + app:showAsAction="never" + android:icon="@drawable/ic_merge"/> + app:showAsAction="never" + android:icon="@drawable/ic_sort"/> diff --git a/catroid/src/main/res/menu/menu_scratch_projects.xml b/catroid/src/main/res/menu/menu_scratch_projects.xml index 5e0320feb53..2030d5153c7 100644 --- a/catroid/src/main/res/menu/menu_scratch_projects.xml +++ b/catroid/src/main/res/menu/menu_scratch_projects.xml @@ -21,6 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> + diff --git a/catroid/src/main/res/menu/menu_script_activity.xml b/catroid/src/main/res/menu/menu_script_activity.xml index dabb876b73d..cb2f481711f 100644 --- a/catroid/src/main/res/menu/menu_script_activity.xml +++ b/catroid/src/main/res/menu/menu_script_activity.xml @@ -21,6 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> + @@ -36,39 +37,48 @@ android:id="@+id/backpack" android:visible="true" android:title="@string/backpack" + android:icon="@drawable/ic_content_paste" app:showAsAction="never" />