Add an option to move thumbnail in compact layout to the left.

This commit is contained in:
Alex Ning 2020-06-13 22:11:57 +08:00
parent ee048b25dd
commit 8ed7f54d46
11 changed files with 160 additions and 48 deletions

View File

@ -22,6 +22,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.Barrier;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet; import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
@ -72,10 +73,10 @@ import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity; import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity; import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.ShareLinkBottomSheetFragment;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.Post.PostDataSource;
@ -153,6 +154,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private int mVoteAndReplyUnavailableVoteButtonColor; private int mVoteAndReplyUnavailableVoteButtonColor;
private int mButtonTextColor; private int mButtonTextColor;
private int mPostIconAndInfoColor; private int mPostIconAndInfoColor;
private int mDividerColor;
private float mScale; private float mScale;
private boolean mDisplaySubredditName; private boolean mDisplaySubredditName;
private boolean mVoteButtonsOnTheRight; private boolean mVoteButtonsOnTheRight;
@ -163,6 +165,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mShowAbsoluteNumberOfVotes; private boolean mShowAbsoluteNumberOfVotes;
private boolean mAutoplay = false; private boolean mAutoplay = false;
private boolean mAutoplayNsfwVideos; private boolean mAutoplayNsfwVideos;
private boolean mShowThumbnailOnTheRightInCompactLayout;
private Drawable mCommentIcon; private Drawable mCommentIcon;
private NetworkState networkState; private NetworkState networkState;
private ExoCreator mExoCreator; private ExoCreator mExoCreator;
@ -196,6 +199,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mAutoplay = Utils.isConnectedToWifi(activity); mAutoplay = Utils.isConnectedToWifi(activity);
} }
mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true); mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
mShowThumbnailOnTheRightInCompactLayout = sharedPreferences.getBoolean(
SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT, false);
mPostLayout = postLayout; mPostLayout = postLayout;
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(); mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
@ -227,6 +232,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor(); mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
mButtonTextColor = customThemeWrapper.getButtonTextColor(); mButtonTextColor = customThemeWrapper.getButtonTextColor();
mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor();
mDividerColor = customThemeWrapper.getDividerColor();
mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); mCommentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp);
if (mCommentIcon != null) { if (mCommentIcon != null) {
@ -1322,6 +1328,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mAutoplayNsfwVideos = autoplayNsfwVideos; mAutoplayNsfwVideos = autoplayNsfwVideos;
} }
public void setShowThumbnailOnTheRightInCompactLayout(boolean showThumbnailOnTheRightInCompactLayout) {
mShowThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout;
}
@Override @Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder); super.onViewRecycled(holder);
@ -2536,6 +2546,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
ImageView stickiedPostImageView; ImageView stickiedPostImageView;
@BindView(R.id.post_time_text_view_item_post_compact) @BindView(R.id.post_time_text_view_item_post_compact)
TextView postTimeTextView; TextView postTimeTextView;
@BindView(R.id.title_and_image_constraint_layout)
ConstraintLayout titleAndImageConstraintLayout;
@BindView(R.id.title_text_view_item_post_compact) @BindView(R.id.title_text_view_item_post_compact)
TextView titleTextView; TextView titleTextView;
@BindView(R.id.type_text_view_item_post_compact) @BindView(R.id.type_text_view_item_post_compact)
@ -2566,6 +2578,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
ImageView playButtonImageView; ImageView playButtonImageView;
@BindView(R.id.image_view_no_preview_link_item_post_compact) @BindView(R.id.image_view_no_preview_link_item_post_compact)
ImageView noPreviewLinkImageView; ImageView noPreviewLinkImageView;
@BindView(R.id.barrier2)
Barrier imageBarrier;
@BindView(R.id.bottom_constraint_layout_item_post_compact) @BindView(R.id.bottom_constraint_layout_item_post_compact)
ConstraintLayout bottomConstraintLayout; ConstraintLayout bottomConstraintLayout;
@BindView(R.id.plus_button_item_post_compact) @BindView(R.id.plus_button_item_post_compact)
@ -2609,6 +2623,38 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
constraintSet.applyTo(bottomConstraintLayout); constraintSet.applyTo(bottomConstraintLayout);
} }
if (mShowThumbnailOnTheRightInCompactLayout) {
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(titleAndImageConstraintLayout);
constraintSet.clear(titleTextView.getId(), ConstraintSet.START);
constraintSet.clear(titleTextView.getId(), ConstraintSet.END);
constraintSet.clear(R.id.flow_layout_item_post_compact, ConstraintSet.START);
constraintSet.clear(R.id.flow_layout_item_post_compact, ConstraintSet.END);
constraintSet.clear(linkTextView.getId(), ConstraintSet.START);
constraintSet.clear(linkTextView.getId(), ConstraintSet.END);
constraintSet.clear(relativeLayout.getId(), ConstraintSet.START);
constraintSet.clear(relativeLayout.getId(), ConstraintSet.END);
constraintSet.clear(noPreviewLinkImageView.getId(), ConstraintSet.START);
constraintSet.clear(noPreviewLinkImageView.getId(), ConstraintSet.END);
int barrierId = 1234;
constraintSet.createBarrier(barrierId, Barrier.END, R.id.image_view_wrapper_item_post_compact,
R.id.image_view_no_preview_link_item_post_compact);
constraintSet.connect(titleTextView.getId(), ConstraintSet.START, barrierId, ConstraintSet.END);
constraintSet.connect(titleTextView.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
constraintSet.connect(R.id.flow_layout_item_post_compact, ConstraintSet.START, barrierId, ConstraintSet.END);
constraintSet.connect(R.id.flow_layout_item_post_compact, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
constraintSet.connect(R.id.flow_layout_item_post_compact, ConstraintSet.BOTTOM, linkTextView.getId(), ConstraintSet.TOP);
constraintSet.connect(linkTextView.getId(), ConstraintSet.START, barrierId, ConstraintSet.END);
constraintSet.connect(linkTextView.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
constraintSet.connect(relativeLayout.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
constraintSet.connect(relativeLayout.getId(), ConstraintSet.END, barrierId, ConstraintSet.START);
constraintSet.connect(noPreviewLinkImageView.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
constraintSet.connect(noPreviewLinkImageView.getId(), ConstraintSet.END, barrierId, ConstraintSet.START);
constraintSet.applyTo(titleAndImageConstraintLayout);
((ConstraintLayout.LayoutParams) relativeLayout.getLayoutParams()).leftMargin = (int) Utils.convertDpToPixel(16, mActivity);
}
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor)); itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
postTimeTextView.setTextColor(mSecondaryTextColor); postTimeTextView.setTextColor(mSecondaryTextColor);
titleTextView.setTextColor(mPostTitleColor); titleTextView.setTextColor(mPostTitleColor);
@ -2641,6 +2687,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null); commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null);
saveButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); saveButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
shareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); shareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
divider.setBackgroundColor(mDividerColor);
} }
} }

