Set toolbar secondary text color. Fix flairs don't show in some posts.

This commit is contained in:
Alex Ning 2020-06-08 16:36:31 +08:00
parent dd8619e783
commit b8e4ce6e1d
4 changed files with 14 additions and 8 deletions

View File

@ -185,14 +185,11 @@ public abstract class BaseActivity extends AppCompatActivity {
}
protected void setToolbarGoToTop(Toolbar toolbar) {
toolbar.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (BaseActivity.this instanceof ActivityToolbarInterface) {
((ActivityToolbarInterface) BaseActivity.this).onLongPress();
}
return true;
toolbar.setOnLongClickListener(view -> {
if (BaseActivity.this instanceof ActivityToolbarInterface) {
((ActivityToolbarInterface) BaseActivity.this).onLongPress();
}
return true;
});
}
@ -247,6 +244,7 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary());
toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor());
toolbar.setSubtitleTextColor(customThemeWrapper.getToolbarSecondaryTextColor());
if (toolbar.getNavigationIcon() != null) {
toolbar.getNavigationIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
}

View File

@ -337,6 +337,7 @@ public class ThemePreviewActivity extends AppCompatActivity {
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
appBarLayout.setBackgroundColor(customTheme.colorPrimary);
toolbar.setTitleTextColor(customTheme.toolbarPrimaryTextAndIconColor);
toolbar.setSubtitleTextColor(customTheme.toolbarSecondaryTextColor);
if (toolbar.getNavigationIcon() != null) {
toolbar.getNavigationIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
}

View File

@ -64,6 +64,7 @@ public class ParsePost {
boolean locked = data.getBoolean(JSONUtils.LOCKEC_KEY);
boolean saved = data.getBoolean(JSONUtils.SAVED_KEY);
StringBuilder postFlairHTMLBuilder = new StringBuilder();
String flair = "";
if (data.has(JSONUtils.LINK_FLAIR_RICHTEXT_KEY)) {
JSONArray flairArray = data.getJSONArray(JSONUtils.LINK_FLAIR_RICHTEXT_KEY);
for (int i = 0; i < flairArray.length(); i++) {
@ -75,8 +76,13 @@ public class ParsePost {
postFlairHTMLBuilder.append("<img src=\"").append(Html.escapeHtml(flairObject.getString(JSONUtils.U_KEY))).append("\">");
}
}
flair = postFlairHTMLBuilder.toString();
}
String flair = postFlairHTMLBuilder.toString();
if (flair.equals("") && data.has(JSONUtils.LINK_FLAIR_TEXT_KEY) && !data.isNull(JSONUtils.LINK_FLAIR_TEXT_KEY)) {
flair = data.getString(JSONUtils.LINK_FLAIR_TEXT_KEY);
}
StringBuilder awardingsBuilder = new StringBuilder();
JSONArray awardingsArray = data.getJSONArray(JSONUtils.ALL_AWARDINGS_KEY);
int nAwards = 0;

View File

@ -23,6 +23,7 @@ public class JSONUtils {
public static final String U_KEY = "u";
public static final String LINK_KEY = "link";
public static final String LINK_AUTHOR_KEY = "link_author";
public static final String LINK_FLAIR_TEXT_KEY = "link_flair_text";
public static final String LINK_FLAIR_RICHTEXT_KEY = "link_flair_richtext";
public static final String SCORE_KEY = "score";
public static final String LIKES_KEY = "likes";