Skip to content

Commit

Permalink
- Add background kill info to settings
Browse files Browse the repository at this point in the history
- Fix category add long click crash
- Update version
  • Loading branch information
YahiaAngelo committed Aug 9, 2020
1 parent 008173c commit 2359de3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 22 deletions.
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId "com.noted.noted"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
versionCode 2
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -69,6 +69,9 @@ dependencies {
implementation "io.noties.markwon:core:4.3.1"
implementation "io.noties.markwon:ext-strikethrough:4.3.1"
implementation 'com.yahiaangelo.markdownedittext:markdownedittext:1.0.1'
implementation('dev.doubledot.doki:library:0.0.1@aar') {
transitive = true
}
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:3.0.0-RC2'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'com.google.code.gson:gson:2.8.6'
Expand Down
41 changes: 21 additions & 20 deletions app/src/main/java/com/noted/noted/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,28 @@ class Utils {
}
}
listView.setOnItemLongClickListener { _, _, position, _ ->
val noteCategory = dbCategories[position - 1]!!
MaterialAlertDialogBuilder(context)
.setTitle("Delete category")
.setMessage("Do you want to delete ${noteCategory.title} category ?")
.setNeutralButton("Delete"
) { dialog, _ ->
itemsList.removeAt(position)
realm = Realm.getDefaultInstance()
realm.use {
it.beginTransaction()
noteCategory.deleteFromRealm()
it.commitTransaction()
if (position > 0){
val noteCategory = dbCategories[position - 1]!!
MaterialAlertDialogBuilder(context)
.setTitle("Delete category")
.setMessage("Do you want to delete ${noteCategory.title} category ?")
.setNeutralButton("Delete"
) { dialog, _ ->
itemsList.removeAt(position)
realm = Realm.getDefaultInstance()
realm.use {
it.beginTransaction()
noteCategory.deleteFromRealm()
it.commitTransaction()
}
simpleAdapter.notifyDataSetChanged()
dialog.dismiss()
}
simpleAdapter.notifyDataSetChanged()
dialog.dismiss()
}
.setNegativeButton(context.resources.getString(android.R.string.cancel)) { dialog, _ ->
dialog.dismiss()
}
.show()

.setNegativeButton(context.resources.getString(android.R.string.cancel)) { dialog, _ ->
dialog.dismiss()
}
.show()
}
true
}
categoriesBottomSheet.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import com.noted.noted.R
import dev.doubledot.doki.ui.DokiActivity

class SettingsActivity : AppCompatActivity() {

Expand All @@ -32,6 +34,7 @@ class SettingsActivity : AppCompatActivity() {
val themePreference = findPreference<ListPreference>("theme")
val notesStylePreference = findPreference<ListPreference>("notes_grid")
val timeFormatPreference = findPreference<SwitchPreference>("hour_format")
val batteryOptimizationPreference = findPreference<Preference>("batt_opt")
themePreference!!.setOnPreferenceChangeListener { _, newValue ->
when(newValue){
"system" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
Expand All @@ -55,6 +58,12 @@ class SettingsActivity : AppCompatActivity() {
commit()
}
}

batteryOptimizationPreference!!.setOnPreferenceClickListener {
DokiActivity.start(requireContext())

true
}
}

}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_info_black.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/text_secondary"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,17c-0.55,0 -1,-0.45 -1,-1v-4c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v4c0,0.55 -0.45,1 -1,1zM13,9h-2L11,7h2v2z"
android:fillColor="#000000"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@
app:defaultValue="false"
app:key="hour_format" />

</PreferenceCategory>

<PreferenceCategory app:title="Notifications">
<Preference
app:selectable="false"
app:persistent="false"
app:icon="@drawable/ic_info_black"
app:summary="Sometimes, Reminder notification might not trigger due to the aggressive battery optimization by your phone manufacturer." />
<Preference
app:key="batt_opt"
app:title="Learn more"
/>
</PreferenceCategory>


Expand Down

0 comments on commit 2359de3

Please sign in to comment.