mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
show the warning at deleting a folder in red
This commit is contained in:
parent
598fa1e949
commit
a9cf7f9d8c
3 changed files with 63 additions and 3 deletions
|
@ -23,6 +23,7 @@ import com.simplemobiletools.commons.views.FastScroller
|
|||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import com.simplemobiletools.gallery.pro.activities.MediaActivity
|
||||
import com.simplemobiletools.gallery.pro.dialogs.ConfirmDeleteFolderDialog
|
||||
import com.simplemobiletools.gallery.pro.dialogs.ExcludeFolderDialog
|
||||
import com.simplemobiletools.gallery.pro.dialogs.PickMediumDialog
|
||||
import com.simplemobiletools.gallery.pro.extensions.*
|
||||
|
@ -399,10 +400,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
R.string.move_to_recycle_bin_confirmation
|
||||
}
|
||||
|
||||
var question = String.format(resources.getString(baseString), items)
|
||||
val question = String.format(resources.getString(baseString), items)
|
||||
val warning = resources.getQuantityString(R.plurals.delete_warning, itemsCnt, itemsCnt)
|
||||
question += "\n\n$warning"
|
||||
ConfirmationDialog(activity, question) {
|
||||
ConfirmDeleteFolderDialog(activity, question, warning) {
|
||||
deleteFolders()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.simplemobiletools.gallery.pro.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import kotlinx.android.synthetic.main.dialog_confirm_delete_folder.view.*
|
||||
|
||||
class ConfirmDeleteFolderDialog(activity: Activity, message: String, warningMessage: String, val callback: () -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_confirm_delete_folder, null)
|
||||
view.message.text = message
|
||||
view.message_warning.text = warningMessage
|
||||
|
||||
val builder = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() }
|
||||
|
||||
builder.setNegativeButton(R.string.no, null)
|
||||
|
||||
dialog = builder.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
dialog.dismiss()
|
||||
callback()
|
||||
}
|
||||
}
|
29
app/src/main/res/layout/dialog_confirm_delete_folder.xml
Normal file
29
app/src/main/res/layout/dialog_confirm_delete_folder.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_confirm_delete_folder_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/big_margin"
|
||||
android:paddingTop="@dimen/big_margin"
|
||||
android:paddingRight="@dimen/big_margin"
|
||||
android:textSize="@dimen/bigger_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message_warning"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/message"
|
||||
android:paddingLeft="@dimen/big_margin"
|
||||
android:paddingTop="@dimen/big_margin"
|
||||
android:paddingRight="@dimen/big_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:textColor="@color/md_red_700"
|
||||
android:textSize="@dimen/bigger_text_size"/>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue