mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-03-29 04:45:28 +01:00
Showing a toast instead of a snackbar when the window flag is set to FLAG_LAYOUT_NO_LIMITS to prevent the snackbar being shown behind the nav bar.
This commit is contained in:
parent
2913c1583b
commit
002fa44d8a
@ -86,6 +86,8 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
@State
|
@State
|
||||||
boolean hasMoreChildren;
|
boolean hasMoreChildren;
|
||||||
|
|
||||||
|
private boolean showToast = false;
|
||||||
|
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private CommentAndPostRecyclerViewAdapter mAdapter;
|
private CommentAndPostRecyclerViewAdapter mAdapter;
|
||||||
private LoadSubredditIconAsyncTask mLoadSubredditIconAsyncTask;
|
private LoadSubredditIconAsyncTask mLoadSubredditIconAsyncTask;
|
||||||
@ -151,6 +153,8 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||||
if (navBarResourceId > 0) {
|
if (navBarResourceId > 0) {
|
||||||
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
|
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
|
||||||
|
|
||||||
|
showToast = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +424,11 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchPostFailed() {
|
public void fetchPostFailed() {
|
||||||
|
if(showToast) {
|
||||||
|
Toast.makeText(ViewPostDetailActivity.this, R.string.refresh_post_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
Snackbar.make(mCoordinatorLayout, R.string.refresh_post_failed, Snackbar.LENGTH_SHORT);
|
Snackbar.make(mCoordinatorLayout, R.string.refresh_post_failed, Snackbar.LENGTH_SHORT);
|
||||||
|
}
|
||||||
isRefreshing = false;
|
isRefreshing = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -13,6 +13,7 @@ import android.view.ViewGroup;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -74,6 +75,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
private boolean mFetchSubredditInfoSuccess = false;
|
private boolean mFetchSubredditInfoSuccess = false;
|
||||||
private boolean subscriptionReady = false;
|
private boolean subscriptionReady = false;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
|
private boolean showToast = false;
|
||||||
|
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private Fragment mFragment;
|
private Fragment mFragment;
|
||||||
@ -135,6 +137,8 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
||||||
params.bottomMargin = resources.getDimensionPixelSize(navBarResourceId);
|
params.bottomMargin = resources.getDimensionPixelSize(navBarResourceId);
|
||||||
fab.setLayoutParams(params);
|
fab.setLayoutParams(params);
|
||||||
|
|
||||||
|
showToast = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,6 +431,9 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeSnackbar(int resId, boolean retry) {
|
private void makeSnackbar(int resId, boolean retry) {
|
||||||
|
if(showToast) {
|
||||||
|
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
if(retry) {
|
if(retry) {
|
||||||
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).setAction(R.string.retry,
|
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).setAction(R.string.retry,
|
||||||
view -> fetchSubredditData()).show();
|
view -> fetchSubredditData()).show();
|
||||||
@ -434,6 +441,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sortTypeSelected(String sortType) {
|
public void sortTypeSelected(String sortType) {
|
||||||
|
@ -13,6 +13,7 @@ import android.view.ViewGroup;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -98,6 +99,7 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
private int collapsedTabTextColor;
|
private int collapsedTabTextColor;
|
||||||
private int collapsedTabBackgroundColor;
|
private int collapsedTabBackgroundColor;
|
||||||
private int collapsedTabIndicatorColor;
|
private int collapsedTabIndicatorColor;
|
||||||
|
private boolean showToast = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("no_oauth")
|
@Named("no_oauth")
|
||||||
@ -141,11 +143,13 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||||
|
|
||||||
|
Resources resources = getResources();
|
||||||
|
|
||||||
//Get status bar height
|
//Get status bar height
|
||||||
int statusBarHeight = 0;
|
int statusBarHeight = 0;
|
||||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
|
||||||
if (resourceId > 0) {
|
if (resourceId > 0) {
|
||||||
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
statusBarHeight = resources.getDimensionPixelSize(resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
String title = "u/" + username;
|
String title = "u/" + username;
|
||||||
@ -158,15 +162,13 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
ViewGroup.MarginLayoutParams toolbarLayoutParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
|
ViewGroup.MarginLayoutParams toolbarLayoutParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
|
||||||
toolbarLayoutParams.topMargin = statusBarHeight;
|
toolbarLayoutParams.topMargin = statusBarHeight;
|
||||||
|
|
||||||
expandedTabTextColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor);
|
expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor);
|
||||||
expandedTabBackgroundColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground);
|
expandedTabBackgroundColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground);
|
||||||
expandedTabIndicatorColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator);
|
expandedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator);
|
||||||
|
|
||||||
collapsedTabTextColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTextColor);
|
collapsedTabTextColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTextColor);
|
||||||
collapsedTabBackgroundColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabBackground);
|
collapsedTabBackgroundColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabBackground);
|
||||||
collapsedTabIndicatorColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator);
|
collapsedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator);
|
||||||
|
|
||||||
Resources resources = getResources();
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
||||||
&& (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
|
&& (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
|
||||||
@ -192,11 +194,14 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
int statusBarResourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
|
||||||
if (statusBarResourceId > 0) {
|
if (statusBarResourceId > 0) {
|
||||||
|
int navBarHeight = resources.getDimensionPixelSize(statusBarResourceId);
|
||||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
|
||||||
params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId);
|
params.topMargin = navBarHeight;
|
||||||
toolbar.setLayoutParams(params);
|
toolbar.setLayoutParams(params);
|
||||||
|
|
||||||
|
showToast = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
|
appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
|
||||||
@ -265,13 +270,13 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
subscribeUserChip.setOnClickListener(view -> {
|
subscribeUserChip.setOnClickListener(view -> {
|
||||||
if (subscriptionReady) {
|
if (subscriptionReady) {
|
||||||
subscriptionReady = false;
|
subscriptionReady = false;
|
||||||
if (subscribeUserChip.getText().equals(getResources().getString(R.string.follow))) {
|
if (subscribeUserChip.getText().equals(resources.getString(R.string.follow))) {
|
||||||
UserFollowing.followUser(mOauthRetrofit, mRetrofit, mAccessToken,
|
UserFollowing.followUser(mOauthRetrofit, mRetrofit, mAccessToken,
|
||||||
username, mAccountName, subscribedUserDao, new UserFollowing.UserFollowingListener() {
|
username, mAccountName, subscribedUserDao, new UserFollowing.UserFollowingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onUserFollowingSuccess() {
|
public void onUserFollowingSuccess() {
|
||||||
subscribeUserChip.setText(R.string.unfollow);
|
subscribeUserChip.setText(R.string.unfollow);
|
||||||
subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorAccent));
|
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent));
|
||||||
makeSnackbar(R.string.followed, false);
|
makeSnackbar(R.string.followed, false);
|
||||||
subscriptionReady = true;
|
subscriptionReady = true;
|
||||||
}
|
}
|
||||||
@ -288,7 +293,7 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onUserFollowingSuccess() {
|
public void onUserFollowingSuccess() {
|
||||||
subscribeUserChip.setText(R.string.follow);
|
subscribeUserChip.setText(R.string.follow);
|
||||||
subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark));
|
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark));
|
||||||
makeSnackbar(R.string.unfollowed, false);
|
makeSnackbar(R.string.unfollowed, false);
|
||||||
subscriptionReady = true;
|
subscriptionReady = true;
|
||||||
}
|
}
|
||||||
@ -307,14 +312,14 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void isSubscribed() {
|
public void isSubscribed() {
|
||||||
subscribeUserChip.setText(R.string.unfollow);
|
subscribeUserChip.setText(R.string.unfollow);
|
||||||
subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorAccent));
|
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent));
|
||||||
subscriptionReady = true;
|
subscriptionReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void isNotSubscribed() {
|
public void isNotSubscribed() {
|
||||||
subscribeUserChip.setText(R.string.follow);
|
subscribeUserChip.setText(R.string.follow);
|
||||||
subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark));
|
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark));
|
||||||
subscriptionReady = true;
|
subscriptionReady = true;
|
||||||
}
|
}
|
||||||
}).execute();
|
}).execute();
|
||||||
@ -438,6 +443,9 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeSnackbar(int resId, boolean retry) {
|
private void makeSnackbar(int resId, boolean retry) {
|
||||||
|
if(showToast) {
|
||||||
|
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
if (retry) {
|
if (retry) {
|
||||||
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).setAction(R.string.retry,
|
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).setAction(R.string.retry,
|
||||||
view -> fetchUserInfo()).show();
|
view -> fetchUserInfo()).show();
|
||||||
@ -445,6 +453,7 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(coordinatorLayout, resId, Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user