diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-02-02 09:48:25 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-02-02 09:48:25 +0000 |
commit | 51d7965527d16662499817ff3ab5849c3a8d42b4 (patch) | |
tree | b3f092427ee67b03179ad9916f6d1f6907dd94aa /app/src/main | |
parent | b09701918f625462c1d90b97710ab6ae2352eb0f (diff) | |
download | infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.tar infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.tar.gz infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.tar.bz2 infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.tar.lz infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.tar.xz infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.tar.zst infinity-for-reddit-51d7965527d16662499817ff3ab5849c3a8d42b4.zip |
Fix fab jumps to top-left of the screen. Add more items in the bottom app bar. Add a bottom app bar in ViewSubredditDetailActivity.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java | 62 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java | 127 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_account_circle_24dp.xml (renamed from app/src/main/res/drawable/ic_outline_account_circle_24px.xml) | 0 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_inbox_24dp.xml (renamed from app/src/main/res/drawable/ic_outline_inbox_24px.xml) | 0 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_main.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_view_subreddit_detail.xml | 78 | ||||
-rw-r--r-- | app/src/main/res/layout/app_bar_main.xml | 44 |
7 files changed, 232 insertions, 83 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 531098c1..63124d8a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -166,16 +166,20 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb RecyclerView accountRecyclerView; @BindView(R.id.tab_layout_main_activity) TabLayout tabLayout; - @BindView(R.id.fab_main_activity) - FloatingActionButton fab; @BindView(R.id.bottom_navigation_main_activity) BottomAppBar bottomNavigationView; @BindView(R.id.linear_layout_bottom_app_bar_main_activity) LinearLayout linearLayoutBottomAppBar; @BindView(R.id.subscriptions_bottom_app_bar_main_activity) - TextView subscriptionsBottomAppBar; + ImageView subscriptionsBottomAppBar; @BindView(R.id.multi_reddit_bottom_app_bar_main_activity) - TextView multiRedditBottomAppBar; + ImageView multiRedditBottomAppBar; + @BindView(R.id.message_bottom_app_bar_main_activity) + ImageView messageBottomAppBar; + @BindView(R.id.profile_bottom_app_bar_main_activity) + ImageView profileBottomAppBar; + @BindView(R.id.fab_main_activity) + FloatingActionButton fab; AccountViewModel accountViewModel; @Inject @Named("oauth") @@ -338,8 +342,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME); getCurrentAccountAndBindView(); } - - fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag())); } @Override @@ -460,6 +462,26 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } else { if (showBottomAppBar) { bottomNavigationView.setVisibility(View.VISIBLE); + subscriptionsBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); + startActivity(intent); + }); + + multiRedditBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, MultiRedditListingActivity.class); + startActivity(intent); + }); + + messageBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(this, ViewMessageActivity.class); + startActivity(intent); + }); + + profileBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(this, ViewUserDetailActivity.class); + intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName); + startActivity(intent); + }); } else { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); lp.setAnchorId(View.NO_ID); @@ -467,16 +489,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb fab.setLayoutParams(lp); } + fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag())); fab.setVisibility(View.VISIBLE); - subscriptionsBottomAppBar.setOnClickListener(view -> { - Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); - startActivity(intent); - }); - - multiRedditBottomAppBar.setOnClickListener(view -> { - Intent intent = new Intent(MainActivity.this, MultiRedditListingActivity.class); - startActivity(intent); - }); } sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); @@ -491,8 +505,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Override public void onPageSelected(int position) { - if (mAccessToken != null && showBottomAppBar) { - bottomNavigationView.performShow(); + if (mAccessToken != null) { + if (showBottomAppBar) { + bottomNavigationView.performShow(); + } fab.show(); } if (isInLazyMode) { @@ -956,16 +972,20 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } public void postScrollUp() { - if (mAccessToken != null && showBottomAppBar) { - bottomNavigationView.performShow(); + if (mAccessToken != null) { + if (showBottomAppBar) { + bottomNavigationView.performShow(); + } fab.show(); } } public void postScrollDown() { - if (mAccessToken != null && showBottomAppBar) { + if (mAccessToken != null) { fab.hide(); - bottomNavigationView.performHide(); + if (showBottomAppBar) { + bottomNavigationView.performHide(); + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index 1dc855f8..53631397 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -6,6 +6,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; +import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -13,6 +14,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -27,6 +30,7 @@ import com.bumptech.glide.RequestManager; import com.bumptech.glide.request.RequestOptions; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.chip.Chip; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; @@ -107,6 +111,18 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp TextView nOnlineSubscribersTextView; @BindView(R.id.description_text_view_view_subreddit_detail_activity) TextView descriptionTextView; + @BindView(R.id.bottom_navigation_view_subreddit_detail_activity) + BottomAppBar bottomNavigationView; + @BindView(R.id.linear_layout_bottom_app_bar_view_subreddit_detail_activity) + LinearLayout linearLayoutBottomAppBar; + @BindView(R.id.subscriptions_bottom_app_bar_view_subreddit_detail_activity) + ImageView subscriptionsBottomAppBar; + @BindView(R.id.multi_reddit_bottom_app_bar_view_subreddit_detail_activity) + ImageView multiRedditBottomAppBar; + @BindView(R.id.message_bottom_app_bar_view_subreddit_detail_activity) + ImageView messageBottomAppBar; + @BindView(R.id.profile_bottom_app_bar_view_subreddit_detail_activity) + ImageView profileBottomAppBar; @BindView(R.id.fab_view_subreddit_detail_activity) FloatingActionButton fab; @Inject @@ -128,6 +144,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp private boolean subscriptionReady = false; private boolean isInLazyMode = false; private boolean showToast = false; + private boolean showBottomAppBar; private String mMessageFullname; private String mNewAccountName; private RequestManager glide; @@ -254,6 +271,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp toolbar.setLayoutParams(toolbarParams); setSupportActionBar(toolbar); + showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); + glide = Glide.with(this); mSubredditViewModel = new ViewModelProvider(this, @@ -311,15 +330,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } } }); - - fab.setOnClickListener(view -> { - if (mAccessToken == null) { - Toast.makeText(ViewSubredditDetailActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show(); - return; - } - - postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); - }); } @Override @@ -388,18 +398,55 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } private void bindView(boolean initializeFragment) { - if (mAccessToken != null && mMessageFullname != null) { - ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() { - @Override - public void readSuccess() { - mMessageFullname = null; - } + if (mAccessToken != null) { + if (mMessageFullname != null) { + ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() { + @Override + public void readSuccess() { + mMessageFullname = null; + } - @Override - public void readFailed() { + @Override + public void readFailed() { - } - }); + } + }); + } + + if (showBottomAppBar) { + bottomNavigationView.setVisibility(View.VISIBLE); + subscriptionsBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(ViewSubredditDetailActivity.this, SubscribedThingListingActivity.class); + startActivity(intent); + }); + + multiRedditBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(ViewSubredditDetailActivity.this, MultiRedditListingActivity.class); + startActivity(intent); + }); + + messageBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(this, ViewMessageActivity.class); + startActivity(intent); + }); + + profileBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(this, ViewUserDetailActivity.class); + intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName); + startActivity(intent); + }); + } else { + CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + lp.setAnchorId(View.NO_ID); + lp.gravity = Gravity.END | Gravity.BOTTOM; + fab.setLayoutParams(lp); + } + + fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag())); + fab.setVisibility(View.VISIBLE); + } else { + bottomNavigationView.setVisibility(View.GONE); + fab.setVisibility(View.GONE); } subscribeSubredditChip.setOnClickListener(view -> { @@ -642,11 +689,21 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } public void postScrollUp() { - fab.show(); + if (mAccessToken != null) { + if (showBottomAppBar) { + bottomNavigationView.performShow(); + } + fab.show(); + } } public void postScrollDown() { - fab.hide(); + if (mAccessToken != null) { + fab.hide(); + if (showBottomAppBar) { + bottomNavigationView.performHide(); + } + } } @Subscribe @@ -660,32 +717,4 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) { ((FragmentCommunicator) mFragment).changeNSFW(changeNSFWEvent.nsfw); } - - /*private static class InsertSubredditDataAsyncTask extends AsyncTask<Void, Void, Void> { - - private SubredditDao mSubredditDao; - private SubredditData subredditData; - private InsertSubredditDataAsyncTaskListener insertSubredditDataAsyncTaskListener; - InsertSubredditDataAsyncTask(RedditDataRoomDatabase db, SubredditData subredditData, - InsertSubredditDataAsyncTaskListener insertSubredditDataAsyncTaskListener) { - mSubredditDao = db.subredditDao(); - this.subredditData = subredditData; - this.insertSubredditDataAsyncTaskListener = insertSubredditDataAsyncTaskListener; - } - - @Override - protected Void doInBackground(final Void... params) { - mSubredditDao.insert(subredditData); - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - insertSubredditDataAsyncTaskListener.insertSuccess(); - } - - interface InsertSubredditDataAsyncTaskListener { - void insertSuccess(); - } - }*/ } diff --git a/app/src/main/res/drawable/ic_outline_account_circle_24px.xml b/app/src/main/res/drawable/ic_account_circle_24dp.xml index 0c9a104b..0c9a104b 100644 --- a/app/src/main/res/drawable/ic_outline_account_circle_24px.xml +++ b/app/src/main/res/drawable/ic_account_circle_24dp.xml diff --git a/app/src/main/res/drawable/ic_outline_inbox_24px.xml b/app/src/main/res/drawable/ic_inbox_24dp.xml index 97d34185..97d34185 100644 --- a/app/src/main/res/drawable/ic_outline_inbox_24px.xml +++ b/app/src/main/res/drawable/ic_inbox_24dp.xml diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cf48f84e..ba6cc170 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -64,7 +64,7 @@ android:layout_height="24dp" android:layout_gravity="center_vertical" android:layout_marginEnd="32dp" - android:src="@drawable/ic_outline_account_circle_24px" + android:src="@drawable/ic_account_circle_24dp" android:tint="@color/primaryTextColor"/> <TextView @@ -144,7 +144,7 @@ android:layout_height="24dp" android:layout_gravity="center_vertical" android:layout_marginEnd="32dp" - android:src="@drawable/ic_outline_inbox_24px" + android:src="@drawable/ic_inbox_24dp" android:tint="@color/primaryTextColor"/> <TextView diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml index fffa6a96..6743aef0 100644 --- a/app/src/main/res/layout/activity_view_subreddit_detail.xml +++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml @@ -124,14 +124,88 @@ <include layout="@layout/content_view_subreddit_detail" /> + <com.google.android.material.bottomappbar.BottomAppBar + android:id="@+id/bottom_navigation_view_subreddit_detail_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:visibility="gone" + app:backgroundTint="?attr/backgroundColor" + app:fabAlignmentMode="center"> + + <LinearLayout + android:id="@+id/linear_layout_bottom_app_bar_view_subreddit_detail_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:weightSum="5"> + + <ImageView + android:id="@+id/subscriptions_bottom_app_bar_view_subreddit_detail_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:src="@drawable/ic_subscritptions_bottom_app_bar_24dp" + android:textColor="@color/primaryTextColor" + android:background="?attr/selectableItemBackgroundBorderless" /> + + <ImageView + android:id="@+id/multi_reddit_bottom_app_bar_view_subreddit_detail_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:src="@drawable/ic_multi_reddit_24dp" + android:textColor="@color/primaryTextColor" + android:background="?attr/selectableItemBackgroundBorderless" /> + + <TextView + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:background="@android:color/transparent"/> + + <ImageView + android:id="@+id/message_bottom_app_bar_view_subreddit_detail_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:src="@drawable/ic_inbox_24dp" + android:textColor="@color/primaryTextColor" + android:background="?attr/selectableItemBackgroundBorderless" /> + + <ImageView + android:id="@+id/profile_bottom_app_bar_view_subreddit_detail_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:layout_marginEnd="16dp" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:gravity="center" + android:src="@drawable/ic_account_circle_24dp" + android:textColor="@color/primaryTextColor" + android:background="?attr/selectableItemBackgroundBorderless" /> + + </LinearLayout> + </com.google.android.material.bottomappbar.BottomAppBar> + <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/fab_view_subreddit_detail_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" + android:visibility="gone" app:backgroundTint="@color/backgroundColorPrimary" + app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:tint="@android:color/white" - app:srcCompat="@drawable/ic_add_24dp" /> + app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" /> </androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index a9008a36..e81f6f7b 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -69,16 +69,29 @@ android:id="@+id/linear_layout_bottom_app_bar_main_activity" android:layout_width="match_parent" android:layout_height="wrap_content" - android:weightSum="3"> + android:weightSum="5"> - <TextView + <ImageView android:id="@+id/subscriptions_bottom_app_bar_main_activity" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" - android:drawableTop="@drawable/ic_subscritptions_bottom_app_bar_24dp" - android:text="@string/subscriptions" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:src="@drawable/ic_subscritptions_bottom_app_bar_24dp" + android:textColor="@color/primaryTextColor" + android:background="?attr/selectableItemBackgroundBorderless" /> + + <ImageView + android:id="@+id/multi_reddit_bottom_app_bar_main_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:src="@drawable/ic_multi_reddit_24dp" android:textColor="@color/primaryTextColor" android:background="?attr/selectableItemBackgroundBorderless" /> @@ -88,17 +101,30 @@ android:layout_weight="1" android:background="@android:color/transparent"/> - <TextView - android:id="@+id/multi_reddit_bottom_app_bar_main_activity" + <ImageView + android:id="@+id/message_bottom_app_bar_main_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:src="@drawable/ic_inbox_24dp" + android:textColor="@color/primaryTextColor" + android:background="?attr/selectableItemBackgroundBorderless" /> + + <ImageView + android:id="@+id/profile_bottom_app_bar_main_activity" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginEnd="16dp" + android:paddingTop="8dp" + android:paddingBottom="8dp" android:gravity="center" - android:drawableTop="@drawable/ic_multi_reddit_24dp" - android:text="@string/multi_reddit_listing_activity" + android:src="@drawable/ic_account_circle_24dp" android:textColor="@color/primaryTextColor" - android:background="?attr/selectableItemBackgroundBorderless"/> + android:background="?attr/selectableItemBackgroundBorderless" /> </LinearLayout> </com.google.android.material.bottomappbar.BottomAppBar> |