diff --git a/app/build.gradle b/app/build.gradle index df8c9d2..99ae0dd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.16.11' + implementation 'com.simplemobiletools:commons:3.17.19' debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt index 73fbed8..95fe147 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/activities/MainActivity.kt @@ -48,8 +48,6 @@ class MainActivity : SimpleActivity(), CanvasListener { private var isEraserOn = false private var isImageCaptureIntent = false - private var storedUseEnglish = false - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) @@ -74,15 +72,10 @@ class MainActivity : SimpleActivity(), CanvasListener { if (!isImageCaptureIntent) { checkWhatsNewDialog() } - storeStateVariables() } override fun onResume() { super.onResume() - if (storedUseEnglish != config.useEnglish) { - restartActivity() - return - } val isStrokeWidthBarEnabled = config.showBrushSize stroke_width_bar.beVisibleIf(isStrokeWidthBarEnabled) @@ -97,7 +90,6 @@ class MainActivity : SimpleActivity(), CanvasListener { super.onPause() config.brushColor = color config.brushSize = strokeWidth - storeStateVariables() if (config.preventPhoneFromSleeping) { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } @@ -134,10 +126,6 @@ class MainActivity : SimpleActivity(), CanvasListener { return true } - private fun storeStateVariables() { - storedUseEnglish = config.useEnglish - } - private fun launchSettings() { startActivity(Intent(applicationContext, SettingsActivity::class.java)) } diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/draw/activities/SettingsActivity.kt index 84ae64b..7f88996 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/activities/SettingsActivity.kt @@ -3,7 +3,6 @@ package com.simplemobiletools.draw.activities import android.os.Bundle import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.updateTextColors -import com.simplemobiletools.commons.extensions.useEnglishToggled import com.simplemobiletools.draw.R import com.simplemobiletools.draw.extensions.config import kotlinx.android.synthetic.main.activity_settings.* @@ -38,7 +37,7 @@ class SettingsActivity : SimpleActivity() { settings_use_english_holder.setOnClickListener { settings_use_english.toggle() config.useEnglish = settings_use_english.isChecked - useEnglishToggled() + System.exit(0) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt index f4c5fdd..6ccf1fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt @@ -1,7 +1,6 @@ package com.simplemobiletools.draw.dialogs import android.support.v7.app.AlertDialog -import android.view.WindowManager import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* @@ -40,40 +39,40 @@ class SaveImageDialog(val activity: SimpleActivity, val defaultExtension: String .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create().apply { - window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - activity.setupDialogStuff(view, this, R.string.save_as) { - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { - val filename = view.save_image_filename.value - if (filename.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) - return@setOnClickListener - } + activity.setupDialogStuff(view, this, R.string.save_as) { + showKeyboard(view.save_image_filename) + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + val filename = view.save_image_filename.value + if (filename.isEmpty()) { + activity.toast(R.string.filename_cannot_be_empty) + return@setOnClickListener + } - val extension = when (view.save_image_radio_group.checkedRadioButtonId) { - R.id.save_image_radio_png -> PNG - R.id.save_image_radio_svg -> SVG - else -> JPG - } + val extension = when (view.save_image_radio_group.checkedRadioButtonId) { + R.id.save_image_radio_png -> PNG + R.id.save_image_radio_svg -> SVG + else -> JPG + } - val newPath = "${folder.trimEnd('/')}/$filename.$extension" - if (!newPath.getFilenameFromPath().isAValidFilename()) { - activity.toast(R.string.filename_invalid_characters) - return@setOnClickListener - } + val newPath = "${folder.trimEnd('/')}/$filename.$extension" + if (!newPath.getFilenameFromPath().isAValidFilename()) { + activity.toast(R.string.filename_invalid_characters) + return@setOnClickListener + } - if (activity.getDoesFilePathExist(newPath)) { - val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newPath.getFilenameFromPath()) - ConfirmationDialog(activity, title) { - callback(newPath) - dismiss() + if (activity.getDoesFilePathExist(newPath)) { + val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newPath.getFilenameFromPath()) + ConfirmationDialog(activity, title) { + callback(newPath) + dismiss() + } + } else { + callback(newPath) + dismiss() + } } - } else { - callback(newPath) - dismiss() } } - } - } } private fun getInitialFilename(): String { diff --git a/app/src/main/res/layout/dialog_save_image.xml b/app/src/main/res/layout/dialog_save_image.xml index 557b7fb..9c58a79 100644 --- a/app/src/main/res/layout/dialog_save_image.xml +++ b/app/src/main/res/layout/dialog_save_image.xml @@ -6,7 +6,6 @@ android:layout_height="match_parent">