mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-25 13:00:31 +01:00
updating commons with some material elements
This commit is contained in:
parent
09e7ee0987
commit
797ac60d56
@ -63,7 +63,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:e1e07bf005'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:4f9c2f94ff'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.documentfile:documentfile:1.0.1'
|
||||
|
||||
|
@ -87,6 +87,8 @@ class MainActivity : SimpleActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
appLaunched(BuildConfig.APPLICATION_ID)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
searchQueryET = findViewById(R.id.search_query)
|
||||
searchPrevBtn = findViewById(R.id.search_previous)
|
||||
@ -113,11 +115,12 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(main_toolbar)
|
||||
if (storedEnableLineWrap != config.enableLineWrap) {
|
||||
initViewPager()
|
||||
}
|
||||
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
pager_title_strip.apply {
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, getPercentageFontSize())
|
||||
setGravity(Gravity.CENTER_VERTICAL)
|
||||
@ -168,11 +171,26 @@ class MainActivity : SimpleActivity() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
private fun refreshMenuItems() {
|
||||
val multipleNotesExist = mNotes.size > 1
|
||||
val isCurrentItemChecklist = isCurrentItemChecklist()
|
||||
|
||||
menu.apply {
|
||||
main_toolbar.menu.apply {
|
||||
val areButtonsVisible = (showRedoButton || showUndoButton) && mCurrentNote.type == NoteType.TYPE_TEXT.value
|
||||
findItem(R.id.undo).apply {
|
||||
isVisible = areButtonsVisible
|
||||
isEnabled = showUndoButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
|
||||
icon.alpha = if (isEnabled) 255 else 127
|
||||
}
|
||||
|
||||
findItem(R.id.redo).apply {
|
||||
isVisible = areButtonsVisible
|
||||
isEnabled = showRedoButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
|
||||
icon.alpha = if (isEnabled) 255 else 127
|
||||
}
|
||||
}
|
||||
|
||||
main_toolbar.menu.apply {
|
||||
findItem(R.id.rename_note).isVisible = multipleNotesExist
|
||||
findItem(R.id.open_note).isVisible = multipleNotesExist
|
||||
findItem(R.id.delete_note).isVisible = multipleNotesExist
|
||||
@ -183,24 +201,25 @@ class MainActivity : SimpleActivity() {
|
||||
findItem(R.id.sort_checklist).isVisible = isCurrentItemChecklist
|
||||
findItem(R.id.import_folder).isVisible = !isQPlus()
|
||||
findItem(R.id.import_notes).isVisible = isQPlus()
|
||||
findItem(R.id.lock_note).isVisible = mNotes.isNotEmpty() && !mCurrentNote.isLocked()
|
||||
findItem(R.id.unlock_note).isVisible = mNotes.isNotEmpty() && mCurrentNote.isLocked()
|
||||
findItem(R.id.lock_note).isVisible = mNotes.isNotEmpty() && (::mCurrentNote.isInitialized && !mCurrentNote.isLocked())
|
||||
findItem(R.id.unlock_note).isVisible = mNotes.isNotEmpty() && (::mCurrentNote.isInitialized && mCurrentNote.isLocked())
|
||||
|
||||
saveNoteButton = findItem(R.id.save_note)
|
||||
saveNoteButton!!.isVisible = !config.autosaveNotes && showSaveButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
|
||||
saveNoteButton!!.isVisible =
|
||||
!config.autosaveNotes && showSaveButton && (::mCurrentNote.isInitialized && mCurrentNote.type == NoteType.TYPE_TEXT.value)
|
||||
}
|
||||
|
||||
pager_title_strip.beVisibleIf(multipleNotesExist)
|
||||
return super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (config.autosaveNotes && item.itemId != R.id.undo && item.itemId != R.id.redo) {
|
||||
private fun setupOptionsMenu() {
|
||||
main_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
if (config.autosaveNotes && menuItem.itemId != R.id.undo && menuItem.itemId != R.id.redo) {
|
||||
saveCurrentNote(false)
|
||||
}
|
||||
|
||||
val fragment = getCurrentFragment()
|
||||
when (item.itemId) {
|
||||
when (menuItem.itemId) {
|
||||
R.id.open_search -> fragment?.handleUnlocking { openSearch() }
|
||||
R.id.open_note -> displayOpenNoteDialog()
|
||||
R.id.save_note -> fragment?.handleUnlocking { saveNote() }
|
||||
@ -223,9 +242,10 @@ class MainActivity : SimpleActivity() {
|
||||
R.id.about -> launchAbout()
|
||||
R.id.remove_done_items -> fragment?.handleUnlocking { removeDoneItems() }
|
||||
R.id.sort_checklist -> fragment?.handleUnlocking { displaySortChecklistDialog() }
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
else -> return@setOnMenuItemClickListener false
|
||||
}
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// https://code.google.com/p/android/issues/detail?id=191430 quickfix
|
||||
@ -286,7 +306,7 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCurrentItemChecklist() = if (this::mCurrentNote.isInitialized) mCurrentNote.type == NoteType.TYPE_CHECKLIST.value else false
|
||||
private fun isCurrentItemChecklist() = if (::mCurrentNote.isInitialized) mCurrentNote.type == NoteType.TYPE_CHECKLIST.value else false
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private fun checkShortcuts() {
|
||||
@ -422,7 +442,7 @@ class MainActivity : SimpleActivity() {
|
||||
.forEach(::removeProtection)
|
||||
|
||||
mNotes = notes
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
mCurrentNote = mNotes[0]
|
||||
mAdapter = NotesPagerAdapter(supportFragmentManager, mNotes, this)
|
||||
view_pager.apply {
|
||||
@ -433,7 +453,7 @@ class MainActivity : SimpleActivity() {
|
||||
onPageChangeListener {
|
||||
mCurrentNote = mNotes[it]
|
||||
config.currentNoteId = mCurrentNote.id!!
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,7 +483,7 @@ class MainActivity : SimpleActivity() {
|
||||
view_pager.onPageChangeListener {
|
||||
currentTextFragment?.removeTextWatcher()
|
||||
currentNotesView()?.let { noteView ->
|
||||
noteView.text.clearBackgroundSpans()
|
||||
noteView.text!!.clearBackgroundSpans()
|
||||
}
|
||||
|
||||
closeSearch()
|
||||
@ -483,7 +503,7 @@ class MainActivity : SimpleActivity() {
|
||||
private fun searchTextChanged(text: String) {
|
||||
currentNotesView()?.let { noteView ->
|
||||
currentTextFragment?.removeTextWatcher()
|
||||
noteView.text.clearBackgroundSpans()
|
||||
noteView.text!!.clearBackgroundSpans()
|
||||
|
||||
if (text.isNotBlank() && text.length > 1) {
|
||||
searchMatches = noteView.value.searchMatches(text)
|
||||
@ -1263,7 +1283,7 @@ class MainActivity : SimpleActivity() {
|
||||
private fun saveNote() {
|
||||
saveCurrentNote(true)
|
||||
showSaveButton = false
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
|
||||
private fun undo() {
|
||||
@ -1309,7 +1329,7 @@ class MainActivity : SimpleActivity() {
|
||||
mCurrentNote.protectionHash = hash
|
||||
mCurrentNote.protectionType = type
|
||||
NotesHelper(this).insertOrUpdateNote(mCurrentNote) {
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1333,7 +1353,7 @@ class MainActivity : SimpleActivity() {
|
||||
shouldShowLockedContent = true
|
||||
checkLockState()
|
||||
}
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1359,7 +1379,7 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
if (shouldRecreateMenu) {
|
||||
invalidateOptionsMenu()
|
||||
refreshMenuItems()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.view.Menu
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
@ -26,6 +27,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
||||
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
@ -42,8 +44,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupCursorPlacement()
|
||||
setupIncognitoMode()
|
||||
setupCustomizeWidgetColors()
|
||||
updateTextColors(settings_scrollview)
|
||||
invalidateOptionsMenu()
|
||||
updateTextColors(settings_nested_scrollview)
|
||||
|
||||
arrayOf(
|
||||
settings_color_customization_label,
|
||||
|
@ -73,6 +73,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
text_note_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, getPercentageFontSize())
|
||||
setupToolbar(config_toolbar)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisible
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
@ -24,10 +25,10 @@ class DeleteNoteDialog(val activity: SimpleActivity, val note: Note, val callbac
|
||||
delete_note_description.text = message
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed(view.delete_note_checkbox.isChecked) }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,13 @@ class ExportFileDialog(val activity: SimpleActivity, val note: Note, val callbac
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_as_file) {
|
||||
showKeyboard(view.file_name)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_as_file) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.file_name)
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val filename = view.file_name.value
|
||||
val extension = view.file_extension.value
|
||||
|
||||
@ -51,7 +51,7 @@ class ExportFileDialog(val activity: SimpleActivity, val note: Note, val callbac
|
||||
activity.config.lastUsedExtension = extension
|
||||
activity.config.lastUsedSavePath = realPath
|
||||
callback("$realPath/$fullFilename")
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,7 @@ package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.pro.extensions.config
|
||||
@ -27,19 +24,19 @@ class ExportFilesDialog(val activity: SimpleActivity, val notes: ArrayList<Note>
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_as_file) {
|
||||
showKeyboard(view.file_extension)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_as_file) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.file_extension)
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
activity.handleSAFDialog(realPath) {
|
||||
val extension = view.file_extension.value
|
||||
activity.config.lastUsedExtension = extension
|
||||
activity.config.lastUsedSavePath = realPath
|
||||
callback(realPath, extension)
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,7 @@ package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.isMediaFile
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
@ -19,19 +16,20 @@ import kotlinx.android.synthetic.main.dialog_import_folder.view.*
|
||||
import java.io.File
|
||||
|
||||
class ImportFolderDialog(val activity: SimpleActivity, val path: String, val callback: () -> Unit) : AlertDialog.Builder(activity) {
|
||||
private var dialog: AlertDialog
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_folder, null) as ViewGroup).apply {
|
||||
open_file_filename.text = activity.humanizePath(path)
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.import_folder) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.import_folder) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val updateFilesOnEdit = view.open_file_type.checkedRadioButtonId == R.id.open_file_update_file
|
||||
ensureBackgroundThread {
|
||||
saveFolder(updateFilesOnEdit)
|
||||
@ -73,7 +71,7 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
|
||||
|
||||
activity.runOnUiThread {
|
||||
callback()
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,15 +6,14 @@ import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import kotlinx.android.synthetic.main.dialog_new_checklist_item.view.*
|
||||
import kotlinx.android.synthetic.main.item_add_checklist.view.*
|
||||
|
||||
class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayList<String>) -> Unit) {
|
||||
private val titles = mutableListOf<EditText>()
|
||||
private val titles = mutableListOf<AppCompatEditText>()
|
||||
private val textColor = activity.getProperTextColor()
|
||||
private val view: ViewGroup = activity.layoutInflater.inflate(R.layout.dialog_new_checklist_item, null) as ViewGroup
|
||||
|
||||
@ -28,19 +27,19 @@ class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayLis
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.add_new_checklist_items) {
|
||||
showKeyboard(titles.first())
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.add_new_checklist_items) { alertDialog ->
|
||||
alertDialog.showKeyboard(titles.first())
|
||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
when {
|
||||
titles.all { it.text.isEmpty() } -> activity.toast(R.string.empty_name)
|
||||
titles.all { it.text!!.isEmpty() } -> activity.toast(R.string.empty_name)
|
||||
else -> {
|
||||
val titles = titles.map { it.text.toString() }.filter { it.isNotEmpty() }.toMutableList() as ArrayList<String>
|
||||
callback(titles)
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,7 @@ package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
@ -30,24 +26,29 @@ class NewNoteDialog(val activity: Activity, title: String? = null, val setCheckl
|
||||
|
||||
view.note_title.setText(title)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.new_note) {
|
||||
showKeyboard(view.note_title)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_title.value
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.new_note) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.note_title)
|
||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val newTitle = view.note_title.value
|
||||
ensureBackgroundThread {
|
||||
when {
|
||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||
activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken)
|
||||
newTitle.isEmpty() -> activity.toast(R.string.no_title)
|
||||
activity.notesDB.getNoteIdWithTitle(newTitle) != null -> activity.toast(R.string.title_taken)
|
||||
else -> {
|
||||
val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) NoteType.TYPE_CHECKLIST.value else NoteType.TYPE_TEXT.value
|
||||
val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) {
|
||||
NoteType.TYPE_CHECKLIST.value
|
||||
} else {
|
||||
NoteType.TYPE_TEXT.value
|
||||
}
|
||||
|
||||
activity.config.lastCreatedNoteType = type
|
||||
val newNote = Note(null, title, "", type, "", PROTECTION_NONE, "")
|
||||
val newNote = Note(null, newTitle, "", type, "", PROTECTION_NONE, "")
|
||||
callback(newNote)
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
@ -10,25 +11,25 @@ import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.pro.helpers.NoteType
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_open_file.*
|
||||
import kotlinx.android.synthetic.main.dialog_open_file.view.*
|
||||
import java.io.File
|
||||
|
||||
class OpenFileDialog(val activity: SimpleActivity, val path: String, val callback: (note: Note) -> Unit) : AlertDialog.Builder(activity) {
|
||||
private var dialog: AlertDialog
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_open_file, null) as ViewGroup).apply {
|
||||
open_file_filename.text = activity.humanizePath(path)
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_file) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == open_file_update_file.id
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_file) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == view.open_file_update_file.id
|
||||
val storePath = if (updateFileOnEdit) path else ""
|
||||
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
|
||||
|
||||
@ -48,6 +49,6 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
|
||||
val filename = path.getFilenameFromPath()
|
||||
val note = Note(null, filename, storeContent, NoteType.TYPE_TEXT.value, storePath, PROTECTION_NONE, "")
|
||||
callback(note)
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,10 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long, new
|
||||
}
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_note)
|
||||
activity.getAlertDialogBuilder().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_note) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,7 @@ package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import kotlinx.android.synthetic.main.dialog_rename_checklist_item.view.*
|
||||
|
||||
@ -16,19 +12,19 @@ class RenameChecklistItemDialog(val activity: Activity, val oldTitle: String, ca
|
||||
checklist_item_title.setText(oldTitle)
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
showKeyboard(view.checklist_item_title)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.checklist_item_title)
|
||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val newTitle = view.checklist_item_title.value
|
||||
when {
|
||||
newTitle.isEmpty() -> activity.toast(R.string.empty_name)
|
||||
else -> {
|
||||
callback(newTitle)
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,16 +20,16 @@ class RenameNoteDialog(val activity: SimpleActivity, val note: Note, val current
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_note, null)
|
||||
view.note_title.setText(note.title)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.rename_note) {
|
||||
showKeyboard(view.note_title)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.rename_note) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.note_title)
|
||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_title.value
|
||||
ensureBackgroundThread {
|
||||
newTitleConfirmed(title, this)
|
||||
newTitleConfirmed(title, alertDialog)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_CREATED
|
||||
@ -21,10 +21,11 @@ class SortChecklistDialog(private val activity: SimpleActivity, private val call
|
||||
setupSortRadio()
|
||||
setupOrderRadio()
|
||||
setupMoveUndoneChecklistItems()
|
||||
AlertDialog.Builder(activity)
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class TextFragment : NoteFragment() {
|
||||
setTextWatcher()
|
||||
}
|
||||
skipTextUpdating = false
|
||||
setSelection(if (config.placeCursorToEnd) text.length else 0)
|
||||
setSelection(if (config.placeCursorToEnd) text!!.length else 0)
|
||||
}
|
||||
|
||||
if (config.showKeyboard && isMenuVisible && (!note!!.isLocked() || shouldShowLockedContent)) {
|
||||
|
@ -1,8 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/main_app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/main_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/color_primary"
|
||||
app:menu="@menu/menu"
|
||||
app:title="@string/app_launcher_name"
|
||||
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<include
|
||||
android:id="@+id/search_wrapper"
|
||||
@ -23,3 +47,4 @@
|
||||
|
||||
</com.simplemobiletools.commons.views.MyViewPager>
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -1,10 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/settings_scrollview"
|
||||
android:id="@+id/settings_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/settings_app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/settings_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/color_primary"
|
||||
app:title="@string/settings"
|
||||
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/settings_nested_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/settings_holder"
|
||||
android:layout_width="match_parent"
|
||||
@ -347,4 +371,5 @@
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -29,14 +29,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/dialog_open_note_divider"
|
||||
android:padding="@dimen/normal_margin">
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:paddingEnd="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/small_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_open_note_new_radio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
android:text="@string/create_new_note" />
|
||||
|
||||
</RadioGroup>
|
||||
|
@ -3,7 +3,8 @@
|
||||
android:id="@+id/open_note_item_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/normal_margin">
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingEnd="@dimen/normal_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/open_note_item_radio_button"
|
||||
|
@ -1,11 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/notes_holder"
|
||||
android:id="@+id/config_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/config_app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/config_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/color_primary"
|
||||
app:title="@string/app_launcher_name"
|
||||
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/config_relative"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_margin="@dimen/activity_margin">
|
||||
android:layout_margin="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/notes_picker_holder"
|
||||
@ -128,17 +150,12 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/config_save"
|
||||
style="@style/MyWidgetConfigSaveStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/widget_config_seekbar_background"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:paddingStart="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:text="@string/ok"
|
||||
android:textColor="@color/dark_grey"
|
||||
android:textFontWeight="400"
|
||||
android:textSize="@dimen/big_text_size" />
|
||||
android:text="@string/ok" />
|
||||
|
||||
</RelativeLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user