mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Include Slidr in code.
This commit is contained in:
parent
b885e12d1a
commit
ef4ead0434
@ -176,7 +176,6 @@ dependencies {
|
||||
implementation 'com.libRG:customtextview:2.4'
|
||||
|
||||
// Dismiss gesturing
|
||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||
implementation 'app.futured.hauler:hauler:5.0.0'
|
||||
|
||||
// Bottom sheet with rounded corners
|
||||
|
@ -12,9 +12,6 @@ import android.view.WindowManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
@ -29,6 +26,8 @@ import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.databinding.ActivityAccountPostsBinding;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
@ -54,7 +53,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mUserWhere;
|
||||
@ -76,7 +75,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -244,15 +243,15 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -36,6 +34,8 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.databinding.ActivityAccountSavedThingBinding;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
@ -71,7 +71,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
Executor mExecutor;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
||||
@ -90,7 +90,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -231,15 +231,15 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ import androidx.core.view.inputmethod.EditorInfoCompat;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -36,6 +35,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
@ -39,8 +39,6 @@ import com.google.android.material.bottomappbar.BottomAppBar;
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -56,6 +54,8 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
|
||||
import ml.docilealligator.infinityforreddit.customviews.ViewPagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.FontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
|
||||
@ -126,7 +126,7 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus
|
||||
private int subscribedColor;
|
||||
private int systemVisibilityToolbarExpanded = 0;
|
||||
private int systemVisibilityToolbarCollapsed = 0;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -232,7 +232,7 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -453,14 +453,14 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus
|
||||
}
|
||||
|
||||
private void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
private void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@ -47,6 +46,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||
import ml.docilealligator.infinityforreddit.postfilter.SavePostFilter;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
@ -24,7 +24,6 @@ import androidx.core.view.inputmethod.EditorInfoCompat;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@ -37,6 +36,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.EditMultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.FetchMultiRedditInfo;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ml.docilealligator.infinityforreddit.activities;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
@ -13,7 +12,6 @@ import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@ -28,7 +26,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -54,6 +51,7 @@ import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
@ -29,8 +29,6 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -45,6 +43,9 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitChangeAvatarEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitChangeBannerEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SubmitSaveProfileEvent;
|
||||
@ -123,8 +124,8 @@ public class EditProfileActivity extends BaseActivity {
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
SlidrInterface slidrInterface = Slidr.attach(this);
|
||||
slidrInterface.unlock();
|
||||
SliderPanel sliderPanel = Slidr.attach(this);
|
||||
sliderPanel.unlock();
|
||||
}
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
@ -18,7 +18,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -46,6 +45,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomS
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UserThingSortTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
|
@ -20,8 +20,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -43,6 +41,8 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
@ -68,7 +68,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -89,7 +89,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
||||
setTitle(" ");
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -147,15 +147,15 @@ public class FullMarkdownActivity extends BaseActivity {
|
||||
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
||||
@Override
|
||||
public void lockSwipe() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipe() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -22,7 +22,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@ -38,6 +37,7 @@ import ml.docilealligator.infinityforreddit.adapters.AwardRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.award.GiveAward;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
@ -23,8 +23,6 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -39,6 +37,8 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.CommentsListingFragment;
|
||||
@ -74,7 +74,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
@ -93,7 +93,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -229,15 +229,15 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,6 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -51,6 +49,8 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeInboxCountEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.PassPrivateMessageEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.PassPrivateMessageIndexEvent;
|
||||
@ -103,7 +103,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private FragmentManager fragmentManager;
|
||||
private String mAccessToken;
|
||||
@ -125,7 +125,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -381,15 +381,15 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ import androidx.core.app.ActivityCompat;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -50,6 +49,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.ParseAndInsertNewAccount;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||
|
@ -7,7 +7,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
@ -19,7 +18,6 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -38,6 +36,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.MultiRedditListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.FetchMyMultiReddits;
|
||||
|
@ -15,7 +15,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -34,6 +33,7 @@ import ml.docilealligator.infinityforreddit.ReportThing;
|
||||
import ml.docilealligator.infinityforreddit.Rule;
|
||||
import ml.docilealligator.infinityforreddit.adapters.ReportReasonRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
@ -11,7 +11,6 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
@ -20,8 +19,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -34,13 +31,16 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.adapters.RulesRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.FetchRules;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.Rule;
|
||||
import ml.docilealligator.infinityforreddit.adapters.RulesRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -98,9 +98,9 @@ public class RulesActivity extends BaseActivity {
|
||||
|
||||
applyCustomTheme();
|
||||
|
||||
SlidrInterface slidrInterface = null;
|
||||
SliderPanel sliderPanel = null;
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
slidrInterface = Slidr.attach(this);
|
||||
sliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -132,7 +132,7 @@ public class RulesActivity extends BaseActivity {
|
||||
|
||||
mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||
|
||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, slidrInterface);
|
||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel);
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
FetchRules.fetchRules(mExecutor, new Handler(), mAccessToken == null ? mRetrofit : mOauthRetrofit, mAccessToken, mSubredditName, new FetchRules.FetchRulesListener() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ml.docilealligator.infinityforreddit.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
@ -14,7 +13,6 @@ import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
@ -29,7 +27,6 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -48,6 +45,7 @@ import ml.docilealligator.infinityforreddit.adapters.SearchActivityRecyclerViewA
|
||||
import ml.docilealligator.infinityforreddit.adapters.SubredditAutocompleteRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.recentsearchquery.DeleteRecentSearchQuery;
|
||||
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery;
|
||||
|
@ -33,8 +33,6 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -64,6 +62,8 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchPostSortT
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SearchUserAndSubredditSortTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||
@ -138,7 +138,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
private boolean mInsertSearchQuerySuccess;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private int fabOption;
|
||||
|
||||
@Override
|
||||
@ -156,7 +156,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -904,15 +904,15 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@ -17,7 +16,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -33,6 +31,7 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
@ -7,7 +7,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@ -17,7 +16,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -33,6 +31,7 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.UserListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
@ -18,7 +18,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -36,6 +35,7 @@ import ml.docilealligator.infinityforreddit.UserFlair;
|
||||
import ml.docilealligator.infinityforreddit.adapters.UserFlairRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
@ -16,7 +16,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -27,12 +26,13 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.adapters.SelectedSubredditsRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SelectSubredditsOrUsersOptionsBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
||||
public class SelectedSubredditsAndUsersActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
@ -25,7 +25,6 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -41,6 +40,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
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.subscribedsubreddit.SubscribedSubredditViewModel;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
@ -19,7 +19,6 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -42,6 +41,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.account.Account;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||
|
@ -32,8 +32,6 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -57,6 +55,8 @@ import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.ViewPagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.GoBackToMainPageEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.RefreshMultiRedditsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
@ -73,6 +73,8 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
;
|
||||
|
||||
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_SHOW_MULTIREDDITS = "ESM";
|
||||
@ -110,7 +112,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private boolean mInsertSuccess = false;
|
||||
@ -134,7 +136,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -443,15 +445,15 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -47,6 +46,7 @@ import ml.docilealligator.infinityforreddit.TrendingSearch;
|
||||
import ml.docilealligator.infinityforreddit.adapters.TrendingSearchRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.post.ParsePost;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
|
@ -48,9 +48,6 @@ import com.github.piasy.biv.loader.glide.GlideImageLoader;
|
||||
import com.github.piasy.biv.view.BigImageView;
|
||||
import com.github.piasy.biv.view.GlideImageViewFactory;
|
||||
import com.google.android.material.bottomappbar.BottomAppBar;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrConfig;
|
||||
import com.r0adkll.slidr.model.SlidrPosition;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -69,6 +66,9 @@ import ml.docilealligator.infinityforreddit.WallpaperSetter;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SaveBitmapImageToFile;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SaveGIFToFile;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SetAsWallpaperBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrConfig;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrPosition;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.FontFamily;
|
||||
|
@ -27,7 +27,6 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -60,6 +59,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomS
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.NavigationWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.events.GoBackToMainPageEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.RefreshMultiRedditsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
|
@ -40,8 +40,6 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.livefront.bridge.Bridge;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -71,6 +69,9 @@ import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
|
||||
import ml.docilealligator.infinityforreddit.comment.Comment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.NeedForPostListFromPostFragmentEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ProvidePostListToViewPostDetailActivityEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
@ -176,7 +177,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
int loadingMorePostsStatus = LoadingMorePostsStatus.NOT_LOADING;
|
||||
public Map<String, String> authorIcons = new HashMap<>();
|
||||
private FragmentManager fragmentManager;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
@ -237,7 +238,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
boolean swipeBetweenPosts = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_BETWEEN_POSTS, false);
|
||||
if (!swipeBetweenPosts) {
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
viewPager2.setUserInputEnabled(false);
|
||||
}
|
||||
@ -862,15 +863,15 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ml.docilealligator.infinityforreddit.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
@ -19,7 +18,6 @@ import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@ -47,8 +45,6 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -95,6 +91,8 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomS
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.NavigationWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.GoBackToMainPageEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
@ -226,7 +224,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
private int unsubscribedColor;
|
||||
private int subscribedColor;
|
||||
private int fabOption;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||
|
||||
@Override
|
||||
@ -252,7 +250,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -1538,15 +1536,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ml.docilealligator.infinityforreddit.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
@ -21,7 +20,6 @@ import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@ -49,8 +47,6 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -98,6 +94,9 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSh
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UserThingSortTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.NavigationWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.GoBackToMainPageEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
@ -227,7 +226,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private boolean lockBottomAppBar;
|
||||
private String mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
//private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||
|
||||
@Override
|
||||
@ -255,7 +254,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY);
|
||||
@ -1766,15 +1765,15 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
@Override
|
||||
public void lockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipeRightToGoBack() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -52,6 +50,8 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||
@ -95,7 +95,7 @@ public class WikiActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
private SlidrInterface mSlidrInterface;
|
||||
private SliderPanel mSliderPanel;
|
||||
private String wikiMarkdown;
|
||||
private Markwon markwon;
|
||||
private MarkwonAdapter markwonAdapter;
|
||||
@ -119,7 +119,7 @@ public class WikiActivity extends BaseActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
mSlidrInterface = Slidr.attach(this);
|
||||
mSliderPanel = Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@ -181,15 +181,15 @@ public class WikiActivity extends BaseActivity {
|
||||
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
||||
@Override
|
||||
public void lockSwipe() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.lock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipe() {
|
||||
if (mSlidrInterface != null) {
|
||||
mSlidrInterface.unlock();
|
||||
if (mSliderPanel != null) {
|
||||
mSliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -12,8 +12,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.r0adkll.slidr.model.SlidrInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
@ -33,21 +31,22 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSh
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
|
||||
|
||||
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
|
||||
private BaseActivity activity;
|
||||
private Markwon markwon;
|
||||
@Nullable
|
||||
private final SlidrInterface slidrInterface;
|
||||
private final SliderPanel sliderPanel;
|
||||
private ArrayList<Rule> rules;
|
||||
private int mPrimaryTextColor;
|
||||
|
||||
public RulesRecyclerViewAdapter(@NonNull BaseActivity activity,
|
||||
@NonNull CustomThemeWrapper customThemeWrapper,
|
||||
@Nullable SlidrInterface slidrInterface) {
|
||||
@Nullable SliderPanel sliderPanel) {
|
||||
this.activity = activity;
|
||||
this.slidrInterface = slidrInterface;
|
||||
this.sliderPanel = sliderPanel;
|
||||
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
int spoilerBackgroundColor = mPrimaryTextColor | 0xFF000000;
|
||||
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
|
||||
@ -142,15 +141,15 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
||||
new SwipeLockInterface() {
|
||||
@Override
|
||||
public void lockSwipe() {
|
||||
if (slidrInterface != null) {
|
||||
slidrInterface.lock();
|
||||
if (sliderPanel != null) {
|
||||
sliderPanel.lock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockSwipe() {
|
||||
if (slidrInterface != null) {
|
||||
slidrInterface.unlock();
|
||||
if (sliderPanel != null) {
|
||||
sliderPanel.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,68 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr;
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
|
||||
|
||||
class ColorPanelSlideListener implements SliderPanel.OnPanelSlideListener {
|
||||
|
||||
private final Activity activity;
|
||||
private final int primaryColor;
|
||||
private final int secondaryColor;
|
||||
private final ArgbEvaluator evaluator = new ArgbEvaluator();
|
||||
|
||||
|
||||
ColorPanelSlideListener(Activity activity, @ColorInt int primaryColor, @ColorInt int secondaryColor) {
|
||||
this.activity = activity;
|
||||
this.primaryColor = primaryColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int state) {
|
||||
// Unused.
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClosed() {
|
||||
activity.finish();
|
||||
activity.overridePendingTransition(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onOpened() {
|
||||
// Unused.
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSlideChange(float percent) {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && areColorsValid()){
|
||||
int newColor = (int) evaluator.evaluate(percent, getPrimaryColor(), getSecondaryColor());
|
||||
activity.getWindow().setStatusBarColor(newColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int getPrimaryColor() {
|
||||
return primaryColor;
|
||||
}
|
||||
|
||||
|
||||
protected int getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
|
||||
protected boolean areColorsValid() {
|
||||
return getPrimaryColor() != -1 && getSecondaryColor() != -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrConfig;
|
||||
|
||||
|
||||
class ConfigPanelSlideListener extends ColorPanelSlideListener {
|
||||
|
||||
private final SlidrConfig config;
|
||||
|
||||
|
||||
ConfigPanelSlideListener(@NonNull Activity activity, @NonNull SlidrConfig config) {
|
||||
super(activity, -1, -1);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int state) {
|
||||
if(config.getListener() != null){
|
||||
config.getListener().onSlideStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClosed() {
|
||||
if(config.getListener() != null){
|
||||
if(config.getListener().onSlideClosed()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.onClosed();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onOpened() {
|
||||
if(config.getListener() != null){
|
||||
config.getListener().onSlideOpened();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSlideChange(float percent) {
|
||||
super.onSlideChange(percent);
|
||||
if(config.getListener() != null){
|
||||
config.getListener().onSlideChange(percent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPrimaryColor() {
|
||||
return config.getPrimaryColor();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getSecondaryColor() {
|
||||
return config.getSecondaryColor();
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrConfig;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
|
||||
|
||||
class FragmentPanelSlideListener implements SliderPanel.OnPanelSlideListener {
|
||||
|
||||
private final View view;
|
||||
private final SlidrConfig config;
|
||||
|
||||
|
||||
FragmentPanelSlideListener(@NonNull View view, @NonNull SlidrConfig config) {
|
||||
this.view = view;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int state) {
|
||||
if (config.getListener() != null) {
|
||||
config.getListener().onSlideStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClosed() {
|
||||
if (config.getListener() != null) {
|
||||
if(config.getListener().onSlideClosed()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that we are attached to a FragmentActivity
|
||||
if (view.getContext() instanceof FragmentActivity) {
|
||||
final FragmentActivity activity = (FragmentActivity) view.getContext();
|
||||
if (activity.getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
||||
activity.finish();
|
||||
activity.overridePendingTransition(0, 0);
|
||||
} else {
|
||||
activity.getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpened() {
|
||||
if (config.getListener() != null) {
|
||||
config.getListener().onSlideOpened();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSlideChange(float percent) {
|
||||
if (config.getListener() != null) {
|
||||
config.getListener().onSlideChange(percent);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrConfig;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
|
||||
|
||||
/**
|
||||
* This attacher class is used to attach the sliding mechanism to any {@link android.app.Activity}
|
||||
* that lets the user slide (or swipe) the activity away as a form of back or up action. The action
|
||||
* causes {@link android.app.Activity#finish()} to be called.
|
||||
*/
|
||||
public final class Slidr {
|
||||
|
||||
/**
|
||||
* Attach a slideable mechanism to an activity that adds the slide to dismiss functionality
|
||||
*
|
||||
* @param activity the activity to attach the slider to
|
||||
* @return a {@link ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface} that allows
|
||||
* the user to lock/unlock the sliding mechanism for whatever purpose.
|
||||
*/
|
||||
@NonNull
|
||||
public static SliderPanel attach(@NonNull Activity activity) {
|
||||
return attach(activity, -1, -1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attach a slideable mechanism to an activity that adds the slide to dismiss functionality
|
||||
* and allows for the statusbar to transition between colors
|
||||
*
|
||||
* @param activity the activity to attach the slider to
|
||||
* @param statusBarColor1 the primaryDark status bar color of the interface that this will slide back to
|
||||
* @param statusBarColor2 the primaryDark status bar color of the activity this is attaching to that will transition
|
||||
* back to the statusBarColor1 color
|
||||
* @return a {@link ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface} that allows
|
||||
* the user to lock/unlock the sliding mechanism for whatever purpose.
|
||||
*/
|
||||
@NonNull
|
||||
public static SliderPanel attach(@NonNull Activity activity, @ColorInt int statusBarColor1,
|
||||
@ColorInt int statusBarColor2) {
|
||||
|
||||
// Setup the slider panel and attach it to the decor
|
||||
final SliderPanel panel = attachSliderPanel(activity, null);
|
||||
|
||||
// Set the panel slide listener for when it becomes closed or opened
|
||||
panel.setOnPanelSlideListener(new ColorPanelSlideListener(activity, statusBarColor1, statusBarColor2));
|
||||
|
||||
// Return the lock interface
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attach a slider mechanism to an activity based on the passed {@link ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrConfig}
|
||||
*
|
||||
* @param activity the activity to attach the slider to
|
||||
* @param config the slider configuration to make
|
||||
* @return a {@link ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface} that allows
|
||||
* the user to lock/unlock the sliding mechanism for whatever purpose.
|
||||
*/
|
||||
@NonNull
|
||||
public static SlidrInterface attach(@NonNull Activity activity, @NonNull SlidrConfig config) {
|
||||
|
||||
// Setup the slider panel and attach it to the decor
|
||||
final SliderPanel panel = attachSliderPanel(activity, config);
|
||||
|
||||
// Set the panel slide listener for when it becomes closed or opened
|
||||
panel.setOnPanelSlideListener(new ConfigPanelSlideListener(activity, config));
|
||||
|
||||
// Return the lock interface
|
||||
return panel.getDefaultInterface();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attach a new {@link SliderPanel} to the root of the activity's content
|
||||
*/
|
||||
@NonNull
|
||||
private static SliderPanel attachSliderPanel(@NonNull Activity activity, @NonNull SlidrConfig config) {
|
||||
// Hijack the decorview
|
||||
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
|
||||
View oldScreen = decorView.getChildAt(0);
|
||||
decorView.removeViewAt(0);
|
||||
|
||||
// Setup the slider panel and attach it to the decor
|
||||
SliderPanel panel = new SliderPanel(activity, oldScreen, config);
|
||||
panel.setId(R.id.slidable_panel);
|
||||
oldScreen.setId(R.id.slidable_content);
|
||||
panel.addView(oldScreen);
|
||||
decorView.addView(panel, 0);
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attach a slider mechanism to a fragment view replacing an internal view
|
||||
*
|
||||
* @param oldScreen the view within a fragment to replace
|
||||
* @param config the slider configuration to attach with
|
||||
* @return a {@link ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface} that allows
|
||||
* the user to lock/unlock the sliding mechanism for whatever purpose.
|
||||
*/
|
||||
@NonNull
|
||||
public static SlidrInterface replace(@NonNull final View oldScreen, @NonNull final SlidrConfig config) {
|
||||
ViewGroup parent = (ViewGroup) oldScreen.getParent();
|
||||
ViewGroup.LayoutParams params = oldScreen.getLayoutParams();
|
||||
parent.removeView(oldScreen);
|
||||
|
||||
// Setup the slider panel and attach it
|
||||
final SliderPanel panel = new SliderPanel(oldScreen.getContext(), oldScreen, config);
|
||||
panel.setId(R.id.slidable_panel);
|
||||
oldScreen.setId(R.id.slidable_content);
|
||||
|
||||
panel.addView(oldScreen);
|
||||
parent.addView(panel, 0, params);
|
||||
|
||||
// Set the panel slide listener for when it becomes closed or opened
|
||||
panel.setOnPanelSlideListener(new FragmentPanelSlideListener(oldScreen, config));
|
||||
|
||||
// Return the lock interface
|
||||
return panel.getDefaultInterface();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,318 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.model;
|
||||
|
||||
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.FloatRange;
|
||||
import androidx.customview.widget.ViewDragHelper;
|
||||
|
||||
|
||||
/**
|
||||
* This class contains the configuration information for all the options available in
|
||||
* this library
|
||||
*/
|
||||
public class SlidrConfig {
|
||||
|
||||
private int colorPrimary = -1;
|
||||
private int colorSecondary = -1;
|
||||
private float touchSize = -1f;
|
||||
private float sensitivity = 1f;
|
||||
private int scrimColor = Color.BLACK;
|
||||
private float scrimStartAlpha = 0.8f;
|
||||
private float scrimEndAlpha = 0f;
|
||||
private float velocityThreshold = 5f;
|
||||
private float distanceThreshold = 0.25f;
|
||||
private boolean edgeOnly = false;
|
||||
private float edgeSize = 0.18f;
|
||||
|
||||
private SlidrPosition position = SlidrPosition.LEFT;
|
||||
private SlidrListener listener;
|
||||
|
||||
|
||||
private SlidrConfig() {
|
||||
// Unused.
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
*
|
||||
* Getters
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the primary color that the slider will interpolate. That is this color is the color
|
||||
* of the status bar of the Activity you are returning to
|
||||
*
|
||||
* @return the primary status bar color
|
||||
*/
|
||||
public int getPrimaryColor(){
|
||||
return colorPrimary;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the secondary color that the slider will interpolatel That is the color of the Activity
|
||||
* that you are making slidable
|
||||
*
|
||||
* @return the secondary status bar color
|
||||
*/
|
||||
public int getSecondaryColor(){
|
||||
return colorSecondary;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the color of the background scrim
|
||||
*
|
||||
* @return the scrim color integer
|
||||
*/
|
||||
@ColorInt
|
||||
public int getScrimColor(){
|
||||
return scrimColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get teh start alpha value for when the activity is not swiped at all
|
||||
*
|
||||
* @return the start alpha value (0.0 to 1.0)
|
||||
*/
|
||||
public float getScrimStartAlpha(){
|
||||
return scrimStartAlpha;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the end alpha value for when the user almost swipes the activity off the screen
|
||||
*
|
||||
* @return the end alpha value (0.0 to 1.0)
|
||||
*/
|
||||
public float getScrimEndAlpha(){
|
||||
return scrimEndAlpha;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the position of the slidable mechanism for this configuration. This is the position on
|
||||
* the screen that the user can swipe the activity away from
|
||||
*
|
||||
* @return the slider position
|
||||
*/
|
||||
public SlidrPosition getPosition(){
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the touch 'width' to be used in the gesture detection. This value should incorporate with
|
||||
* the device's touch slop
|
||||
*
|
||||
* @return the touch area size
|
||||
*/
|
||||
public float getTouchSize(){
|
||||
return touchSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the velocity threshold at which the slide action is completed regardless of offset
|
||||
* distance of the drag
|
||||
*
|
||||
* @return the velocity threshold
|
||||
*/
|
||||
public float getVelocityThreshold(){
|
||||
return velocityThreshold;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get at what % of the screen is the minimum viable distance the activity has to be dragged
|
||||
* in-order to be slinged off the screen
|
||||
*
|
||||
* @return the distant threshold as a percentage of the screen size (width or height)
|
||||
*/
|
||||
public float getDistanceThreshold(){
|
||||
return distanceThreshold;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the touch sensitivity set in the {@link ViewDragHelper} when
|
||||
* creating it.
|
||||
*
|
||||
* @return the touch sensitivity
|
||||
*/
|
||||
public float getSensitivity(){
|
||||
return sensitivity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the slidr listener set by the user to respond to certain events in the sliding
|
||||
* mechanism.
|
||||
*
|
||||
* @return the slidr listener
|
||||
*/
|
||||
public SlidrListener getListener(){
|
||||
return listener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Has the user configured slidr to only catch at the edge of the screen ?
|
||||
*
|
||||
* @return true if is edge capture only
|
||||
*/
|
||||
public boolean isEdgeOnly() {
|
||||
return edgeOnly;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the edge field that is catchable
|
||||
*
|
||||
* @see #isEdgeOnly()
|
||||
* @return the size of the edge that is grabable
|
||||
*/
|
||||
public float getEdgeSize(float size) {
|
||||
return edgeSize * size;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
*
|
||||
* Setters
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public void setColorPrimary(int colorPrimary) {
|
||||
this.colorPrimary = colorPrimary;
|
||||
}
|
||||
|
||||
|
||||
public void setColorSecondary(int colorSecondary) {
|
||||
this.colorSecondary = colorSecondary;
|
||||
}
|
||||
|
||||
|
||||
public void setTouchSize(float touchSize) {
|
||||
this.touchSize = touchSize;
|
||||
}
|
||||
|
||||
|
||||
public void setSensitivity(float sensitivity) {
|
||||
this.sensitivity = sensitivity;
|
||||
}
|
||||
|
||||
|
||||
public void setScrimColor(@ColorInt int scrimColor) {
|
||||
this.scrimColor = scrimColor;
|
||||
}
|
||||
|
||||
|
||||
public void setScrimStartAlpha(float scrimStartAlpha) {
|
||||
this.scrimStartAlpha = scrimStartAlpha;
|
||||
}
|
||||
|
||||
|
||||
public void setScrimEndAlpha(float scrimEndAlpha) {
|
||||
this.scrimEndAlpha = scrimEndAlpha;
|
||||
}
|
||||
|
||||
|
||||
public void setVelocityThreshold(float velocityThreshold) {
|
||||
this.velocityThreshold = velocityThreshold;
|
||||
}
|
||||
|
||||
|
||||
public void setDistanceThreshold(float distanceThreshold) {
|
||||
this.distanceThreshold = distanceThreshold;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The Builder for this configuration class. This is the only way to create a
|
||||
* configuration
|
||||
*/
|
||||
public static class Builder{
|
||||
|
||||
private SlidrConfig config;
|
||||
|
||||
public Builder(){
|
||||
config = new SlidrConfig();
|
||||
}
|
||||
|
||||
public Builder primaryColor(@ColorInt int color){
|
||||
config.colorPrimary = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder secondaryColor(@ColorInt int color){
|
||||
config.colorSecondary = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder position(SlidrPosition position){
|
||||
config.position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder touchSize(float size){
|
||||
config.touchSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder sensitivity(float sensitivity){
|
||||
config.sensitivity = sensitivity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder scrimColor(@ColorInt int color){
|
||||
config.scrimColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder scrimStartAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha){
|
||||
config.scrimStartAlpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder scrimEndAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha){
|
||||
config.scrimEndAlpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder velocityThreshold(float threshold){
|
||||
config.velocityThreshold = threshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder distanceThreshold(@FloatRange(from = .1f, to = .9f) float threshold){
|
||||
config.distanceThreshold = threshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder edge(boolean flag){
|
||||
config.edgeOnly = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder edgeSize(@FloatRange(from = 0f, to = 1f) float edgeSize){
|
||||
config.edgeSize = edgeSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder listener(SlidrListener listener){
|
||||
config.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlidrConfig build(){
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.model;
|
||||
|
||||
|
||||
public interface SlidrInterface {
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.model;
|
||||
|
||||
import androidx.customview.widget.ViewDragHelper;
|
||||
|
||||
/**
|
||||
* This listener interface is for receiving events from the sliding panel such as state changes
|
||||
* and slide progress
|
||||
*/
|
||||
public interface SlidrListener {
|
||||
|
||||
/**
|
||||
* This is called when the {@link ViewDragHelper} calls it's
|
||||
* state change callback.
|
||||
*
|
||||
* @see ViewDragHelper#STATE_IDLE
|
||||
* @see ViewDragHelper#STATE_DRAGGING
|
||||
* @see ViewDragHelper#STATE_SETTLING
|
||||
*
|
||||
* @param state the {@link ViewDragHelper} state
|
||||
*/
|
||||
void onSlideStateChanged(int state);
|
||||
|
||||
void onSlideChange(float percent);
|
||||
|
||||
void onSlideOpened();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> than event was processed in the callback.
|
||||
*/
|
||||
boolean onSlideClosed();
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.model;
|
||||
|
||||
|
||||
public class SlidrListenerAdapter implements SlidrListener {
|
||||
|
||||
@Override
|
||||
public void onSlideStateChanged(int state) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlideChange(float percent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlideOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSlideClosed() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.model;
|
||||
|
||||
|
||||
public enum SlidrPosition {
|
||||
|
||||
LEFT,
|
||||
RIGHT,
|
||||
TOP,
|
||||
BOTTOM,
|
||||
VERTICAL,
|
||||
HORIZONTAL
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,125 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.widget;
|
||||
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrPosition;
|
||||
|
||||
|
||||
final class ScrimRenderer {
|
||||
|
||||
private final View rootView;
|
||||
private final View decorView;
|
||||
private final Rect dirtyRect;
|
||||
|
||||
|
||||
ScrimRenderer(@NonNull View rootView, @NonNull View decorView) {
|
||||
this.rootView = rootView;
|
||||
this.decorView = decorView;
|
||||
dirtyRect = new Rect();
|
||||
}
|
||||
|
||||
|
||||
void render(Canvas canvas, SlidrPosition position, Paint paint) {
|
||||
switch (position) {
|
||||
case LEFT:
|
||||
renderLeft(canvas, paint);
|
||||
break;
|
||||
case RIGHT:
|
||||
renderRight(canvas, paint);
|
||||
break;
|
||||
case TOP:
|
||||
renderTop(canvas, paint);
|
||||
break;
|
||||
case BOTTOM:
|
||||
renderBottom(canvas, paint);
|
||||
break;
|
||||
case VERTICAL:
|
||||
renderVertical(canvas, paint);
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
renderHorizontal(canvas, paint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rect getDirtyRect(SlidrPosition position) {
|
||||
switch (position) {
|
||||
case LEFT:
|
||||
dirtyRect.set(0, 0, decorView.getLeft(), rootView.getMeasuredHeight());
|
||||
break;
|
||||
case RIGHT:
|
||||
dirtyRect.set(decorView.getRight(), 0, rootView.getMeasuredWidth(), rootView.getMeasuredHeight());
|
||||
break;
|
||||
case TOP:
|
||||
dirtyRect.set(0, 0, rootView.getMeasuredWidth(), decorView.getTop());
|
||||
break;
|
||||
case BOTTOM:
|
||||
dirtyRect.set(0, decorView.getBottom(), rootView.getMeasuredWidth(), rootView.getMeasuredHeight());
|
||||
break;
|
||||
case VERTICAL:
|
||||
if (decorView.getTop() > 0) {
|
||||
dirtyRect.set(0, 0, rootView.getMeasuredWidth(), decorView.getTop());
|
||||
}
|
||||
else {
|
||||
dirtyRect.set(0, decorView.getBottom(), rootView.getMeasuredWidth(), rootView.getMeasuredHeight());
|
||||
}
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
if (decorView.getLeft() > 0) {
|
||||
dirtyRect.set(0, 0, decorView.getLeft(), rootView.getMeasuredHeight());
|
||||
}
|
||||
else {
|
||||
dirtyRect.set(decorView.getRight(), 0, rootView.getMeasuredWidth(), rootView.getMeasuredHeight());
|
||||
}
|
||||
break;
|
||||
}
|
||||
return dirtyRect;
|
||||
}
|
||||
|
||||
|
||||
private void renderLeft(Canvas canvas, Paint paint) {
|
||||
canvas.drawRect(0, 0, decorView.getLeft(), rootView.getMeasuredHeight(), paint);
|
||||
}
|
||||
|
||||
|
||||
private void renderRight(Canvas canvas, Paint paint) {
|
||||
canvas.drawRect(decorView.getRight(), 0, rootView.getMeasuredWidth(), rootView.getMeasuredHeight(), paint);
|
||||
}
|
||||
|
||||
|
||||
private void renderTop(Canvas canvas, Paint paint) {
|
||||
canvas.drawRect(0, 0, rootView.getMeasuredWidth(), decorView.getTop(), paint);
|
||||
}
|
||||
|
||||
|
||||
private void renderBottom(Canvas canvas, Paint paint) {
|
||||
canvas.drawRect(0, decorView.getBottom(), rootView.getMeasuredWidth(), rootView.getMeasuredHeight(), paint);
|
||||
}
|
||||
|
||||
|
||||
private void renderVertical(Canvas canvas, Paint paint) {
|
||||
if (decorView.getTop() > 0) {
|
||||
renderTop(canvas, paint);
|
||||
}
|
||||
else {
|
||||
renderBottom(canvas, paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderHorizontal(Canvas canvas, Paint paint) {
|
||||
if (decorView.getLeft() > 0) {
|
||||
renderLeft(canvas, paint);
|
||||
}
|
||||
else {
|
||||
renderRight(canvas, paint);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,782 @@
|
||||
package ml.docilealligator.infinityforreddit.customviews.slidr.widget;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.ViewGroupCompat;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrConfig;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.model.SlidrInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.slidr.util.ViewDragHelper;
|
||||
|
||||
|
||||
public class SliderPanel extends FrameLayout {
|
||||
|
||||
private static final int MIN_FLING_VELOCITY = 400; // dips per second
|
||||
|
||||
private int screenWidth;
|
||||
private int screenHeight;
|
||||
|
||||
private View decorView;
|
||||
private ViewDragHelper dragHelper;
|
||||
private OnPanelSlideListener listener;
|
||||
private Paint scrimPaint;
|
||||
private ScrimRenderer scrimRenderer;
|
||||
|
||||
private boolean isLocked = false;
|
||||
private boolean isEdgeTouched = false;
|
||||
private int edgePosition;
|
||||
|
||||
private SlidrConfig config;
|
||||
|
||||
|
||||
public SliderPanel(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
||||
public SliderPanel(Context context, View decorView, SlidrConfig config){
|
||||
super(context);
|
||||
this.decorView = decorView;
|
||||
this.config = (config == null ? new SlidrConfig.Builder().build() : config);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
boolean interceptForDrag;
|
||||
|
||||
if(isLocked){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(config.isEdgeOnly()) {
|
||||
isEdgeTouched = canDragFromEdge(ev);
|
||||
}
|
||||
|
||||
// Fix for pull request #13 and issue #12
|
||||
try {
|
||||
interceptForDrag = dragHelper.shouldInterceptTouchEvent(ev);
|
||||
} catch (Exception e) {
|
||||
interceptForDrag = false;
|
||||
}
|
||||
|
||||
return interceptForDrag && !isLocked;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(isLocked){
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
dragHelper.processTouchEvent(event);
|
||||
}catch (IllegalArgumentException e){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void computeScroll() {
|
||||
super.computeScroll();
|
||||
if(dragHelper.continueSettling(true)){
|
||||
ViewCompat.postInvalidateOnAnimation(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
scrimRenderer.render(canvas, config.getPosition(), scrimPaint);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the panel slide listener that gets called based on slider changes
|
||||
* @param listener callback implementation
|
||||
*/
|
||||
public void setOnPanelSlideListener(OnPanelSlideListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the default {@link SlidrInterface} from which to control the panel with after attachment
|
||||
*/
|
||||
public SlidrInterface getDefaultInterface() {
|
||||
return defaultSlidrInterface;
|
||||
}
|
||||
|
||||
|
||||
private final SlidrInterface defaultSlidrInterface = new SlidrInterface() {
|
||||
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
SliderPanel.this.lock();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unlock() {
|
||||
SliderPanel.this.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The drag helper callback interface for the Left position
|
||||
*/
|
||||
private final ViewDragHelper.Callback leftCallback = new ViewDragHelper.Callback() {
|
||||
|
||||
@Override
|
||||
public boolean tryCaptureView(View child, int pointerId) {
|
||||
boolean edgeCase = !config.isEdgeOnly() || dragHelper.isEdgeTouched(edgePosition, pointerId);
|
||||
return child.getId() == decorView.getId() && edgeCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clampViewPositionHorizontal(View child, int left, int dx) {
|
||||
return clamp(left, 0, screenWidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewHorizontalDragRange(View child) {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewReleased(View releasedChild, float xvel, float yvel) {
|
||||
super.onViewReleased(releasedChild, xvel, yvel);
|
||||
|
||||
int left = releasedChild.getLeft();
|
||||
int settleLeft = 0;
|
||||
int leftThreshold = (int) (getWidth() * config.getDistanceThreshold());
|
||||
boolean isVerticalSwiping = Math.abs(yvel) > config.getVelocityThreshold();
|
||||
|
||||
if(xvel > 0){
|
||||
|
||||
if(Math.abs(xvel) > config.getVelocityThreshold() && !isVerticalSwiping){
|
||||
settleLeft = screenWidth;
|
||||
}else if(left > leftThreshold){
|
||||
settleLeft = screenWidth;
|
||||
}
|
||||
|
||||
}else if(xvel == 0){
|
||||
if(left > leftThreshold){
|
||||
settleLeft = screenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
dragHelper.settleCapturedViewAt(settleLeft, releasedChild.getTop());
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||
super.onViewPositionChanged(changedView, left, top, dx, dy);
|
||||
float percent = 1f - ((float)left / (float) screenWidth);
|
||||
|
||||
if(listener != null) listener.onSlideChange(percent);
|
||||
|
||||
// Update the dimmer alpha
|
||||
applyScrim(percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDragStateChanged(int state) {
|
||||
super.onViewDragStateChanged(state);
|
||||
if(listener != null) listener.onStateChanged(state);
|
||||
switch (state){
|
||||
case ViewDragHelper.STATE_IDLE:
|
||||
if(decorView.getLeft() == 0){
|
||||
// State Open
|
||||
if(listener != null) listener.onOpened();
|
||||
}else{
|
||||
// State Closed
|
||||
if(listener != null) listener.onClosed();
|
||||
}
|
||||
break;
|
||||
case ViewDragHelper.STATE_DRAGGING:
|
||||
|
||||
break;
|
||||
case ViewDragHelper.STATE_SETTLING:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The drag helper callbacks for dragging the slidr attachment from the right of the screen
|
||||
*/
|
||||
private final ViewDragHelper.Callback rightCallback = new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(View child, int pointerId) {
|
||||
boolean edgeCase = !config.isEdgeOnly() || dragHelper.isEdgeTouched(edgePosition, pointerId);
|
||||
return child.getId() == decorView.getId() && edgeCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clampViewPositionHorizontal(View child, int left, int dx) {
|
||||
return clamp(left, -screenWidth, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewHorizontalDragRange(View child) {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewReleased(View releasedChild, float xvel, float yvel) {
|
||||
super.onViewReleased(releasedChild, xvel, yvel);
|
||||
|
||||
int left = releasedChild.getLeft();
|
||||
int settleLeft = 0;
|
||||
int leftThreshold = (int) (getWidth() * config.getDistanceThreshold());
|
||||
boolean isVerticalSwiping = Math.abs(yvel) > config.getVelocityThreshold();
|
||||
|
||||
if(xvel < 0){
|
||||
|
||||
if(Math.abs(xvel) > config.getVelocityThreshold() && !isVerticalSwiping){
|
||||
settleLeft = -screenWidth;
|
||||
}else if(left < -leftThreshold){
|
||||
settleLeft = -screenWidth;
|
||||
}
|
||||
|
||||
}else if(xvel == 0){
|
||||
if(left < -leftThreshold){
|
||||
settleLeft = -screenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
dragHelper.settleCapturedViewAt(settleLeft, releasedChild.getTop());
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||
super.onViewPositionChanged(changedView, left, top, dx, dy);
|
||||
float percent = 1f - ((float)Math.abs(left) / (float) screenWidth);
|
||||
|
||||
if(listener != null) listener.onSlideChange(percent);
|
||||
|
||||
// Update the dimmer alpha
|
||||
applyScrim(percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDragStateChanged(int state) {
|
||||
super.onViewDragStateChanged(state);
|
||||
if(listener != null) listener.onStateChanged(state);
|
||||
switch (state){
|
||||
case ViewDragHelper.STATE_IDLE:
|
||||
if(decorView.getLeft() == 0){
|
||||
// State Open
|
||||
if(listener != null) listener.onOpened();
|
||||
}else{
|
||||
// State Closed
|
||||
if(listener != null) listener.onClosed();
|
||||
}
|
||||
break;
|
||||
case ViewDragHelper.STATE_DRAGGING:
|
||||
|
||||
break;
|
||||
case ViewDragHelper.STATE_SETTLING:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The drag helper callbacks for dragging the slidr attachment from the top of the screen
|
||||
*/
|
||||
private final ViewDragHelper.Callback topCallback = new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(View child, int pointerId) {
|
||||
return child.getId() == decorView.getId() && (!config.isEdgeOnly() || isEdgeTouched);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clampViewPositionVertical(View child, int top, int dy) {
|
||||
return clamp(top, 0, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewVerticalDragRange(View child) {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewReleased(View releasedChild, float xvel, float yvel) {
|
||||
super.onViewReleased(releasedChild, xvel, yvel);
|
||||
|
||||
int top = releasedChild.getTop();
|
||||
int settleTop = 0;
|
||||
int topThreshold = (int) (getHeight() * config.getDistanceThreshold());
|
||||
boolean isSideSwiping = Math.abs(xvel) > config.getVelocityThreshold();
|
||||
|
||||
if(yvel > 0){
|
||||
if(Math.abs(yvel) > config.getVelocityThreshold() && !isSideSwiping){
|
||||
settleTop = screenHeight;
|
||||
}else if(top > topThreshold){
|
||||
settleTop = screenHeight;
|
||||
}
|
||||
}else if(yvel == 0){
|
||||
if(top > topThreshold){
|
||||
settleTop = screenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
dragHelper.settleCapturedViewAt(releasedChild.getLeft(), settleTop);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||
super.onViewPositionChanged(changedView, left, top, dx, dy);
|
||||
float percent = 1f - ((float)Math.abs(top) / (float) screenHeight);
|
||||
|
||||
if(listener != null) listener.onSlideChange(percent);
|
||||
|
||||
// Update the dimmer alpha
|
||||
applyScrim(percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDragStateChanged(int state) {
|
||||
super.onViewDragStateChanged(state);
|
||||
if(listener != null) listener.onStateChanged(state);
|
||||
switch (state){
|
||||
case ViewDragHelper.STATE_IDLE:
|
||||
if(decorView.getTop() == 0){
|
||||
// State Open
|
||||
if(listener != null) listener.onOpened();
|
||||
}else{
|
||||
// State Closed
|
||||
if(listener != null) listener.onClosed();
|
||||
}
|
||||
break;
|
||||
case ViewDragHelper.STATE_DRAGGING:
|
||||
|
||||
break;
|
||||
case ViewDragHelper.STATE_SETTLING:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The drag helper callbacks for dragging the slidr attachment from the bottom of hte screen
|
||||
*/
|
||||
private final ViewDragHelper.Callback bottomCallback = new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(View child, int pointerId) {
|
||||
return child.getId() == decorView.getId() && (!config.isEdgeOnly() || isEdgeTouched);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clampViewPositionVertical(View child, int top, int dy) {
|
||||
return clamp(top, -screenHeight, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewVerticalDragRange(View child) {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewReleased(View releasedChild, float xvel, float yvel) {
|
||||
super.onViewReleased(releasedChild, xvel, yvel);
|
||||
|
||||
int top = releasedChild.getTop();
|
||||
int settleTop = 0;
|
||||
int topThreshold = (int) (getHeight() * config.getDistanceThreshold());
|
||||
boolean isSideSwiping = Math.abs(xvel) > config.getVelocityThreshold();
|
||||
|
||||
if(yvel < 0){
|
||||
if(Math.abs(yvel) > config.getVelocityThreshold() && !isSideSwiping){
|
||||
settleTop = -screenHeight;
|
||||
}else if(top < -topThreshold){
|
||||
settleTop = -screenHeight;
|
||||
}
|
||||
}else if(yvel == 0){
|
||||
if(top < -topThreshold){
|
||||
settleTop = -screenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
dragHelper.settleCapturedViewAt(releasedChild.getLeft(), settleTop);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||
super.onViewPositionChanged(changedView, left, top, dx, dy);
|
||||
float percent = 1f - ((float)Math.abs(top) / (float) screenHeight);
|
||||
|
||||
if(listener != null) listener.onSlideChange(percent);
|
||||
|
||||
// Update the dimmer alpha
|
||||
applyScrim(percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDragStateChanged(int state) {
|
||||
super.onViewDragStateChanged(state);
|
||||
if(listener != null) listener.onStateChanged(state);
|
||||
switch (state){
|
||||
case ViewDragHelper.STATE_IDLE:
|
||||
if(decorView.getTop() == 0){
|
||||
// State Open
|
||||
if(listener != null) listener.onOpened();
|
||||
}else{
|
||||
// State Closed
|
||||
if(listener != null) listener.onClosed();
|
||||
}
|
||||
break;
|
||||
case ViewDragHelper.STATE_DRAGGING:
|
||||
|
||||
break;
|
||||
case ViewDragHelper.STATE_SETTLING:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The drag helper callbacks for dragging the slidr attachment in both vertical directions
|
||||
*/
|
||||
private final ViewDragHelper.Callback verticalCallback = new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(View child, int pointerId) {
|
||||
return child.getId() == decorView.getId() && (!config.isEdgeOnly() || isEdgeTouched);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clampViewPositionVertical(View child, int top, int dy) {
|
||||
return clamp(top, -screenHeight, screenHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewVerticalDragRange(View child) {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewReleased(View releasedChild, float xvel, float yvel) {
|
||||
super.onViewReleased(releasedChild, xvel, yvel);
|
||||
|
||||
int top = releasedChild.getTop();
|
||||
int settleTop = 0;
|
||||
int topThreshold = (int) (getHeight() * config.getDistanceThreshold());
|
||||
boolean isSideSwiping = Math.abs(xvel) > config.getVelocityThreshold();
|
||||
|
||||
if(yvel > 0){
|
||||
|
||||
// Being slinged down
|
||||
if(Math.abs(yvel) > config.getVelocityThreshold() && !isSideSwiping){
|
||||
settleTop = screenHeight;
|
||||
}else if(top > topThreshold){
|
||||
settleTop = screenHeight;
|
||||
}
|
||||
|
||||
}else if(yvel < 0){
|
||||
// Being slinged up
|
||||
if(Math.abs(yvel) > config.getVelocityThreshold() && !isSideSwiping){
|
||||
settleTop = -screenHeight;
|
||||
}else if(top < -topThreshold){
|
||||
settleTop = -screenHeight;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if(top > topThreshold){
|
||||
settleTop = screenHeight;
|
||||
}else if(top < -topThreshold){
|
||||
settleTop = -screenHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dragHelper.settleCapturedViewAt(releasedChild.getLeft(), settleTop);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||
super.onViewPositionChanged(changedView, left, top, dx, dy);
|
||||
float percent = 1f - ((float)Math.abs(top) / (float) screenHeight);
|
||||
|
||||
if(listener != null) listener.onSlideChange(percent);
|
||||
|
||||
// Update the dimmer alpha
|
||||
applyScrim(percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDragStateChanged(int state) {
|
||||
super.onViewDragStateChanged(state);
|
||||
if(listener != null) listener.onStateChanged(state);
|
||||
switch (state){
|
||||
case ViewDragHelper.STATE_IDLE:
|
||||
if(decorView.getTop() == 0){
|
||||
// State Open
|
||||
if(listener != null) listener.onOpened();
|
||||
}else{
|
||||
// State Closed
|
||||
if(listener != null) listener.onClosed();
|
||||
}
|
||||
break;
|
||||
case ViewDragHelper.STATE_DRAGGING:
|
||||
|
||||
break;
|
||||
case ViewDragHelper.STATE_SETTLING:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The drag helper callbacks for dragging the slidr attachment in both horizontal directions
|
||||
*/
|
||||
private final ViewDragHelper.Callback horizontalCallback = new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(View child, int pointerId) {
|
||||
boolean edgeCase = !config.isEdgeOnly() || dragHelper.isEdgeTouched(edgePosition, pointerId);
|
||||
return child.getId() == decorView.getId() && edgeCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clampViewPositionHorizontal(View child, int left, int dx) {
|
||||
return clamp(left, -screenWidth, screenWidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewHorizontalDragRange(View child) {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewReleased(View releasedChild, float xvel, float yvel) {
|
||||
super.onViewReleased(releasedChild, xvel, yvel);
|
||||
|
||||
int left = releasedChild.getLeft();
|
||||
int settleLeft = 0;
|
||||
int leftThreshold = (int) (getWidth() * config.getDistanceThreshold());
|
||||
boolean isVerticalSwiping = Math.abs(yvel) > config.getVelocityThreshold();
|
||||
|
||||
if(xvel > 0){
|
||||
|
||||
if(Math.abs(xvel) > config.getVelocityThreshold() && !isVerticalSwiping){
|
||||
settleLeft = screenWidth;
|
||||
}else if(left > leftThreshold){
|
||||
settleLeft = screenWidth;
|
||||
}
|
||||
|
||||
}else if(xvel < 0){
|
||||
|
||||
if(Math.abs(xvel) > config.getVelocityThreshold() && !isVerticalSwiping){
|
||||
settleLeft = -screenWidth;
|
||||
}else if(left < -leftThreshold){
|
||||
settleLeft = -screenWidth;
|
||||
}
|
||||
|
||||
}else{
|
||||
if(left > leftThreshold){
|
||||
settleLeft = screenWidth;
|
||||
}else if(left < -leftThreshold){
|
||||
settleLeft = -screenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
dragHelper.settleCapturedViewAt(settleLeft, releasedChild.getTop());
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
|
||||
super.onViewPositionChanged(changedView, left, top, dx, dy);
|
||||
float percent = 1f - ((float)Math.abs(left) / (float) screenWidth);
|
||||
|
||||
if(listener != null) listener.onSlideChange(percent);
|
||||
|
||||
// Update the dimmer alpha
|
||||
applyScrim(percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDragStateChanged(int state) {
|
||||
super.onViewDragStateChanged(state);
|
||||
if(listener != null) listener.onStateChanged(state);
|
||||
switch (state){
|
||||
case ViewDragHelper.STATE_IDLE:
|
||||
if(decorView.getLeft() == 0){
|
||||
// State Open
|
||||
if(listener != null) listener.onOpened();
|
||||
}else{
|
||||
// State Closed
|
||||
if(listener != null) listener.onClosed();
|
||||
}
|
||||
break;
|
||||
case ViewDragHelper.STATE_DRAGGING:
|
||||
|
||||
break;
|
||||
case ViewDragHelper.STATE_SETTLING:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private void init(){
|
||||
setWillNotDraw(false);
|
||||
screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||
|
||||
final float density = getResources().getDisplayMetrics().density;
|
||||
final float minVel = MIN_FLING_VELOCITY * density;
|
||||
|
||||
ViewDragHelper.Callback callback;
|
||||
switch (config.getPosition()){
|
||||
case LEFT:
|
||||
callback = leftCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_LEFT;
|
||||
break;
|
||||
case RIGHT:
|
||||
callback = rightCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_RIGHT;
|
||||
break;
|
||||
case TOP:
|
||||
callback = topCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_TOP;
|
||||
break;
|
||||
case BOTTOM:
|
||||
callback = bottomCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_BOTTOM;
|
||||
break;
|
||||
case VERTICAL:
|
||||
callback = verticalCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_TOP | ViewDragHelper.EDGE_BOTTOM;
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
callback = horizontalCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_LEFT | ViewDragHelper.EDGE_RIGHT;
|
||||
break;
|
||||
default:
|
||||
callback = leftCallback;
|
||||
edgePosition = ViewDragHelper.EDGE_LEFT;
|
||||
}
|
||||
|
||||
dragHelper = ViewDragHelper.create(this, config.getSensitivity(), callback);
|
||||
dragHelper.setMinVelocity(minVel);
|
||||
dragHelper.setEdgeTrackingEnabled(edgePosition);
|
||||
|
||||
ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
|
||||
|
||||
// Setup the dimmer view
|
||||
scrimPaint = new Paint();
|
||||
scrimPaint.setColor(config.getScrimColor());
|
||||
scrimPaint.setAlpha(toAlpha(config.getScrimStartAlpha()));
|
||||
scrimRenderer = new ScrimRenderer(this, decorView);
|
||||
|
||||
/*
|
||||
* This is so we can get the height of the view and
|
||||
* ignore the system navigation that would be included if we
|
||||
* retrieved this value from the DisplayMetrics
|
||||
*/
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
screenHeight = getHeight();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void lock(){
|
||||
dragHelper.abort();
|
||||
isLocked = true;
|
||||
}
|
||||
|
||||
|
||||
public void unlock(){
|
||||
dragHelper.abort();
|
||||
isLocked = false;
|
||||
}
|
||||
|
||||
|
||||
private boolean canDragFromEdge(MotionEvent ev) {
|
||||
float x = ev.getX();
|
||||
float y = ev.getY();
|
||||
|
||||
switch (config.getPosition()) {
|
||||
case LEFT:
|
||||
return x < config.getEdgeSize(getWidth());
|
||||
case RIGHT:
|
||||
return x > getWidth() - config.getEdgeSize(getWidth());
|
||||
case BOTTOM:
|
||||
return y > getHeight() - config.getEdgeSize(getHeight());
|
||||
case TOP:
|
||||
return y < config.getEdgeSize(getHeight());
|
||||
case HORIZONTAL:
|
||||
return x < config.getEdgeSize(getWidth()) || x > getWidth() - config.getEdgeSize(getWidth());
|
||||
case VERTICAL:
|
||||
return y < config.getEdgeSize(getHeight()) || y > getHeight() - config.getEdgeSize(getHeight());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void applyScrim(float percent){
|
||||
float alpha = (percent * (config.getScrimStartAlpha() - config.getScrimEndAlpha())) + config.getScrimEndAlpha();
|
||||
scrimPaint.setAlpha(toAlpha(alpha));
|
||||
invalidate(scrimRenderer.getDirtyRect(config.getPosition()));
|
||||
}
|
||||
|
||||
|
||||
private static int clamp(int value, int min, int max){
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
|
||||
private static int toAlpha(float percentage) {
|
||||
return (int) (percentage * 255);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The panel sliding interface that gets called
|
||||
* whenever the panel is closed or opened
|
||||
*/
|
||||
public interface OnPanelSlideListener{
|
||||
void onStateChanged(int state);
|
||||
void onClosed();
|
||||
void onOpened();
|
||||
void onSlideChange(float percent);
|
||||
}
|
||||
|
||||
}
|
@ -1205,5 +1205,5 @@ Toque para volver a intentarlo."</string>
|
||||
<string name="message_change_banner_success">"Banner cambiado correctamente"</string>
|
||||
<string name="message_change_banner_failed">"Error al cambiar banner %s"</string>
|
||||
<string name="message_save_profile_success">"Perfil guardado correctamente"</string>
|
||||
<string name="message_save_profile_failed">"Error al guardar perfil"</string>
|
||||
<string name="message_save_profile_failed">Error al guardar perfil %s</string>
|
||||
</resources>
|
@ -1159,11 +1159,11 @@ Nhấn để thử lại."</string>
|
||||
<string name="message_remove_avatar_success">"Xoá ảnh đại diện thành công"</string>
|
||||
<string name="message_remove_avatar_failed">"Xoá ảnh đại diện %s thất bại"</string>
|
||||
<string name="message_remove_banner_success">"Xoá banner thành công"</string>
|
||||
<string name="message_remove_banner_failed">"Gỡ bỏ banner thất bại"</string>
|
||||
<string name="message_remove_banner_failed">Gỡ bỏ banner thất bại %s</string>
|
||||
<string name="message_change_avatar_success">"Thay đổi ảnh đại diện thành công"</string>
|
||||
<string name="message_change_avatar_failed">"Thay đổi ảnh đại diện thất bại"</string>
|
||||
<string name="message_change_avatar_failed">Thay đổi ảnh đại diện thất bại %s</string>
|
||||
<string name="message_change_banner_success">"Thay đổi banner thành công"</string>
|
||||
<string name="message_change_banner_failed">"Thay đổi banner thất bại"</string>
|
||||
<string name="message_change_banner_failed">Thay đổi banner thất bại %s</string>
|
||||
<string name="message_save_profile_success">"Lưu Hồ sơ thành công"</string>
|
||||
<string name="message_save_profile_failed">"Lưu hồ sơ %s thất bại"</string>
|
||||
</resources>
|
5
app/src/main/res/values/ids.xml
Normal file
5
app/src/main/res/values/ids.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="slidable_panel" type="id" />
|
||||
<item name="slidable_content" type="id" />
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user