mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
minor code style and strings update
This commit is contained in:
@ -139,7 +139,6 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentWidgetNoteTitle(currentNoteId: Int, notes: List<Note>): String {
|
||||
return notes.firstOrNull { it.id == currentNoteId }?.title ?: ""
|
||||
}
|
||||
private fun getCurrentWidgetNoteTitle(currentNoteId: Int, notes: List<Note>) =
|
||||
notes.firstOrNull { it.id == currentNoteId }?.title ?: ""
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title:
|
||||
activity.setupDialogStuff(view, this, R.string.new_note)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_name.value
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.no_title)
|
||||
} else if (db.doesTitleExist(title)) {
|
||||
activity.toast(R.string.title_taken)
|
||||
} else {
|
||||
callback(title)
|
||||
dismiss()
|
||||
when {
|
||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||
db.doesTitleExist(title) -> activity.toast(R.string.title_taken)
|
||||
else -> {
|
||||
callback(title)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,39 +25,39 @@ class RenameNoteDialog(val activity: SimpleActivity, val db: DBHelper, val note:
|
||||
activity.setupDialogStuff(view, this, R.string.rename_note)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener({
|
||||
val title = view.note_name.value
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.no_title)
|
||||
} else if (db.doesTitleExist(title)) {
|
||||
activity.toast(R.string.title_taken)
|
||||
} else {
|
||||
note.title = title
|
||||
val path = note.path
|
||||
if (path.isNotEmpty()) {
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
when {
|
||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||
db.doesTitleExist(title) -> activity.toast(R.string.title_taken)
|
||||
else -> {
|
||||
note.title = title
|
||||
val path = note.path
|
||||
if (path.isNotEmpty()) {
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val file = File(path)
|
||||
val newFile = File(file.parent, title)
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.invalid_name)
|
||||
return@setOnClickListener
|
||||
}
|
||||
val file = File(path)
|
||||
val newFile = File(file.parent, title)
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.invalid_name)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
activity.renameFile(file, newFile) {
|
||||
if (it) {
|
||||
note.path = newFile.absolutePath
|
||||
db.updateNotePath(note)
|
||||
} else {
|
||||
activity.toast(R.string.rename_file_error)
|
||||
return@renameFile
|
||||
activity.renameFile(file, newFile) {
|
||||
if (it) {
|
||||
note.path = newFile.absolutePath
|
||||
db.updateNotePath(note)
|
||||
} else {
|
||||
activity.toast(R.string.rename_file_error)
|
||||
return@renameFile
|
||||
}
|
||||
}
|
||||
}
|
||||
db.updateNoteTitle(note)
|
||||
dismiss()
|
||||
callback(note)
|
||||
}
|
||||
db.updateNoteTitle(note)
|
||||
dismiss()
|
||||
callback(note)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -45,12 +45,10 @@ class MyWidgetProvider : AppWidgetProvider() {
|
||||
super.onUpdate(context, appWidgetManager, appWidgetIds)
|
||||
}
|
||||
|
||||
private fun getProperTextView(context: Context): Int {
|
||||
return when (context.config.gravity) {
|
||||
GRAVITY_CENTER -> R.id.notes_view_center
|
||||
GRAVITY_RIGHT -> R.id.notes_view_right
|
||||
else -> R.id.notes_view_left
|
||||
}
|
||||
private fun getProperTextView(context: Context) = when (context.config.gravity) {
|
||||
GRAVITY_CENTER -> R.id.notes_view_center
|
||||
GRAVITY_RIGHT -> R.id.notes_view_right
|
||||
else -> R.id.notes_view_left
|
||||
}
|
||||
|
||||
private fun initVariables(context: Context) {
|
||||
|
Reference in New Issue
Block a user