diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-04-21 15:52:54 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-04-21 20:59:56 +0200 |
commit | 62524dcf152b274b855005402d082debaa3fc84a (patch) | |
tree | 37cf01a649575404d7dd34d42ee3ddf1c829aebb /android | |
parent | a03d7b1871673473b6201a8a15be175d7b65d71d (diff) |
android: Avoid using resource ID in switch-case
Adresses this warning shown in Android Studio:
> Resource IDs will be non-final by default in Android Gradle Plugin
> version 8.0, avoid using them in switch case statements
Change-Id: I8cead0ceb3b71e263b29d4283a8cfac522ed4204
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133266
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index f2e366c90ed3..3b7b401804b8 100644 --- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -318,19 +318,18 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.action_about: { - AboutDialogFragment aboutDialogFragment = new AboutDialogFragment(); - aboutDialogFragment.show(getSupportFragmentManager(), "AboutDialogFragment"); - } - return true; - case R.id.action_settings: - startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); - return true; - - default: - return super.onOptionsItemSelected(item); + final int itemId = item.getItemId(); + if (itemId == R.id.action_about) { + AboutDialogFragment aboutDialogFragment = new AboutDialogFragment(); + aboutDialogFragment.show(getSupportFragmentManager(), "AboutDialogFragment"); + return true; } + if (itemId == R.id.action_settings) { + startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); + return true; + } + + return super.onOptionsItemSelected(item); } public void readPreferences(){ @@ -441,35 +440,28 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings @Override public void onClick(View v) { int id = v.getId(); - switch (id){ - case R.id.editFAB: - // Intent.ACTION_CREATE_DOCUMENT, used in 'createNewFileDialog' requires SDK version 19 - if (Build.VERSION.SDK_INT < 19) { - Toast.makeText(this, - getString(R.string.creating_new_files_not_supported), Toast.LENGTH_SHORT).show(); - return; - } - if (isFabMenuOpen) { - collapseFabMenu(); - } else { - expandFabMenu(); - } - break; - case R.id.open_file_view: - showSystemFilePickerAndOpenFile(); - break; - case R.id.newWriterFAB: - loadNewDocument(DocumentType.WRITER); - break; - case R.id.newImpressFAB: - loadNewDocument(DocumentType.IMPRESS); - break; - case R.id.newCalcFAB: - loadNewDocument(DocumentType.CALC); - break; - case R.id.newDrawFAB: - loadNewDocument(DocumentType.DRAW); - break; + if (id == R.id.editFAB) { + // Intent.ACTION_CREATE_DOCUMENT, used in 'createNewFileDialog' requires SDK version 19 + if (Build.VERSION.SDK_INT < 19) { + Toast.makeText(this, + getString(R.string.creating_new_files_not_supported), Toast.LENGTH_SHORT).show(); + return; + } + if (isFabMenuOpen) { + collapseFabMenu(); + } else { + expandFabMenu(); + } + } else if (id == R.id.open_file_view) { + showSystemFilePickerAndOpenFile(); + } else if (id == R.id.newWriterFAB) { + loadNewDocument(DocumentType.WRITER); + } else if (id == R.id.newImpressFAB) { + loadNewDocument(DocumentType.IMPRESS); + } else if (id == R.id.newCalcFAB) { + loadNewDocument(DocumentType.CALC); + } else if (id == R.id.newDrawFAB) { + loadNewDocument(DocumentType.DRAW); } } } |