Skip to content

Commit 153fd81

Browse files
committed
update commons to 3.18.9
1 parent f14bc3d commit 153fd81

File tree

13 files changed

+176
-161
lines changed

13 files changed

+176
-161
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ext {
4545
}
4646

4747
dependencies {
48-
implementation 'com.simplemobiletools:commons:3.13.9'
48+
implementation 'com.simplemobiletools:commons:3.18.9'
4949
implementation 'com.facebook.stetho:stetho:1.5.0'
5050

5151
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"

app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import android.view.MenuItem
1414
import com.simplemobiletools.commons.dialogs.FilePickerDialog
1515
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
1616
import com.simplemobiletools.commons.extensions.*
17-
import com.simplemobiletools.commons.helpers.*
17+
import com.simplemobiletools.commons.helpers.LICENSE_LEAK_CANARY
18+
import com.simplemobiletools.commons.helpers.LICENSE_RTL
19+
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
20+
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
1821
import com.simplemobiletools.commons.models.FAQItem
1922
import com.simplemobiletools.commons.models.FileDirItem
2023
import com.simplemobiletools.commons.models.RadioItem
@@ -44,7 +47,6 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
4447

4548
private var noteViewWithTextSelected: MyEditText? = null
4649
private var wasInit = false
47-
private var storedUseEnglish = false
4850
private var storedEnableLineWrap = true
4951
private var showSaveButton = false
5052
private var saveNoteButton: MenuItem? = null
@@ -84,11 +86,6 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
8486

8587
override fun onResume() {
8688
super.onResume()
87-
if (storedUseEnglish != config.useEnglish) {
88-
restartActivity()
89-
return
90-
}
91-
9289
if (storedEnableLineWrap != config.enableLineWrap) {
9390
initViewPager()
9491
}
@@ -173,7 +170,6 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
173170

174171
private fun storeStateVariables() {
175172
config.apply {
176-
storedUseEnglish = useEnglish
177173
storedEnableLineWrap = enableLineWrap
178174
}
179175
}
@@ -241,7 +237,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
241237
}
242238

243239
private fun displayRenameDialog() {
244-
RenameNoteDialog(this, dbHelper, mCurrentNote) {
240+
RenameNoteDialog(this, mCurrentNote) {
245241
mCurrentNote = it
246242
initViewPager()
247243
}
@@ -276,10 +272,10 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
276272
private fun launchAbout() {
277273
val faqItems = arrayListOf(
278274
FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons),
279-
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons),
280-
FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons)
275+
FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons),
276+
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons)
281277
)
282-
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_STETHO or LICENSE_RTL or LICENSE_LEAK_CANARY, BuildConfig.VERSION_NAME, faqItems)
278+
startAboutActivity(R.string.app_name, LICENSE_STETHO or LICENSE_RTL or LICENSE_LEAK_CANARY, BuildConfig.VERSION_NAME, faqItems)
283279
}
284280

285281
private fun tryOpenFile() {

app/src/main/kotlin/com/simplemobiletools/notes/activities/SettingsActivity.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.view.View
66
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
77
import com.simplemobiletools.commons.extensions.beVisibleIf
88
import com.simplemobiletools.commons.extensions.updateTextColors
9-
import com.simplemobiletools.commons.extensions.useEnglishToggled
109
import com.simplemobiletools.commons.models.RadioItem
1110
import com.simplemobiletools.notes.R
1211
import com.simplemobiletools.notes.extensions.config
@@ -61,7 +60,7 @@ class SettingsActivity : SimpleActivity() {
6160
settings_use_english_holder.setOnClickListener {
6261
settings_use_english.toggle()
6362
config.useEnglish = settings_use_english.isChecked
64-
useEnglishToggled()
63+
System.exit(0)
6564
}
6665
}
6766

app/src/main/kotlin/com/simplemobiletools/notes/activities/WidgetConfigureActivity.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,20 @@ class WidgetConfigureActivity : SimpleActivity() {
111111
}
112112

113113
private fun pickBackgroundColor() {
114-
ColorPickerDialog(this, mBgColorWithoutTransparency) {
115-
mBgColorWithoutTransparency = it
116-
updateBackgroundColor()
114+
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
115+
if (wasPositivePressed) {
116+
mBgColorWithoutTransparency = color
117+
updateBackgroundColor()
118+
}
117119
}
118120
}
119121

120122
private fun pickTextColor() {
121-
ColorPickerDialog(this, mTextColor) {
122-
mTextColor = it
123-
updateTextColor()
123+
ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
124+
if (wasPositivePressed) {
125+
mTextColor = color
126+
updateTextColor()
127+
}
124128
}
125129
}
126130

app/src/main/kotlin/com/simplemobiletools/notes/dialogs/DeleteNoteDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class DeleteNoteDialog(val activity: SimpleActivity, val note: Note, val callbac
2525
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed(view.delete_note_checkbox.isChecked) })
2626
.setNegativeButton(R.string.cancel, null)
2727
.create().apply {
28-
activity.setupDialogStuff(view, this)
29-
}
28+
activity.setupDialogStuff(view, this)
29+
}
3030
}
3131

