updating commons with some material elements

This commit is contained in:
tibbi 2022-07-11 23:28:40 +02:00
parent 09e7ee0987
commit 797ac60d56
21 changed files with 742 additions and 656 deletions

View File

@ -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'

View File

@ -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,49 +201,51 @@ 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) {
saveCurrentNote(false)
}
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) {
R.id.open_search -> fragment?.handleUnlocking { openSearch() }
R.id.open_note -> displayOpenNoteDialog()
R.id.save_note -> fragment?.handleUnlocking { saveNote() }
R.id.undo -> undo()
R.id.redo -> redo()
R.id.new_note -> displayNewNoteDialog()
R.id.rename_note -> fragment?.handleUnlocking { displayRenameDialog() }
R.id.share -> fragment?.handleUnlocking { shareText() }
R.id.lock_note -> lockNote()
R.id.unlock_note -> unlockNote()
R.id.open_file -> tryOpenFile()
R.id.import_folder -> openFolder()
R.id.export_as_file -> fragment?.handleUnlocking { tryExportAsFile() }
R.id.export_all_notes -> tryExportAllNotes()
R.id.export_notes -> tryExportNotes()
R.id.import_notes -> tryImportNotes()
R.id.print -> fragment?.handleUnlocking { printText() }
R.id.delete_note -> fragment?.handleUnlocking { displayDeleteNotePrompt() }
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
R.id.remove_done_items -> fragment?.handleUnlocking { removeDoneItems() }
R.id.sort_checklist -> fragment?.handleUnlocking { displaySortChecklistDialog() }
else -> return super.onOptionsItemSelected(item)
val fragment = getCurrentFragment()
when (menuItem.itemId) {
R.id.open_search -> fragment?.handleUnlocking { openSearch() }
R.id.open_note -> displayOpenNoteDialog()
R.id.save_note -> fragment?.handleUnlocking { saveNote() }
R.id.undo -> undo()
R.id.redo -> redo()
R.id.new_note -> displayNewNoteDialog()
R.id.rename_note -> fragment?.handleUnlocking { displayRenameDialog() }
R.id.share -> fragment?.handleUnlocking { shareText() }
R.id.lock_note -> lockNote()
R.id.unlock_note -> unlockNote()
R.id.open_file -> tryOpenFile()
R.id.import_folder -> openFolder()
R.id.export_as_file -> fragment?.handleUnlocking { tryExportAsFile() }
R.id.export_all_notes -> tryExportAllNotes()
R.id.export_notes -> tryExportNotes()
R.id.import_notes -> tryImportNotes()
R.id.print -> fragment?.handleUnlocking { printText() }
R.id.delete_note -> fragment?.handleUnlocking { displayDeleteNotePrompt() }
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
R.id.remove_done_items -> fragment?.handleUnlocking { removeDoneItems() }
R.id.sort_checklist -> fragment?.handleUnlocking { displaySortChecklistDialog() }
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()
}
}
}

View File

@ -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,

View File

@ -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 {

View File

@ -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)
}
}

View File

@ -27,33 +27,33 @@ class ExportFileDialog(val activity: SimpleActivity, val note: Note, val callbac
}
}
AlertDialog.Builder(activity)
.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 {
val filename = view.file_name.value
val extension = view.file_extension.value
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.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
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
val fullFilename = if (extension.isEmpty()) filename else "$filename.$extension"
if (!fullFilename.isAValidFilename()) {
activity.toast(String.format(activity.getString(R.string.filename_invalid_characters_placeholder, fullFilename)))
return@setOnClickListener
}
activity.config.lastUsedExtension = extension
activity.config.lastUsedSavePath = realPath
callback("$realPath/$fullFilename")
dismiss()
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
val fullFilename = if (extension.isEmpty()) filename else "$filename.$extension"
if (!fullFilename.isAValidFilename()) {
activity.toast(String.format(activity.getString(R.string.filename_invalid_characters_placeholder, fullFilename)))
return@setOnClickListener
}
activity.config.lastUsedExtension = extension
activity.config.lastUsedSavePath = realPath
callback("$realPath/$fullFilename")
alertDialog.dismiss()
}
}
}
}
}

