diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-08-10 10:29:04 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-08-10 10:29:04 +0000 |
commit | 413a18f6d39bf274369d7a1ee3279e20d3a608a7 (patch) | |
tree | b4b12366690744fd18a0caa4fe8b27e938716532 /app/src/main | |
parent | 4c21eea852e08d0c65b3eb917b04404722d28f5d (diff) | |
download | infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.tar infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.tar.gz infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.tar.bz2 infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.tar.lz infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.tar.xz infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.tar.zst infinity-for-reddit-413a18f6d39bf274369d7a1ee3279e20d3a608a7.zip |
Make navigation bar and status bar transparent to display posts, comments, subreddits and users under them. Minor UI tweaks for bottom sheet fragments.
Diffstat (limited to '')
31 files changed, 476 insertions, 115 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java new file mode 100644 index 00000000..dcb034bf --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppBarStateChangeListener.java @@ -0,0 +1,41 @@ +package ml.docilealligator.infinityforreddit; + +import com.google.android.material.appbar.AppBarLayout; + +abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { + // State + public enum State { + EXPANDED, + COLLAPSED, + IDLE + } + + private AppBarStateChangeListener.State mCurrentState = AppBarStateChangeListener.State.IDLE; + + @Override + public final void onOffsetChanged(AppBarLayout appBarLayout, int i) { + if (i == 0) { + if (mCurrentState != AppBarStateChangeListener.State.EXPANDED) { + onStateChanged(appBarLayout, AppBarStateChangeListener.State.EXPANDED); + } + mCurrentState = AppBarStateChangeListener.State.EXPANDED; + } else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) { + if (mCurrentState != AppBarStateChangeListener.State.COLLAPSED) { + onStateChanged(appBarLayout, AppBarStateChangeListener.State.COLLAPSED); + } + mCurrentState = AppBarStateChangeListener.State.COLLAPSED; + } else { + if (mCurrentState != AppBarStateChangeListener.State.IDLE) { + onStateChanged(appBarLayout, AppBarStateChangeListener.State.IDLE); + } + mCurrentState = AppBarStateChangeListener.State.IDLE; + } + } + + /** + * Notifies on state change + * @param appBarLayout Layout + * @param state Collapse state + */ + abstract void onStateChanged(AppBarLayout appBarLayout, AppBarStateChangeListener.State state); +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingFragment.java index dc584f00..63eefa89 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingFragment.java @@ -3,6 +3,9 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -76,6 +79,17 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni mGlide = Glide.with(activity); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + mCommentRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); + } + } + } + mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(activity)); mAdapter = new CommentsListingRecyclerViewAdapter(activity, mOauthRetrofit, @@ -85,7 +99,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni mCommentRecyclerView.setAdapter(mAdapter); - CommentViewModel.Factory factory = new CommentViewModel.Factory(mRetrofit, getResources().getConfiguration().locale, username); + CommentViewModel.Factory factory = new CommentViewModel.Factory(mRetrofit, resources.getConfiguration().locale, username); mCommentViewModel = ViewModelProviders.of(this, factory).get(CommentViewModel.class); mCommentViewModel.getComments().observe(this, comments -> mAdapter.submitList(comments)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FlairBottomSheetFragment.java index 5ccec346..bd8af127 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FlairBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FlairBottomSheetFragment.java @@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -67,6 +69,11 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment { ((Infinity) mAcitivity.getApplication()).getAppComponent().inject(this); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + mAdapter = new FlairBottomSheetRecyclerViewAdapter(flair -> ((FlairSelectionCallback) mAcitivity).flairSelected(flair)); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setAdapter(mAdapter); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FollowedUsersListingFragment.java index 53fb9506..ffd2cf95 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FollowedUsersListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FollowedUsersListingFragment.java @@ -2,6 +2,9 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -59,6 +62,17 @@ public class FollowedUsersListingFragment extends Fragment { ((Infinity) mActivity.getApplication()).getAppComponent().inject(this); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); + } + } + } + mGlide = Glide.with(this); mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 07e545b4..3fd746aa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -2,11 +2,16 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; 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; @@ -15,6 +20,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; @@ -62,6 +68,8 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe private static final int LOGIN_ACTIVITY_REQUEST_CODE = 0; @BindView(R.id.drawer_layout) DrawerLayout drawer; + @BindView(R.id.coordinator_layout_main_activity) CoordinatorLayout coordinatorLayout; + @BindView(R.id.appbar_layout_main_activity) AppBarLayout appBarLayout; @BindView(R.id.view_pager_main_activity) ViewPager viewPager; @BindView(R.id.collapsing_toolbar_layout_main_activity) CollapsingToolbarLayout collapsingToolbarLayout; @BindView(R.id.toolbar) Toolbar toolbar; @@ -119,6 +127,41 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe ((Infinity) getApplication()).getAppComponent().inject(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + Resources resources = getResources(); + + if(resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + Window window = getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + + View decorView = window.getDecorView(); + appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + @Override + void onStateChanged(AppBarLayout appBarLayout, State state) { + if(state == State.COLLAPSED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } else if(state == State.EXPANDED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + } + }); + + int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarResourceId > 0) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); + params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId); + toolbar.setLayoutParams(params); + } + + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + params.bottomMargin = resources.getDimensionPixelSize(navBarResourceId); + fab.setLayoutParams(params); + } + } + } + postTypeBottomSheetFragment = new PostTypeBottomSheetFragment(); bestSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); @@ -390,10 +433,9 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == LOGIN_ACTIVITY_REQUEST_CODE && resultCode == Activity.RESULT_OK) { - Intent intent = getIntent(); - finish(); + Intent intent = new Intent(this, MainActivity.class); startActivity(intent); - overridePendingTransition(0, 0); + finish(); } super.onActivityResult(requestCode, resultCode, data); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index 2506dde8..851d351a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -4,6 +4,9 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; @@ -125,6 +128,17 @@ public class PostFragment extends Fragment implements FragmentCommunicator { window = activity.getWindow(); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + mPostRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); + } + } + } + mGlide = Glide.with(activity); lazyModeRunnable = new Runnable() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTypeBottomSheetFragment.java index c8dd0d28..338821c0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTypeBottomSheetFragment.java @@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -48,6 +50,11 @@ public class PostTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen Activity activity = getActivity(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + textTypeLinearLayout.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_TEXT); dismiss(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java index f54cf5b4..d0b2bf6b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java @@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -44,6 +46,11 @@ public class SearchPostSortTypeBottomSheetFragment extends RoundedBottomSheetDia Activity activity = getActivity(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + relevanceTypeTextView.setOnClickListener(view -> { ((SearchSortTypeSelectionCallback) activity).searchSortTypeSelected(PostDataSource.SORT_TYPE_RELEVANCE); dismiss(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java index 7e663e03..d528488d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java @@ -1,10 +1,16 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -14,6 +20,7 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.tabs.TabLayout; import javax.inject.Inject; @@ -36,6 +43,7 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos private String mQuery; private String mSubredditName; + @BindView(R.id.appbar_search_result_activity) AppBarLayout appBarLayout; @BindView(R.id.toolbar_search_result_activity) Toolbar toolbar; @BindView(R.id.tab_layout_search_result_activity) TabLayout tabLayout; @BindView(R.id.view_pager_search_result_activity) ViewPager viewPager; @@ -57,6 +65,34 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos ((Infinity) getApplication()).getAppComponent().inject(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + Resources resources = getResources(); + + if(resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + Window window = getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + + View decorView = window.getDecorView(); + appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + @Override + void onStateChanged(AppBarLayout appBarLayout, State state) { + if(state == State.COLLAPSED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } else if(state == State.EXPANDED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + } + }); + + int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarResourceId > 0) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); + params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId); + toolbar.setLayoutParams(params); + } + } + } + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java index ae652fd4..5579d220 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java @@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -43,6 +45,11 @@ public class SearchUserAndSubredditSortTypeBottomSheetFragment extends RoundedBo Activity activity = getActivity(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + int position = getArguments().getInt(EXTRA_FRAGMENT_POSITION); relevanceTypeTextView.setOnClickListener(view -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java index 76ebbea4..b4825274 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java @@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -49,6 +51,11 @@ public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen Activity activity = getActivity(); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + if(getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) { bestTypeTextView.setVisibility(View.GONE); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java index 058143bb..bf6e3894 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java @@ -3,6 +3,9 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -78,6 +81,17 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun ButterKnife.bind(this, rootView); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + mSubredditListingRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); + } + } + } + mLinearLayoutManager = new LinearLayoutManager(getActivity()); mSubredditListingRecyclerView.setLayoutManager(mLinearLayoutManager); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java index d4c877d8..15da8748 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java @@ -2,6 +2,9 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -63,6 +66,17 @@ public class SubscribedSubredditsListingFragment extends Fragment { ((Infinity) mActivity.getApplication()).getAppComponent().inject(this); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); + } + } + } + String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); mGlide = Glide.with(this); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedThingListingActivity.java index 1f35288d..85ad1196 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedThingListingActivity.java @@ -1,8 +1,14 @@ package ml.docilealligator.infinityforreddit; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.MenuItem; +import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -12,6 +18,7 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.tabs.TabLayout; import java.util.ArrayList; @@ -33,6 +40,7 @@ public class SubscribedThingListingActivity extends AppCompatActivity { private static final String ACCESS_TOKEN_STATE = "ATS"; private static final String ACCOUNT_NAME_STATE = "ANS"; + @BindView(R.id.appbar_subscribed_thing_listing_activity) AppBarLayout appBarLayout; @BindView(R.id.toolbar_subscribed_thing_listing_activity) Toolbar toolbar; @BindView(R.id.tab_layout_subscribed_thing_listing_activity) TabLayout tabLayout; @BindView(R.id.view_pager_subscribed_thing_listing_activity) ViewPager viewPager; @@ -60,6 +68,34 @@ public class SubscribedThingListingActivity extends AppCompatActivity { ((Infinity) getApplication()).getAppComponent().inject(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + Resources resources = getResources(); + + if(resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + Window window = getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + + View decorView = window.getDecorView(); + appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + @Override + void onStateChanged(AppBarLayout appBarLayout, State state) { + if(state == State.COLLAPSED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } else if(state == State.EXPANDED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + } + }); + + int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarResourceId > 0) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); + params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId); + toolbar.setLayoutParams(params); + } + } + } + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java index 04fe267d..46971ffe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java @@ -1,6 +1,9 @@ package ml.docilealligator.infinityforreddit; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -74,6 +77,17 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato ButterKnife.bind(this, rootView); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + mUserListingRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); + } + } + } + mLinearLayoutManager = new LinearLayoutManager(getActivity()); mUserListingRecyclerView.setLayoutManager(mLinearLayoutManager); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java index 4c734251..efbc07a1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java @@ -1,12 +1,17 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; import android.widget.TextView; import androidx.annotation.NonNull; @@ -99,6 +104,41 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So ((Infinity) getApplication()).getAppComponent().inject(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + Resources resources = getResources(); + + if(resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) { + Window window = getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + + View decorView = window.getDecorView(); + appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + @Override + void onStateChanged(AppBarLayout appBarLayout, State state) { + if (state == State.COLLAPSED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } else if (state == State.EXPANDED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + } + }); + + int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarResourceId > 0) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); + params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId); + toolbar.setLayoutParams(params); + } + + int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (navBarResourceId > 0) { + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + params.bottomMargin = resources.getDimensionPixelSize(navBarResourceId); + fab.setLayoutParams(params); + } + } + } + subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME_KEY); if(savedInstanceState == null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java index 1901f179..f88b5ac8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java @@ -1,12 +1,17 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; import android.widget.TextView; import androidx.annotation.NonNull; @@ -51,16 +56,26 @@ public class ViewUserDetailActivity extends AppCompatActivity { private static final String ACCOUNT_NAME_STATE = "ANS"; private static final String IS_IN_LAZY_MODE_STATE = "IILMS"; - @BindView(R.id.coordinator_layout_view_user_detail_activity) CoordinatorLayout coordinatorLayout; - @BindView(R.id.view_pager_view_user_detail_activity) ViewPager viewPager; - @BindView(R.id.appbar_layout_view_user_detail) AppBarLayout appBarLayout; - @BindView(R.id.tab_layout_view_user_detail_activity) TabLayout tabLayout; - @BindView(R.id.collapsing_toolbar_layout_view_user_detail_activity) CollapsingToolbarLayout collapsingToolbarLayout; - @BindView(R.id.banner_image_view_view_user_detail_activity) GifImageView bannerImageView; - @BindView(R.id.icon_gif_image_view_view_user_detail_activity) GifImageView iconGifImageView; - @BindView(R.id.user_name_text_view_view_user_detail_activity) TextView userNameTextView; - @BindView(R.id.subscribe_user_chip_view_user_detail_activity) Chip subscribeUserChip; - @BindView(R.id.karma_text_view_view_user_detail_activity) TextView karmaTextView; + @BindView(R.id.coordinator_layout_view_user_detail_activity) + CoordinatorLayout coordinatorLayout; + @BindView(R.id.view_pager_view_user_detail_activity) + ViewPager viewPager; + @BindView(R.id.appbar_layout_view_user_detail) + AppBarLayout appBarLayout; + @BindView(R.id.tab_layout_view_user_detail_activity) + TabLayout tabLayout; + @BindView(R.id.collapsing_toolbar_layout_view_user_detail_activity) + CollapsingToolbarLayout collapsingToolbarLayout; + @BindView(R.id.banner_image_view_view_user_detail_activity) + GifImageView bannerImageView; + @BindView(R.id.icon_gif_image_view_view_user_detail_activity) + GifImageView iconGifImageView; + @BindView(R.id.user_name_text_view_view_user_detail_activity) + TextView userNameTextView; + @BindView(R.id.subscribe_user_chip_view_user_detail_activity) + Chip subscribeUserChip; + @BindView(R.id.karma_text_view_view_user_detail_activity) + TextView karmaTextView; private SectionsPagerAdapter sectionsPagerAdapter; @@ -106,7 +121,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { username = getIntent().getExtras().getString(EXTRA_USER_NAME_KEY); - if(savedInstanceState == null) { + if (savedInstanceState == null) { getCurrentAccountAndInitializeViewPager(); } else { mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE); @@ -115,7 +130,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); - if(!mNullAccessToken && mAccessToken == null) { + if (!mNullAccessToken && mAccessToken == null) { getCurrentAccountAndInitializeViewPager(); } else { initializeViewPager(); @@ -140,8 +155,8 @@ public class ViewUserDetailActivity extends AppCompatActivity { toolbar.setTitle(title); setSupportActionBar(toolbar); - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); - params.topMargin = statusBarHeight; + ViewGroup.MarginLayoutParams toolbarLayoutParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); + toolbarLayoutParams.topMargin = statusBarHeight; expandedTabTextColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor); expandedTabBackgroundColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground); @@ -151,20 +166,54 @@ public class ViewUserDetailActivity extends AppCompatActivity { collapsedTabBackgroundColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabBackground); collapsedTabIndicatorColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator); - appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { - @Override - void onStateChanged(AppBarLayout appBarLayout, State state) { - if(state == State.EXPANDED) { - tabLayout.setTabTextColors(expandedTabTextColor, expandedTabTextColor); - tabLayout.setSelectedTabIndicatorColor(expandedTabIndicatorColor); - tabLayout.setBackgroundColor(expandedTabBackgroundColor); - } else if(state == State.COLLAPSED) { - tabLayout.setTabTextColors(collapsedTabTextColor, collapsedTabTextColor); - tabLayout.setSelectedTabIndicatorColor(collapsedTabIndicatorColor); - tabLayout.setBackgroundColor(collapsedTabBackgroundColor); + Resources resources = getResources(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 + && (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT + || resources.getBoolean(R.bool.isTablet))) { + Window window = getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + + View decorView = window.getDecorView(); + appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + @Override + void onStateChanged(AppBarLayout appBarLayout, State state) { + if (state == State.COLLAPSED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + tabLayout.setTabTextColors(collapsedTabTextColor, collapsedTabTextColor); + tabLayout.setSelectedTabIndicatorColor(collapsedTabIndicatorColor); + tabLayout.setBackgroundColor(collapsedTabBackgroundColor); + } else if (state == State.EXPANDED) { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + tabLayout.setTabTextColors(expandedTabTextColor, expandedTabTextColor); + tabLayout.setSelectedTabIndicatorColor(expandedTabIndicatorColor); + tabLayout.setBackgroundColor(expandedTabBackgroundColor); + } } + }); + + int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarResourceId > 0) { + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); + params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId); + toolbar.setLayoutParams(params); } - }); + } else { + appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + @Override + void onStateChanged(AppBarLayout appBarLayout, State state) { + if (state == State.EXPANDED) { + tabLayout.setTabTextColors(expandedTabTextColor, expandedTabTextColor); + tabLayout.setSelectedTabIndicatorColor(expandedTabIndicatorColor); + tabLayout.setBackgroundColor(expandedTabBackgroundColor); + } else if (state == State.COLLAPSED) { + tabLayout.setTabTextColors(collapsedTabTextColor, collapsedTabTextColor); + tabLayout.setSelectedTabIndicatorColor(collapsedTabIndicatorColor); + tabLayout.setBackgroundColor(collapsedTabBackgroundColor); + } + } + }); + } subscribedUserDao = mRedditDataRoomDatabase.subscribedUserDao(); glide = Glide.with(this); @@ -172,8 +221,8 @@ public class ViewUserDetailActivity extends AppCompatActivity { userViewModel = ViewModelProviders.of(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username)) .get(UserViewModel.class); userViewModel.getUserLiveData().observe(this, userData -> { - if(userData != null) { - if(userData.getBanner().equals("")) { + if (userData != null) { + if (userData.getBanner().equals("")) { bannerImageView.setOnClickListener(view -> { //Do nothing since the user has no banner image }); @@ -188,7 +237,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { }); } - if(userData.getIconUrl().equals("")) { + if (userData.getIconUrl().equals("")) { glide.load(getDrawable(R.drawable.subreddit_default_icon)) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))) .into(iconGifImageView); @@ -211,12 +260,12 @@ public class ViewUserDetailActivity extends AppCompatActivity { }); } - if(userData.isCanBeFollowed()) { + if (userData.isCanBeFollowed()) { subscribeUserChip.setVisibility(View.VISIBLE); subscribeUserChip.setOnClickListener(view -> { - if(subscriptionReady) { + if (subscriptionReady) { subscriptionReady = false; - if(subscribeUserChip.getText().equals(getResources().getString(R.string.follow))) { + if (subscribeUserChip.getText().equals(getResources().getString(R.string.follow))) { UserFollowing.followUser(mOauthRetrofit, mRetrofit, mAccessToken, username, mAccountName, subscribedUserDao, new UserFollowing.UserFollowingListener() { @Override @@ -275,7 +324,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { String userFullName = "u/" + userData.getName(); userNameTextView.setText(userFullName); - if(!title.equals(userFullName)) { + if (!title.equals(userFullName)) { getSupportActionBar().setTitle(userFullName); } String karma = getString(R.string.karma_info, userData.getKarma()); @@ -286,7 +335,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { private void getCurrentAccountAndInitializeViewPager() { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { - if(account == null) { + if (account == null) { mNullAccessToken = true; } else { mAccessToken = account.getAccessToken(); @@ -304,7 +353,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { } private void fetchUserInfo() { - if(!mFetchUserInfoSuccess) { + if (!mFetchUserInfoSuccess) { FetchUserData.fetchUserData(mRetrofit, username, new FetchUserData.FetchUserDataListener() { @Override public void onFetchUserDataSuccess(UserData userData) { @@ -326,7 +375,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { getMenuInflater().inflate(R.menu.view_user_detail_activity, menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity); - if(isInLazyMode) { + if (isInLazyMode) { lazyModeItem.setTitle(R.string.action_stop_lazy_mode); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED); collapsingToolbarLayout.setLayoutParams(params); @@ -389,7 +438,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { } private void makeSnackbar(int resId, boolean retry) { - if(retry) { + if (retry) { Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).setAction(R.string.retry, view -> fetchUserInfo()).show(); } else { @@ -397,44 +446,6 @@ public class ViewUserDetailActivity extends AppCompatActivity { } } - public abstract static class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { - // State - public enum State { - EXPANDED, - COLLAPSED, - IDLE - } - - private State mCurrentState = State.IDLE; - - @Override - public final void onOffsetChanged(AppBarLayout appBarLayout, int i) { - if (i == 0) { - if (mCurrentState != State.EXPANDED) { - onStateChanged(appBarLayout, State.EXPANDED); - } - mCurrentState = State.EXPANDED; - } else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) { - if (mCurrentState != State.COLLAPSED) { - onStateChanged(appBarLayout, State.COLLAPSED); - } - mCurrentState = State.COLLAPSED; - } else { - if (mCurrentState != State.IDLE) { - onStateChanged(appBarLayout, State.IDLE); - } - mCurrentState = State.IDLE; - } - } - - /** - * Notifies on state change - * @param appBarLayout Layout - * @param state Collapse state - */ - abstract void onStateChanged(AppBarLayout appBarLayout, State state); - } - private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> { interface InsertUserDataAsyncTaskListener { @@ -524,7 +535,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { } public void refresh() { - if(viewPager.getCurrentItem() == 0) { + if (viewPager.getCurrentItem() == 0) { postFragment.refresh(); } else { commentsListingFragment.refresh(); diff --git a/app/src/main/res/layout/activity_search_result.xml b/app/src/main/res/layout/activity_search_result.xml index 797b08d3..8620b0ec 100644 --- a/app/src/main/res/layout/activity_search_result.xml +++ b/app/src/main/res/layout/activity_search_result.xml @@ -11,38 +11,48 @@ android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> - <FrameLayout + <com.google.android.material.appbar.CollapsingToolbarLayout android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="match_parent" + app:layout_scrollFlags="scroll|enterAlways" + app:titleEnabled="false" + app:toolbarId="@+id/toolbar_search_result_activity"> - <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar_search_result_activity" + <FrameLayout android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="?attr/colorPrimary" - app:popupTheme="@style/AppTheme.PopupOverlay" /> + android:layout_height="wrap_content"> - <com.ferfalk.simplesearchview.SimpleSearchView - android:id="@+id/search_view_search_result_activity" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:textColor="@android:color/white" - app:voiceSearch="true" - app:searchBackground="@color/colorPrimary" - app:cursorColor="@android:color/white" - app:hintColor="#E0E0E0" - app:iconsTint="@android:color/white" - app:backIconTint="@android:color/white" - app:iconsAlpha="1" - app:backIconAlpha="1" /> + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar_search_result_activity" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + app:popupTheme="@style/AppTheme.PopupOverlay" /> + + <com.ferfalk.simplesearchview.SimpleSearchView + android:id="@+id/search_view_search_result_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:textColor="@android:color/white" + app:voiceSearch="true" + app:searchBackground="@color/colorPrimary" + app:cursorColor="@android:color/white" + app:hintColor="#E0E0E0" + app:iconsTint="@android:color/white" + app:backIconTint="@android:color/white" + app:iconsAlpha="1" + app:backIconAlpha="1" /> + + </FrameLayout> - </FrameLayout> + </com.google.android.material.appbar.CollapsingToolbarLayout> <com.google.android.material.tabs.TabLayout android:id="@+id/tab_layout_search_result_activity" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimary" + app:layout_scrollFlags="scroll|enterAlways" app:tabGravity="fill" app:tabMode="fixed" app:tabIndicatorColor="@android:color/white" diff --git a/app/src/main/res/layout/activity_subscribed_thing_listing.xml b/app/src/main/res/layout/activity_subscribed_thing_listing.xml index c448e631..45092748 100644 --- a/app/src/main/res/layout/activity_subscribed_thing_listing.xml +++ b/app/src/main/res/layout/activity_subscribed_thing_listing.xml @@ -12,18 +12,28 @@ android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> - <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar_subscribed_thing_listing_activity" + <com.google.android.material.appbar.CollapsingToolbarLayout android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="?attr/colorPrimary" - app:popupTheme="@style/AppTheme.PopupOverlay" /> + android:layout_height="match_parent" + app:layout_scrollFlags="scroll|enterAlways" + app:titleEnabled="false" + app:toolbarId="@+id/toolbar_subscribed_thing_listing_activity"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar_subscribed_thing_listing_activity" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + app:popupTheme="@style/AppTheme.PopupOverlay" /> + + </com.google.android.material.appbar.CollapsingToolbarLayout> <com.google.android.material.tabs.TabLayout android:id="@+id/tab_layout_subscribed_thing_listing_activity" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimary" + app:layout_scrollFlags="scroll|enterAlways" app:tabGravity="fill" app:tabMode="fixed" app:tabIndicatorColor="@android:color/white" diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 46a388a9..27a54b4c 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -4,9 +4,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:id="@+id/coordinator_layout_main_activity" tools:application="ml.docilealligator.infinityforreddit.MainActivity"> <com.google.android.material.appbar.AppBarLayout + android:id="@+id/appbar_layout_main_activity" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> diff --git a/app/src/main/res/layout/fragment_comments_listing.xml b/app/src/main/res/layout/fragment_comments_listing.xml index e0741118..7dfb31e4 100644 --- a/app/src/main/res/layout/fragment_comments_listing.xml +++ b/app/src/main/res/layout/fragment_comments_listing.xml @@ -21,7 +21,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view_comments_listing_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:clipToPadding="false" /> <LinearLayout android:id="@+id/fetch_comments_info_linear_layout_comments_listing_fragment" diff --git a/app/src/main/res/layout/fragment_followed_users_listing.xml b/app/src/main/res/layout/fragment_followed_users_listing.xml index c7e33729..e5b64728 100644 --- a/app/src/main/res/layout/fragment_followed_users_listing.xml +++ b/app/src/main/res/layout/fragment_followed_users_listing.xml @@ -8,7 +8,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view_followed_users_listing_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:clipToPadding="false" /> <LinearLayout android:id="@+id/no_subscriptions_linear_layout_followed_users_listing_fragment" diff --git a/app/src/main/res/layout/fragment_post.xml b/app/src/main/res/layout/fragment_post.xml index 27add5a2..dcacaf49 100644 --- a/app/src/main/res/layout/fragment_post.xml +++ b/app/src/main/res/layout/fragment_post.xml @@ -20,7 +20,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view_post_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:clipToPadding="false" /> <LinearLayout android:id="@+id/fetch_post_info_linear_layout_post_fragment" diff --git a/app/src/main/res/layout/fragment_subreddit_listing.xml b/app/src/main/res/layout/fragment_subreddit_listing.xml index 1b789601..d460b569 100644 --- a/app/src/main/res/layout/fragment_subreddit_listing.xml +++ b/app/src/main/res/layout/fragment_subreddit_listing.xml @@ -21,7 +21,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view_subreddit_listing_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:clipToPadding="false" /> <LinearLayout android:id="@+id/fetch_subreddit_listing_info_linear_layout_subreddit_listing_fragment" diff --git a/app/src/main/res/layout/fragment_subscribed_subreddits_listing.xml b/app/src/main/res/layout/fragment_subscribed_subreddits_listing.xml index 2263dd7c..25294baf 100644 --- a/app/src/main/res/layout/fragment_subscribed_subreddits_listing.xml +++ b/app/src/main/res/layout/fragment_subscribed_subreddits_listing.xml @@ -8,7 +8,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view_subscribed_subreddits_listing_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:clipToPadding="false" /> <LinearLayout android:id="@+id/no_subscriptions_linear_layout_subreddits_listing_fragment" diff --git a/app/src/main/res/layout/fragment_user_listing.xml b/app/src/main/res/layout/fragment_user_listing.xml index b2e55538..91eb926e 100644 --- a/app/src/main/res/layout/fragment_user_listing.xml +++ b/app/src/main/res/layout/fragment_user_listing.xml @@ -21,7 +21,8 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view_user_listing_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:clipToPadding="false" /> <LinearLayout android:id="@+id/fetch_user_listing_info_linear_layout_user_listing_fragment" diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index e79b7fa2..4827628f 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -26,7 +26,7 @@ <color name="roundedBottomSheetPrimaryBackground">#242424</color> - <color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color> + <color name="roundedBottomSheetPrimaryNavigationBarColor">@color/roundedBottomSheetPrimaryBackground</color> <color name="voteUnavailableVoteButtonColor">#3C3C3C</color> diff --git a/app/src/main/res/values-sw600dp/attr.xml b/app/src/main/res/values-sw600dp/attr.xml new file mode 100644 index 00000000..d3a0e92c --- /dev/null +++ b/app/src/main/res/values-sw600dp/attr.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="isTablet">true</bool> +</resources>
\ No newline at end of file diff --git a/app/src/main/res/values/attr.xml b/app/src/main/res/values/attr.xml new file mode 100644 index 00000000..f855de6a --- /dev/null +++ b/app/src/main/res/values/attr.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <bool name="isTablet">false</bool> +</resources>
\ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index b69907f3..2f5b389f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -26,7 +26,7 @@ <color name="roundedBottomSheetPrimaryBackground">#FFFFFF</color> - <color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color> + <color name="roundedBottomSheetPrimaryNavigationBarColor">@color/roundedBottomSheetPrimaryBackground</color> <color name="voteUnavailableVoteButtonColor">#F0F0F0</color> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 596e3813..75f23b15 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,4 +1,4 @@ -<resources> +<resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> |