mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-27 05:28:45 +02:00
add an option to show a note picker on startup
This commit is contained in:
parent
eccdd5229b
commit
98a37986a9
@ -71,6 +71,9 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
}
|
||||
|
||||
storeStateVariables()
|
||||
if (config.showNotePicker) {
|
||||
displayOpenNoteDialog()
|
||||
}
|
||||
wasInit = true
|
||||
}
|
||||
|
||||
@ -204,9 +207,10 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
addOnPageChangeListener(this@MainActivity)
|
||||
}
|
||||
|
||||
if (!config.showKeyboard)
|
||||
if (!config.showKeyboard) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
private fun currentNotesView() = if (view_pager == null) {
|
||||
null
|
||||
|
@ -19,11 +19,13 @@ import java.util.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
lateinit var res: Resources
|
||||
var notes = ArrayList<Note>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
res = resources
|
||||
notes = dbHelper.getNotes()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -35,6 +37,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupClickableLinks()
|
||||
setupMonospacedFont()
|
||||
setupShowKeyboard()
|
||||
setupShowNotePicker()
|
||||
setupShowWordCount()
|
||||
setupFontSize()
|
||||
setupGravity()
|
||||
@ -91,6 +94,15 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowNotePicker() {
|
||||
settings_show_note_picker_holder.beVisibleIf(notes.size > 1)
|
||||
settings_show_note_picker.isChecked = config.showNotePicker
|
||||
settings_show_note_picker_holder.setOnClickListener {
|
||||
settings_show_note_picker.toggle()
|
||||
config.showNotePicker = settings_show_note_picker.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowWordCount() {
|
||||
settings_show_word_count.isChecked = config.showWordCount
|
||||
settings_show_word_count_holder.setOnClickListener {
|
||||
@ -146,7 +158,6 @@ class SettingsActivity : SimpleActivity() {
|
||||
})
|
||||
|
||||
private fun setupWidgetNote() {
|
||||
val notes = dbHelper.getNotes()
|
||||
if (notes.size <= 1) {
|
||||
settings_widget_note_holder.visibility = View.GONE
|
||||
return
|
||||
|
@ -25,6 +25,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getBoolean(SHOW_KEYBOARD, true)
|
||||
set(showKeyboard) = prefs.edit().putBoolean(SHOW_KEYBOARD, showKeyboard).apply()
|
||||
|
||||
var showNotePicker: Boolean
|
||||
get() = prefs.getBoolean(SHOW_NOTE_PICKER, false)
|
||||
set(showNotePicker) = prefs.edit().putBoolean(SHOW_NOTE_PICKER, showNotePicker).apply()
|
||||
|
||||
var showWordCount: Boolean
|
||||
get() = prefs.getBoolean(SHOW_WORD_COUNT, false)
|
||||
set(showWordCount) = prefs.edit().putBoolean(SHOW_WORD_COUNT, showWordCount).apply()
|
||||
|
@ -10,6 +10,7 @@ const val CLICKABLE_LINKS = "clickable_links"
|
||||
const val WIDGET_NOTE_ID = "widget_note_id"
|
||||
const val MONOSPACED_FONT = "monospaced_font"
|
||||
const val SHOW_KEYBOARD = "show_keyboard"
|
||||
const val SHOW_NOTE_PICKER = "show_note_picker"
|
||||
const val SHOW_WORD_COUNT = "show_word_count"
|
||||
const val FONT_SIZE = "font_size"
|
||||
const val GRAVITY = "gravity"
|
||||
|
@ -84,7 +84,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
||||
}
|
||||
}
|
||||
|
||||
fun getNotes(): List<Note> {
|
||||
fun getNotes(): ArrayList<Note> {
|
||||
val notes = ArrayList<Note>()
|
||||
val cols = arrayOf(COL_ID, COL_TITLE, COL_VALUE, COL_TYPE, COL_PATH)
|
||||
var cursor: Cursor? = null
|
||||
|
@ -159,6 +159,29 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_note_picker_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_show_note_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/show_note_picker"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_word_count_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user