diff --git a/app/build.gradle b/app/build.gradle index 32228199..fced4802 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -93,6 +93,7 @@ dependencies { implementation 'com.atlassian.commonmark:commonmark:0.13.1' implementation 'com.google.code.gson:gson:2.8.6' implementation 'me.zhanghai.android.fastscroll:library:1.1.2' + implementation "com.thefuntasty.hauler:core:3.1.0" // androidX startup for auto-init implementation "androidx.startup:startup-runtime:1.0.0-alpha01" //crashy diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c42e67b7..285030d4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,7 +43,7 @@ android:name=".Activity.ViewImgurMediaActivity" android:configChanges="orientation|screenSize|layoutDirection" android:parentActivityName=".Activity.MainActivity" - android:theme="@style/AppTheme.SlidableWithActionBar" /> + android:theme="@style/AppTheme.Draggable" /> + android:theme="@style/AppTheme.Draggable" /> { + 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"; } diff --git a/app/src/main/res/anim/slide_out_down.xml b/app/src/main/res/anim/slide_out_down.xml new file mode 100644 index 00000000..f6fb89c8 --- /dev/null +++ b/app/src/main/res/anim/slide_out_down.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_up.xml b/app/src/main/res/anim/slide_out_up.xml new file mode 100644 index 00000000..fcbe785b --- /dev/null +++ b/app/src/main/res/anim/slide_out_up.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_view_imgur_media.xml b/app/src/main/res/layout/activity_view_imgur_media.xml index 60122cfa..8e17ae8b 100644 --- a/app/src/main/res/layout/activity_view_imgur_media.xml +++ b/app/src/main/res/layout/activity_view_imgur_media.xml @@ -1,39 +1,54 @@ - - - - + android:fillViewport="true"> - - - + android:layout_height="match_parent"> - + - \ No newline at end of file + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml index 240f165b..1d18f2ab 100644 --- a/app/src/main/res/layout/activity_view_video.xml +++ b/app/src/main/res/layout/activity_view_video.xml @@ -1,25 +1,40 @@ - - + android:fillViewport="true"> - + - \ No newline at end of file + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24d7639d..fd9182f4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -365,6 +365,8 @@ Mute Videos Mute NSFW Videos Automatically Try Accessing Redgifs if Videos on Gfycat are Removed. + Ignore Navigation Bar in Video Player + Prevent the Video Controller Having Extra Margin Confirm to Exit Show Top-level Comments First Show Comment Divider diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c7db48b6..ec6ebc0d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -47,6 +47,16 @@ @android:color/transparent + + diff --git a/app/src/main/res/xml/video_preferences.xml b/app/src/main/res/xml/video_preferences.xml index 9c215db2..a0924140 100644 --- a/app/src/main/res/xml/video_preferences.xml +++ b/app/src/main/res/xml/video_preferences.xml @@ -19,6 +19,12 @@ app:key="automatically_try_redgifs" app:title="@string/settings_automatically_try_redgifs_title" /> + +