Browse Source

refactor: minor refactoring

develop
Ezerous 2 years ago
parent
commit
610b0fc594
  1. 71
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 2
      app/src/main/res/layout/activity_bookmarks.xml
  3. 1
      app/src/main/res/layout/activity_topic.xml
  4. 2
      app/src/main/res/menu/downloads_menu.xml
  5. 2
      app/src/main/res/menu/shoutbox_menu.xml
  6. 6
      app/src/main/res/menu/topic_menu.xml
  7. 2
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  8. 2
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  9. 4
      app/src/main/res/values/ic_launcher_background.xml
  10. 1
      app/src/main/res/values/strings.xml

71
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -228,42 +228,43 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items // Handle presses on the action bar items
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.menu_bookmark: if (itemId == R.id.menu_bookmark) {
topicMenuBookmarkClick(); topicMenuBookmarkClick();
return true; return true;
case R.id.menu_info: }
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); else if (itemId == R.id.menu_info) {
LayoutInflater inflater = this.getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent);
LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info LayoutInflater inflater = this.getLayoutInflater();
, null); LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info
TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); , null);
treeAndMods.setText(new SpannableStringBuilder("Loading...")); TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods);
treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); treeAndMods.setText(new SpannableStringBuilder("Loading..."));
TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); treeAndMods.setMovementMethod(LinkMovementMethod.getInstance());
usersViewing.setText(new SpannableStringBuilder("Loading...")); TextView usersViewing = infoDialog.findViewById(R.id.users_viewing);
usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); usersViewing.setText(new SpannableStringBuilder("Loading..."));
viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { usersViewing.setMovementMethod(LinkMovementMethod.getInstance());
if (topicTreeAndMods == null) return; viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> {
treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); if (topicTreeAndMods == null) return;
}); treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods));
viewModel.getTopicViewers().observe(this, topicViewers -> { });
if (topicViewers == null) return; viewModel.getTopicViewers().observe(this, topicViewers -> {
usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); if (topicViewers == null) return;
}); usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers));
builder.setView(infoDialog); });
topicInfoDialog = builder.create(); builder.setView(infoDialog);
topicInfoDialog.show(); topicInfoDialog = builder.create();
return true; topicInfoDialog.show();
case R.id.menu_share: return true;
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); }
sendIntent.setType("text/plain"); else if (itemId == R.id.menu_share) {
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, viewModel.getTopicUrl()); Intent sendIntent = new Intent(Intent.ACTION_SEND);
startActivity(Intent.createChooser(sendIntent, "Share via")); sendIntent.setType("text/plain");
return true; //invalidateOptionsMenu(); sendIntent.putExtra(Intent.EXTRA_TEXT, viewModel.getTopicUrl());
default: startActivity(Intent.createChooser(sendIntent, "Share via"));
return super.onOptionsItemSelected(item); return true; //invalidateOptionsMenu();
} }
return super.onOptionsItemSelected(item);
} }
@Override @Override

2
app/src/main/res/layout/activity_bookmarks.xml

@ -21,7 +21,7 @@
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:gravity="center" android:gravity="center"
app:popupTheme="@style/ToolbarTheme"></androidx.appcompat.widget.Toolbar> app:popupTheme="@style/ToolbarTheme" />
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/bookmark_tabs" android:id="@+id/bookmark_tabs"

1
app/src/main/res/layout/activity_topic.xml

@ -148,6 +148,7 @@
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/fab_margins" android:layout_marginEnd="@dimen/fab_margins"
android:layout_marginBottom="50dp" android:layout_marginBottom="50dp"
android:contentDescription="@string/reply_button"
app:layout_behavior="gr.thmmy.mthmmy.utils.ui.ScrollAwareFABBehavior" app:layout_behavior="gr.thmmy.mthmmy.utils.ui.ScrollAwareFABBehavior"
app:srcCompat="@drawable/ic_reply" /> app:srcCompat="@drawable/ic_reply" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

2
app/src/main/res/menu/downloads_menu.xml

@ -5,5 +5,5 @@
android:id="@+id/menu_upload" android:id="@+id/menu_upload"
android:icon="@drawable/ic_file_upload_white_24dp" android:icon="@drawable/ic_file_upload_white_24dp"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="@string/upload_button"></item> android:title="@string/upload_button" />
</menu> </menu>

2
app/src/main/res/menu/shoutbox_menu.xml

@ -5,5 +5,5 @@
android:id="@+id/menu_refresh" android:id="@+id/menu_refresh"
android:icon="@drawable/ic_refresh_white_24dp" android:icon="@drawable/ic_refresh_white_24dp"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="@string/refresh"></item> android:title="@string/refresh" />
</menu> </menu>

6
app/src/main/res/menu/topic_menu.xml

@ -5,15 +5,15 @@
android:id="@+id/menu_bookmark" android:id="@+id/menu_bookmark"
android:icon="@drawable/ic_bookmark_false_accent_24dp" android:icon="@drawable/ic_bookmark_false_accent_24dp"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="@string/bookmark"></item> android:title="@string/bookmark" />
<item <item
android:id="@+id/menu_share" android:id="@+id/menu_share"
android:icon="@drawable/ic_share_white_24dp" android:icon="@drawable/ic_share_white_24dp"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="@string/share"></item> android:title="@string/share" />
<item <item
android:id="@+id/menu_info" android:id="@+id/menu_info"
android:icon="@drawable/ic_info_outline_white_24dp" android:icon="@drawable/ic_info_outline_white_24dp"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:title="@string/info"></item> android:title="@string/info" />
</menu> </menu>

2
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" /> <background android:drawable="@color/primary_light" />
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon> </adaptive-icon>

2
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" /> <background android:drawable="@color/primary_light" />
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon> </adaptive-icon>

4
app/src/main/res/values/ic_launcher_background.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#333333</color>
</resources>

1
app/src/main/res/values/strings.xml

@ -76,6 +76,7 @@
</plurals> </plurals>
<string name="show_vote_options_button">hide results</string> <string name="show_vote_options_button">hide results</string>
<string name="pref_topic_drafts_key">preference-topic-drafts-key</string> <string name="pref_topic_drafts_key">preference-topic-drafts-key</string>
<string name="reply_button">Reply</string>
<!--Profile Activity--> <!--Profile Activity-->
<string name="username">Username</string> <string name="username">Username</string>

Loading…
Cancel
Save