mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Make navigation bar and status bar transparent to display posts, comments, subreddits and users under them. Minor UI tweaks for bottom sheet fragments.
This commit is contained in:
parent
4c21eea852
commit
413a18f6d3
@ -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);
|
||||
}
|
@ -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));
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 -> {
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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" />
|
||||
|
||||
</FrameLayout>
|
||||
<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>
|
||||
|
||||
</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"
|
||||
|
@ -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"
|
||||
|
@ -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">
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
||||
|
4
app/src/main/res/values-sw600dp/attr.xml
Normal file
4
app/src/main/res/values-sw600dp/attr.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isTablet">true</bool>
|
||||
</resources>
|
4
app/src/main/res/values/attr.xml
Normal file
4
app/src/main/res/values/attr.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isTablet">false</bool>
|
||||
</resources>
|
@ -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>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
|
||||
|
Loading…
Reference in New Issue
Block a user