View File

@ -0,0 +1,9 @@
package ml.docilealligator.infinityforreddit.Event;
public class ShowThumbnailOnTheRightInCompactLayoutEvent {
public boolean showThumbnailOnTheRightInCompactLayout;
public ShowThumbnailOnTheRightInCompactLayoutEvent(boolean showThumbnailOnTheRightInCompactLayout) {
this.showThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout;
}
}

View File

@ -69,6 +69,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent
import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent; import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList; import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent; import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.Event.ShowThumbnailOnTheRightInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
@ -905,6 +906,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
} }
@Subscribe
public void onShowThumbnailOnTheRightInCompactLayoutEvent(ShowThumbnailOnTheRightInCompactLayoutEvent showThumbnailOnTheRightInCompactLayoutEvent) {
if (mAdapter != null) {
mAdapter.setShowThumbnailOnTheRightInCompactLayout(showThumbnailOnTheRightInCompactLayoutEvent.showThumbnailOnTheRightInCompactLayout);
refreshAdapter();
}
}
private void refreshAdapter() { private void refreshAdapter() {
int previousPosition = -1; int previousPosition = -1;
if (mLinearLayoutManager != null) { if (mLinearLayoutManager != null) {

View File

@ -0,0 +1,53 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.os.Build;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class ImmersiveInterfacePreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.immersive_interface_preferences, rootKey);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
SwitchPreference immersiveInterfaceIgnoreNavBarSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY);
if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
immersiveInterfaceSwitch.setVisible(true);
immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
if ((Boolean) newValue) {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(true);
} else {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
if (immersiveInterfaceSwitch.isChecked()) {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(true);
} else {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
immersiveInterfaceIgnoreNavBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
} else {
immersiveInterfaceSwitch.setVisible(false);
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
}
}
}

View File

@ -1,10 +1,8 @@
package ml.docilealligator.infinityforreddit.Settings; package ml.docilealligator.infinityforreddit.Settings;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference; import androidx.preference.SwitchPreference;
@ -17,56 +15,24 @@ import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent; import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent; import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.Event.ShowThumbnailOnTheRightInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
/**
* A simple {@link Fragment} subclass.
*/
public class InterfacePreferenceFragment extends PreferenceFragmentCompat { public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.interface_preference, rootKey); setPreferencesFromResource(R.xml.interface_preference, rootKey);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
SwitchPreference immersiveInterfaceIgnoreNavBarSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY);
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY); SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY); SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY); SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY); ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT); SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
SwitchPreference showThumbnailOnTheRightInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT);
SwitchPreference showAbsoluteNumberOfVotes = findPreference(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES); SwitchPreference showAbsoluteNumberOfVotes = findPreference(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES);
if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
immersiveInterfaceSwitch.setVisible(true);
immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
if ((Boolean) newValue) {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(true);
} else {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
if (immersiveInterfaceSwitch.isChecked()) {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(true);
} else {
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
immersiveInterfaceIgnoreNavBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
} else {
immersiveInterfaceSwitch.setVisible(false);
immersiveInterfaceIgnoreNavBarSwitch.setVisible(false);
}
}
if (bottomAppBarSwitch != null) { if (bottomAppBarSwitch != null) {
bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
@ -102,6 +68,13 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
if (showThumbnailOnTheRightInCompactLayout != null) {
showThumbnailOnTheRightInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowThumbnailOnTheRightInCompactLayoutEvent((Boolean) newValue));
return true;
});
}
if (showAbsoluteNumberOfVotes != null) { if (showAbsoluteNumberOfVotes != null) {
showAbsoluteNumberOfVotes.setOnPreferenceChangeListener((preference, newValue) -> { showAbsoluteNumberOfVotes.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeShowAbsoluteNumberOfVotesEvent((Boolean) newValue)); EventBus.getDefault().post(new ChangeShowAbsoluteNumberOfVotesEvent((Boolean) newValue));

View File

@ -74,6 +74,7 @@ public class SharedPreferencesUtils {
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time"; public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout"; public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout";
public static final String SHOW_DIVIDER_IN_COMPACT_LAYOUT = "show_divider_in_compact_layout"; public static final String SHOW_DIVIDER_IN_COMPACT_LAYOUT = "show_divider_in_compact_layout";
public static final String SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT = "show_thumbnail_on_the_right_in_compact_layout";
public static final String SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL = "swipe_to_go_back_from_post_detail"; public static final String SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL = "swipe_to_go_back_from_post_detail";
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";

View File

@ -7,6 +7,7 @@ import android.net.Network;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.text.Html; import android.text.Html;
import android.text.Spannable; import android.text.Spannable;
import android.util.DisplayMetrics;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.TextView; import android.widget.TextView;
@ -126,4 +127,8 @@ public class Utils {
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
} }
} }
public static float convertDpToPixel(float dp, Context context){
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
} }

