From beedafd0424d6f75c91475df5b95b3b9c3f87ccd Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 28 Oct 2024 15:33:42 -0300 Subject: [PATCH] Move AppCheckFragment into check package --- .../{settings => ui/check}/AppCheckFragment.kt | 15 +++++++-------- app/src/main/res/xml/settings.xml | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) rename app/src/main/java/com/stevesoltys/seedvault/{settings => ui/check}/AppCheckFragment.kt (86%) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/check/AppCheckFragment.kt similarity index 86% rename from app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt rename to app/src/main/java/com/stevesoltys/seedvault/ui/check/AppCheckFragment.kt index cea46c86..f6988b80 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/check/AppCheckFragment.kt @@ -3,22 +3,21 @@ * SPDX-License-Identifier: Apache-2.0 */ -package com.stevesoltys.seedvault.settings +package com.stevesoltys.seedvault.ui.check import android.os.Bundle -import android.text.format.Formatter.formatShortFileSize +import android.text.format.Formatter import android.view.LayoutInflater import android.view.View -import android.view.View.GONE -import android.view.View.VISIBLE import android.view.ViewGroup import android.widget.Button import android.widget.ScrollView import android.widget.TextView import androidx.fragment.app.Fragment -import com.google.android.material.slider.LabelFormatter.LABEL_VISIBLE +import com.google.android.material.slider.LabelFormatter import com.google.android.material.slider.Slider import com.stevesoltys.seedvault.R +import com.stevesoltys.seedvault.settings.SettingsViewModel import org.koin.androidx.viewmodel.ext.android.activityViewModel private const val WARN_PERCENT = 25 @@ -42,7 +41,7 @@ class AppCheckFragment : Fragment() { // label not scrolling will be fixed in material-components 1.12.0 (next update) slider.setLabelFormatter { value -> viewModel.backupSize.value?.let { - formatShortFileSize(context, (it * value / 100).toLong()) + Formatter.formatShortFileSize(context, (it * value / 100).toLong()) } ?: "${value.toInt()}%" } slider.addOnChangeListener { _, value, _ -> @@ -51,7 +50,7 @@ class AppCheckFragment : Fragment() { viewModel.backupSize.observe(viewLifecycleOwner) { if (it != null) { - slider.labelBehavior = LABEL_VISIBLE + slider.labelBehavior = LabelFormatter.LABEL_VISIBLE slider.invalidate() onSliderChanged(slider.value) } @@ -81,7 +80,7 @@ class AppCheckFragment : Fragment() { size * value / 100 > WARN_BYTES } // only update label visibility when different from before - val newVisibility = if (showWarning) VISIBLE else GONE + val newVisibility = if (showWarning) View.VISIBLE else View.GONE if (sliderLabel.visibility != newVisibility) { sliderLabel.visibility = newVisibility } diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 7b283fd9..0ab94037 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -51,7 +51,7 @@ tools:summary="Next backup: Never" />