New option: Swipe Vertically to Go Back From Media.

This commit is contained in:
Alex Ning 2021-05-15 13:41:20 +08:00
parent 004bd22f67
commit bb36cc79fd
7 changed files with 37 additions and 16 deletions

View File

@ -135,7 +135,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
actionBar.setHomeAsUpIndicator(upArrow); actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
Slidr.attach(this, new SlidrConfig.Builder().position(SlidrPosition.VERTICAL).distanceThreshold(0.125f).build()); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA, true)) {
Slidr.attach(this, new SlidrConfig.Builder().position(SlidrPosition.VERTICAL).distanceThreshold(0.125f).build());
}
glide = Glide.with(this); glide = Glide.with(this);

View File

@ -133,11 +133,15 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE); images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE);
} }
haulerView.setOnDragDismissedListener(dragDirection -> { if (sharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA, true)) {
int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; haulerView.setOnDragDismissedListener(dragDirection -> {
finish(); int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down;
overridePendingTransition(0, slide); finish();
}); overridePendingTransition(0, slide);
});
} else {
haulerView.setDragEnabled(false);
}
if (images == null) { if (images == null) {
fetchImgurMedia(imgurId); fetchImgurMedia(imgurId);

View File

@ -105,11 +105,15 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
} }
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
haulerView.setOnDragDismissedListener(dragDirection -> { if (sharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA, true)) {
int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; haulerView.setOnDragDismissedListener(dragDirection -> {
finish(); int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down;
overridePendingTransition(0, slide); finish();
}); overridePendingTransition(0, slide);
});
} else {
haulerView.setDragEnabled(false);
}
setupViewPager(); setupViewPager();
} }

View File

@ -204,11 +204,15 @@ public class ViewVideoActivity extends AppCompatActivity {
} }
} }
haulerView.setOnDragDismissedListener(dragDirection -> { if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA, true)) {
int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; haulerView.setOnDragDismissedListener(dragDirection -> {
finish(); int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down;
overridePendingTransition(0, slide); finish();
}); overridePendingTransition(0, slide);
});
} else {
haulerView.setDragEnabled(false);
}
Intent intent = getIntent(); Intent intent = getIntent();
postTitle = intent.getStringExtra(EXTRA_POST_TITLE); postTitle = intent.getStringExtra(EXTRA_POST_TITLE);

View File

@ -87,6 +87,7 @@ public class SharedPreferencesUtils {
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_GALLERY_LAYOUT = "number_of_columns_in_post_feed_portrait_gallery_layout"; public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_GALLERY_LAYOUT = "number_of_columns_in_post_feed_portrait_gallery_layout";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_GALLERY_LAYOUT = "number_of_columns_in_post_feed_landscape_gallery_layout"; public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_GALLERY_LAYOUT = "number_of_columns_in_post_feed_landscape_gallery_layout";
public static final String SWIPE_RIGHT_TO_GO_BACK = "swipe_to_go_back_from_post_detail"; public static final String SWIPE_RIGHT_TO_GO_BACK = "swipe_to_go_back_from_post_detail";
public static final String SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA = "swipe_vertically_to_go_back_from_media";
public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments"; public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments";
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts"; public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
public static final String MUTE_VIDEO = "mute_video"; public static final String MUTE_VIDEO = "mute_video";

View File

@ -398,6 +398,7 @@
<string name="settings_swap_tap_and_long_title">Swap Tap and Long Press in Comments</string> <string name="settings_swap_tap_and_long_title">Swap Tap and Long Press in Comments</string>
<string name="settings_swipe_to_go_back_title">Swipe Right to Go Back</string> <string name="settings_swipe_to_go_back_title">Swipe Right to Go Back</string>
<string name="settings_swipe_to_go_back_summary">Does Not Apply to All Pages</string> <string name="settings_swipe_to_go_back_summary">Does Not Apply to All Pages</string>
<string name="settings_swipe_vertically_to_go_back_from_media_title">Swipe Vertically to Go Back From Media</string>
<string name="settings_lock_jump_to_next_top_level_comment_button_title">Lock Jump to Next Top-level Comment Button</string> <string name="settings_lock_jump_to_next_top_level_comment_button_title">Lock Jump to Next Top-level Comment Button</string>
<string name="settings_lock_bottom_app_bar_title">Lock Bottom Navigation Bar</string> <string name="settings_lock_bottom_app_bar_title">Lock Bottom Navigation Bar</string>
<string name="settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title">Swipe Up to Hide Jump to Next Top-level Comment Button</string> <string name="settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title">Swipe Up to Hide Jump to Next Top-level Comment Button</string>

View File

@ -7,6 +7,11 @@
app:title="@string/settings_swipe_to_go_back_title" app:title="@string/settings_swipe_to_go_back_title"
app:summary="@string/settings_swipe_to_go_back_summary" /> app:summary="@string/settings_swipe_to_go_back_summary" />
<SwitchPreference
app:defaultValue="true"
app:key="swipe_vertically_to_go_back_from_media"
app:title="@string/settings_swipe_vertically_to_go_back_from_media_title" />
<SwitchPreference <SwitchPreference
app:defaultValue="false" app:defaultValue="false"
app:key="lock_jump_to_next_top_level_comment_button" app:key="lock_jump_to_next_top_level_comment_button"