View File

@ -76,6 +76,7 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/title_and_image_constraint_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

View File

@ -343,6 +343,7 @@
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string> <string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
<string name="settings_default_post_layout">Default Post Layout</string> <string name="settings_default_post_layout">Default Post Layout</string>
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string> <string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
<string name="settings_show_thumbnail_on_the_right_in_compact_layout">Show Thumbnail on the Right in Compact Layout</string>
<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_from_post_detail_title">Swipe Right to Go Back From Comments</string> <string name="settings_swipe_to_go_back_from_post_detail_title">Swipe Right to Go Back From Comments</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>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreference
app:defaultValue="true"
app:key="immersive_interface"
app:title="@string/settings_immersive_interface_title"
app:isPreferenceVisible="false" />
<SwitchPreference
app:defaultValue="false"
app:key="immersive_interface_ignore_nav_bar"
app:title="@string/settings_immersive_interface_ignore_nav_bar_title"
app:summary="@string/settings_immersive_interface_ignore_nav_bar_summary"
app:isPreferenceVisible="false" />
</PreferenceScreen>

View File

@ -7,18 +7,9 @@
app:icon="@drawable/ic_font_size_24dp" app:icon="@drawable/ic_font_size_24dp"
app:fragment="ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment" /> app:fragment="ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment" />
<SwitchPreference <Preference
app:defaultValue="true"
app:key="immersive_interface"
app:title="@string/settings_immersive_interface_title" app:title="@string/settings_immersive_interface_title"
app:isPreferenceVisible="false" /> app:fragment="ml.docilealligator.infinityforreddit.Settings.ImmersiveInterfacePreferenceFragment" />
<SwitchPreference
app:defaultValue="false"
app:key="immersive_interface_ignore_nav_bar"
app:title="@string/settings_immersive_interface_ignore_nav_bar_title"
app:summary="@string/settings_immersive_interface_ignore_nav_bar_summary"
app:isPreferenceVisible="false" />
<Preference <Preference
app:title="@string/settings_customize_tabs_in_main_page_title" app:title="@string/settings_customize_tabs_in_main_page_title"
@ -54,6 +45,11 @@
app:key="show_divider_in_compact_layout" app:key="show_divider_in_compact_layout"
app:title="@string/settings_show_divider_in_compact_layout" /> app:title="@string/settings_show_divider_in_compact_layout" />
<SwitchPreference
app:defaultValue="false"
app:key="show_thumbnail_on_the_right_in_compact_layout"
app:title="@string/settings_show_thumbnail_on_the_right_in_compact_layout" />
<SwitchPreference <SwitchPreference
app:defaultValue="false" app:defaultValue="false"
app:key="show_top_level_comments_first" app:key="show_top_level_comments_first"