Reduce catalog mode margin between the cards

Add option to override how many columns the catalog mode should have.
multisite
Floens 9 years ago
parent 9db1044fbd
commit 8e58b92592
  1. 2
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  2. 4
      Clover/app/src/main/java/org/floens/chan/ui/cell/CardPostCell.java
  3. 12
      Clover/app/src/main/java/org/floens/chan/ui/controller/MainSettingsController.java
  4. 54
      Clover/app/src/main/java/org/floens/chan/ui/layout/FixedRatioLinearLayout.java
  5. 15
      Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java
  6. 11
      Clover/app/src/main/res/layout/cell_post_card.xml
  7. 1
      Clover/app/src/main/res/values-sw600dp/dimens.xml
  8. 3
      Clover/app/src/main/res/values-v21/dimens.xml
  9. 2
      Clover/app/src/main/res/values/dimens.xml
  10. 3
      Clover/app/src/main/res/values/strings.xml

@ -71,6 +71,7 @@ public class ChanSettings {
public static final BooleanSetting videoOpenExternal;
public static final BooleanSetting videoErrorIgnore;
public static final StringSetting boardViewMode;
public static final IntegerSetting boardGridSpanCount;
public static final StringSetting boardOrder;
public static final StringSetting postDefaultName;
@ -141,6 +142,7 @@ public class ChanSettings {
videoOpenExternal = new BooleanSetting(p, "preference_video_external", false);
videoErrorIgnore = new BooleanSetting(p, "preference_video_error_ignore", false);
boardViewMode = new StringSetting(p, "preference_board_view_mode", PostCellInterface.PostViewMode.LIST.name); // "list" or "grid"
boardGridSpanCount = new IntegerSetting(p, "preference_board_grid_span_count", 0);
boardOrder = new StringSetting(p, "preference_board_order", PostsFilter.Order.BUMP.name);
postDefaultName = new StringSetting(p, "preference_default_name", "");

@ -30,6 +30,7 @@ import android.widget.TextView;
import org.floens.chan.R;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.layout.FixedRatioLinearLayout;
import org.floens.chan.ui.theme.Theme;
import org.floens.chan.ui.theme.ThemeHelper;
import org.floens.chan.ui.text.FastTextView;
@ -51,6 +52,7 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
private Post post;
private PostCellInterface.PostCellCallback callback;
private FixedRatioLinearLayout content;
private FixedRatioThumbnailView thumbnailView;
private TextView title;
private FastTextView comment;
@ -74,6 +76,8 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
protected void onFinishInflate() {
super.onFinishInflate();
content = (FixedRatioLinearLayout) findViewById(R.id.card_content);
content.setRatio(9f / 16f);
thumbnailView = (FixedRatioThumbnailView) findViewById(R.id.thumbnail);
thumbnailView.setRatio(16f / 9f);
thumbnailView.setOnClickListener(this);

@ -65,6 +65,7 @@ public class MainSettingsController extends SettingsController implements Toolba
private SettingView developerView;
private SettingView fontView;
private SettingView fontCondensed;
private SettingView gridColumnsView;
private ToolbarMenuItem overflow;
private PopupWindow advancedSettingsHint;
@ -135,6 +136,8 @@ public class MainSettingsController extends SettingsController implements Toolba
updateVideoLoadModes();
} else if (item == fontView || item == fontCondensed) {
EventBus.getDefault().post(new RefreshUIMessage("font"));
} else if (item == gridColumnsView) {
EventBus.getDefault().post(new RefreshUIMessage("gridcolumns"));
}
}
@ -179,12 +182,19 @@ public class MainSettingsController extends SettingsController implements Toolba
List<ListSettingView.Item> fontSizes = new ArrayList<>();
for (int size = 10; size <= 19; size++) {
String name = size + (String.valueOf(size).equals(ChanSettings.fontSize.getDefault()) ? " " + getString(R.string.setting_font_size_default) : "");
fontSizes.add(new ListSettingView.Item(name, String.valueOf(size)));
fontSizes.add(new ListSettingView.Item<>(name, String.valueOf(size)));
}
fontView = appearance.add(new ListSettingView<>(this, ChanSettings.fontSize, R.string.setting_font_size, fontSizes.toArray(new ListSettingView.Item[fontSizes.size()])));
fontCondensed = appearance.add(new BooleanSettingView(this, ChanSettings.fontCondensed, R.string.setting_font_condensed, R.string.setting_font_condensed_description));
List<ListSettingView.Item> gridColumns = new ArrayList<>();
gridColumns.add(new ListSettingView.Item<>(getString(R.string.setting_board_grid_span_count_default), 0));
for (int columns = 2; columns <= 5; columns++) {
gridColumns.add(new ListSettingView.Item<>(context.getString(R.string.setting_board_grid_span_count_item, columns), columns));
}
gridColumnsView = appearance.add(new ListSettingView<>(this, ChanSettings.boardGridSpanCount, R.string.setting_board_grid_span_count, gridColumns));
groups.add(appearance);
// Browsing group

@ -0,0 +1,54 @@
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.ui.layout;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class FixedRatioLinearLayout extends LinearLayout {
private float ratio;
public FixedRatioLinearLayout(Context context) {
super(context);
}
public FixedRatioLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FixedRatioLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setRatio(float ratio) {
this.ratio = ratio;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY && (heightMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.AT_MOST)) {
int width = MeasureSpec.getSize(widthMeasureSpec);
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec((int) (width / ratio), MeasureSpec.EXACTLY));
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}

@ -142,7 +142,12 @@ public class ThreadListLayout extends FrameLayout implements ReplyLayout.ReplyLa
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int cardWidth = getResources().getDimensionPixelSize(R.dimen.grid_card_width);
spanCount = Math.max(1, Math.round(getMeasuredWidth() / cardWidth));
int gridCountSetting = ChanSettings.boardGridSpanCount.get();
if (gridCountSetting > 0) {
spanCount = gridCountSetting;
} else {
spanCount = Math.max(1, Math.round(getMeasuredWidth() / cardWidth));
}
if (postViewMode == PostCellInterface.PostViewMode.CARD) {
((GridLayoutManager) layoutManager).setSpanCount(spanCount);
@ -171,9 +176,9 @@ public class ThreadListLayout extends FrameLayout implements ReplyLayout.ReplyLa
break;
case CARD:
GridLayoutManager gridLayoutManager = new GridLayoutManager(null, spanCount, GridLayoutManager.VERTICAL, false);
// The cards have a 4dp padding, this way there is always 8dp between the edges
recyclerViewTopPadding = dp(4);
recyclerView.setPadding(dp(4), recyclerViewTopPadding + toolbarHeight(), dp(4), dp(4));
// The cards have a 1dp padding, this way there is always 2dp between the edges
recyclerViewTopPadding = dp(1);
recyclerView.setPadding(dp(1), recyclerViewTopPadding + toolbarHeight(), dp(1), dp(1));
recyclerView.setLayoutManager(gridLayoutManager);
layoutManager = gridLayoutManager;
@ -317,7 +322,7 @@ public class ThreadListLayout extends FrameLayout implements ReplyLayout.ReplyLa
case CARD:
if (getTopAdapterPosition() == 0) {
View top = layoutManager.findViewByPosition(0);
return top.getTop() != getDimen(getContext(), R.dimen.grid_card_margin) + dp(4) + toolbarHeight(); // 4dp for the cards, 4dp for this layout
return top.getTop() != getDimen(getContext(), R.dimen.grid_card_margin) + dp(1) + toolbarHeight();
}
break;
}

@ -22,12 +22,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_height="wrap_content"
android:layout_margin="@dimen/grid_card_margin"
card_view:cardBackgroundColor="?backcolor"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="4dp">
card_view:cardCornerRadius="@dimen/grid_card_corner_radius"
card_view:cardElevation="1dp">
<LinearLayout
<org.floens.chan.ui.layout.FixedRatioLinearLayout
android:id="@+id/card_content"
android:layout_width="match_parent"
android:layout_height="@dimen/grid_card_height"
android:layout_height="wrap_content"
android:background="@drawable/item_background"
android:orientation="vertical">
@ -88,6 +89,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:singleLine="true"
android:textColor="?attr/text_color_secondary" />
</LinearLayout>
</org.floens.chan.ui.layout.FixedRatioLinearLayout>
</org.floens.chan.ui.cell.CardPostCell>

@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<bool name="is_tablet">true</bool>
<dimen name="grid_card_width">105dp</dimen>
<dimen name="grid_card_height">240dp</dimen>
<dimen name="cell_post_thumbnail_size">100dp</dimen>
</resources>

@ -16,5 +16,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<dimen name="grid_card_margin">4dp</dimen>
<dimen name="grid_card_margin">0dp</dimen>
<dimen name="grid_card_corner_radius">2dp</dimen>
</resources>

@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<dimen name="toolbar_height">56dp</dimen>
<dimen name="grid_card_width">120dp</dimen>
<dimen name="grid_card_height">200dp</dimen>
<dimen name="grid_card_margin">0dp</dimen>
<dimen name="grid_card_corner_radius">0dp</dimen>
<dimen name="cell_post_thumbnail_size">72dp</dimen>
</resources>

@ -334,6 +334,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="setting_font_size_default">(default)</string>
<string name="setting_font_condensed">Use condensed font</string>
<string name="setting_font_condensed_description">Use a condensed font for the posts</string>
<string name="setting_board_grid_span_count">Catalog mode columns</string>
<string name="setting_board_grid_span_count_default">Auto</string>
<string name="setting_board_grid_span_count_item">%1$d columns</string>
<string name="setting_open_link_confirmation">Ask before opening links</string>
<string name="setting_auto_refresh_thread">Auto refresh threads</string>
<string name="setting_image_auto_load">Auto load images</string>

Loading…
Cancel
Save