aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-07-15 03:51:29 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-07-15 03:51:29 +0000
commit2d69170f4f6bd54efc472462d47f10988942bcba (patch)
tree7d5b4f09aa0fb8ae738dae9e16b8cf727a6d6614 /app/src/main/java/ml/docilealligator/infinityforreddit
parenta9ba807cf42632b1744b5af5b9e1081575fecae5 (diff)
downloadinfinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.tar
infinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.tar.gz
infinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.tar.bz2
infinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.tar.lz
infinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.tar.xz
infinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.tar.zst
infinity-for-reddit-2d69170f4f6bd54efc472462d47f10988942bcba.zip
Add an option to ignore nav bar in ViewVideoActivity and ViewImgurVideoFragment. Use Hauler to do drag up or down to finish Activity in ViewVideoActivity and ViewImgurMediaActivity.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java39
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurVideoFragment.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java1
4 files changed, 47 insertions, 32 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
index db10f445..5beb5cfd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
@@ -20,9 +20,8 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
-import com.r0adkll.slidr.Slidr;
-import com.r0adkll.slidr.model.SlidrConfig;
-import com.r0adkll.slidr.model.SlidrPosition;
+import com.thefuntasty.hauler.DragDirection;
+import com.thefuntasty.hauler.HaulerView;
import org.json.JSONArray;
import org.json.JSONException;
@@ -66,6 +65,8 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
public static final int IMGUR_TYPE_IMAGE = 2;
private static final String IMGUR_IMAGES_STATE = "IIS";
+ @BindView(R.id.hauler_view_view_imgur_media_activity)
+ HaulerView haulerView;
@BindView(R.id.progress_bar_view_imgur_media_activity)
ProgressBar progressBar;
@BindView(R.id.view_pager_view_imgur_media_activity)
@@ -128,7 +129,11 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE);
}
- Slidr.attach(this, new SlidrConfig.Builder().position(SlidrPosition.VERTICAL).build());
+ haulerView.setOnDragDismissedListener(dragDirection -> {
+ int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down;
+ finish();
+ overridePendingTransition(0, slide);
+ });
if (images == null) {
fetchImgurMedia(imgurId);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
index f9f2728b..82621a6c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java
@@ -46,9 +46,8 @@ import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
import com.google.android.material.snackbar.Snackbar;
-import com.r0adkll.slidr.Slidr;
-import com.r0adkll.slidr.model.SlidrConfig;
-import com.r0adkll.slidr.model.SlidrPosition;
+import com.thefuntasty.hauler.DragDirection;
+import com.thefuntasty.hauler.HaulerView;
import javax.inject.Inject;
import javax.inject.Named;
@@ -85,6 +84,8 @@ public class ViewVideoActivity extends AppCompatActivity {
private static final String IS_MUTE_STATE = "IMS";
private static final String VIDEO_DOWNLOAD_URL_STATE = "VDUS";
private static final String VIDEO_URI_STATE = "VUS";
+ @BindView(R.id.hauler_view_view_video_activity)
+ HaulerView haulerView;
@BindView(R.id.coordinator_layout_view_video_activity)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.progress_bar_view_video_activity)
@@ -150,21 +151,27 @@ public class ViewVideoActivity extends AppCompatActivity {
actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) {
- //Set player controller bottom margin in order to display it above the navbar
- int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
- LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view);
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
- params.bottomMargin = getResources().getDimensionPixelSize(resourceId);
- } else {
- //Set player controller right margin in order to display it above the navbar
- int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
- LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view);
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
- params.rightMargin = getResources().getDimensionPixelSize(resourceId);
+ if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) {
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) {
+ //Set player controller bottom margin in order to display it above the navbar
+ int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
+ LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view);
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
+ params.bottomMargin = getResources().getDimensionPixelSize(resourceId);
+ } else {
+ //Set player controller right margin in order to display it above the navbar
+ int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
+ LinearLayout controllerLinearLayout = findViewById(R.id.linear_layout_exo_playback_control_view);
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
+ params.rightMargin = getResources().getDimensionPixelSize(resourceId);
+ }
}
- Slidr.attach(this, new SlidrConfig.Builder().position(SlidrPosition.VERTICAL).build());
+ haulerView.setOnDragDismissedListener(dragDirection -> {
+ int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down;
+ finish();
+ overridePendingTransition(0, slide);
+ });
mediaDownloader = new MediaDownloaderImpl();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurVideoFragment.java
index dd3853d0..e64ad295 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurVideoFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurVideoFragment.java
@@ -97,18 +97,20 @@ public class ViewImgurVideoFragment extends Fragment {
imgurMedia = getArguments().getParcelable(EXTRA_IMGUR_VIDEO);
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) {
- //Set player controller bottom margin in order to display it above the navbar
- int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
- LinearLayout controllerLinearLayout = rootView.findViewById(R.id.linear_layout_exo_playback_control_view);
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
- params.bottomMargin = getResources().getDimensionPixelSize(resourceId);
- } else {
- //Set player controller right margin in order to display it above the navbar
- int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
- LinearLayout controllerLinearLayout = rootView.findViewById(R.id.linear_layout_exo_playback_control_view);
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
- params.rightMargin = getResources().getDimensionPixelSize(resourceId);
+ if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) {
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) {
+ //Set player controller bottom margin in order to display it above the navbar
+ int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
+ LinearLayout controllerLinearLayout = rootView.findViewById(R.id.linear_layout_exo_playback_control_view);
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
+ params.bottomMargin = getResources().getDimensionPixelSize(resourceId);
+ } else {
+ //Set player controller right margin in order to display it above the navbar
+ int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
+ LinearLayout controllerLinearLayout = rootView.findViewById(R.id.linear_layout_exo_playback_control_view);
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
+ params.rightMargin = getResources().getDimensionPixelSize(resourceId);
+ }
}
videoPlayerView.setControllerVisibilityListener(visibility -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
index b473bc34..768db21a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -131,4 +131,5 @@ public class SharedPreferencesUtils {
public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT = "start_autoplay_visible_area_offset_portrait";
public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE = "start_autoplay_visible_area_offset_landscape";
public static final String MUTE_NSFW_VIDEO = "mute_nsfw_video";
+ public static final String VIDEO_PLAYER_IGNORE_NAV_BAR = "video_player_ignore_nav_bar";
}