From 610b0fc594b6ee98df372166c1e6428df0c5b153 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 5 Oct 2022 12:30:08 +0300 Subject: [PATCH] refactor: minor refactoring --- .../activities/topic/TopicActivity.java | 71 ++++++++++--------- .../main/res/layout/activity_bookmarks.xml | 2 +- app/src/main/res/layout/activity_topic.xml | 1 + app/src/main/res/menu/downloads_menu.xml | 2 +- app/src/main/res/menu/shoutbox_menu.xml | 2 +- app/src/main/res/menu/topic_menu.xml | 6 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 2 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 2 +- .../res/values/ic_launcher_background.xml | 4 -- app/src/main/res/values/strings.xml | 1 + 10 files changed, 46 insertions(+), 47 deletions(-) delete mode 100644 app/src/main/res/values/ic_launcher_background.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 959a0939..7c2c5d96 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -228,42 +228,43 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items - switch (item.getItemId()) { - case R.id.menu_bookmark: - topicMenuBookmarkClick(); - return true; - case R.id.menu_info: - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); - LayoutInflater inflater = this.getLayoutInflater(); - LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info - , null); - TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); - treeAndMods.setText(new SpannableStringBuilder("Loading...")); - treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); - TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); - usersViewing.setText(new SpannableStringBuilder("Loading...")); - usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); - viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { - if (topicTreeAndMods == null) return; - treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); - }); - viewModel.getTopicViewers().observe(this, topicViewers -> { - if (topicViewers == null) return; - usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); - }); - builder.setView(infoDialog); - topicInfoDialog = builder.create(); - topicInfoDialog.show(); - return true; - case R.id.menu_share: - Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); - sendIntent.setType("text/plain"); - sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, viewModel.getTopicUrl()); - startActivity(Intent.createChooser(sendIntent, "Share via")); - return true; //invalidateOptionsMenu(); - default: - return super.onOptionsItemSelected(item); + int itemId = item.getItemId(); + if (itemId == R.id.menu_bookmark) { + topicMenuBookmarkClick(); + return true; + } + else if (itemId == R.id.menu_info) { + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); + LayoutInflater inflater = this.getLayoutInflater(); + LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info + , null); + TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); + treeAndMods.setText(new SpannableStringBuilder("Loading...")); + treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); + TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); + usersViewing.setText(new SpannableStringBuilder("Loading...")); + usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); + viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { + if (topicTreeAndMods == null) return; + treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); + }); + viewModel.getTopicViewers().observe(this, topicViewers -> { + if (topicViewers == null) return; + usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); + }); + builder.setView(infoDialog); + topicInfoDialog = builder.create(); + topicInfoDialog.show(); + return true; + } + else if (itemId == R.id.menu_share) { + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.setType("text/plain"); + sendIntent.putExtra(Intent.EXTRA_TEXT, viewModel.getTopicUrl()); + startActivity(Intent.createChooser(sendIntent, "Share via")); + return true; //invalidateOptionsMenu(); } + return super.onOptionsItemSelected(item); } @Override diff --git a/app/src/main/res/layout/activity_bookmarks.xml b/app/src/main/res/layout/activity_bookmarks.xml index a57f969d..44c29305 100644 --- a/app/src/main/res/layout/activity_bookmarks.xml +++ b/app/src/main/res/layout/activity_bookmarks.xml @@ -21,7 +21,7 @@ android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:gravity="center" - app:popupTheme="@style/ToolbarTheme"> + app:popupTheme="@style/ToolbarTheme" /> diff --git a/app/src/main/res/menu/downloads_menu.xml b/app/src/main/res/menu/downloads_menu.xml index 04eb3822..be7150a4 100644 --- a/app/src/main/res/menu/downloads_menu.xml +++ b/app/src/main/res/menu/downloads_menu.xml @@ -5,5 +5,5 @@ android:id="@+id/menu_upload" android:icon="@drawable/ic_file_upload_white_24dp" app:showAsAction="ifRoom" - android:title="@string/upload_button"> + android:title="@string/upload_button" /> \ No newline at end of file diff --git a/app/src/main/res/menu/shoutbox_menu.xml b/app/src/main/res/menu/shoutbox_menu.xml index dc5c6ab0..c3e6dd5b 100644 --- a/app/src/main/res/menu/shoutbox_menu.xml +++ b/app/src/main/res/menu/shoutbox_menu.xml @@ -5,5 +5,5 @@ android:id="@+id/menu_refresh" android:icon="@drawable/ic_refresh_white_24dp" app:showAsAction="ifRoom" - android:title="@string/refresh"> + android:title="@string/refresh" /> \ No newline at end of file diff --git a/app/src/main/res/menu/topic_menu.xml b/app/src/main/res/menu/topic_menu.xml index 42a144ef..17352ba9 100644 --- a/app/src/main/res/menu/topic_menu.xml +++ b/app/src/main/res/menu/topic_menu.xml @@ -5,15 +5,15 @@ android:id="@+id/menu_bookmark" android:icon="@drawable/ic_bookmark_false_accent_24dp" app:showAsAction="ifRoom" - android:title="@string/bookmark"> + android:title="@string/bookmark" /> + android:title="@string/share" /> + android:title="@string/info" /> \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index ac94b34f..f78ee51a 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index ac94b34f..f78ee51a 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml deleted file mode 100644 index f2269c54..00000000 --- a/app/src/main/res/values/ic_launcher_background.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #333333 - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1e83bc57..9fc3304b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -76,6 +76,7 @@ hide results preference-topic-drafts-key + Reply Username