3232
private fun dialogConfirmed(deleteFile: Boolean) {
Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.simplemobiletools.notes.dialogs
22

33
import android.support.v7.app.AlertDialog
4-
import android.view.WindowManager
54
import com.simplemobiletools.commons.dialogs.FilePickerDialog
65
import com.simplemobiletools.commons.extensions.*
76
import com.simplemobiletools.notes.R
@@ -32,29 +31,29 @@ class ExportFileDialog(val activity: SimpleActivity, val note: Note, val callbac
3231
.setPositiveButton(R.string.ok, null)
3332
.setNegativeButton(R.string.cancel, null)
3433
.create().apply {
35-
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
36-
activity.setupDialogStuff(view, this, R.string.export_as_file) {
37-
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
38-
val filename = view.file_name.value
39-
val extension = view.file_extension.value
40-
41-
if (filename.isEmpty()) {
42-
activity.toast(R.string.filename_cannot_be_empty)
43-
return@setOnClickListener
34+
activity.setupDialogStuff(view, this, R.string.export_as_file) {
35+
showKeyboard(view.file_name)
36+
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
37+
val filename = view.file_name.value
38+
val extension = view.file_extension.value
39+
40+
if (filename.isEmpty()) {
41+
activity.toast(R.string.filename_cannot_be_empty)
42+
return@setOnClickListener
43+
}
44+
45+
val fullFilename = if (extension.isEmpty()) filename else "$filename.$extension"
46+
if (!fullFilename.isAValidFilename()) {
47+
activity.toast(String.format(activity.getString(R.string.filename_invalid_characters_placeholder, fullFilename)))
48+
return@setOnClickListener
49+
}
50+
51+
activity.config.lastUsedExtension = extension
52+
activity.config.lastUsedSavePath = realPath
53+
callback("$realPath/$fullFilename")
54+
dismiss()
55+
}
4456
}
45-
46-
val fullFilename = if (extension.isEmpty()) filename else "$filename.$extension"
47-
if (!fullFilename.isAValidFilename()) {
48-
activity.toast(String.format(activity.getString(R.string.filename_invalid_characters_placeholder, fullFilename)))
49-
return@setOnClickListener
50-
}
51-
52-
activity.config.lastUsedExtension = extension
53-
activity.config.lastUsedSavePath = realPath
54-
callback("$realPath/$fullFilename")
55-
dismiss()
5657
}
57-
}
58-
}
5958
}
6059
}

app/src/main/kotlin/com/simplemobiletools/notes/dialogs/ExportFilesDialog.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.simplemobiletools.notes.dialogs
22

33
import android.support.v7.app.AlertDialog
4-
import android.view.WindowManager
54
import com.simplemobiletools.commons.dialogs.FilePickerDialog
65
import com.simplemobiletools.commons.extensions.humanizePath
76
import com.simplemobiletools.commons.extensions.setupDialogStuff
7+
import com.simplemobiletools.commons.extensions.showKeyboard
88
import com.simplemobiletools.commons.extensions.value
99
import com.simplemobiletools.notes.R
1010
import com.simplemobiletools.notes.activities.SimpleActivity
@@ -31,18 +31,18 @@ class ExportFilesDialog(val activity: SimpleActivity, val notes: ArrayList<Note>
3131
.setPositiveButton(R.string.ok, null)
3232
.setNegativeButton(R.string.cancel, null)
3333
.create().apply {
34-
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
35-
activity.setupDialogStuff(view, this, R.string.export_as_file) {
36-
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
37-
activity.handleSAFDialog(realPath) {
38-
val extension = view.file_extension.value
39-
activity.config.lastUsedExtension = extension
40-
activity.config.lastUsedSavePath = realPath
41-
callback(realPath, extension)
42-
dismiss()
34+
activity.setupDialogStuff(view, this, R.string.export_as_file) {
35+
showKeyboard(view.file_extension)
36+
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
37+
activity.handleSAFDialog(realPath) {
38+
val extension = view.file_extension.value
39+
activity.config.lastUsedExtension = extension
40+
activity.config.lastUsedSavePath = realPath
41+
callback(realPath, extension)
42+
dismiss()
43+
}
44+
}
4345
}
4446
}
45-
}
46-
}
4747
}
4848
}