View File

@ -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,22 +24,22 @@ class ExportFilesDialog(val activity: SimpleActivity, val notes: ArrayList<Note>
}
}
AlertDialog.Builder(activity)
.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 {
activity.handleSAFDialog(realPath) {
val extension = view.file_extension.value
activity.config.lastUsedExtension = extension
activity.config.lastUsedSavePath = realPath
callback(realPath, extension)
dismiss()
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.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)
alertDialog.dismiss()
}
}
}
}
}
}

View File

@ -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,26 +16,27 @@ 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)
.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 {
val updateFilesOnEdit = view.open_file_type.checkedRadioButtonId == R.id.open_file_update_file
ensureBackgroundThread {
saveFolder(updateFilesOnEdit)
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.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)
}
}
}
}
}
private fun saveFolder(updateFilesOnEdit: Boolean) {
@ -73,7 +71,7 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
activity.runOnUiThread {
callback()
dialog.dismiss()
dialog?.dismiss()
}
}

View File

@ -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()
}
}
}

View File

@ -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()
}
}
}

View File

@ -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,44 +11,44 @@ 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)
.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
val storePath = if (updateFileOnEdit) path else ""
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.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()
if (updateFileOnEdit) {
activity.handleSAFDialog(path) {
saveNote(storeContent, storePath)
}
} else {
if (updateFileOnEdit) {
activity.handleSAFDialog(path) {
saveNote(storeContent, storePath)
}
} else {
saveNote(storeContent, storePath)
}
}
}
}
}
private fun saveNote(storeContent: String, storePath: String) {
val filename = path.getFilenameFromPath()
val note = Note(null, filename, storeContent, NoteType.TYPE_TEXT.value, storePath, PROTECTION_NONE, "")
callback(note)
dialog.dismiss()
dialog?.dismiss()
}
}

View File

@ -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
}
}
}
}

View File

@ -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,23 +12,23 @@ class RenameChecklistItemDialog(val activity: Activity, val oldTitle: String, ca
checklist_item_title.setText(oldTitle)
}
AlertDialog.Builder(activity)
.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 {
val newTitle = view.checklist_item_title.value
when {
newTitle.isEmpty() -> activity.toast(R.string.empty_name)
else -> {
callback(newTitle)
dismiss()
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.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)
alertDialog.dismiss()
}
}
}
}
}
}
}

View File

@ -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)
}
}
}

View File

@ -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)
}
}

View File

