diff --git a/Clover/app/src/main/java/org/floens/chan/core/manager/ThreadManager.java b/Clover/app/src/main/java/org/floens/chan/core/manager/ThreadManager.java
index ea7a3e88..636e7d4c 100644
--- a/Clover/app/src/main/java/org/floens/chan/core/manager/ThreadManager.java
+++ b/Clover/app/src/main/java/org/floens/chan/core/manager/ThreadManager.java
@@ -506,7 +506,7 @@ public class ThreadManager implements Loader.LoaderListener {
private void deletePost(final Post post) {
final CheckBox view = new CheckBox(activity);
view.setText(R.string.delete_image_only);
- int padding = activity.getResources().getDimensionPixelSize(R.dimen.general_padding);
+ int padding = Utils.dp(12f);
view.setPadding(padding, padding, padding, padding);
new AlertDialog.Builder(activity).setTitle(R.string.delete_confirm).setView(view)
diff --git a/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java b/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java
index a6ca0e5f..2a7b4989 100644
--- a/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java
+++ b/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java
@@ -115,7 +115,7 @@ public class PostAdapter extends BaseAdapter {
ThreadWatchCounterView view = new ThreadWatchCounterView(context);
Utils.setPressedDrawable(view);
view.init(threadManager, listView, this);
- int padding = context.getResources().getDimensionPixelSize(R.dimen.general_padding);
+ int padding = Utils.dp(12f);
view.setPadding(padding, padding, padding, padding);
int height = Utils.dp(48f);
view.setHeight(height);
@@ -125,7 +125,7 @@ public class PostAdapter extends BaseAdapter {
if (endOfLine) {
TextView textView = new TextView(context);
textView.setText(context.getString(R.string.thread_load_end_of_line));
- int padding = context.getResources().getDimensionPixelSize(R.dimen.general_padding);
+ int padding = Utils.dp(12f);
textView.setPadding(padding, padding, padding, padding);
return textView;
} else {
diff --git a/Clover/app/src/main/java/org/floens/chan/ui/fragment/ThreadFragment.java b/Clover/app/src/main/java/org/floens/chan/ui/fragment/ThreadFragment.java
index 6edae5c6..78b41ec3 100644
--- a/Clover/app/src/main/java/org/floens/chan/ui/fragment/ThreadFragment.java
+++ b/Clover/app/src/main/java/org/floens/chan/ui/fragment/ThreadFragment.java
@@ -19,6 +19,7 @@ package org.floens.chan.ui.fragment;
import android.app.Fragment;
import android.content.Intent;
+import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -196,9 +197,13 @@ public class ThreadFragment extends Fragment implements ThreadManager.ThreadMana
} else if (viewMode == ThreadManager.ViewMode.GRID) {
GridView grid = new GridView(baseActivity);
grid.setNumColumns(GridView.AUTO_FIT);
- grid.setColumnWidth(baseActivity.getResources().getDimensionPixelSize(R.dimen.post_grid_width));
- grid.setVerticalSpacing(baseActivity.getResources().getDimensionPixelSize(R.dimen.post_grid_spacing));
- grid.setHorizontalSpacing(baseActivity.getResources().getDimensionPixelSize(R.dimen.post_grid_spacing));
+ TypedArray ta = baseActivity.obtainStyledAttributes(null, R.styleable.PostView, R.attr.post_style, 0);
+ int postGridWidth = ta.getDimensionPixelSize(R.styleable.PostView_grid_width, 0);
+ int postGridSpacing = ta.getDimensionPixelSize(R.styleable.PostView_grid_spacing, 0);
+ ta.recycle();
+ grid.setColumnWidth(postGridWidth);
+ grid.setVerticalSpacing(postGridSpacing);
+ grid.setHorizontalSpacing(postGridSpacing);
listView = grid;
postAdapter = new PostAdapter(baseActivity, threadManager, listView);
listView.setAdapter(postAdapter);
diff --git a/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java b/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java
index d8436d8c..5acc7318 100644
--- a/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java
+++ b/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java
@@ -19,7 +19,6 @@ package org.floens.chan.ui.view;
import android.app.Activity;
import android.content.Context;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.text.Layout;
import android.text.Selection;
@@ -85,12 +84,6 @@ public class PostView extends LinearLayout implements View.OnClickListener {
private ImageView optionsView;
private View lastSeen;
- private int thumbnailBackground;
- private int savedReplyColor;
- private int highlightedColor;
- private int replyCountColor;
- private int dateColor;
-
/**
* Represents a post. Use setPost(Post ThreadManager) to fill it with data.
* setPost can be called multiple times (useful for ListView).
@@ -100,19 +93,16 @@ public class PostView extends LinearLayout implements View.OnClickListener {
public PostView(Context activity) {
super(activity);
context = (Activity) activity;
- init();
}
public PostView(Context activity, AttributeSet attbs) {
super(activity, attbs);
context = (Activity) activity;
- init();
}
public PostView(Context activity, AttributeSet attbs, int style) {
super(activity, attbs, style);
context = (Activity) activity;
- init();
}
@Override
@@ -129,14 +119,23 @@ public class PostView extends LinearLayout implements View.OnClickListener {
this.manager = manager;
boolean boardCatalogMode = manager.getLoadable().isBoardMode() || manager.getLoadable().isCatalogMode();
- post.setLinkableListener(null);
+ TypedArray ta = context.obtainStyledAttributes(null, R.styleable.PostView, R.attr.post_style, 0);
if (!post.parsedSpans) {
+ parseSpans(post, ta);
post.parsedSpans = true;
- parseSpans(post);
}
- buildView(context);
+ if (!isBuild) {
+ buildView(context, ta);
+ isBuild = true;
+ }
+
+ int dateColor = ta.getColor(R.styleable.PostView_date_color, 0);
+ int savedReplyColor = ta.getColor(R.styleable.PostView_saved_reply_color, 0);
+ int highlightedColor = ta.getColor(R.styleable.PostView_highlighted_color, 0);
+
+ ta.recycle();
if (post.hasImage) {
imageView.setVisibility(View.VISIBLE);
@@ -189,24 +188,17 @@ public class PostView extends LinearLayout implements View.OnClickListener {
titleView.setVisibility(View.GONE);
}
- if (!TextUtils.isEmpty(post.comment)) {
- commentView.setVisibility(View.VISIBLE);
- commentView.setText(post.comment);
-
- if (manager.getLoadable().isThreadMode()) {
- commentView.setMovementMethod(new PostViewMovementMethod());
- }
+ commentView.setText(post.comment);
+ if (manager.getLoadable().isThreadMode()) {
+ post.setLinkableListener(this);
+ commentView.setMovementMethod(new PostViewMovementMethod());
commentView.setOnClickListener(this);
-
- if (manager.getLoadable().isThreadMode()) {
- post.setLinkableListener(this);
- }
} else {
- commentView.setVisibility(View.GONE);
- commentView.setText("");
- commentView.setOnClickListener(null);
post.setLinkableListener(null);
+ commentView.setOnClickListener(null);
+ commentView.setClickable(false);
+ commentView.setMovementMethod(null);
}
if (isGrid() || ((post.isOP && boardCatalogMode && post.replies > 0) || (post.repliesFrom.size() > 0))) {
@@ -276,18 +268,8 @@ public class PostView extends LinearLayout implements View.OnClickListener {
}
}
- private void init() {
- TypedArray ta = context.obtainStyledAttributes(null, R.styleable.PostView, R.attr.post_style, 0);
- thumbnailBackground = ta.getColor(R.styleable.PostView_thumbnail_background, 0);
- savedReplyColor = ta.getColor(R.styleable.PostView_saved_reply_color, 0);
- highlightedColor = ta.getColor(R.styleable.PostView_highlighted_color, 0);
- replyCountColor = ta.getColor(R.styleable.PostView_reply_count_color, 0);
- dateColor = ta.getColor(R.styleable.PostView_date_color, 0);
- ta.recycle();
- }
-
- private void parseSpans(Post post) {
- TypedArray ta = context.obtainStyledAttributes(null, R.styleable.PostView, R.attr.post_style, 0);
+ private void parseSpans(Post post, TypedArray ta) {
+ int detailSize = ta.getDimensionPixelSize(R.styleable.PostView_detail_size, 0);
if (!TextUtils.isEmpty(post.subject)) {
post.subjectSpan = new SpannableString(post.subject);
@@ -305,7 +287,7 @@ public class PostView extends LinearLayout implements View.OnClickListener {
if (!TextUtils.isEmpty(post.tripcode)) {
post.tripcodeSpan = new SpannableString(post.tripcode);
post.tripcodeSpan.setSpan(new ForegroundColorSpan(ta.getColor(R.styleable.PostView_name_color, 0)), 0, post.tripcodeSpan.length(), 0);
- post.tripcodeSpan.setSpan(new AbsoluteSizeSpan(10, true), 0, post.tripcodeSpan.length(), 0);
+ post.tripcodeSpan.setSpan(new AbsoluteSizeSpan(detailSize), 0, post.tripcodeSpan.length(), 0);
}
if (!TextUtils.isEmpty(post.id)) {
@@ -324,48 +306,51 @@ public class PostView extends LinearLayout implements View.OnClickListener {
post.idSpan.setSpan(new ForegroundColorSpan(idColor), 0, post.idSpan.length(), 0);
post.idSpan.setSpan(new BackgroundColorSpan(idBgColor), 0, post.idSpan.length(), 0);
- post.idSpan.setSpan(new AbsoluteSizeSpan(10, true), 0, post.idSpan.length(), 0);
+ post.idSpan.setSpan(new AbsoluteSizeSpan(detailSize), 0, post.idSpan.length(), 0);
}
if (!TextUtils.isEmpty(post.capcode)) {
post.capcodeSpan = new SpannableString("Capcode: " + post.capcode);
post.capcodeSpan.setSpan(new ForegroundColorSpan(ta.getColor(R.styleable.PostView_capcode_color, 0)), 0, post.capcodeSpan.length(), 0);
- post.capcodeSpan.setSpan(new AbsoluteSizeSpan(10, true), 0, post.capcodeSpan.length(), 0);
+ post.capcodeSpan.setSpan(new AbsoluteSizeSpan(detailSize), 0, post.capcodeSpan.length(), 0);
}
-
- ta.recycle();
}
- private void buildView(final Context context) {
- if (isBuild)
- return;
- isBuild = true;
+ private void buildView(final Context context, TypedArray ta) {
+ int thumbnailBackground = ta.getColor(R.styleable.PostView_thumbnail_background, 0);
+ int replyCountColor = ta.getColor(R.styleable.PostView_reply_count_color, 0);
- Resources resources = context.getResources();
- int postPadding = 0;
- if (isList()) {
- postPadding = resources.getDimensionPixelSize(R.dimen.post_padding);
- } else if (isGrid()) {
- postPadding = resources.getDimensionPixelSize(R.dimen.post_padding_grid);
- }
- int commentPadding = 0;
- if (isList()) {
- commentPadding = resources.getDimensionPixelSize(R.dimen.post_comment_padding);
- } else if (isGrid()) {
- commentPadding = resources.getDimensionPixelSize(R.dimen.post_comment_padding_grid);
- }
- int iconPadding = resources.getDimensionPixelSize(R.dimen.post_icon_padding);
- int iconWidth = resources.getDimensionPixelSize(R.dimen.post_icon_width);
- int iconHeight = resources.getDimensionPixelSize(R.dimen.post_icon_height);
- int imageSize = resources.getDimensionPixelSize(R.dimen.thumbnail_size);
- int gridHeight = resources.getDimensionPixelSize(R.dimen.post_grid_height);
- int gridImageHeight = resources.getDimensionPixelSize(R.dimen.post_grid_image_height);
+ int iconPadding = ta.getDimensionPixelSize(R.styleable.PostView_icon_padding, 0);
+ int iconWidth = ta.getDimensionPixelSize(R.styleable.PostView_icon_width, 0);
+ int iconHeight = ta.getDimensionPixelSize(R.styleable.PostView_icon_height, 0);
+ int gridHeight = ta.getDimensionPixelSize(R.styleable.PostView_grid_height, 0);
+ int optionsSpacing = ta.getDimensionPixelSize(R.styleable.PostView_options_spacing, 0);
+ int titleSize = ta.getDimensionPixelSize(R.styleable.PostView_title_size, 0);
+ int optionsLeftPadding = ta.getDimensionPixelSize(R.styleable.PostView_options_left_padding, 0);
+ int optionsTopPadding = ta.getDimensionPixelSize(R.styleable.PostView_options_top_padding, 0);
+ int optionsRightPadding = ta.getDimensionPixelSize(R.styleable.PostView_options_right_padding, 0);
+ int optionsBottomPadding = ta.getDimensionPixelSize(R.styleable.PostView_options_bottom_padding, 0);
+ int lastSeenHeight = ta.getDimensionPixelSize(R.styleable.PostView_last_seen_height, 0);
+
+ int postListMaxHeight = ta.getDimensionPixelSize(R.styleable.PostView_list_comment_max_height, 0);
int postCommentSize = 0;
+ int commentPadding = 0;
+ int postPadding = 0;
+ int imageSize = 0;
+ int repliesCountSize = 0;
if (isList()) {
- postCommentSize = resources.getDimensionPixelSize(R.dimen.post_comment_text);
+ postCommentSize = ta.getDimensionPixelSize(R.styleable.PostView_list_comment_size, 0);
+ commentPadding = ta.getDimensionPixelSize(R.styleable.PostView_list_comment_padding, 0);
+ postPadding = ta.getDimensionPixelSize(R.styleable.PostView_list_padding, 0);
+ imageSize = ta.getDimensionPixelSize(R.styleable.PostView_list_image_size, 0);
+ repliesCountSize = ta.getDimensionPixelSize(R.styleable.PostView_list_replies_count_size, 0);
} else if (isGrid()) {
- postCommentSize = resources.getDimensionPixelSize(R.dimen.post_comment_text_grid);
+ postCommentSize = ta.getDimensionPixelSize(R.styleable.PostView_grid_comment_size, 0);
+ commentPadding = ta.getDimensionPixelSize(R.styleable.PostView_grid_comment_padding, 0);
+ postPadding = ta.getDimensionPixelSize(R.styleable.PostView_grid_padding, 0);
+ imageSize = ta.getDimensionPixelSize(R.styleable.PostView_grid_image_size, 0);
+ repliesCountSize = ta.getDimensionPixelSize(R.styleable.PostView_grid_replies_count_size, 0);
}
RelativeLayout wrapper = new RelativeLayout(context);
@@ -401,7 +386,7 @@ public class PostView extends LinearLayout implements View.OnClickListener {
full.addView(imageContainer, wrapMatchParams);
full.setMinimumHeight(imageSize);
} else if (isGrid()) {
- imageContainer.addView(imageView, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, gridImageHeight));
+ imageContainer.addView(imageView, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, imageSize));
full.addView(imageContainer, matchWrapParams);
}
@@ -413,11 +398,11 @@ public class PostView extends LinearLayout implements View.OnClickListener {
if (isList()) {
// 25 padding to give optionsView some space
- titleContainer.setPadding(0, 0, Utils.dp(25), 0);
+ titleContainer.setPadding(0, 0, optionsSpacing, 0);
}
titleView = new TextView(context);
- titleView.setTextSize(14);
+ titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
titleView.setPadding(postPadding, postPadding, postPadding, 0);
titleContainer.addView(titleView, wrapParams);
@@ -449,14 +434,12 @@ public class PostView extends LinearLayout implements View.OnClickListener {
commentView.setPadding(postPadding, commentPadding, postPadding, commentPadding);
if (manager.getLoadable().isBoardMode() || manager.getLoadable().isCatalogMode()) {
- int maxHeight = context.getResources().getDimensionPixelSize(R.dimen.post_max_height);
- commentView.setMaxHeight(maxHeight);
+ commentView.setMaxHeight(postListMaxHeight);
}
} else if (isGrid()) {
commentView.setPadding(postPadding, commentPadding, postPadding, 0);
// So that is fills up all the height using weight later on
commentView.setMinHeight(10000);
- commentView.setEllipsize(TextUtils.TruncateAt.END);
}
if (isList()) {
@@ -469,18 +452,14 @@ public class PostView extends LinearLayout implements View.OnClickListener {
Utils.setPressedDrawable(repliesCountView);
repliesCountView.setTextColor(replyCountColor);
repliesCountView.setPadding(postPadding, postPadding, postPadding, postPadding);
- if (isList()) {
- repliesCountView.setTextSize(14);
- } else if (isGrid()) {
- repliesCountView.setTextSize(11);
- }
+ repliesCountView.setTextSize(TypedValue.COMPLEX_UNIT_PX, repliesCountSize);
repliesCountView.setSingleLine();
contentContainer.addView(repliesCountView, wrapParams);
lastSeen = new View(context);
lastSeen.setBackgroundColor(0xffff0000);
- contentContainer.addView(lastSeen, new LayoutParams(LayoutParams.MATCH_PARENT, Utils.dp(6f)));
+ contentContainer.addView(lastSeen, new LayoutParams(LayoutParams.MATCH_PARENT, lastSeenHeight));
if (!manager.getLoadable().isThreadMode()) {
Utils.setPressedDrawable(contentContainer);
@@ -491,7 +470,7 @@ public class PostView extends LinearLayout implements View.OnClickListener {
optionsView = new ImageView(context);
optionsView.setImageResource(R.drawable.ic_overflow);
Utils.setPressedDrawable(optionsView);
- optionsView.setPadding(Utils.dp(15), Utils.dp(5), Utils.dp(5), Utils.dp(15));
+ optionsView.setPadding(optionsLeftPadding, optionsTopPadding, optionsRightPadding, optionsBottomPadding);
optionsView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
diff --git a/Clover/app/src/main/java/org/floens/chan/utils/ThemeHelper.java b/Clover/app/src/main/java/org/floens/chan/utils/ThemeHelper.java
index 6394deae..7f96ce83 100644
--- a/Clover/app/src/main/java/org/floens/chan/utils/ThemeHelper.java
+++ b/Clover/app/src/main/java/org/floens/chan/utils/ThemeHelper.java
@@ -101,6 +101,7 @@ public class ThemeHelper {
public int getSpoilerColor() {
return spoilerColor;
}
+
public int getInlineQuoteColor() {
return inlineQuoteColor;
}
diff --git a/Clover/app/src/main/res/values/attrs.xml b/Clover/app/src/main/res/values/attrs.xml
index 8a17befd..1c36f132 100644
--- a/Clover/app/src/main/res/values/attrs.xml
+++ b/Clover/app/src/main/res/values/attrs.xml
@@ -54,6 +54,33 @@ along with this program. If not, see .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Clover/app/src/main/res/values/dimens.xml b/Clover/app/src/main/res/values/dimens.xml
index 47ccee1b..c5dfda6d 100644
--- a/Clover/app/src/main/res/values/dimens.xml
+++ b/Clover/app/src/main/res/values/dimens.xml
@@ -17,22 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
-->
- 12dp
-
- 10dp
- 5dp
- 11dp
- 8dp
- 6dp
- 70dp
- 24dp
- 14dp
- 200dp
- 110dp
- 300dp
- 120dp
- 15sp
- 14sp
- 1dp
8dp
diff --git a/Clover/app/src/main/res/values/styles.xml b/Clover/app/src/main/res/values/styles.xml
index 8a50ff84..92ec8cdc 100644
--- a/Clover/app/src/main/res/values/styles.xml
+++ b/Clover/app/src/main/res/values/styles.xml
@@ -79,6 +79,35 @@ along with this program. If not, see .