New option: Pinch to Zoom Video.

This commit is contained in:
Alex Ning 2021-10-14 20:57:22 +08:00
parent c8c3c23093
commit a8f21a94b0
6 changed files with 40 additions and 3 deletions

View File

@ -292,8 +292,10 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
// Fixes #383 // Fixes #383
// Not having a background will cause visual glitches on some devices. // Not having a background will cause visual glitches on some devices.
FrameLayout slidablePanel = findViewById(R.id.slidable_panel); FrameLayout slidablePanel = findViewById(R.id.slidable_panel);
if (slidablePanel != null) {
slidablePanel.setBackgroundColor(getResources().getColor(android.R.color.black)); slidablePanel.setBackgroundColor(getResources().getColor(android.R.color.black));
} }
}
private void loadImage() { private void loadImage() {
mImageView.showImage(Uri.parse(mImageUrl)); mImageView.showImage(Uri.parse(mImageUrl));

View File

@ -7,6 +7,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.media.AudioManager; 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.exoplayer2.video.VideoListener;
import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.otaliastudios.zoom.ZoomEngine;
import com.otaliastudios.zoom.ZoomSurfaceView; import com.otaliastudios.zoom.ZoomSurfaceView;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@ -69,6 +71,7 @@ import javax.inject.Named;
import app.futured.hauler.DragDirection; import app.futured.hauler.DragDirection;
import app.futured.hauler.HaulerView; import app.futured.hauler.HaulerView;
import app.futured.hauler.LockableNestedScrollView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
@ -147,6 +150,8 @@ public class ViewVideoActivity extends AppCompatActivity {
TextView titleTextView; TextView titleTextView;
@BindView(R.id.download_image_view_exo_playback_control_view) @BindView(R.id.download_image_view_exo_playback_control_view)
ImageView downloadImageView; ImageView downloadImageView;
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
LockableNestedScrollView nestedScrollView;
private Uri mVideoUri; private Uri mVideoUri;
private SimpleExoPlayer player; 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 -> { zoomSurfaceView.setOnClickListener(view -> {
if (playerControlView.isVisible()) { if (playerControlView.isVisible()) {
playerControlView.hide(); playerControlView.hide();

View File

@ -194,6 +194,7 @@ public class SharedPreferencesUtils {
public static final String LOOP_VIDEO = "loop_video"; public static final String LOOP_VIDEO = "loop_video";
public static final String DEFAULT_PLAYBACK_SPEED = "default_playback_speed"; 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 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 DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";

View File

@ -10,7 +10,8 @@
app:dragUpEnabled="true" app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.activities.ViewVideoActivity"> 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true"> android:fillViewport="true">
@ -45,6 +46,6 @@
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.core.widget.NestedScrollView> </app.futured.hauler.LockableNestedScrollView>
</app.futured.hauler.HaulerView> </app.futured.hauler.HaulerView>

View File

@ -613,6 +613,8 @@
<string name="settings_link_handler_value_custom_tab">Custom Tab</string> <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_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_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> <string name="no_link_available">Cannot get the link</string>

View File

@ -54,6 +54,12 @@
app:key="swipe_between_posts" app:key="swipe_between_posts"
app:title="@string/settings_swipe_between_posts_title" /> 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 <Preference
app:title="@string/settings_swipe_action_title" app:title="@string/settings_swipe_action_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.SwipeActionPreferenceFragment" /> app:fragment="ml.docilealligator.infinityforreddit.settings.SwipeActionPreferenceFragment" />