show the warning at deleting a folder in red

This commit is contained in:
tibbi 2019-05-26 20:37:35 +02:00
parent 598fa1e949
commit a9cf7f9d8c
3 changed files with 63 additions and 3 deletions

View file

@ -23,6 +23,7 @@ import com.simplemobiletools.commons.views.FastScroller
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.activities.MediaActivity 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.ExcludeFolderDialog
import com.simplemobiletools.gallery.pro.dialogs.PickMediumDialog import com.simplemobiletools.gallery.pro.dialogs.PickMediumDialog
import com.simplemobiletools.gallery.pro.extensions.* 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 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) val warning = resources.getQuantityString(R.plurals.delete_warning, itemsCnt, itemsCnt)
question += "\n\n$warning" ConfirmDeleteFolderDialog(activity, question, warning) {
ConfirmationDialog(activity, question) {
deleteFolders() deleteFolders()
} }
} }

View file

@ -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()
}
}

View 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>