@ -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)) {

View File

@ -1,25 +1,50 @@
<?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"
android:orientation="vertical">
android:layout_height="match_parent">
<include
android:id="@+id/search_wrapper"
layout="@layout/search_bar" />
<com.simplemobiletools.commons.views.MyViewPager
android:id="@+id/view_pager"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/main_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<androidx.viewpager.widget.PagerTitleStrip
android:id="@+id/pager_title_strip"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin" />
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.simplemobiletools.commons.views.MyViewPager>
</LinearLayout>
</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"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include
android:id="@+id/search_wrapper"
layout="@layout/search_bar" />
<com.simplemobiletools.commons.views.MyViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager.widget.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin" />
</com.simplemobiletools.commons.views.MyViewPager>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,350 +1,375 @@
<?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="wrap_content">
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/settings_holder"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/settings_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<TextView
android:id="@+id/settings_color_customization_label"
style="@style/SettingsSectionLabelStyle"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/settings_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/color_customization" />
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_color_customization_holder"
android:id="@+id/settings_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_customize_colors_holder"
style="@style/SettingsHolderTextViewOneLinerStyle"
<TextView
android:id="@+id/settings_color_customization_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
android:text="@string/color_customization" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_customize_colors_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customize_colors" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_customize_widget_colors_holder"
style="@style/SettingsHolderTextViewOneLinerStyle"
<LinearLayout
android:id="@+id/settings_color_customization_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_customize_widget_colors_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
<RelativeLayout
android:id="@+id/settings_customize_colors_holder"
style="@style/SettingsHolderTextViewOneLinerStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customize_widget_colors" />
android:background="@drawable/ripple_top_corners">
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_customize_colors_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customize_colors" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_customize_widget_colors_holder"
style="@style/SettingsHolderTextViewOneLinerStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_customize_widget_colors_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customize_widget_colors" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_general_settings_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/general_settings" />
<LinearLayout
android:id="@+id/settings_general_settings_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_use_english_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_use_english"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/use_english_language" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_font_size_holder"
style="@style/SettingsHolderTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_font_size_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/font_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_font_size"
style="@style/SettingsTextValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_font_size_label"
tools:text="100%" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_text_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text" />
<LinearLayout
android:id="@+id/settings_text_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_show_word_count_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_word_count"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_word_count" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_clickable_links_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_clickable_links"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/links_and_emails_clickable" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_monospaced_font_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_monospaced_font"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/monospaced_font" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_use_incognito_mode_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_use_incognito_mode"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/use_incognito_mode" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_enable_line_wrap_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_enable_line_wrap"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enable_line_wrap" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_gravity_holder"
style="@style/SettingsHolderTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_gravity_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/alignment" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_gravity"
style="@style/SettingsTextValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_gravity_label"
tools:text="@string/left" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_startup_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/startup" />
<LinearLayout
android:id="@+id/settings_startup_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_cursor_placement_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_cursor_placement"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/place_cursor_end" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_keyboard_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_keyboard"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_keyboard" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_note_picker_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_note_picker"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_note_picker" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_saving_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/saving_label" />
<LinearLayout
android:id="@+id/settings_saving_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_autosave_notes_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_autosave_notes"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/autosave_notes" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_display_success_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_display_success"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/display_success_message" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_general_settings_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/general_settings" />
<LinearLayout
android:id="@+id/settings_general_settings_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_use_english_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_use_english"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/use_english_language" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_font_size_holder"
style="@style/SettingsHolderTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_font_size_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/font_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_font_size"
style="@style/SettingsTextValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_font_size_label"
tools:text="100%" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_text_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text" />
<LinearLayout
android:id="@+id/settings_text_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_show_word_count_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_word_count"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_word_count" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_clickable_links_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_clickable_links"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/links_and_emails_clickable" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_monospaced_font_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_monospaced_font"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/monospaced_font" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_use_incognito_mode_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_use_incognito_mode"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/use_incognito_mode" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_enable_line_wrap_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_enable_line_wrap"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enable_line_wrap" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_gravity_holder"
style="@style/SettingsHolderTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_gravity_label"
style="@style/SettingsTextLabelStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/alignment" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_gravity"
style="@style/SettingsTextValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/settings_gravity_label"
tools:text="@string/left" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_startup_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/startup" />
<LinearLayout
android:id="@+id/settings_startup_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_cursor_placement_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_cursor_placement"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/place_cursor_end" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_keyboard_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_keyboard"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_keyboard" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_note_picker_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_note_picker"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_note_picker" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/settings_saving_label"
style="@style/SettingsSectionLabelStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/saving_label" />
<LinearLayout
android:id="@+id/settings_saving_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/settings_autosave_notes_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_top_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_autosave_notes"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/autosave_notes" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_display_success_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_bottom_corners">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_display_success"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/display_success_message" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -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>

View File

@ -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"

View File

@ -1,144 +1,161 @@
<?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="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="@dimen/activity_margin">
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/notes_picker_holder"
android:id="@+id/config_relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin">
android:layout_centerHorizontal="true"
android:layout_margin="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:id="@+id/show_note_title_holder"
android:id="@+id/notes_picker_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/activity_margin">
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/show_note_title"
<RelativeLayout
android:id="@+id/show_note_title_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:layoutDirection="rtl"
android:text="@string/show_note_title"
app:switchPadding="@dimen/medium_margin" />
android:background="?attr/selectableItemBackground"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/show_note_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:layoutDirection="rtl"
android:text="@string/show_note_title"
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/notes_picker_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/show_note_title_holder"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/normal_margin"
android:paddingStart="@dimen/activity_margin"
android:text="@string/note_shown_widget" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/notes_picker_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notes_picker_label"
android:layout_marginStart="@dimen/activity_margin"
android:background="@drawable/button_background"
android:padding="@dimen/normal_margin"
android:text="@string/general_note" />
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/notes_picker_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/show_note_title_holder"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/normal_margin"
android:paddingStart="@dimen/activity_margin"
android:text="@string/note_shown_widget" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/notes_picker_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notes_picker_label"
android:layout_marginStart="@dimen/activity_margin"
android:background="@drawable/button_background"
android:padding="@dimen/normal_margin"
android:text="@string/general_note" />
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/text_note_view_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/notes_picker_holder"
android:background="@null"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:padding="@dimen/tiny_margin"
android:text="@string/title"
android:textSize="@dimen/smaller_text_size" />
<TextView
android:id="@+id/text_note_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/config_bg_color"
android:layout_below="@+id/text_note_view_title"
android:layout_marginBottom="@dimen/activity_margin"
android:background="@null"
android:gravity="top"
android:padding="@dimen/activity_margin"
android:text="@string/widget_config" />
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/checklist_note_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/config_bg_color"
android:layout_below="@+id/text_note_view_title"
android:layout_marginBottom="@dimen/activity_margin"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="@dimen/small_margin"
android:visibility="gone"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
<ImageView
android:id="@+id/config_bg_color"
android:layout_width="@dimen/widget_colorpicker_size"
android:layout_height="@dimen/widget_colorpicker_size"
android:layout_above="@+id/config_text_color"
android:layout_margin="@dimen/tiny_margin" />
<RelativeLayout
android:id="@+id/config_bg_seekbar_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/config_bg_color"
android:layout_alignBottom="@+id/config_bg_color"
android:layout_marginStart="@dimen/medium_margin"
android:layout_toEndOf="@+id/config_bg_color"
android:background="@drawable/widget_config_seekbar_background">
<com.simplemobiletools.commons.views.MySeekBar
android:id="@+id/config_bg_seekbar"
android:id="@+id/text_note_view_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin" />
android:layout_below="@+id/notes_picker_holder"
android:background="@null"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:padding="@dimen/tiny_margin"
android:text="@string/title"
android:textSize="@dimen/smaller_text_size" />
<TextView
android:id="@+id/text_note_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/config_bg_color"
android:layout_below="@+id/text_note_view_title"
android:layout_marginBottom="@dimen/activity_margin"
android:background="@null"
android:gravity="top"
android:padding="@dimen/activity_margin"
android:text="@string/widget_config" />
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/checklist_note_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/config_bg_color"
android:layout_below="@+id/text_note_view_title"
android:layout_marginBottom="@dimen/activity_margin"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="@dimen/small_margin"
android:visibility="gone"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
<ImageView
android:id="@+id/config_bg_color"
android:layout_width="@dimen/widget_colorpicker_size"
android:layout_height="@dimen/widget_colorpicker_size"
android:layout_above="@+id/config_text_color"
android:layout_margin="@dimen/tiny_margin" />
<RelativeLayout
android:id="@+id/config_bg_seekbar_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/config_bg_color"
android:layout_alignBottom="@+id/config_bg_color"
android:layout_marginStart="@dimen/medium_margin"
android:layout_toEndOf="@+id/config_bg_color"
android:background="@drawable/widget_config_seekbar_background">
<com.simplemobiletools.commons.views.MySeekBar
android:id="@+id/config_bg_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin" />
</RelativeLayout>
<ImageView
android:id="@+id/config_text_color"
android:layout_width="@dimen/widget_colorpicker_size"
android:layout_height="@dimen/widget_colorpicker_size"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/tiny_margin" />
<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:text="@string/ok" />
</RelativeLayout>
<ImageView
android:id="@+id/config_text_color"
android:layout_width="@dimen/widget_colorpicker_size"
android:layout_height="@dimen/widget_colorpicker_size"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/tiny_margin" />
<Button
android:id="@+id/config_save"
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" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>