Skip to content

Commit 98a3798

Browse files
committed
add an option to show a note picker on startup
1 parent eccdd52 commit 98a3798

File tree

6 files changed

+46
-3
lines changed

6 files changed

+46
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
7171
}
7272

7373
storeStateVariables()
74+
if (config.showNotePicker) {
75+
displayOpenNoteDialog()
76+
}
7477
wasInit = true
7578
}
7679

@@ -204,8 +207,9 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
204207
addOnPageChangeListener(this@MainActivity)
205208
}
206209

207-
if (!config.showKeyboard)
210+
if (!config.showKeyboard) {
208211
hideKeyboard()
212+
}
209213
}
210214

211215
private fun currentNotesView() = if (view_pager == null) {

app/src/main/kotlin/com/simplemobiletools/notes/activities/SettingsActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import java.util.*
1919

2020
class SettingsActivity : SimpleActivity() {
2121
lateinit var res: Resources
22+
var notes = ArrayList<Note>()
2223

2324
override fun onCreate(savedInstanceState: Bundle?) {
2425
super.onCreate(savedInstanceState)
2526
setContentView(R.layout.activity_settings)
2627
res = resources
28+
notes = dbHelper.getNotes()
2729
}
2830

2931
override fun onResume() {
@@ -35,6 +37,7 @@ class SettingsActivity : SimpleActivity() {
3537
setupClickableLinks()
3638
setupMonospacedFont()
3739
setupShowKeyboard()
40+
setupShowNotePicker()
3841
setupShowWordCount()
3942
setupFontSize()
4043
setupGravity()
@@ -91,6 +94,15 @@ class SettingsActivity : SimpleActivity() {
9194
}
9295
}
9396

97+
private fun setupShowNotePicker() {
98+
settings_show_note_picker_holder.beVisibleIf(notes.size > 1)
99+
settings_show_note_picker.isChecked = config.showNotePicker
100+
settings_show_note_picker_holder.setOnClickListener {
101+
settings_show_note_picker.toggle()
102+
config.showNotePicker = settings_show_note_picker.isChecked
103+
}
104+
}
105+
94106
private fun setupShowWordCount() {
95107
settings_show_word_count.isChecked = config.showWordCount
96108
settings_show_word_count_holder.setOnClickListener {
@@ -146,7 +158,6 @@ class SettingsActivity : SimpleActivity() {
146158
})
147159

148160
private fun setupWidgetNote() {
149-
val notes = dbHelper.getNotes()
150161
if (notes.size <= 1) {
151162
settings_widget_note_holder.visibility = View.GONE
152163
return

app/src/main/kotlin/com/simplemobiletools/notes/helpers/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class Config(context: Context) : BaseConfig(context) {
2525
get() = prefs.getBoolean(SHOW_KEYBOARD, true)
2626
set(showKeyboard) = prefs.edit().putBoolean(SHOW_KEYBOARD, showKeyboard).apply()
2727

28+
var showNotePicker: Boolean
29+
get() = prefs.getBoolean(SHOW_NOTE_PICKER, false)
30+
set(showNotePicker) = prefs.edit().putBoolean(SHOW_NOTE_PICKER, showNotePicker).apply()
31+
2832
var showWordCount: Boolean
2933
get() = prefs.getBoolean(SHOW_WORD_COUNT, false)
3034
set(showWordCount) = prefs.edit().putBoolean(SHOW_WORD_COUNT, showWordCount).apply()

app/src/main/kotlin/com/simplemobiletools/notes/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const val CLICKABLE_LINKS = "clickable_links"
1010
const val WIDGET_NOTE_ID = "widget_note_id"
1111
const val MONOSPACED_FONT = "monospaced_font"
1212
const val SHOW_KEYBOARD = "show_keyboard"
13+
const val SHOW_NOTE_PICKER = "show_note_picker"
1314
const val SHOW_WORD_COUNT = "show_word_count"
1415
const val FONT_SIZE = "font_size"
1516
const val GRAVITY = "gravity"

app/src/main/kotlin/com/simplemobiletools/notes/helpers/DBHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
8484
}
8585
}
8686

87-
fun getNotes(): List<Note> {
87+
fun getNotes(): ArrayList<Note> {
8888
val notes = ArrayList<Note>()
8989
val cols = arrayOf(COL_ID, COL_TITLE, COL_VALUE, COL_TYPE, COL_PATH)
9090
var cursor: Cursor? = null

app/src/main/res/layout/activity_settings.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,29 @@
159159

160160
</RelativeLayout>
161161

162+
<RelativeLayout
163+
android:id="@+id/settings_show_note_picker_holder"
164+
android:layout_width="match_parent"
165+
android:layout_height="wrap_content"
166+
android:layout_marginTop="@dimen/medium_margin"
167+
android:background="?attr/selectableItemBackground"
168+
android:paddingBottom="@dimen/bigger_margin"
169+
android:paddingLeft="@dimen/activity_margin"
170+
android:paddingRight="@dimen/activity_margin"
171+
android:paddingTop="@dimen/bigger_margin">
172+
173+
<com.simplemobiletools.commons.views.MySwitchCompat
174+
android:id="@+id/settings_show_note_picker"
175+
android:layout_width="match_parent"
176+
android:layout_height="wrap_content"
177+
android:background="@null"
178+
android:clickable="false"
179+
android:paddingLeft="@dimen/medium_margin"
180+
android:paddingStart="@dimen/medium_margin"
181+
android:text="@string/show_note_picker"/>
182+
183+
</RelativeLayout>
184+
162185
<RelativeLayout
163186
android:id="@+id/settings_show_word_count_holder"
164187
android:layout_width="match_parent"

0 commit comments

Comments
 (0)