Skip to content

Commit

Permalink
setTranslucent(false) in onPause() in BaseActivity to solve the app l…
Browse files Browse the repository at this point in the history
…aggy issue on Android >= 11.
  • Loading branch information
Docile-Alligator committed Nov 22, 2024
1 parent ae1846c commit aafc3ff
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 26 deletions.
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
android:name=".activities.EditProfileActivity"
android:label="@string/edit_profile_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activities.WikiActivity"
Expand Down Expand Up @@ -201,7 +201,7 @@
android:name=".activities.EditMultiRedditActivity"
android:label="@string/edit_multi_reddit_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.CustomThemePreviewActivity"
android:label="@string/theme_preview_activity_label"
Expand All @@ -221,7 +221,7 @@
android:name=".activities.SubredditMultiselectionActivity"
android:label="@string/subreddit_multiselection_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.CreateMultiRedditActivity"
android:label="@string/create_multi_reddit_activity_label"
Expand Down Expand Up @@ -286,7 +286,7 @@
android:name=".activities.EditPostActivity"
android:label="@string/edit_post_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activities.FilteredPostsActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -79,6 +81,7 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
public String accessToken;
@NonNull
public String accountName = Account.ANONYMOUS_ACCOUNT;
protected Handler mHandler;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down Expand Up @@ -230,6 +233,30 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

accessToken = getCurrentAccountSharedPreferences().getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
accountName = getCurrentAccountSharedPreferences().getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);

mHandler = new Handler(Looper.getMainLooper());
}

@Override
protected void onResume() {
super.onResume();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && mSliderPanel != null) {
setTranslucent(true);
}
}

@Override
protected void onPause() {
super.onPause();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && mSliderPanel != null && !isFinishing()) {
mHandler.postDelayed(() -> setTranslucent(false), 500);
}
}

@Override
protected void onDestroy() {
super.onDestroy();
mHandler.removeCallbacksAndMessages(null);
}

public abstract SharedPreferences getDefaultSharedPreferences();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.databinding.ActivityEditMultiRedditBinding;
import ml.docilealligator.infinityforreddit.multireddit.EditMultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.FetchMultiRedditInfo;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;

Expand Down Expand Up @@ -72,10 +70,6 @@ protected void onCreate(Bundle savedInstanceState) {

applyCustomTheme();

if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(binding.appbarLayoutEditMultiRedditActivity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ protected void onCreate(Bundle savedInstanceState) {

applyCustomTheme();

if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(binding.appbarLayoutEditPostActivity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.databinding.ActivityEditProfileBinding;
import ml.docilealligator.infinityforreddit.events.SubmitChangeAvatarEvent;
import ml.docilealligator.infinityforreddit.events.SubmitChangeBannerEvent;
import ml.docilealligator.infinityforreddit.events.SubmitSaveProfileEvent;
import ml.docilealligator.infinityforreddit.services.EditProfileService;
import ml.docilealligator.infinityforreddit.user.UserViewModel;
import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;

Expand Down Expand Up @@ -91,10 +89,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

setSupportActionBar(binding.toolbarViewEditProfileActivity);

if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}

binding.imageViewChangeBannerEditProfileActivity.setOnClickListener(view -> {
startPickImage(PICK_IMAGE_BANNER_REQUEST_CODE);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
import ml.docilealligator.infinityforreddit.adapters.SubredditMultiselectionRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
import ml.docilealligator.infinityforreddit.databinding.ActivitySubscribedSubredditsMultiselectionBinding;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditViewModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit;

public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
Expand Down Expand Up @@ -69,10 +67,6 @@ protected void onCreate(Bundle savedInstanceState) {

applyCustomTheme();

if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();

Expand Down

0 comments on commit aafc3ff

Please sign in to comment.