app/src/main/kotlin/com/simplemobiletools/notes/dialogs/NewNoteDialog.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package com.simplemobiletools.notes.dialogs
33
import android.app.Activity
44
import android.content.DialogInterface.BUTTON_POSITIVE
55
import android.support.v7.app.AlertDialog
6-
import android.view.WindowManager
76
import com.simplemobiletools.commons.extensions.setupDialogStuff
7+
import com.simplemobiletools.commons.extensions.showKeyboard
88
import com.simplemobiletools.commons.extensions.toast
99
import com.simplemobiletools.commons.extensions.value
1010
import com.simplemobiletools.notes.R
@@ -19,20 +19,20 @@ class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title:
1919
.setPositiveButton(R.string.ok, null)
2020
.setNegativeButton(R.string.cancel, null)
2121
.create().apply {
22-
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
23-
activity.setupDialogStuff(view, this, R.string.new_note) {
24-
getButton(BUTTON_POSITIVE).setOnClickListener {
25-
val title = view.note_name.value
26-
when {
27-
title.isEmpty() -> activity.toast(R.string.no_title)
28-
db.doesTitleExist(title) -> activity.toast(R.string.title_taken)
29-
else -> {
30-
callback(title)
31-
dismiss()
22+
activity.setupDialogStuff(view, this, R.string.new_note) {
23+
showKeyboard(view.note_name)
24+
getButton(BUTTON_POSITIVE).setOnClickListener {
25+
val title = view.note_name.value
26+
when {
27+
title.isEmpty() -> activity.toast(R.string.no_title)
28+
db.doesTitleExist(title) -> activity.toast(R.string.title_taken)
29+
else -> {
30+
callback(title)
31+
dismiss()
32+
}
33+
}
3234
}
3335
}
3436
}
35-
}
36-
}
3737
}
3838
}

app/src/main/kotlin/com/simplemobiletools/notes/dialogs/OpenFileDialog.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
2525
.setPositiveButton(R.string.ok, null)
2626
.setNegativeButton(R.string.cancel, null)
2727
.create().apply {
28-
activity.setupDialogStuff(view, this, R.string.open_file) {
29-
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
30-
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == open_file_update_file
31-
val storePath = if (updateFileOnEdit) path else ""
32-
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
28+
activity.setupDialogStuff(view, this, R.string.open_file) {
29+
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
30+
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == open_file_update_file
31+
val storePath = if (updateFileOnEdit) path else ""
32+
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
3333

34-
if (updateFileOnEdit) {
35-
activity.handleSAFDialog(path) {
36-
saveNote(storeContent, storePath)
34+
if (updateFileOnEdit) {
35+
activity.handleSAFDialog(path) {
36+
saveNote(storeContent, storePath)
37+
}
38+
} else {
39+
saveNote(storeContent, storePath)
40+
}
3741
}
38-
} else {
39-
saveNote(storeContent, storePath)
4042
}
4143
}
42-
}
43-
}
4444
}
4545

4646
private fun saveNote(storeContent: String, storePath: String) {

app/src/main/kotlin/com/simplemobiletools/notes/dialogs/OpenNoteDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> U
4747

4848
dialog = AlertDialog.Builder(activity)
4949
.create().apply {
50-
activity.setupDialogStuff(view, this, R.string.pick_a_note)
51-
}
50+
activity.setupDialogStuff(view, this, R.string.pick_a_note)
51+
}
5252
}
5353
}

0 commit comments

Comments
 (0)