Loading app/src/main/java/foundation/e/advancedprivacy/common/BigNumberFormatter.kt +12 −0 Original line number Diff line number Diff line Loading @@ -23,4 +23,16 @@ class BigNumberFormatter(context: Context) { private val formatter = NumberFormatter.withLocale(context.resources.configuration.locales[0]) fun format(number: Int): CharSequence = formatter.format(number) fun format(number: String?): CharSequence? { if (number == null) { return number } return try { formatter.format(number.toLong()) } catch (e: Exception) { number } } } app/src/main/java/foundation/e/advancedprivacy/features/weeklyreport/CallsAndLeaksViewFactory.kt +10 −3 Original line number Diff line number Diff line Loading @@ -26,11 +26,14 @@ import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.core.view.isVisible import foundation.e.advancedprivacy.R import foundation.e.advancedprivacy.common.BigNumberFormatter import foundation.e.advancedprivacy.databinding.WeeklyreportItemCallsAndLeaksBinding import foundation.e.advancedprivacy.domain.entities.weeklyreport.DisplayableReport import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReport class CallsAndLeaksViewFactory(private val context: Context) { private val numberFormatter: BigNumberFormatter by lazy { BigNumberFormatter(context) } fun getShareTitle(): CharSequence { return context.getString(R.string.weeklyreport_call_and_leaks_share_title) } Loading @@ -51,7 +54,7 @@ class CallsAndLeaksViewFactory(private val context: Context) { binding.secondaryValue.text = context.getString( R.string.weeklyreport_label_call_and_leaks_secondaryvalue, report.report.secondaryValues.firstOrNull() numberFormatter.format(report.report.secondaryValues.firstOrNull()) ) binding.description2.setText( Loading Loading @@ -81,7 +84,7 @@ class CallsAndLeaksViewFactory(private val context: Context) { binding.secondaryValue.text = context.getString( R.string.weeklyreport_label_call_and_leaks_secondaryvalue_sharing, report.report.secondaryValues.firstOrNull() numberFormatter.format(report.report.secondaryValues.firstOrNull()) ) binding.description2.setText( Loading Loading @@ -128,7 +131,11 @@ class CallsAndLeaksViewFactory(private val context: Context) { R.string.empty } return context.getString(descriptionId, report.report.primaryValue, *report.report.secondaryValues.toTypedArray()) return context.getString( descriptionId, report.report.primaryValue, numberFormatter.format(report.report.secondaryValues.firstOrNull()) ) } fun getIconForNotification(): Drawable? = null Loading app/src/main/java/foundation/e/advancedprivacy/features/weeklyreport/CallsPerAppViewFactory.kt +4 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.ViewGroup import androidx.core.text.buildSpannedString import androidx.core.text.inSpans import foundation.e.advancedprivacy.R import foundation.e.advancedprivacy.common.BigNumberFormatter import foundation.e.advancedprivacy.common.ChipSpan import foundation.e.advancedprivacy.databinding.WeeklyReportItemCallsPerAppBinding import foundation.e.advancedprivacy.databinding.WeeklyReportItemCallsPerAppForSharingBinding Loading @@ -32,6 +33,8 @@ import foundation.e.advancedprivacy.domain.entities.weeklyreport.DisplayableRepo import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReport class CallsPerAppViewFactory(private val context: Context) { private val numberFormatter: BigNumberFormatter by lazy { BigNumberFormatter(context) } fun getShareTitle(): CharSequence { return context.getString(R.string.weeklyreport_share_title_base) } Loading Loading @@ -107,7 +110,7 @@ class CallsPerAppViewFactory(private val context: Context) { report.app.label ) val counts = report.report.secondaryValues.firstOrNull() ?: "" val counts = numberFormatter.format(report.report.secondaryValues.firstOrNull()) ?: "" val desc2 = context.getString( when { Loading Loading
app/src/main/java/foundation/e/advancedprivacy/common/BigNumberFormatter.kt +12 −0 Original line number Diff line number Diff line Loading @@ -23,4 +23,16 @@ class BigNumberFormatter(context: Context) { private val formatter = NumberFormatter.withLocale(context.resources.configuration.locales[0]) fun format(number: Int): CharSequence = formatter.format(number) fun format(number: String?): CharSequence? { if (number == null) { return number } return try { formatter.format(number.toLong()) } catch (e: Exception) { number } } }
app/src/main/java/foundation/e/advancedprivacy/features/weeklyreport/CallsAndLeaksViewFactory.kt +10 −3 Original line number Diff line number Diff line Loading @@ -26,11 +26,14 @@ import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.core.view.isVisible import foundation.e.advancedprivacy.R import foundation.e.advancedprivacy.common.BigNumberFormatter import foundation.e.advancedprivacy.databinding.WeeklyreportItemCallsAndLeaksBinding import foundation.e.advancedprivacy.domain.entities.weeklyreport.DisplayableReport import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReport class CallsAndLeaksViewFactory(private val context: Context) { private val numberFormatter: BigNumberFormatter by lazy { BigNumberFormatter(context) } fun getShareTitle(): CharSequence { return context.getString(R.string.weeklyreport_call_and_leaks_share_title) } Loading @@ -51,7 +54,7 @@ class CallsAndLeaksViewFactory(private val context: Context) { binding.secondaryValue.text = context.getString( R.string.weeklyreport_label_call_and_leaks_secondaryvalue, report.report.secondaryValues.firstOrNull() numberFormatter.format(report.report.secondaryValues.firstOrNull()) ) binding.description2.setText( Loading Loading @@ -81,7 +84,7 @@ class CallsAndLeaksViewFactory(private val context: Context) { binding.secondaryValue.text = context.getString( R.string.weeklyreport_label_call_and_leaks_secondaryvalue_sharing, report.report.secondaryValues.firstOrNull() numberFormatter.format(report.report.secondaryValues.firstOrNull()) ) binding.description2.setText( Loading Loading @@ -128,7 +131,11 @@ class CallsAndLeaksViewFactory(private val context: Context) { R.string.empty } return context.getString(descriptionId, report.report.primaryValue, *report.report.secondaryValues.toTypedArray()) return context.getString( descriptionId, report.report.primaryValue, numberFormatter.format(report.report.secondaryValues.firstOrNull()) ) } fun getIconForNotification(): Drawable? = null Loading
app/src/main/java/foundation/e/advancedprivacy/features/weeklyreport/CallsPerAppViewFactory.kt +4 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.ViewGroup import androidx.core.text.buildSpannedString import androidx.core.text.inSpans import foundation.e.advancedprivacy.R import foundation.e.advancedprivacy.common.BigNumberFormatter import foundation.e.advancedprivacy.common.ChipSpan import foundation.e.advancedprivacy.databinding.WeeklyReportItemCallsPerAppBinding import foundation.e.advancedprivacy.databinding.WeeklyReportItemCallsPerAppForSharingBinding Loading @@ -32,6 +33,8 @@ import foundation.e.advancedprivacy.domain.entities.weeklyreport.DisplayableRepo import foundation.e.advancedprivacy.domain.entities.weeklyreport.WeeklyReport class CallsPerAppViewFactory(private val context: Context) { private val numberFormatter: BigNumberFormatter by lazy { BigNumberFormatter(context) } fun getShareTitle(): CharSequence { return context.getString(R.string.weeklyreport_share_title_base) } Loading Loading @@ -107,7 +110,7 @@ class CallsPerAppViewFactory(private val context: Context) { report.app.label ) val counts = report.report.secondaryValues.firstOrNull() ?: "" val counts = numberFormatter.format(report.report.secondaryValues.firstOrNull()) ?: "" val desc2 = context.getString( when { Loading