show the Recycle Bin content size at settings

This commit is contained in:
tibbi 2018-06-27 18:59:00 +02:00
parent 317089a4ff
commit b0cafd05c4
2 changed files with 29 additions and 9 deletions

View File

@ -6,17 +6,16 @@ import android.os.Bundle
import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.dialogs.SecurityDialog import com.simplemobiletools.commons.dialogs.SecurityDialog
import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.handleHiddenFolderPasswordProtection
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.helpers.PROTECTION_FINGERPRINT import com.simplemobiletools.commons.helpers.PROTECTION_FINGERPRINT
import com.simplemobiletools.commons.helpers.SHOW_ALL_TABS import com.simplemobiletools.commons.helpers.SHOW_ALL_TABS
import com.simplemobiletools.commons.helpers.sumByLong
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.dialogs.ManageExtendedDetailsDialog import com.simplemobiletools.gallery.dialogs.ManageExtendedDetailsDialog
import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin
import com.simplemobiletools.gallery.extensions.galleryDB
import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO
import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION
import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING
@ -424,8 +423,16 @@ class SettingsActivity : SimpleActivity() {
} }
private fun setupEmptyRecycleBin() { private fun setupEmptyRecycleBin() {
Thread {
val size = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size }
runOnUiThread {
settings_empty_recycle_bin_size.text = size.formatSize()
}
}.start()
settings_empty_recycle_bin_holder.setOnClickListener { settings_empty_recycle_bin_holder.setOnClickListener {
emptyTheRecycleBin() emptyTheRecycleBin()
settings_empty_recycle_bin_size.text = 0L.formatSize()
} }
} }
} }

View File

@ -989,20 +989,33 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin" android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/activity_margin" android:paddingBottom="@dimen/bigger_margin"
android:paddingLeft="@dimen/normal_margin" android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin" android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"> android:paddingTop="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_empty_recycle_bin" android:id="@+id/settings_empty_recycle_bin_label"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/settings_empty_recycle_bin_size"
android:layout_toStartOf="@+id/settings_empty_recycle_bin_size"
android:paddingLeft="@dimen/medium_margin" android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin" android:paddingRight="@dimen/medium_margin"
android:text="@string/empty_recycle_bin"/> android:text="@string/empty_recycle_bin"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_empty_recycle_bin_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin"
android:background="@null"
android:clickable="false"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>