Loading app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +56 −4 Original line number Diff line number Diff line Loading @@ -20,12 +20,15 @@ package foundation.e.apps.application import android.content.Intent import android.graphics.Color import android.graphics.drawable.Drawable import android.os.Bundle import android.text.Html import android.util.Log import android.view.View import android.widget.ImageView import androidx.core.content.ContextCompat import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeCompat import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels Loading Loading @@ -233,11 +236,17 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { // Ratings widgets binding.ratingsInclude.apply { if (it.ratings.usageQualityScore != -1.0) { val rating = applicationViewModel.handleRatingFormat(it.ratings.usageQualityScore) appRating.text = getString( R.string.rating_out_of, applicationViewModel.handleRatingFormat(it.ratings.usageQualityScore) R.string.rating_out_of, rating ) appRating.setCompoundDrawablesWithIntrinsicBounds( null, null, getRatingDrawable(rating), null ) appRating.compoundDrawablePadding = 15 } appRatingLayout.setOnClickListener { ApplicationDialogFragment( Loading @@ -248,10 +257,16 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { } if (it.ratings.privacyScore != -1.0) { val privacyScore = it.ratings.privacyScore.toInt().toString() appPrivacyScore.text = getString( R.string.privacy_rating_out_of, it.ratings.privacyScore.toInt().toString() privacyScore ) appPrivacyScore.setCompoundDrawablesRelativeWithIntrinsicBounds( null, null, getPrivacyDrawable(privacyScore), null ) appPrivacyScore.compoundDrawablePadding = 15 } appPrivacyScoreLayout.setOnClickListener { ApplicationDialogFragment( Loading Loading @@ -319,7 +334,6 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { getString(R.string.trackers_title), trackers ).show(childFragmentManager, TAG) } } Loading Loading @@ -348,4 +362,42 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { } return shareIntent } private fun getPrivacyDrawable(privacyRating: String): Drawable? { val rating = privacyRating.toInt() var dotColor = ContextCompat.getColor(requireContext(), R.color.colorGreen) if (rating <= 3) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorRed) } else if (rating <= 6) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorYellow) } return applyDotAccent(dotColor) } private fun getRatingDrawable(reviewRating: String): Drawable? { val rating = reviewRating.toDouble() var dotColor = ContextCompat.getColor(requireContext(), R.color.colorGreen) if (rating <= 2.0) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorRed) } else if (rating <= 3.4) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorYellow) } return applyDotAccent(dotColor) } private fun applyDotAccent(dotColor: Int): Drawable? { val circleDrawable = ContextCompat.getDrawable(requireContext(), R.drawable.ic_rating_privacy_circle) circleDrawable?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat( dotColor, BlendModeCompat.SRC_ATOP ) return circleDrawable } } app/src/main/res/drawable/ic_rating_privacy_circle.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <!-- ~ Apps Quickly and easily install Android apps onto your device! ~ Copyright (C) 2021 E FOUNDATION ~ ~ 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 <https://www.gnu.org/licenses/>. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="11dp" android:height="11dp" android:viewportWidth="11" android:viewportHeight="11" android:tint="@color/colorAccent"> <path android:pathData="M5.2093,5.8407m-5.0443,0a5.0443,5.0443 0,1 1,10.0885 0a5.0443,5.0443 0,1 1,-10.0885 0" android:fillColor="@color/colorAccent"/> </vector> app/src/main/res/values/colors.xml +7 −1 Original line number Diff line number Diff line Loading @@ -32,4 +32,10 @@ <!-- Application Page--> <color name="app_info_text_color_grey">#A4AEB7</color> <!-- Rating Dot --> <color name="colorGreen">#34A853</color> <color name="colorRed">#FB3846</color> <color name="colorYellow">#FFEB3B</color> </resources> No newline at end of file Loading
app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +56 −4 Original line number Diff line number Diff line Loading @@ -20,12 +20,15 @@ package foundation.e.apps.application import android.content.Intent import android.graphics.Color import android.graphics.drawable.Drawable import android.os.Bundle import android.text.Html import android.util.Log import android.view.View import android.widget.ImageView import androidx.core.content.ContextCompat import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeCompat import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels Loading Loading @@ -233,11 +236,17 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { // Ratings widgets binding.ratingsInclude.apply { if (it.ratings.usageQualityScore != -1.0) { val rating = applicationViewModel.handleRatingFormat(it.ratings.usageQualityScore) appRating.text = getString( R.string.rating_out_of, applicationViewModel.handleRatingFormat(it.ratings.usageQualityScore) R.string.rating_out_of, rating ) appRating.setCompoundDrawablesWithIntrinsicBounds( null, null, getRatingDrawable(rating), null ) appRating.compoundDrawablePadding = 15 } appRatingLayout.setOnClickListener { ApplicationDialogFragment( Loading @@ -248,10 +257,16 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { } if (it.ratings.privacyScore != -1.0) { val privacyScore = it.ratings.privacyScore.toInt().toString() appPrivacyScore.text = getString( R.string.privacy_rating_out_of, it.ratings.privacyScore.toInt().toString() privacyScore ) appPrivacyScore.setCompoundDrawablesRelativeWithIntrinsicBounds( null, null, getPrivacyDrawable(privacyScore), null ) appPrivacyScore.compoundDrawablePadding = 15 } appPrivacyScoreLayout.setOnClickListener { ApplicationDialogFragment( Loading Loading @@ -319,7 +334,6 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { getString(R.string.trackers_title), trackers ).show(childFragmentManager, TAG) } } Loading Loading @@ -348,4 +362,42 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) { } return shareIntent } private fun getPrivacyDrawable(privacyRating: String): Drawable? { val rating = privacyRating.toInt() var dotColor = ContextCompat.getColor(requireContext(), R.color.colorGreen) if (rating <= 3) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorRed) } else if (rating <= 6) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorYellow) } return applyDotAccent(dotColor) } private fun getRatingDrawable(reviewRating: String): Drawable? { val rating = reviewRating.toDouble() var dotColor = ContextCompat.getColor(requireContext(), R.color.colorGreen) if (rating <= 2.0) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorRed) } else if (rating <= 3.4) { dotColor = ContextCompat.getColor(requireContext(), R.color.colorYellow) } return applyDotAccent(dotColor) } private fun applyDotAccent(dotColor: Int): Drawable? { val circleDrawable = ContextCompat.getDrawable(requireContext(), R.drawable.ic_rating_privacy_circle) circleDrawable?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat( dotColor, BlendModeCompat.SRC_ATOP ) return circleDrawable } }
app/src/main/res/drawable/ic_rating_privacy_circle.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <!-- ~ Apps Quickly and easily install Android apps onto your device! ~ Copyright (C) 2021 E FOUNDATION ~ ~ 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 <https://www.gnu.org/licenses/>. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="11dp" android:height="11dp" android:viewportWidth="11" android:viewportHeight="11" android:tint="@color/colorAccent"> <path android:pathData="M5.2093,5.8407m-5.0443,0a5.0443,5.0443 0,1 1,10.0885 0a5.0443,5.0443 0,1 1,-10.0885 0" android:fillColor="@color/colorAccent"/> </vector>
app/src/main/res/values/colors.xml +7 −1 Original line number Diff line number Diff line Loading @@ -32,4 +32,10 @@ <!-- Application Page--> <color name="app_info_text_color_grey">#A4AEB7</color> <!-- Rating Dot --> <color name="colorGreen">#34A853</color> <color name="colorRed">#FB3846</color> <color name="colorYellow">#FFEB3B</color> </resources> No newline at end of file