mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-19 17:57:27 +02:00
update commons to 3.0.21
This commit is contained in:
parent
af7f5408cf
commit
dba8871459
@ -47,7 +47,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.0.9'
|
implementation 'com.simplemobiletools:commons:3.0.21'
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
|
|
||||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||||
|
@ -2,10 +2,9 @@ package com.simplemobiletools.notes
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.facebook.stetho.Stetho
|
import com.facebook.stetho.Stetho
|
||||||
|
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
||||||
import com.simplemobiletools.notes.BuildConfig.USE_LEAK_CANARY
|
import com.simplemobiletools.notes.BuildConfig.USE_LEAK_CANARY
|
||||||
import com.simplemobiletools.notes.extensions.config
|
|
||||||
import com.squareup.leakcanary.LeakCanary
|
import com.squareup.leakcanary.LeakCanary
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class App : Application() {
|
class App : Application() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
@ -17,11 +16,7 @@ class App : Application() {
|
|||||||
LeakCanary.install(this)
|
LeakCanary.install(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.useEnglish) {
|
checkUseEnglish()
|
||||||
val conf = resources.configuration
|
|
||||||
conf.locale = Locale.ENGLISH
|
|
||||||
resources.updateConfiguration(conf, resources.displayMetrics)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
Stetho.initializeWithDefaults(this)
|
Stetho.initializeWithDefaults(this)
|
||||||
|
@ -25,7 +25,6 @@ import com.simplemobiletools.notes.extensions.config
|
|||||||
import com.simplemobiletools.notes.extensions.dbHelper
|
import com.simplemobiletools.notes.extensions.dbHelper
|
||||||
import com.simplemobiletools.notes.extensions.getTextSize
|
import com.simplemobiletools.notes.extensions.getTextSize
|
||||||
import com.simplemobiletools.notes.extensions.updateWidget
|
import com.simplemobiletools.notes.extensions.updateWidget
|
||||||
import com.simplemobiletools.notes.helpers.DBHelper
|
|
||||||
import com.simplemobiletools.notes.helpers.MIME_TEXT_PLAIN
|
import com.simplemobiletools.notes.helpers.MIME_TEXT_PLAIN
|
||||||
import com.simplemobiletools.notes.helpers.OPEN_NOTE_ID
|
import com.simplemobiletools.notes.helpers.OPEN_NOTE_ID
|
||||||
import com.simplemobiletools.notes.helpers.TYPE_NOTE
|
import com.simplemobiletools.notes.helpers.TYPE_NOTE
|
||||||
@ -38,7 +37,6 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
private var mAdapter: NotesPagerAdapter? = null
|
private var mAdapter: NotesPagerAdapter? = null
|
||||||
|
|
||||||
lateinit var mCurrentNote: Note
|
lateinit var mCurrentNote: Note
|
||||||
lateinit var mDb: DBHelper
|
|
||||||
lateinit var mNotes: List<Note>
|
lateinit var mNotes: List<Note>
|
||||||
|
|
||||||
private var noteViewWithTextSelected: MyEditText? = null
|
private var noteViewWithTextSelected: MyEditText? = null
|
||||||
@ -48,14 +46,13 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
appLaunched()
|
||||||
|
|
||||||
mDb = applicationContext.dbHelper
|
|
||||||
initViewPager()
|
initViewPager()
|
||||||
|
|
||||||
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||||
pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2).toInt()
|
pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2).toInt()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
storeStoragePaths()
|
|
||||||
|
|
||||||
intent.apply {
|
intent.apply {
|
||||||
if (action == Intent.ACTION_SEND && type == MIME_TEXT_PLAIN) {
|
if (action == Intent.ACTION_SEND && type == MIME_TEXT_PLAIN) {
|
||||||
@ -157,7 +154,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleText(text: String) {
|
private fun handleText(text: String) {
|
||||||
val notes = mDb.getNotes()
|
val notes = dbHelper.getNotes()
|
||||||
val list = arrayListOf<RadioItem>().apply {
|
val list = arrayListOf<RadioItem>().apply {
|
||||||
add(RadioItem(0, getString(R.string.create_new_note)))
|
add(RadioItem(0, getString(R.string.create_new_note)))
|
||||||
notes.forEachIndexed { index, note ->
|
notes.forEachIndexed { index, note ->
|
||||||
@ -176,9 +173,9 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleFile(path: String) {
|
private fun handleFile(path: String) {
|
||||||
val id = mDb.getNoteId(path)
|
val id = dbHelper.getNoteId(path)
|
||||||
|
|
||||||
if (mDb.isValidId(id)) {
|
if (dbHelper.isValidId(id)) {
|
||||||
updateSelectedNote(id)
|
updateSelectedNote(id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -191,7 +188,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initViewPager() {
|
private fun initViewPager() {
|
||||||
mNotes = mDb.getNotes()
|
mNotes = dbHelper.getNotes()
|
||||||
mCurrentNote = mNotes[0]
|
mCurrentNote = mNotes[0]
|
||||||
var wantedNoteId = intent.getIntExtra(OPEN_NOTE_ID, -1)
|
var wantedNoteId = intent.getIntExtra(OPEN_NOTE_ID, -1)
|
||||||
if (wantedNoteId == -1)
|
if (wantedNoteId == -1)
|
||||||
@ -217,7 +214,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun displayRenameDialog() {
|
private fun displayRenameDialog() {
|
||||||
RenameNoteDialog(this, mDb, mCurrentNote) {
|
RenameNoteDialog(this, dbHelper, mCurrentNote) {
|
||||||
mCurrentNote = it
|
mCurrentNote = it
|
||||||
initViewPager()
|
initViewPager()
|
||||||
}
|
}
|
||||||
@ -231,15 +228,15 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun displayNewNoteDialog(value: String = "") {
|
private fun displayNewNoteDialog(value: String = "") {
|
||||||
NewNoteDialog(this, mDb) {
|
NewNoteDialog(this, dbHelper) {
|
||||||
val newNote = Note(0, it, value, TYPE_NOTE)
|
val newNote = Note(0, it, value, TYPE_NOTE)
|
||||||
addNewNote(newNote)
|
addNewNote(newNote)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addNewNote(note: Note) {
|
private fun addNewNote(note: Note) {
|
||||||
val id = mDb.insertNote(note)
|
val id = dbHelper.insertNote(note)
|
||||||
mNotes = mDb.getNotes()
|
mNotes = dbHelper.getNotes()
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
initViewPager()
|
initViewPager()
|
||||||
updateSelectedNote(id)
|
updateSelectedNote(id)
|
||||||
@ -276,7 +273,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
toast(R.string.invalid_file_format)
|
toast(R.string.invalid_file_format)
|
||||||
} else if (file.length() > 10 * 1000 * 1000) {
|
} else if (file.length() > 10 * 1000 * 1000) {
|
||||||
toast(R.string.file_too_large)
|
toast(R.string.file_too_large)
|
||||||
} else if (checkTitle && mDb.doesTitleExist(path.getFilenameFromPath())) {
|
} else if (checkTitle && dbHelper.doesTitleExist(path.getFilenameFromPath())) {
|
||||||
toast(R.string.title_taken)
|
toast(R.string.title_taken)
|
||||||
} else {
|
} else {
|
||||||
onChecksPassed(file)
|
onChecksPassed(file)
|
||||||
@ -286,7 +283,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
private fun importFileWithSync(path: String) {
|
private fun importFileWithSync(path: String) {
|
||||||
openFile(path, false) {
|
openFile(path, false) {
|
||||||
var title = path.getFilenameFromPath()
|
var title = path.getFilenameFromPath()
|
||||||
if (mDb.doesTitleExist(title))
|
if (dbHelper.doesTitleExist(title))
|
||||||
title += " (file)"
|
title += " (file)"
|
||||||
|
|
||||||
val note = Note(0, title, "", TYPE_NOTE, path)
|
val note = Note(0, title, "", TYPE_NOTE, path)
|
||||||
@ -372,8 +369,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
|
|
||||||
val deletedNoteId = mCurrentNote.id
|
val deletedNoteId = mCurrentNote.id
|
||||||
val path = mCurrentNote.path
|
val path = mCurrentNote.path
|
||||||
mDb.deleteNote(mCurrentNote.id)
|
dbHelper.deleteNote(mCurrentNote.id)
|
||||||
mNotes = mDb.getNotes()
|
mNotes = dbHelper.getNotes()
|
||||||
|
|
||||||
val firstNoteId = mNotes[0].id
|
val firstNoteId = mNotes[0].id
|
||||||
updateSelectedNote(firstNoteId)
|
updateSelectedNote(firstNoteId)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.simplemobiletools.notes.dialogs
|
package com.simplemobiletools.notes.dialogs
|
||||||
|
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
|
||||||
import com.simplemobiletools.commons.extensions.beVisible
|
import com.simplemobiletools.commons.extensions.beVisible
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.notes.R
|
import com.simplemobiletools.notes.R
|
||||||
@ -14,7 +13,7 @@ class DeleteNoteDialog(val activity: SimpleActivity, val note: Note, val callbac
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val message = String.format(activity.getString(R.string.delete_note_prompt_message), note.title)
|
val message = String.format(activity.getString(R.string.delete_note_prompt_message), note.title)
|
||||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_delete_note, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_note, null).apply {
|
||||||
if (note.path.isNotEmpty()) {
|
if (note.path.isNotEmpty()) {
|
||||||
delete_note_checkbox.text = String.format(activity.getString(R.string.delete_file_itself), note.path)
|
delete_note_checkbox.text = String.format(activity.getString(R.string.delete_file_itself), note.path)
|
||||||
delete_note_checkbox.beVisible()
|
delete_note_checkbox.beVisible()
|
||||||
|
@ -2,7 +2,6 @@ package com.simplemobiletools.notes.dialogs
|
|||||||
|
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
@ -17,7 +16,7 @@ class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback:
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
var realPath = File(note.path).parent ?: Environment.getExternalStorageDirectory().toString()
|
var realPath = File(note.path).parent ?: Environment.getExternalStorageDirectory().toString()
|
||||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_export_as, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_export_as, null).apply {
|
||||||
file_path.text = activity.humanizePath(realPath)
|
file_path.text = activity.humanizePath(realPath)
|
||||||
|
|
||||||
file_name.setText(note.title)
|
file_name.setText(note.title)
|
||||||
@ -35,8 +34,8 @@ class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback:
|
|||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
activity.setupDialogStuff(view, this, R.string.export_as_file)
|
activity.setupDialogStuff(view, this, R.string.export_as_file) {
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.file_name.value
|
val filename = view.file_name.value
|
||||||
val extension = view.file_extension.value
|
val extension = view.file_extension.value
|
||||||
|
|
||||||
@ -55,7 +54,8 @@ class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback:
|
|||||||
activity.config.lastUsedExtension = extension
|
activity.config.lastUsedExtension = extension
|
||||||
callback(newFile.absolutePath)
|
callback(newFile.absolutePath)
|
||||||
dismiss()
|
dismiss()
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title:
|
|||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
activity.setupDialogStuff(view, this, R.string.new_note)
|
activity.setupDialogStuff(view, this, R.string.new_note) {
|
||||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||||
val title = view.note_name.value
|
val title = view.note_name.value
|
||||||
when {
|
when {
|
||||||
@ -35,3 +35,4 @@ class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.simplemobiletools.notes.dialogs
|
package com.simplemobiletools.notes.dialogs
|
||||||
|
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||||
import com.simplemobiletools.commons.extensions.humanizePath
|
import com.simplemobiletools.commons.extensions.humanizePath
|
||||||
@ -18,7 +17,7 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
|
|||||||
private var dialog: AlertDialog
|
private var dialog: AlertDialog
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = (LayoutInflater.from(activity).inflate(R.layout.dialog_open_file, null) as ViewGroup).apply {
|
val view = (activity.layoutInflater.inflate(R.layout.dialog_open_file, null) as ViewGroup).apply {
|
||||||
open_file_filename.text = activity.humanizePath(path)
|
open_file_filename.text = activity.humanizePath(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,8 +25,8 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
|
|||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.open_file)
|
activity.setupDialogStuff(view, this, R.string.open_file) {
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == open_file_update_file
|
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == open_file_update_file
|
||||||
val storePath = if (updateFileOnEdit) path else ""
|
val storePath = if (updateFileOnEdit) path else ""
|
||||||
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
|
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
|
||||||
@ -39,7 +38,8 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
|
|||||||
} else {
|
} else {
|
||||||
saveNote(storeContent, storePath)
|
saveNote(storeContent, storePath)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.simplemobiletools.notes.dialogs
|
package com.simplemobiletools.notes.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.graphics.PorterDuff
|
|
||||||
import android.graphics.PorterDuffColorFilter
|
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RadioGroup
|
import android.widget.RadioGroup
|
||||||
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
@ -37,7 +36,7 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> U
|
|||||||
}
|
}
|
||||||
open_note_item_icon.apply {
|
open_note_item_icon.apply {
|
||||||
beVisibleIf(note.path.isNotEmpty())
|
beVisibleIf(note.path.isNotEmpty())
|
||||||
colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
applyColorFilter(textColor)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
activity.toast(note.path)
|
activity.toast(note.path)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class RenameNoteDialog(val activity: SimpleActivity, val db: DBHelper, val note:
|
|||||||
.create().apply {
|
.create().apply {
|
||||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
activity.setupDialogStuff(view, this, R.string.rename_note)
|
activity.setupDialogStuff(view, this, R.string.rename_note)
|
||||||
getButton(BUTTON_POSITIVE).setOnClickListener({
|
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||||
val title = view.note_name.value
|
val title = view.note_name.value
|
||||||
when {
|
when {
|
||||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||||
@ -59,7 +59,7 @@ class RenameNoteDialog(val activity: SimpleActivity, val db: DBHelper, val note:
|
|||||||
callback(note)
|
callback(note)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user