adding a Settings button for emptying the recycle bin
This commit is contained in:
parent
b0c4ba7d99
commit
317089a4ff
3 changed files with 34 additions and 2 deletions
|
@ -16,6 +16,7 @@ import com.simplemobiletools.commons.models.RadioItem
|
|||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.dialogs.ManageExtendedDetailsDialog
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin
|
||||
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_SYSTEM_SETTING
|
||||
|
@ -71,6 +72,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
updateTextColors(settings_holder)
|
||||
setupSectionColors()
|
||||
setupUseRecycleBin()
|
||||
setupEmptyRecycleBin()
|
||||
}
|
||||
|
||||
private fun setupSectionColors() {
|
||||
|
@ -412,10 +414,18 @@ class SettingsActivity : SimpleActivity() {
|
|||
})
|
||||
|
||||
private fun setupUseRecycleBin() {
|
||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
settings_use_recycle_bin.isChecked = config.useRecycleBin
|
||||
settings_use_recycle_bin_holder.setOnClickListener {
|
||||
settings_use_recycle_bin.toggle()
|
||||
config.useRecycleBin = settings_use_recycle_bin.isChecked
|
||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupEmptyRecycleBin() {
|
||||
settings_empty_recycle_bin_holder.setOnClickListener {
|
||||
emptyTheRecycleBin()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,13 +205,13 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, callback:
|
|||
}.start()
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.emptyTheRecycleBin(callback: () -> Unit) {
|
||||
fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) {
|
||||
Thread {
|
||||
filesDir.deleteRecursively()
|
||||
galleryDB.MediumDao().clearRecycleBin()
|
||||
galleryDB.DirectoryDao().deleteRecycleBin()
|
||||
toast(R.string.recycle_bin_emptied)
|
||||
callback()
|
||||
callback?.invoke()
|
||||
}.start()
|
||||
}
|
||||
|
||||
|
|
|
@ -982,5 +982,27 @@
|
|||
android:text="@string/move_items_into_recycle_bin"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_empty_recycle_bin_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_empty_recycle_bin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/empty_recycle_bin"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in a new issue