diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2025-05-06 13:04:28 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2025-05-06 13:04:28 +0300 |
| commit | 73f8dac69f24ba8e07b08a79b393cd64e13907e9 (patch) | |
| tree | 75be8cc1b1230764181ad0659ea88eff6883b437 | |
| parent | e4fa3f1c1084a7527216831d856942c37072aa01 (diff) | |
switch some more imageviews to material buttons and drop hardcoded article background preferring material3 default
5 files changed, 39 insertions, 40 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java index 0523c144..08905aec 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java @@ -6,6 +6,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Color; import android.net.Uri; @@ -35,6 +36,7 @@ import android.widget.TextView; import androidx.core.text.HtmlCompat; import com.evernote.android.state.State; +import com.google.android.material.button.MaterialButton; import org.fox.ttrss.types.Article; import org.fox.ttrss.types.Attachment; @@ -218,21 +220,11 @@ public class ArticleFragment extends StateSavedFragment { } - final ImageView scoreView = view.findViewById(R.id.score); + final MaterialButton scoreView = view.findViewById(R.id.score); if (scoreView != null) { setScoreImage(scoreView, m_article.score); - Resources.Theme theme = m_activity.getTheme(); - TypedValue tv = new TypedValue(); - theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true); - int titleHighScoreUnreadColor = tv.data; - - if (m_article.score > Article.SCORE_HIGH) - scoreView.setColorFilter(titleHighScoreUnreadColor); - else - scoreView.setColorFilter(null); - if (m_activity.getApiLevel() >= 16) { scoreView.setOnClickListener(new OnClickListener() { @Override @@ -282,7 +274,7 @@ public class ArticleFragment extends StateSavedFragment { } } - ImageView attachments = view.findViewById(R.id.attachments); + MaterialButton attachments = view.findViewById(R.id.attachments); if (attachments != null) { if (m_article.attachments != null && m_article.attachments.size() > 0) { @@ -298,7 +290,7 @@ public class ArticleFragment extends StateSavedFragment { } } - ImageView share = view.findViewById(R.id.share); + MaterialButton share = view.findViewById(R.id.share); if (share != null) { share.setOnClickListener(new OnClickListener() { @@ -409,6 +401,8 @@ public class ArticleFragment extends StateSavedFragment { m_web = view.findViewById(R.id.article_content); + m_web.setBackgroundColor(Color.TRANSPARENT); + m_web.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { @@ -447,7 +441,7 @@ public class ArticleFragment extends StateSavedFragment { return view; } - private void setScoreImage(ImageView scoreView, int score) { + private void setScoreImage(MaterialButton scoreView, int score) { TypedValue tv = new TypedValue(); int scoreAttr = R.attr.ic_action_trending_flat; @@ -458,7 +452,20 @@ public class ArticleFragment extends StateSavedFragment { m_activity.getTheme().resolveAttribute(scoreAttr, tv, true); - scoreView.setImageResource(tv.resourceId); + scoreView.setIconResource(tv.resourceId); + + Resources.Theme theme = m_activity.getTheme(); + TypedValue tvColorHighScore = new TypedValue(); + theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tvColorHighScore, true); + + TypedValue tvPrimary = new TypedValue(); + m_activity.getTheme().resolveAttribute(R.attr.colorPrimary, tvPrimary, true); + + if (m_article.score > Article.SCORE_HIGH) + scoreView.setIconTint(ColorStateList.valueOf(tvColorHighScore.data)); + else + scoreView.setIconTint(ColorStateList.valueOf(tvPrimary.data)); + } protected void renderContent(Bundle savedInstanceState) { @@ -469,21 +476,12 @@ public class ArticleFragment extends StateSavedFragment { WebSettings ws = m_web.getSettings(); ws.setSupportZoom(false); - TypedValue tvBackground = new TypedValue(); - getActivity().getTheme().resolveAttribute(R.attr.articleBackground, tvBackground, true); - - String backgroundHexColor = String.format("#%06X", (0xFFFFFF & tvBackground.data)); - - String cssOverride = ""; - - cssOverride = "body { background : "+ backgroundHexColor+"; }"; - TypedValue tvTextColor = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.articleTextColor, tvTextColor, true); String textColor = String.format("#%06X", (0xFFFFFF & tvTextColor.data)); - cssOverride += "body { color : "+textColor+"; }"; + String cssOverride = "body { color : "+textColor+"; }"; TypedValue tvLinkColor = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tvLinkColor, true); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java index 3f452a63..28839388 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -43,6 +43,8 @@ import java.util.Date; import androidx.fragment.app.Fragment; +import com.google.android.material.button.MaterialButton; + public class OfflineArticleFragment extends Fragment { private final String TAG = this.getClass().getSimpleName(); @@ -234,19 +236,19 @@ public class OfflineArticleFragment extends Fragment { } - ImageView score = view.findViewById(R.id.score); + MaterialButton score = view.findViewById(R.id.score); if (score != null) { score.setVisibility(View.GONE); } - ImageView attachments = view.findViewById(R.id.attachments); + MaterialButton attachments = view.findViewById(R.id.attachments); if (attachments != null) { attachments.setVisibility(View.GONE); } - ImageView share = view.findViewById(R.id.share); + MaterialButton share = view.findViewById(R.id.share); if (share != null) { share.setOnClickListener(new OnClickListener() { diff --git a/org.fox.ttrss/src/main/res/layout-sw600dp/activity_detail.xml b/org.fox.ttrss/src/main/res/layout-sw600dp/activity_detail.xml index 95215992..89ab61f5 100644 --- a/org.fox.ttrss/src/main/res/layout-sw600dp/activity_detail.xml +++ b/org.fox.ttrss/src/main/res/layout-sw600dp/activity_detail.xml @@ -35,7 +35,6 @@ android:layout_width="0dp" android:layout_weight="0.7" android:elevation="4dp" - android:background="?articleBackground" android:layout_height="match_parent"> <FrameLayout diff --git a/org.fox.ttrss/src/main/res/layout/activity_detail_phone.xml b/org.fox.ttrss/src/main/res/layout/activity_detail_phone.xml index 6d9a8dbd..ddffc89e 100644 --- a/org.fox.ttrss/src/main/res/layout/activity_detail_phone.xml +++ b/org.fox.ttrss/src/main/res/layout/activity_detail_phone.xml @@ -31,8 +31,7 @@ android:id="@+id/article_fragment" app:layout_behavior=".util.DetailActivityScrollingViewBehavior" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="?articleBackground"> + android:layout_height="wrap_content"> </FrameLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/org.fox.ttrss/src/main/res/layout/fragment_article.xml b/org.fox.ttrss/src/main/res/layout/fragment_article.xml index 61215a40..cffc7c33 100755 --- a/org.fox.ttrss/src/main/res/layout/fragment_article.xml +++ b/org.fox.ttrss/src/main/res/layout/fragment_article.xml @@ -3,8 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/article_fragment" android:layout_width="fill_parent" - android:layout_height="match_parent" - android:background="?articleBackground"> + android:layout_height="match_parent"> <FrameLayout android:id="@+id/article_fullscreen_video" @@ -17,7 +16,6 @@ android:layout_height="wrap_content"> <com.google.android.material.appbar.AppBarLayout - android:background="?articleHeader" android:elevation="0dp" app:elevation="0dp" android:layout_width="match_parent" @@ -51,7 +49,8 @@ android:layout_marginRight="8dp" android:gravity="start" /> - <ImageView + <com.google.android.material.button.MaterialButton + style="?attr/materialIconButtonStyle" android:id="@+id/score" android:layout_width="wrap_content" android:layout_height="24dp" @@ -59,10 +58,11 @@ android:background="@drawable/ripple" android:clickable="true" android:layout_marginLeft="8dp" - android:src="?ic_action_trending_flat" + app:icon="?ic_action_trending_flat" android:layout_gravity="center_vertical|end" /> - <ImageView + <com.google.android.material.button.MaterialButton + style="?attr/materialIconButtonStyle" android:id="@+id/attachments" android:background="@drawable/ripple" android:layout_width="wrap_content" @@ -70,17 +70,18 @@ android:layout_weight="0" android:layout_marginLeft="8dp" android:clickable="true" - android:src="?ic_attachment_vert" + app:icon="?ic_attachment_vert" android:layout_gravity="center_vertical|end" /> - <ImageView + <com.google.android.material.button.MaterialButton + style="?attr/materialIconButtonStyle" android:id="@+id/share" android:background="@drawable/ripple" android:layout_width="wrap_content" android:layout_height="24dp" android:layout_weight="0" android:clickable="true" - android:src="?ic_share" + app:icon="?ic_share" android:layout_gravity="center_vertical|end" /> </LinearLayout> |