mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
#1590 Comfortable and compact spacing for feed and story lists
This commit is contained in:
parent
5b3acd67ac
commit
24b6ad0c45
13 changed files with 125 additions and 34 deletions
|
@ -106,8 +106,6 @@
|
|||
android:layout_toLeftOf="@id/story_item_shared_icon"
|
||||
android:layout_toRightOf="@id/story_item_inteldot_container"
|
||||
android:layout_below="@id/story_item_feedicon"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingRight="4dp"
|
||||
android:maxLines="3"
|
||||
android:ellipsize="end" />
|
||||
|
@ -119,7 +117,6 @@
|
|||
android:layout_toLeftOf="@id/story_item_thumbnail_right"
|
||||
android:layout_toRightOf="@id/story_item_inteldot_container"
|
||||
android:layout_below="@id/story_item_title"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingRight="4dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
|
|
|
@ -77,6 +77,17 @@
|
|||
<item android:id="@+id/menu_textsize"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_textsize"/>
|
||||
<item android:id="@+id/menu_spacing"
|
||||
android:title="@string/menu_spacing" >
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<item android:id="@+id/menu_spacing_comfortable"
|
||||
android:title="@string/comfortable" />
|
||||
<item android:id="@+id/menu_spacing_compact"
|
||||
android:title="@string/compact" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
<item android:id="@+id/menu_theme"
|
||||
android:title="@string/menu_theme_choose" >
|
||||
<menu>
|
||||
|
|
|
@ -26,6 +26,18 @@
|
|||
app:showAsAction="never"
|
||||
android:title="@string/menu_textsize"/>
|
||||
|
||||
<item android:id="@+id/menu_spacing"
|
||||
android:title="@string/menu_spacing" >
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<item android:id="@+id/menu_spacing_comfortable"
|
||||
android:title="@string/comfortable" />
|
||||
<item android:id="@+id/menu_spacing_compact"
|
||||
android:title="@string/compact" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item android:id="@+id/menu_theme"
|
||||
android:title="@string/menu_theme_choose" >
|
||||
<menu>
|
||||
|
|
|
@ -226,6 +226,7 @@
|
|||
<string name="menu_feedback_post">Create a feedback post</string>
|
||||
<string name="menu_feedback_email">Email a bug report</string>
|
||||
<string name="menu_theme_choose">Theme</string>
|
||||
<string name="menu_spacing">Spacing</string>
|
||||
<string name="menu_premium_account">Premium subscription…</string>
|
||||
|
||||
<string name="description_add_new_folder_icon">Add new folder icon</string>
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.newsblur.util.PrefConstants.ThemeValue;
|
|||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.ReadFilter;
|
||||
import com.newsblur.util.ReadFilterChangedListener;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.StateFilter;
|
||||
import com.newsblur.util.StoryContentPreviewStyle;
|
||||
import com.newsblur.util.StoryListStyle;
|
||||
|
@ -283,6 +284,13 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
menu.findItem(R.id.menu_story_thumbnail_no_preview).setChecked(true);
|
||||
}
|
||||
|
||||
SpacingStyle spacingStyle = PrefsUtils.getSpacingStyle(this);
|
||||
if (spacingStyle == SpacingStyle.COMFORTABLE) {
|
||||
menu.findItem(R.id.menu_spacing_comfortable).setChecked(true);
|
||||
} else if (spacingStyle == SpacingStyle.COMPACT) {
|
||||
menu.findItem(R.id.menu_spacing_compact).setChecked(true);
|
||||
}
|
||||
|
||||
boolean isMarkReadOnScroll = PrefsUtils.isMarkReadOnFeedScroll(this);
|
||||
if (isMarkReadOnScroll) {
|
||||
menu.findItem(R.id.menu_mark_read_on_scroll_enabled).setChecked(true);
|
||||
|
@ -335,18 +343,24 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
} else if (item.getItemId() == R.id.menu_theme_black) {
|
||||
PrefsUtils.setSelectedTheme(this, ThemeValue.BLACK);
|
||||
UIUtils.restartActivity(this);
|
||||
} else if (item.getItemId() == R.id.menu_spacing_comfortable) {
|
||||
PrefsUtils.setSpacingStyle(this, SpacingStyle.COMFORTABLE);
|
||||
itemSetFragment.updateSpacingStyle();
|
||||
} else if (item.getItemId() == R.id.menu_spacing_compact) {
|
||||
PrefsUtils.setSpacingStyle(this, SpacingStyle.COMPACT);
|
||||
itemSetFragment.updateSpacingStyle();
|
||||
} else if (item.getItemId() == R.id.menu_list_style_list) {
|
||||
PrefsUtils.updateStoryListStyle(this, fs, StoryListStyle.LIST);
|
||||
itemSetFragment.updateStyle();
|
||||
itemSetFragment.updateListStyle();
|
||||
} else if (item.getItemId() == R.id.menu_list_style_grid_f) {
|
||||
PrefsUtils.updateStoryListStyle(this, fs, StoryListStyle.GRID_F);
|
||||
itemSetFragment.updateStyle();
|
||||
itemSetFragment.updateListStyle();
|
||||
} else if (item.getItemId() == R.id.menu_list_style_grid_m) {
|
||||
PrefsUtils.updateStoryListStyle(this, fs, StoryListStyle.GRID_M);
|
||||
itemSetFragment.updateStyle();
|
||||
itemSetFragment.updateListStyle();
|
||||
} else if (item.getItemId() == R.id.menu_list_style_grid_c) {
|
||||
PrefsUtils.updateStoryListStyle(this, fs, StoryListStyle.GRID_C);
|
||||
itemSetFragment.updateStyle();
|
||||
itemSetFragment.updateListStyle();
|
||||
} else if (item.getItemId() == R.id.menu_save_search) {
|
||||
String feedId = getSaveSearchFeedId();
|
||||
if (feedId != null) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.newsblur.util.AppConstants;
|
|||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.PrefConstants.ThemeValue;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.StateFilter;
|
||||
import com.newsblur.util.UIUtils;
|
||||
import com.newsblur.view.StateToggleButton.StateChangedListener;
|
||||
|
@ -287,6 +288,13 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
} else if (themeValue == ThemeValue.AUTO) {
|
||||
menu.findItem(R.id.menu_theme_auto).setChecked(true);
|
||||
}
|
||||
|
||||
SpacingStyle spacingStyle = PrefsUtils.getSpacingStyle(this);
|
||||
if (spacingStyle == SpacingStyle.COMFORTABLE) {
|
||||
menu.findItem(R.id.menu_spacing_comfortable).setChecked(true);
|
||||
} else if (spacingStyle == SpacingStyle.COMPACT) {
|
||||
menu.findItem(R.id.menu_spacing_compact).setChecked(true);
|
||||
}
|
||||
|
||||
menu.findItem(R.id.menu_widget).setVisible(WidgetUtils.hasActiveAppWidgets(this));
|
||||
|
||||
|
@ -323,6 +331,12 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
TextSizeDialogFragment textSize = TextSizeDialogFragment.newInstance(PrefsUtils.getListTextSize(this), TextSizeDialogFragment.TextSizeType.ListText);
|
||||
textSize.show(getSupportFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_spacing_comfortable) {
|
||||
folderFeedList.setSpacingStyle(SpacingStyle.COMFORTABLE);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_spacing_compact) {
|
||||
folderFeedList.setSpacingStyle(SpacingStyle.COMPACT);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_loginas) {
|
||||
DialogFragment newFragment = new LoginAsDialogFragment();
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.newsblur.domain.StarredCount;
|
|||
import com.newsblur.domain.SocialFeed;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.FeedListOrder;
|
||||
import com.newsblur.util.FeedListStyle;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.FeedSet;
|
||||
import com.newsblur.util.ImageLoader;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
@ -136,7 +136,7 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
|
|||
public WeakReference<ExpandableListView> listBackref;
|
||||
|
||||
private float textSize;
|
||||
private FeedListStyle feedListStyle;
|
||||
private SpacingStyle spacingStyle;
|
||||
|
||||
// in order to implement the laggy disappearance of marked-read feeds, preserve the ID of
|
||||
// the last feed or folder viewed and force the DB to include it in the selection
|
||||
|
@ -153,7 +153,7 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
|
|||
this.dbHelper = dbHelper;
|
||||
|
||||
textSize = PrefsUtils.getListTextSize(context);
|
||||
feedListStyle = PrefsUtils.getFeedListStyle(context);
|
||||
spacingStyle = PrefsUtils.getSpacingStyle(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,7 +215,7 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
|
|||
|
||||
@NonNull TextView groupNameView = v.findViewById(R.id.row_foldername);
|
||||
groupNameView.setTextSize(textSize * defaultTextSize_groupName);
|
||||
int titleVerticalPadding = feedListStyle.getGroupTitleVerticalPadding(context);
|
||||
int titleVerticalPadding = spacingStyle.getGroupTitleVerticalPadding(context);
|
||||
groupNameView.setPadding(0, titleVerticalPadding, 0, titleVerticalPadding);
|
||||
@Nullable TextView sumNeutView = v.findViewById(R.id.row_foldersumneu);
|
||||
if (sumNeutView != null ) sumNeutView.setTextSize(textSize * defaultTextSize_count);
|
||||
|
@ -253,7 +253,7 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
|
|||
@Override
|
||||
public synchronized View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
int titleVerticalPadding = feedListStyle.getChildTitleVerticalPadding(context);
|
||||
int titleVerticalPadding = spacingStyle.getChildTitleVerticalPadding(context);
|
||||
if (isRowAllSharedStories(groupPosition)) {
|
||||
if (v == null) v = inflater.inflate(R.layout.row_socialfeed, parent, false);
|
||||
SocialFeed f = socialFeedsActive.get(childPosition);
|
||||
|
@ -978,8 +978,8 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
|
|||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public void setFeedListStyle(FeedListStyle feedListStyle) {
|
||||
this.feedListStyle = feedListStyle;
|
||||
public void setSpacingStyle(SpacingStyle spacingStyle) {
|
||||
this.spacingStyle = spacingStyle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import java.util.concurrent.Executors;
|
|||
import com.newsblur.R;
|
||||
import com.newsblur.activity.FeedItemsList;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.di.IconLoader;
|
||||
import com.newsblur.di.ThumbnailLoader;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.UserDetails;
|
||||
import com.newsblur.fragment.ItemSetFragment;
|
||||
|
@ -43,6 +41,7 @@ import com.newsblur.util.FeedUtils;
|
|||
import com.newsblur.util.GestureAction;
|
||||
import com.newsblur.util.ImageLoader;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.StoryContentPreviewStyle;
|
||||
import com.newsblur.util.StoryListStyle;
|
||||
import com.newsblur.util.StoryUtils;
|
||||
|
@ -91,6 +90,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
private float textSize;
|
||||
private final UserDetails user;
|
||||
private ThumbnailStyle thumbnailStyle;
|
||||
private SpacingStyle spacingStyle;
|
||||
|
||||
public StoryViewAdapter(NbActivity context,
|
||||
ItemSetFragment fragment,
|
||||
|
@ -119,10 +119,9 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
if (fs.isSingleSavedTag()) {ignoreReadStatus = true; ignoreIntel = true; singleFeed = false;}
|
||||
|
||||
textSize = PrefsUtils.getListTextSize(context);
|
||||
|
||||
user = PrefsUtils.getUserDetails(context);
|
||||
|
||||
thumbnailStyle = PrefsUtils.getThumbnailStyle(context);
|
||||
spacingStyle = PrefsUtils.getSpacingStyle(context);
|
||||
|
||||
executorService = Executors.newFixedThreadPool(1);
|
||||
|
||||
|
@ -141,6 +140,10 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
this.thumbnailStyle = thumbnailStyle;
|
||||
}
|
||||
|
||||
public void setSpacingStyle(SpacingStyle spacingStyle) {
|
||||
this.spacingStyle = spacingStyle;
|
||||
}
|
||||
|
||||
public void addFooterView(View v) {
|
||||
footerViews.add(v);
|
||||
}
|
||||
|
@ -536,14 +539,14 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
Story story = stories.get(position);
|
||||
vh.story = story;
|
||||
|
||||
bindCommon(vh, position, story);
|
||||
bindCommon(vh, story);
|
||||
|
||||
if (vh instanceof StoryRowViewHolder) {
|
||||
StoryRowViewHolder vhRow = (StoryRowViewHolder) vh;
|
||||
bindRow(vhRow, position, story);
|
||||
bindRow(vhRow, story);
|
||||
} else {
|
||||
StoryTileViewHolder vhTile = (StoryTileViewHolder) vh;
|
||||
bindTile(vhTile, position, story);
|
||||
bindTile(vhTile, story);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -566,7 +569,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
/**
|
||||
* Bind view elements that are common to tiles and rows.
|
||||
*/
|
||||
private void bindCommon(StoryViewHolder vh, int position, Story story) {
|
||||
private void bindCommon(StoryViewHolder vh, Story story) {
|
||||
vh.leftBarOne.setBackgroundColor(UIUtils.decodeColourValue(story.extern_feedColor, Color.GRAY));
|
||||
vh.leftBarTwo.setBackgroundColor(UIUtils.decodeColourValue(story.extern_feedFade, Color.LTGRAY));
|
||||
|
||||
|
@ -620,6 +623,11 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
vh.feedTitleView.setTextSize(textSize * defaultTextSize_story_item_feedtitle);
|
||||
vh.storyTitleView.setTextSize(textSize * defaultTextSize_story_item_title);
|
||||
vh.storyDate.setTextSize(textSize * defaultTextSize_story_item_date);
|
||||
|
||||
// dynamic spacing
|
||||
int verticalTitlePadding = spacingStyle.getStoryTitleVerticalPadding(context);
|
||||
vh.storyTitleView.setPadding(vh.storyTitleView.getPaddingLeft(), verticalTitlePadding,
|
||||
vh.storyTitleView.getPaddingRight(), verticalTitlePadding);
|
||||
|
||||
// read/unread fading
|
||||
if (this.ignoreReadStatus || (! story.read)) {
|
||||
|
@ -647,7 +655,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
}
|
||||
|
||||
private void bindTile(StoryTileViewHolder vh, int position, Story story) {
|
||||
private void bindTile(StoryTileViewHolder vh, Story story) {
|
||||
// when first created, tiles' views tend to not yet have their dimensions calculated, but
|
||||
// upon being recycled they will often have a known size, which lets us give a max size to
|
||||
// the image loader, which in turn can massively optimise loading. the image loader will
|
||||
|
@ -662,7 +670,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
}
|
||||
|
||||
private void bindRow(StoryRowViewHolder vh, int position, Story story) {
|
||||
private void bindRow(StoryRowViewHolder vh, Story story) {
|
||||
StoryContentPreviewStyle storyContentPreviewStyle = PrefsUtils.getStoryContentPreviewStyle(context);
|
||||
if (storyContentPreviewStyle != StoryContentPreviewStyle.NONE) {
|
||||
vh.storyTitleView.setMaxLines(3);
|
||||
|
@ -689,6 +697,10 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
vh.storyAuthor.setTextSize(textSize * defaultTextSize_story_item_author);
|
||||
vh.storySnippet.setTextSize(textSize * defaultTextSize_story_item_snip);
|
||||
|
||||
int contentVerticalPadding = spacingStyle.getStoryContentVerticalPadding(context);
|
||||
vh.storySnippet.setPadding(vh.storySnippet.getPaddingLeft(), vh.storySnippet.getPaddingTop(),
|
||||
vh.storySnippet.getPaddingRight(), contentVerticalPadding);
|
||||
|
||||
if (PrefsUtils.getThumbnailStyle(context) != ThumbnailStyle.OFF && vh.thumbViewRight != null && vh.thumbViewLeft != null) {
|
||||
// the view will display a stale, recycled thumb before the new one loads if the old is not cleared
|
||||
if (thumbnailStyle == ThumbnailStyle.LEFT_LARGE || thumbnailStyle == ThumbnailStyle.LEFT_SMALL) {
|
||||
|
|
|
@ -52,7 +52,7 @@ import com.newsblur.domain.Folder;
|
|||
import com.newsblur.domain.SavedSearch;
|
||||
import com.newsblur.domain.SocialFeed;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.FeedListStyle;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.FeedSet;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.ImageLoader;
|
||||
|
@ -116,9 +116,9 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
super.onResume();
|
||||
if (adapter != null) {
|
||||
float textSize = PrefsUtils.getListTextSize(requireContext());
|
||||
SpacingStyle spacingStyle = PrefsUtils.getSpacingStyle(requireContext());
|
||||
adapter.setTextSize(textSize);
|
||||
FeedListStyle feedListStyle = PrefsUtils.getFeedListStyle(requireContext());
|
||||
adapter.setFeedListStyle(feedListStyle);
|
||||
adapter.setSpacingStyle(spacingStyle);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
|
||||
break;
|
||||
|
||||
case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
|
||||
case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
|
||||
if (adapter.isRowSavedStories(groupPosition)) break;
|
||||
if (currentState == StateFilter.SAVED) break;
|
||||
inflater.inflate(R.menu.context_feed, menu);
|
||||
|
@ -607,7 +607,13 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
adapter.setTextSize(size);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setSpacingStyle(SpacingStyle spacingStyle) {
|
||||
PrefsUtils.setSpacingStyle(requireContext(), spacingStyle);
|
||||
if (adapter != null) {
|
||||
adapter.setSpacingStyle(spacingStyle);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.newsblur.util.FeedUtils;
|
|||
import com.newsblur.util.ImageLoader;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.ReadFilter;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.StoryListStyle;
|
||||
import com.newsblur.util.ThumbnailStyle;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
@ -168,7 +169,7 @@ public class ItemSetFragment extends NbFragment {
|
|||
public void onGlobalLayout() {
|
||||
itemGridWidthPx = binding.itemgridfragmentGrid.getMeasuredWidth();
|
||||
binding.itemgridfragmentGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
updateStyle();
|
||||
updateListStyle();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -361,7 +362,7 @@ public class ItemSetFragment extends NbFragment {
|
|||
adapter.notifyAllItemsChanged();
|
||||
}
|
||||
|
||||
public void updateStyle() {
|
||||
public void updateListStyle() {
|
||||
StoryListStyle listStyle = PrefsUtils.getStoryListStyle(getActivity(), getFeedSet());
|
||||
calcColumnCount(listStyle);
|
||||
calcGridSpacing(listStyle);
|
||||
|
@ -370,6 +371,12 @@ public class ItemSetFragment extends NbFragment {
|
|||
adapter.notifyAllItemsChanged();
|
||||
}
|
||||
|
||||
public void updateSpacingStyle() {
|
||||
SpacingStyle spacingStyle = PrefsUtils.getSpacingStyle(requireContext());
|
||||
adapter.setSpacingStyle(spacingStyle);
|
||||
adapter.notifyAllItemsChanged();
|
||||
}
|
||||
|
||||
public void setTextSize(Float size) {
|
||||
if (adapter != null) {
|
||||
adapter.setTextSize(size);
|
||||
|
|
|
@ -64,7 +64,7 @@ public class PrefConstants {
|
|||
public static final String STORIES_SHOW_PREVIEWS_STYLE = "pref_show_content_preview_style";
|
||||
public static final String STORIES_THUMBNAIL_STYLE = "pref_thumbnail_style";
|
||||
public static final String STORY_MARK_READ_BEHAVIOR = "pref_story_mark_read_behavior";
|
||||
public static final String FEED_LIST_STYLE = "pref_feed_list_style";
|
||||
public static final String SPACING_STYLE = "pref_spacing_style";
|
||||
|
||||
public static final String ENABLE_OFFLINE = "enable_offline";
|
||||
public static final String ENABLE_IMAGE_PREFETCH = "enable_image_prefetch";
|
||||
|
|
|
@ -1052,9 +1052,16 @@ public class PrefsUtils {
|
|||
editor.commit();
|
||||
}
|
||||
|
||||
public static FeedListStyle getFeedListStyle(Context context) {
|
||||
public static SpacingStyle getSpacingStyle(Context context) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
return FeedListStyle.valueOf(preferences.getString(PrefConstants.FEED_LIST_STYLE, FeedListStyle.COMFORTABLE.name()));
|
||||
return SpacingStyle.valueOf(preferences.getString(PrefConstants.SPACING_STYLE, SpacingStyle.COMFORTABLE.name()));
|
||||
}
|
||||
|
||||
public static void setSpacingStyle(Context context, SpacingStyle spacingStyle) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
Editor editor = preferences.edit();
|
||||
editor.putString(PrefConstants.SPACING_STYLE, spacingStyle.toString());
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,4 +16,14 @@ enum class SpacingStyle {
|
|||
COMFORTABLE -> UIUtils.dp2px(context, 7)
|
||||
COMPACT -> UIUtils.dp2px(context, 3)
|
||||
}
|
||||
|
||||
fun getStoryTitleVerticalPadding(context: Context): Int = when (this) {
|
||||
COMFORTABLE -> UIUtils.dp2px(context, 6)
|
||||
COMPACT -> UIUtils.dp2px(context, 1)
|
||||
}
|
||||
|
||||
fun getStoryContentVerticalPadding(context: Context): Int = when (this) {
|
||||
COMFORTABLE -> UIUtils.dp2px(context, 6)
|
||||
COMPACT -> UIUtils.dp2px(context, 1)
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue