From 0efab3ef606770b33900abf5f72c5342d0ccbc46 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 19 Dec 2016 23:47:18 +0100 Subject: [PATCH] updating the dialog colors --- .../gallery/activities/SettingsActivity.kt | 1 + .../gallery/dialogs/ChangeSortingDialog.kt | 23 +++++++------- .../gallery/dialogs/CopyDialog.kt | 15 +++++----- .../gallery/dialogs/PickAlbumDialog.kt | 30 +++++++++---------- .../gallery/dialogs/RenameDirectoryDialog.kt | 11 ++++--- .../gallery/dialogs/RenameFileDialog.kt | 10 +++---- .../gallery/dialogs/ResizeDialog.kt | 7 ++--- .../gallery/dialogs/SaveAsDialog.kt | 7 ++--- .../main/res/layout/dialog_change_sorting.xml | 12 ++++---- app/src/main/res/layout/dialog_copy_move.xml | 4 +-- app/src/main/res/layout/rename_file.xml | 13 ++++---- 11 files changed, 66 insertions(+), 67 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index b78657e38..27279d7a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.activities import android.os.Bundle import android.view.View import android.widget.AdapterView +import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.gallery.R import kotlinx.android.synthetic.main.activity_settings.* diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt index 337b3afac..8d998203e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt @@ -1,35 +1,34 @@ package com.simplemobiletools.gallery.dialogs -import android.app.Activity -import android.app.AlertDialog import android.content.DialogInterface +import android.support.v7.app.AlertDialog import android.view.LayoutInflater -import android.view.View +import android.view.ViewGroup +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.helpers.* import kotlinx.android.synthetic.main.dialog_change_sorting.view.* -class ChangeSortingDialog(val activity: Activity, val isDirectorySorting: Boolean, val callback: () -> Unit) : DialogInterface.OnClickListener { +class ChangeSortingDialog(val activity: SimpleActivity, val isDirectorySorting: Boolean, val callback: () -> Unit) : DialogInterface.OnClickListener { companion object { private var currSorting = 0 lateinit var config: Config - lateinit var view: View + lateinit var view: ViewGroup } init { config = Config.newInstance(activity) - view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null) + view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null) as ViewGroup - val dialog = AlertDialog.Builder(activity) - .setTitle(R.string.sort_by) + AlertDialog.Builder(activity) .setView(view) .setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, null) - .create() - - dialog.setCanceledOnTouchOutside(true) - dialog.show() + .create().apply { + activity.setupDialogStuff(view, this, R.string.sort_by) + } currSorting = if (isDirectorySorting) config.directorySorting else config.sorting setupSortRadio() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt index ca513a4fb..87e7c57fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt @@ -1,9 +1,10 @@ package com.simplemobiletools.gallery.dialogs -import android.app.AlertDialog import android.support.v4.util.Pair +import android.support.v7.app.AlertDialog import android.view.LayoutInflater -import android.view.WindowManager +import android.view.ViewGroup +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask import com.simplemobiletools.filepicker.extensions.humanizePath import com.simplemobiletools.filepicker.extensions.isPathOnSD @@ -17,9 +18,12 @@ import java.io.File import java.util.* class CopyDialog(val activity: SimpleActivity, val files: ArrayList, val copyMoveListener: CopyMoveTask.CopyMoveListener) { + companion object { + lateinit var view: ViewGroup + } init { - val view = LayoutInflater.from(activity).inflate(R.layout.dialog_copy_move, null) + view = LayoutInflater.from(activity).inflate(R.layout.dialog_copy_move, null) as ViewGroup val sourcePath = files[0].parent.trimEnd('/') var destinationPath = "" @@ -33,14 +37,11 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList, val c } AlertDialog.Builder(activity) - .setTitle(R.string.copy_move) .setView(view) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create().apply { - window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - setCanceledOnTouchOutside(true) - show() + activity.setupDialogStuff(view, this, R.string.copy_move) getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ if (destinationPath == context.resources.getString(R.string.select_destination) || destinationPath.isEmpty()) { context.toast(R.string.please_select_destination) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt index 3bb451b05..3960d80ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt @@ -1,9 +1,11 @@ package com.simplemobiletools.gallery.dialogs -import android.app.AlertDialog import android.os.Environment +import android.support.v7.app.AlertDialog import android.support.v7.widget.RecyclerView import android.view.LayoutInflater +import android.view.ViewGroup +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.filepicker.dialogs.FilePickerDialog import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity @@ -14,29 +16,27 @@ import kotlinx.android.synthetic.main.dialog_album_picker.view.* import java.util.* class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String) -> Unit) { - var dialog: AlertDialog var directoriesGrid: RecyclerView init { - val view = LayoutInflater.from(activity).inflate(R.layout.dialog_album_picker, null) + val view = LayoutInflater.from(activity).inflate(R.layout.dialog_album_picker, null) as ViewGroup directoriesGrid = view.directories_grid - dialog = AlertDialog.Builder(activity) - .setTitle(R.string.select_destination) + AlertDialog.Builder(activity) .setView(view) .setNeutralButton(R.string.other_folder, { dialogInterface, i -> showOtherFolder() }) .setPositiveButton(R.string.ok, null) - .create() + .create().apply { + activity.setupDialogStuff(view, this, R.string.select_destination) - dialog.setCanceledOnTouchOutside(true) - dialog.show() - GetDirectoriesAsynctask(activity, false, false, ArrayList()) { - val adapter = DirectoryAdapter(activity, it, null) { - callback.invoke(it.path) - dialog.dismiss() - } - directoriesGrid.adapter = adapter - }.execute() + GetDirectoriesAsynctask(activity, false, false, ArrayList()) { + val adapter = DirectoryAdapter(activity, it, null) { + callback.invoke(it.path) + dismiss() + } + directoriesGrid.adapter = adapter + }.execute() + } } fun showOtherFolder() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt index 296bc5277..cacc2dc53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt @@ -1,8 +1,10 @@ package com.simplemobiletools.gallery.dialogs -import android.app.AlertDialog +import android.support.v7.app.AlertDialog import android.view.LayoutInflater +import android.view.ViewGroup import android.view.WindowManager +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity @@ -13,20 +15,17 @@ import java.util.* class RenameDirectoryDialog(val activity: SimpleActivity, val dir: File, val callback: (changedPaths: ArrayList) -> Unit) { init { - val view = LayoutInflater.from(activity).inflate(R.layout.rename_directory, null) - + val view = LayoutInflater.from(activity).inflate(R.layout.rename_directory, null) as ViewGroup view.directory_name.setText(dir.name) view.directory_path.text = "${activity.humanizePath(dir.parent)}/" AlertDialog.Builder(activity) - .setTitle(R.string.rename_folder) .setView(view) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - setCanceledOnTouchOutside(true) - show() + activity.setupDialogStuff(view, this, R.string.rename_folder) getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val newDirName = view.directory_name.value if (newDirName.isEmpty()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt index 75dae5ca1..e331d697b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt @@ -1,8 +1,10 @@ package com.simplemobiletools.gallery.dialogs -import android.app.AlertDialog +import android.support.v7.app.AlertDialog import android.view.LayoutInflater +import android.view.ViewGroup import android.view.WindowManager +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity @@ -13,7 +15,7 @@ import java.io.File class RenameFileDialog(val activity: SimpleActivity, val file: File, val callback: (newFile: File) -> Unit) { init { - val view = LayoutInflater.from(activity).inflate(R.layout.rename_file, null) + val view = LayoutInflater.from(activity).inflate(R.layout.rename_file, null) as ViewGroup val fullName = file.name val dotAt = fullName.lastIndexOf(".") var name = fullName @@ -28,14 +30,12 @@ class RenameFileDialog(val activity: SimpleActivity, val file: File, val callbac view.file_path.text = "${activity.humanizePath(file.parent)}/" AlertDialog.Builder(activity) - .setTitle(R.string.rename_file) .setView(view) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - setCanceledOnTouchOutside(true) - show() + activity.setupDialogStuff(view, this, R.string.rename_file) getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val filename = view.file_name.value val extension = view.file_extension.value diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt index 0e71dcc81..fb156fb7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt @@ -1,12 +1,13 @@ package com.simplemobiletools.gallery.dialogs -import android.app.AlertDialog import android.graphics.Point +import android.support.v7.app.AlertDialog import android.text.Editable import android.text.TextWatcher import android.view.LayoutInflater import android.view.WindowManager import android.widget.EditText +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.filepicker.extensions.toast import com.simplemobiletools.filepicker.extensions.value import com.simplemobiletools.gallery.R @@ -69,14 +70,12 @@ class ResizeDialog(val activity: SimpleActivity, val size: Point, val callback: }) AlertDialog.Builder(activity) - .setTitle(R.string.resize_and_save) .setView(view) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - setCanceledOnTouchOutside(true) - show() + activity.setupDialogStuff(view, this, R.string.resize_and_save) getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val width = getViewValue(widthView) val height = getViewValue(heightView) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt index fda4ae24b..545f0ddf3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -1,9 +1,10 @@ package com.simplemobiletools.gallery.dialogs import android.app.Activity -import android.app.AlertDialog +import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.WindowManager +import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.filepicker.dialogs.FilePickerDialog import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.gallery.R @@ -43,14 +44,12 @@ class SaveAsDialog(val activity: Activity, val path: String, val callback: (save } AlertDialog.Builder(activity) - .setTitle(R.string.save_as) .setView(view) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - setCanceledOnTouchOutside(true) - show() + activity.setupDialogStuff(view, this, R.string.save_as) getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val filename = view.file_name.value val extension = view.file_extension.value diff --git a/app/src/main/res/layout/dialog_change_sorting.xml b/app/src/main/res/layout/dialog_change_sorting.xml index a820f3dfa..50df73f4d 100644 --- a/app/src/main/res/layout/dialog_change_sorting.xml +++ b/app/src/main/res/layout/dialog_change_sorting.xml @@ -19,7 +19,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - - - - - - +