aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/layout/activity_view_video.xml5
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/gestures_and_buttons_preferences.xml6
6 files changed, 40 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java
index d07e8c69..e5d5f72b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java
@@ -292,7 +292,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
// Fixes #383
// Not having a background will cause visual glitches on some devices.
FrameLayout slidablePanel = findViewById(R.id.slidable_panel);
- slidablePanel.setBackgroundColor(getResources().getColor(android.R.color.black));
+ if (slidablePanel != null) {
+ slidablePanel.setBackgroundColor(getResources().getColor(android.R.color.black));
+ }
}
private void loadImage() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
index 5a473d29..09d9850b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -7,6 +7,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Matrix;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@@ -57,6 +58,7 @@ import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoListener;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.snackbar.Snackbar;
+import com.otaliastudios.zoom.ZoomEngine;
import com.otaliastudios.zoom.ZoomSurfaceView;
import org.apache.commons.io.FilenameUtils;
@@ -69,6 +71,7 @@ import javax.inject.Named;
import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView;
+import app.futured.hauler.LockableNestedScrollView;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
@@ -147,6 +150,8 @@ public class ViewVideoActivity extends AppCompatActivity {
TextView titleTextView;
@BindView(R.id.download_image_view_exo_playback_control_view)
ImageView downloadImageView;
+ @BindView(R.id.lockable_nested_scroll_view_view_video_activity)
+ LockableNestedScrollView nestedScrollView;
private Uri mVideoUri;
private SimpleExoPlayer player;
@@ -371,7 +376,27 @@ public class ViewVideoActivity extends AppCompatActivity {
}
});
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.PINCH_TO_ZOOM_VIDEO, false)) {
+ zoomSurfaceView.getEngine().addListener(new ZoomEngine.Listener() {
+ @Override
+ public void onUpdate(@NonNull ZoomEngine zoomEngine, @NonNull Matrix matrix) {
+ if (zoomEngine.getZoom() < 1.00001) {
+ haulerView.setDragEnabled(true);
+ nestedScrollView.setScrollEnabled(true);
+ } else {
+ haulerView.setDragEnabled(false);
+ nestedScrollView.setScrollEnabled(false);
+ }
+ }
+ @Override
+ public void onIdle(@NonNull ZoomEngine zoomEngine) {
+
+ }
+ });
+ } else {
+ zoomSurfaceView.setZoomEnabled(false);
+ }
zoomSurfaceView.setOnClickListener(view -> {
if (playerControlView.isVisible()) {
playerControlView.hide();
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 9cc3c839..285c8d58 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -194,6 +194,7 @@ public class SharedPreferencesUtils {
public static final String LOOP_VIDEO = "loop_video";
public static final String DEFAULT_PLAYBACK_SPEED = "default_playback_speed";
public static final String LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI = "legacy_autoplay_video_controller_ui";
+ public static final String PINCH_TO_ZOOM_VIDEO = "pinch_to_zoom_video";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml
index bc828a7c..bd314ccc 100644
--- a/app/src/main/res/layout/activity_view_video.xml
+++ b/app/src/main/res/layout/activity_view_video.xml
@@ -10,7 +10,8 @@
app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.activities.ViewVideoActivity">
- <androidx.core.widget.NestedScrollView
+ <app.futured.hauler.LockableNestedScrollView
+ android:id="@+id/lockable_nested_scroll_view_view_video_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
@@ -45,6 +46,6 @@
</androidx.coordinatorlayout.widget.CoordinatorLayout>
- </androidx.core.widget.NestedScrollView>
+ </app.futured.hauler.LockableNestedScrollView>
</app.futured.hauler.HaulerView> \ 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 0f7e8f98..85c90a0e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -613,6 +613,8 @@
<string name="settings_link_handler_value_custom_tab">Custom Tab</string>
<string name="settings_link_handler_value_internal_browser">Internal Browser</string>
<string name="settings_legacy_autoplay_video_controller_ui_title">Legacy Video Controller UI</string>
+ <string name="settings_pinch_to_zoom_video_title">Pinch to Zoom Video</string>
+ <string name="settings_experimental_feature">Experimental feature</string>
<string name="no_link_available">Cannot get the link</string>
diff --git a/app/src/main/res/xml/gestures_and_buttons_preferences.xml b/app/src/main/res/xml/gestures_and_buttons_preferences.xml
index fd49d4c0..2784977a 100644
--- a/app/src/main/res/xml/gestures_and_buttons_preferences.xml
+++ b/app/src/main/res/xml/gestures_and_buttons_preferences.xml
@@ -54,6 +54,12 @@
app:key="swipe_between_posts"
app:title="@string/settings_swipe_between_posts_title" />
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="pinch_to_zoom_video"
+ app:title="@string/settings_pinch_to_zoom_video_title"
+ app:summary="@string/settings_experimental_feature" />
+
<Preference
app:title="@string/settings_swipe_action_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.SwipeActionPreferenceFragment" />