mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2025-10-29 19:44:40 +00:00
New toolbar options in ViewPostDetailActivity: Next Top-Level Comment and Previous Top-Level Comment.
This commit is contained in:
parent
bf74b206f3
commit
05824bf046
@ -250,24 +250,10 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
mVolumeKeysNavigateComments = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOLUME_KEYS_NAVIGATE_COMMENTS, false);
|
||||
|
||||
binding.fabViewPostDetailActivity.setOnClickListener(view -> {
|
||||
if (mSectionsPagerAdapter != null) {
|
||||
ViewPostDetailFragment fragment = mSectionsPagerAdapter.getCurrentFragment();
|
||||
if (fragment != null) {
|
||||
fragment.scrollToNextParentComment();
|
||||
}
|
||||
}
|
||||
scrollToNextParentComment();
|
||||
});
|
||||
|
||||
binding.fabViewPostDetailActivity.setOnLongClickListener(view -> {
|
||||
if (mSectionsPagerAdapter != null) {
|
||||
ViewPostDetailFragment fragment = mSectionsPagerAdapter.getCurrentFragment();
|
||||
if (fragment != null) {
|
||||
fragment.scrollToPreviousParentComment();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
binding.fabViewPostDetailActivity.setOnLongClickListener(view -> scrollToPreviousParentComment());
|
||||
|
||||
if (accountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
binding.searchTextInputEditTextViewPostDetailActivity.setImeOptions(binding.searchTextInputEditTextViewPostDetailActivity.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||
@ -318,6 +304,27 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
Snackbar.make(binding.getRoot(), resId, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void scrollToNextParentComment() {
|
||||
if (mSectionsPagerAdapter != null) {
|
||||
ViewPostDetailFragment fragment = mSectionsPagerAdapter.getCurrentFragment();
|
||||
if (fragment != null) {
|
||||
fragment.scrollToNextParentComment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean scrollToPreviousParentComment() {
|
||||
if (mSectionsPagerAdapter != null) {
|
||||
ViewPostDetailFragment fragment = mSectionsPagerAdapter.getCurrentFragment();
|
||||
if (fragment != null) {
|
||||
fragment.scrollToPreviousParentComment();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
@ -792,6 +799,12 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
} else if (item.getItemId() == R.id.action_reset_fab_position_view_post_detail_activity) {
|
||||
binding.fabViewPostDetailActivity.resetCoordinates();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_next_parent_comment_view_post_detail_activity) {
|
||||
scrollToNextParentComment();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_previous_parent_comment_view_post_detail_activity) {
|
||||
scrollToPreviousParentComment();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -858,16 +871,13 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (mVolumeKeysNavigateComments) {
|
||||
ViewPostDetailFragment fragment = mSectionsPagerAdapter.getCurrentFragment();
|
||||
if (fragment != null) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
fragment.scrollToPreviousParentComment();
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
fragment.scrollToNextParentComment();
|
||||
return true;
|
||||
}
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
scrollToPreviousParentComment();
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
scrollToNextParentComment();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
|
||||
@ -6,4 +6,16 @@
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_reset_fab_position"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_next_parent_comment_view_post_detail_activity"
|
||||
android:orderInCategory="101"
|
||||
android:title="@string/action_next_parent_comment"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_previous_parent_comment_view_post_detail_activity"
|
||||
android:orderInCategory="102"
|
||||
android:title="@string/action_previous_parent_comment"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@ -101,6 +101,8 @@
|
||||
<string name="action_reset_fab_position">Reset FAB position</string>
|
||||
<string name="action_download_all_gallery_media">Download All Gallery Media</string>
|
||||
<string name="action_download_all_imgur_album_media">Download All Imgur Album Media</string>
|
||||
<string name="action_next_parent_comment">Next Top-Level Comment</string>
|
||||
<string name="action_previous_parent_comment">Previous Top-Level Comment</string>
|
||||
|
||||
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
|
||||
<string name="retrieve_token_error">Error Retrieving the token</string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user