diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/AppDetailFragment.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/AppDetailFragment.kt index 6c5024ff..f28d93ce 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/AppDetailFragment.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/AppDetailFragment.kt @@ -21,7 +21,6 @@ import org.eu.exodus_privacy.exodusprivacy.R import org.eu.exodus_privacy.exodusprivacy.databinding.FragmentAppDetailBinding import org.eu.exodus_privacy.exodusprivacy.fragments.appdetail.model.AppDetailVPAdapter import org.eu.exodus_privacy.exodusprivacy.utils.openURL -import org.eu.exodus_privacy.exodusprivacy.utils.setExodusColor import javax.inject.Inject @AndroidEntryPoint @@ -164,16 +163,6 @@ class AppDetailFragment : Fragment(R.layout.fragment_app_detail) { } else { appReportTV.visibility = View.GONE } - trackersChip.apply { - val trackerNum = app.exodusTrackers.size - text = if (app.exodusVersionCode == 0L) "?" else trackerNum.toString() - setExodusColor(trackerNum) - } - permsChip.apply { - val permsNum = app.permissions.size - text = permsNum.toString() - setExodusColor(permsNum) - } sourceChip.text = app.source.name.lowercase().replaceFirstChar { it.uppercase() } diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADPermissionsFragment.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADPermissionsFragment.kt index 8ec26549..ad082399 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADPermissionsFragment.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADPermissionsFragment.kt @@ -55,8 +55,8 @@ class ADPermissionsFragment : Fragment(R.layout.fragment_a_d_permissions) { permissionsStatusTV.text = getString(R.string.code_permission_found) } permissionsChip.apply { - val permsNum = app.permissions.size - text = permsNum.toString() + val permsNum = app.permissions.size.toString() + text = permsNum setExodusColor(permsNum) } permissionsLearnGoogleTV.apply { diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADTrackersFragment.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADTrackersFragment.kt index 5f9557a5..ee488b44 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADTrackersFragment.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/appdetail/subfrags/ADTrackersFragment.kt @@ -48,8 +48,9 @@ class ADTrackersFragment : Fragment(R.layout.fragment_a_d_trackers) { } } trackersChip.apply { - val trackerNum = app.exodusTrackers.size - text = if (app.exodusVersionCode == 0L) "?" else trackerNum.toString() + val trackerNum = + if (app.exodusVersionCode == 0L) "?" else app.exodusTrackers.size.toString() + text = trackerNum setExodusColor(trackerNum) } trackersLearnTV.apply { diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/model/AppsRVAdapter.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/model/AppsRVAdapter.kt index 9369f881..47332250 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/model/AppsRVAdapter.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/model/AppsRVAdapter.kt @@ -64,13 +64,14 @@ class AppsRVAdapter( } } trackersChip.apply { - val trackerNum = app.exodusTrackers.size - text = if (app.exodusVersionCode == 0L) "?" else trackerNum.toString() + val trackerNum = + if (app.exodusVersionCode == 0L) "?" else app.exodusTrackers.size.toString() + text = trackerNum setExodusColor(trackerNum) } permsChip.apply { - val permsNum = app.permissions.size - text = permsNum.toString() + val permsNum = app.permissions.size.toString() + text = permsNum setExodusColor(permsNum) } } diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt index c3a5061f..34df9958 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt @@ -9,46 +9,44 @@ import android.content.res.ColorStateList import android.os.Build import android.widget.Toast import androidx.core.content.ContextCompat +import androidx.core.text.isDigitsOnly import com.google.android.material.chip.Chip import org.eu.exodus_privacy.exodusprivacy.R import java.util.Locale -fun Chip.setExodusColor(size: Int) { - if (this.text != "?") { +fun Chip.setExodusColor(size: String) { + val textColorStateList: ColorStateList + val backgroundColorStateList: ColorStateList + if (size.isDigitsOnly()) { val colorRed = ContextCompat.getColor(context, R.color.colorRedLight) val colorYellow = ContextCompat.getColor(context, R.color.colorYellow) val colorGreen = ContextCompat.getColor(context, R.color.colorGreen) val colorDark = ContextCompat.getColor(context, R.color.textColorDark) val colorWhite = ContextCompat.getColor(context, R.color.textColorLikeWhite) - val textColorStateList = when (size) { + textColorStateList = when (size.toInt()) { 0 -> ColorStateList.valueOf(colorDark) in 1..4 -> ColorStateList.valueOf(colorDark) else -> ColorStateList.valueOf(colorWhite) } - val backgroundColorStateList = when (size) { + backgroundColorStateList = when (size.toInt()) { 0 -> ColorStateList.valueOf(colorGreen) in 1..4 -> ColorStateList.valueOf(colorYellow) else -> ColorStateList.valueOf(colorRed) } - - this.chipIconTint = textColorStateList - this.setTextColor(textColorStateList) - this.chipBackgroundColor = backgroundColorStateList } else { - val colorForeground = + textColorStateList = ColorStateList.valueOf( ContextCompat.getColor( context, com.google.android.material.R.color.m3_chip_text_color, ), ) - this.chipIconTint = colorForeground - this.setTextColor(colorForeground) - val colorBackground = ContextCompat.getColor(context, R.color.chipColor) - this.chipBackgroundColor = ColorStateList.valueOf(colorBackground) + backgroundColorStateList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.chipColor)) } + this.setTextColor(textColorStateList) + this.chipBackgroundColor = backgroundColorStateList } fun getLanguage(): String { diff --git a/app/src/main/res/layout/fragment_a_d_permissions.xml b/app/src/main/res/layout/fragment_a_d_permissions.xml index 794632df..71c05134 100644 --- a/app/src/main/res/layout/fragment_a_d_permissions.xml +++ b/app/src/main/res/layout/fragment_a_d_permissions.xml @@ -1,6 +1,6 @@ - @@ -29,6 +27,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" + android:layout_gravity="center" android:maxLines="1" android:text="@string/permissions" android:textColor="?android:textColorPrimary" diff --git a/app/src/main/res/layout/fragment_a_d_trackers.xml b/app/src/main/res/layout/fragment_a_d_trackers.xml index b7920d00..df0190be 100644 --- a/app/src/main/res/layout/fragment_a_d_trackers.xml +++ b/app/src/main/res/layout/fragment_a_d_trackers.xml @@ -1,5 +1,6 @@ - - - - + android:id="@+id/appNameTV" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="15dp" + android:layout_marginTop="10dp" + android:layout_marginRight="15dp" + android:ellipsize="end" + android:maxLines="2" + android:textAlignment="center" + android:textColor="?android:textColorPrimary" + android:textSize="22sp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/appIconIV" + tools:text="@string/app_name" /> - - - + android:id="@+id/sourceChip" + style="@style/Theme.Exodus.Chip" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="5dp" + android:layout_marginTop="10dp" + app:chipIcon="@drawable/ic_android" + app:layout_constraintBottom_toTopOf="@+id/appIVTV" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/appNameTV" + app:layout_constraintVertical_bias="0.5" + tools:text="Google" /> + + diff --git a/app/src/main/res/layout/shimmer_layout_app_item.xml b/app/src/main/res/layout/shimmer_layout_app_item.xml index c3d19909..83f8d33c 100644 --- a/app/src/main/res/layout/shimmer_layout_app_item.xml +++ b/app/src/main/res/layout/shimmer_layout_app_item.xml @@ -56,8 +56,6 @@ android:layout_marginStart="10dp" android:layout_marginTop="8dp" app:chipBackgroundColor="@color/colorGrey" - app:chipIcon="@drawable/ic_tracker" - app:chipIconTint="@color/colorGrey" app:layout_constraintStart_toEndOf="@id/appIconIV" app:layout_constraintTop_toBottomOf="@id/appVersionTV" /> @@ -69,8 +67,6 @@ android:layout_marginStart="10dp" android:layout_marginTop="8dp" app:chipBackgroundColor="@color/colorGrey" - app:chipIcon="@drawable/ic_permission" - app:chipIconTint="@color/colorGrey" app:layout_constraintStart_toEndOf="@id/trackersChip" app:layout_constraintTop_toBottomOf="@id/appVersionTV" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c251bf7e..0dd31445 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -14,7 +14,7 @@ @color/chipIconTintColor @color/chipColor @color/chipIconTintColor - 50dp + 20dp true false