From 5e54543cfb0e76d035eb1a41a768c8f8d683ec7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Feb 2021 13:22:06 +0100 Subject: [PATCH 01/10] Bump kotlin_version from 1.4.21-2 to 1.4.30 (#97) Bumps `kotlin_version` from 1.4.21-2 to 1.4.30. Updates `kotlin-gradle-plugin` from 1.4.21-2 to 1.4.30 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.4.21-2...v1.4.30) Updates `kotlin-stdlib-jdk7` from 1.4.21-2 to 1.4.30 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.4.21-2...v1.4.30) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fdd9bf8d..505ddcb7 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { ext.library_version = '1.1.0' ext.library_version_code = 1100 - ext.kotlin_version = '1.4.21-2' + ext.kotlin_version = '1.4.30' repositories { google() jcenter() From 6b8565f46c8933bd8986ae8138e53091a84e70ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Feb 2021 13:22:26 +0100 Subject: [PATCH 02/10] Bump aboutlibraries-core from 8.7.0 to 8.7.1 (#96) Bumps [aboutlibraries-core](https://github.com/mikepenz/AboutLibraries) from 8.7.0 to 8.7.1. - [Release notes](https://github.com/mikepenz/AboutLibraries/releases) - [Changelog](https://github.com/mikepenz/AboutLibraries/blob/develop/gradle-release.gradle) - [Commits](https://github.com/mikepenz/AboutLibraries/compare/v8.7.0...v8.7.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- simplesettings/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplesettings/build.gradle b/simplesettings/build.gradle index fabfc063..f6ea9001 100644 --- a/simplesettings/build.gradle +++ b/simplesettings/build.gradle @@ -46,7 +46,7 @@ dependencies { api 'androidx.preference:preference-ktx:1.1.1' // External dependencies - api 'com.mikepenz:aboutlibraries-core:8.7.0' + api 'com.mikepenz:aboutlibraries-core:8.7.1' api 'com.mikepenz:aboutlibraries:8.7.0@aar' api 'com.mikepenz:fastadapter:5.3.2' api 'com.github.ibrahimsn98:live-preferences:1.9' From bc3a35c46e5e9e26cd584cb79fdc86044e16cc68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Feb 2021 13:22:45 +0100 Subject: [PATCH 03/10] Bump aboutlibraries from 8.7.0 to 8.7.1 (#95) Bumps [aboutlibraries](https://github.com/mikepenz/AboutLibraries) from 8.7.0 to 8.7.1. - [Release notes](https://github.com/mikepenz/AboutLibraries/releases) - [Changelog](https://github.com/mikepenz/AboutLibraries/blob/develop/gradle-release.gradle) - [Commits](https://github.com/mikepenz/AboutLibraries/compare/v8.7.0...v8.7.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 60f4ca096727be40d6968ae51f1d25cc55c8d8b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Feb 2021 19:02:40 +0100 Subject: [PATCH 04/10] Bump aboutlibraries from 8.7.0 to 8.8.0 (#99) Bumps [aboutlibraries](https://github.com/mikepenz/AboutLibraries) from 8.7.0 to 8.8.0. - [Release notes](https://github.com/mikepenz/AboutLibraries/releases) - [Changelog](https://github.com/mikepenz/AboutLibraries/blob/develop/gradle-release.gradle) - [Commits](https://github.com/mikepenz/AboutLibraries/compare/v8.7.0...v8.8.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- simplesettings/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplesettings/build.gradle b/simplesettings/build.gradle index f6ea9001..8b998b59 100644 --- a/simplesettings/build.gradle +++ b/simplesettings/build.gradle @@ -47,7 +47,7 @@ dependencies { // External dependencies api 'com.mikepenz:aboutlibraries-core:8.7.1' - api 'com.mikepenz:aboutlibraries:8.7.0@aar' + api 'com.mikepenz:aboutlibraries:8.8.0@aar' api 'com.mikepenz:fastadapter:5.3.2' api 'com.github.ibrahimsn98:live-preferences:1.9' api 'com.github.skydoves:colorpickerpreference:2.0.5' From 4118941bffd93de1daa7b6a8e3b400835723da55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Feb 2021 19:07:39 +0100 Subject: [PATCH 05/10] Bump aboutlibraries-core from 8.7.1 to 8.8.0 (#98) Bumps [aboutlibraries-core](https://github.com/mikepenz/AboutLibraries) from 8.7.1 to 8.8.0. - [Release notes](https://github.com/mikepenz/AboutLibraries/releases) - [Changelog](https://github.com/mikepenz/AboutLibraries/blob/develop/gradle-release.gradle) - [Commits](https://github.com/mikepenz/AboutLibraries/compare/v8.7.1...v8.8.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- simplesettings/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplesettings/build.gradle b/simplesettings/build.gradle index 8b998b59..50a902a5 100644 --- a/simplesettings/build.gradle +++ b/simplesettings/build.gradle @@ -46,7 +46,7 @@ dependencies { api 'androidx.preference:preference-ktx:1.1.1' // External dependencies - api 'com.mikepenz:aboutlibraries-core:8.7.1' + api 'com.mikepenz:aboutlibraries-core:8.8.0' api 'com.mikepenz:aboutlibraries:8.8.0@aar' api 'com.mikepenz:fastadapter:5.3.2' api 'com.github.ibrahimsn98:live-preferences:1.9' From abb55bcdd345d41c3289074b2b582d24c0d53ab7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Feb 2021 13:12:11 +0100 Subject: [PATCH 06/10] Bump material from 1.3.0-rc01 to 1.3.0 (#100) Bumps [material](https://github.com/material-components/material-components-android) from 1.3.0-rc01 to 1.3.0. - [Release notes](https://github.com/material-components/material-components-android/releases) - [Commits](https://github.com/material-components/material-components-android/compare/1.3.0-rc01...1.3.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- app/build.gradle | 2 +- simplesettings/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cf8b89af..592e156b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,7 +39,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.5.0-beta01' // Google dependencies - implementation 'com.google.android.material:material:1.3.0-rc01' + implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' // Test dependencies diff --git a/simplesettings/build.gradle b/simplesettings/build.gradle index 50a902a5..e28b88da 100644 --- a/simplesettings/build.gradle +++ b/simplesettings/build.gradle @@ -42,7 +42,7 @@ dependencies { implementation 'androidx.activity:activity-ktx:1.2.0-rc01' // Google dependencies - api 'com.google.android.material:material:1.2.1' + api 'com.google.android.material:material:1.3.0' api 'androidx.preference:preference-ktx:1.1.1' // External dependencies From 58d36512e5f2524db10dd4e842084e457f0961df Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Fri, 12 Feb 2021 23:26:31 +0100 Subject: [PATCH 07/10] Fix third party dependency name in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae561b31..4f8ea6ab 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ implementation 'com.chillibits:simplesettings:1.1.0' // Required dependencies implementation 'com.google.android.material:material:' -implementation 'androidx.preference:preference:' +implementation 'androidx.preference:preference-ktx:' ``` You also have to register the activity in your manifest: From 928ee9b321d5d96d5dce3348829173121c2317a2 Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sat, 13 Feb 2021 18:37:42 +0100 Subject: [PATCH 08/10] Refactoring --- .../com/chillibits/simplesettings/core/SimpleSettings.kt | 3 +++ .../simplesettings/core/{ => elements}/PreferenceElement.kt | 2 +- .../simplesettings/core/{ => elements}/PreferenceHeader.kt | 2 +- .../simplesettings/core/{ => elements}/PreferencePage.kt | 3 ++- .../simplesettings/core/{ => elements}/PreferenceSection.kt | 2 +- .../chillibits/simplesettings/ui/SimpleSettingsActivity.kt | 4 ++-- .../chillibits/simplesettings/ui/SimpleSettingsFragment.kt | 6 +++++- 7 files changed, 15 insertions(+), 7 deletions(-) rename simplesettings/src/main/java/com/chillibits/simplesettings/core/{ => elements}/PreferenceElement.kt (79%) rename simplesettings/src/main/java/com/chillibits/simplesettings/core/{ => elements}/PreferenceHeader.kt (89%) rename simplesettings/src/main/java/com/chillibits/simplesettings/core/{ => elements}/PreferencePage.kt (93%) rename simplesettings/src/main/java/com/chillibits/simplesettings/core/{ => elements}/PreferenceSection.kt (98%) diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/SimpleSettings.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/SimpleSettings.kt index aef5b6b6..a414eb60 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/SimpleSettings.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/SimpleSettings.kt @@ -7,6 +7,9 @@ package com.chillibits.simplesettings.core import android.content.Context import android.content.Intent import androidx.annotation.XmlRes +import com.chillibits.simplesettings.core.elements.PreferenceElement +import com.chillibits.simplesettings.core.elements.PreferenceHeader +import com.chillibits.simplesettings.core.elements.PreferenceSection import com.chillibits.simplesettings.ui.SimpleSettingsActivity class SimpleSettings( diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceElement.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceElement.kt similarity index 79% rename from simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceElement.kt rename to simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceElement.kt index 9d7f0eb7..920968c3 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceElement.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceElement.kt @@ -1,4 +1,4 @@ -package com.chillibits.simplesettings.core +package com.chillibits.simplesettings.core.elements import android.content.Context diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceHeader.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceHeader.kt similarity index 89% rename from simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceHeader.kt rename to simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceHeader.kt index 21d0b689..14d6f558 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceHeader.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceHeader.kt @@ -1,4 +1,4 @@ -package com.chillibits.simplesettings.core +package com.chillibits.simplesettings.core.elements import android.content.Context import androidx.annotation.LayoutRes diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferencePage.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt similarity index 93% rename from simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferencePage.kt rename to simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt index b70d28b2..4d49b85c 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferencePage.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt @@ -2,9 +2,10 @@ * Copyright © Marc Auberer 2020-2021. All rights reserved */ -package com.chillibits.simplesettings.core +package com.chillibits.simplesettings.core.elements import android.content.Context +import com.chillibits.simplesettings.core.SimpleSettings import com.chillibits.simplesettings.item.SimplePreference /** diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceSection.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt similarity index 98% rename from simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceSection.kt rename to simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt index 5f26654e..6b3d411c 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/PreferenceSection.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt @@ -2,7 +2,7 @@ * Copyright © Marc Auberer 2020-2021. All rights reserved */ -package com.chillibits.simplesettings.core +package com.chillibits.simplesettings.core.elements import android.content.Context import com.chillibits.simplesettings.item.* diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsActivity.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsActivity.kt index e12caf14..2973c5e1 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsActivity.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsActivity.kt @@ -13,9 +13,9 @@ import android.view.MenuItem import android.view.View import androidx.appcompat.app.AppCompatActivity import com.chillibits.simplesettings.R -import com.chillibits.simplesettings.core.PreferenceHeader -import com.chillibits.simplesettings.core.PreferenceSection import com.chillibits.simplesettings.core.SimpleSettings +import com.chillibits.simplesettings.core.elements.PreferenceHeader +import com.chillibits.simplesettings.core.elements.PreferenceSection import com.chillibits.simplesettings.exception.SettingsResetException import com.chillibits.simplesettings.tool.Constants import com.chillibits.simplesettings.tool.getPrefs diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsFragment.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsFragment.kt index a6313115..2513da48 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsFragment.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/ui/SimpleSettingsFragment.kt @@ -7,7 +7,11 @@ package com.chillibits.simplesettings.ui import android.os.Bundle import androidx.core.content.res.ResourcesCompat import androidx.preference.* -import com.chillibits.simplesettings.core.* +import com.chillibits.simplesettings.core.SimpleSettings +import com.chillibits.simplesettings.core.SimpleSettingsConfig +import com.chillibits.simplesettings.core.elements.PreferenceHeader +import com.chillibits.simplesettings.core.elements.PreferencePage +import com.chillibits.simplesettings.core.elements.PreferenceSection import com.chillibits.simplesettings.item.* import com.chillibits.simplesettings.tool.SimpleMSListPreferenceSummaryProvider import com.chillibits.simplesettings.tool.toCamelCase From 4e37436209b8055250c1bc0a2669e8cb8f824a6d Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sat, 13 Feb 2021 19:37:32 +0100 Subject: [PATCH 09/10] Allow setting string properties with resource ids --- .../core/elements/PreferencePage.kt | 7 ++- .../core/elements/PreferenceSection.kt | 21 ++++--- .../item/SimpleCheckboxPreference.kt | 14 ++++- .../item/SimpleColorPreference.kt | 19 +++++- .../item/SimpleDropDownPreference.kt | 12 +++- .../item/SimpleInputPreference.kt | 22 +++++-- .../item/SimpleLibsPreference.kt | 58 +++++++++++++++++-- .../item/SimpleListPreference.kt | 24 +++++++- .../item/SimpleMSListPreference.kt | 25 +++++++- .../simplesettings/item/SimplePreference.kt | 22 +++++++ .../item/SimpleSeekBarPreference.kt | 9 ++- .../item/SimpleSwitchPreference.kt | 14 ++++- .../item/SimpleTextPreference.kt | 5 +- 13 files changed, 221 insertions(+), 31 deletions(-) diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt index 4d49b85c..011997d5 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferencePage.kt @@ -5,6 +5,7 @@ package com.chillibits.simplesettings.core.elements import android.content.Context +import androidx.annotation.StringRes import com.chillibits.simplesettings.core.SimpleSettings import com.chillibits.simplesettings.item.SimplePreference @@ -15,11 +16,15 @@ import com.chillibits.simplesettings.item.SimplePreference class PreferencePage( private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var subSections = ArrayList() + var activityTitle = "" + @StringRes var activityTitleRes = 0 + set(value) { activityTitle = context.getString(value) } + var displayHomeAsUpEnabled = true // ----------------------------------- Preference section -------------------------------------- diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt index 6b3d411c..880c7c2b 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/core/elements/PreferenceSection.kt @@ -5,6 +5,7 @@ package com.chillibits.simplesettings.core.elements import android.content.Context +import androidx.annotation.StringRes import com.chillibits.simplesettings.item.* /** @@ -18,7 +19,11 @@ class PreferenceSection( // Attributes var title = "" + @StringRes var titleRes = 0 + set(value) { title = context.getString(value) } + var enabled = true + val items = ArrayList() // ----------------------------------------- Item types ---------------------------------------- @@ -38,7 +43,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleTextPreference */ fun TextPref(func: SimpleTextPreference.() -> Unit) - = SimpleTextPreference(iconSpaceReserved).apply { + = SimpleTextPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -48,7 +53,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleSwitchPreference */ fun SwitchPref(func: SimpleSwitchPreference.() -> Unit) - = SimpleSwitchPreference(iconSpaceReserved).apply { + = SimpleSwitchPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -58,7 +63,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleCheckboxPreference */ fun CheckboxPref(func: SimpleCheckboxPreference.() -> Unit) - = SimpleCheckboxPreference(iconSpaceReserved).apply { + = SimpleCheckboxPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -68,7 +73,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleInputPreference */ fun InputPref(func: SimpleInputPreference.() -> Unit) - = SimpleInputPreference(iconSpaceReserved).apply { + = SimpleInputPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -78,7 +83,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleListPreference */ fun ListPref(func: SimpleListPreference.() -> Unit) - = SimpleListPreference(iconSpaceReserved).apply { + = SimpleListPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -88,7 +93,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleMSListPreference */ fun MSListPref(func: SimpleMSListPreference.() -> Unit) - = SimpleMSListPreference(iconSpaceReserved).apply { + = SimpleMSListPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -98,7 +103,7 @@ class PreferenceSection( * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleDropDownPreference */ fun DropDownPref(func: SimpleDropDownPreference.() -> Unit) - = SimpleDropDownPreference(iconSpaceReserved).apply { + = SimpleDropDownPreference(context, iconSpaceReserved).apply { func() items.add(this) } @@ -107,7 +112,7 @@ class PreferenceSection( * Seek Bar Preference. For selecting a number between two customizable bounds. * More information: https://github.com/marcauberer/simple-settings/wiki/SimpleSeekbarPreference */ - fun SeekBarPref(func: SimpleSeekBarPreference.() -> Unit) = SimpleSeekBarPreference(iconSpaceReserved).apply { + fun SeekBarPref(func: SimpleSeekBarPreference.() -> Unit) = SimpleSeekBarPreference(context, iconSpaceReserved).apply { func() items.add(this) } diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleCheckboxPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleCheckboxPreference.kt index b9c5695c..70749366 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleCheckboxPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleCheckboxPreference.kt @@ -4,14 +4,26 @@ package com.chillibits.simplesettings.item +import android.content.Context +import androidx.annotation.StringRes + class SimpleCheckboxPreference( + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var defaultValue = OFF + var summaryOn = "" + @StringRes + var summaryOnRes = 0 + set(value) { summaryOn = context.getString(value) } + var summaryOff = "" + @StringRes + var summaryOffRes = 0 + set(value) { summaryOff = context.getString(value) } companion object { const val OFF = false diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleColorPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleColorPreference.kt index 399a4795..153ea9ca 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleColorPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleColorPreference.kt @@ -1,18 +1,33 @@ package com.chillibits.simplesettings.item import android.content.Context +import androidx.annotation.StringRes import com.chillibits.simplesettings.R class SimpleColorPreference( - context: Context, + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var attachAlphaSlideBar = false + var attachBrightnessSlideBar = false + var colorBoxRadius = 26.0 + var dialogNegative = context.getString(R.string.cancel) + @StringRes + var dialogNegativeRes = 0 + set(value) { dialogNegative = context.getString(value) } + var dialogPositive = context.getString(R.string.ok) + @StringRes + var dialogPositiveRes = 0 + set(value) { dialogPositive = context.getString(value) } + var dialogTitle = title + @StringRes + var dialogTitleRes = 0 + set(value) { dialogTitle = context.getString(value) } } \ No newline at end of file diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleDropDownPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleDropDownPreference.kt index 030368a8..668065da 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleDropDownPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleDropDownPreference.kt @@ -4,12 +4,20 @@ package com.chillibits.simplesettings.item +import android.content.Context +import androidx.annotation.ArrayRes + class SimpleDropDownPreference( + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var defaultIndex = 0 + var simpleSummaryProvider = false - var entries: List = emptyList() + + var entries = emptyList() + @ArrayRes var entriesRes = 0 + set(value) { entries = context.resources.getStringArray(value).toList() } } \ No newline at end of file diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleInputPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleInputPreference.kt index 66f18d81..729a6833 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleInputPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleInputPreference.kt @@ -4,21 +4,35 @@ package com.chillibits.simplesettings.item +import android.content.Context import android.graphics.drawable.Drawable import androidx.annotation.DrawableRes import androidx.annotation.LayoutRes +import androidx.annotation.StringRes class SimpleInputPreference( + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { + // Attributes var defaultValue = "" + @StringRes var defaultValueRes = 0 + set(value) { defaultValue = context.getString(value) } + var dialogTitle = "" + @StringRes var dialogTitleRes = 0 + set(value) { dialogTitle = context.getString(value) } + var dialogMessage: String? = null + @StringRes var dialogMessageRes = 0 + set(value) { dialogMessage = context.getString(value) } + + var dialogIcon: Drawable? = null @DrawableRes var dialogIconRes = 0 - var dialogIcon: Drawable? = null - @LayoutRes - var dialogLayoutRes = 0 + set(value) { dialogIcon = context.getDrawable(value) } + + @LayoutRes var dialogLayoutRes = 0 var simpleSummaryProvider = false } \ No newline at end of file diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleLibsPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleLibsPreference.kt index 42886131..2705ef53 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleLibsPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleLibsPreference.kt @@ -5,44 +5,92 @@ package com.chillibits.simplesettings.item import android.content.Context +import androidx.annotation.StringRes import com.chillibits.simplesettings.R import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.aboutlibraries.ui.LibsActivity import java.util.* class SimpleLibsPreference( - context: Context, + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var activityTitle: String? = null + @StringRes var activityTitleRes = 0 + set(value) { activityTitle = context.getString(value) } + var edgeToEdge = false + var aboutAppName: String? = null + @StringRes var aboutAppNameRes = 0 + set(value) { aboutAppName = context.getString(value) } + var aboutAppSpecial1: String? = null + @StringRes var aboutAppSpecial1Res = 0 + set(value) { aboutAppSpecial1 = context.getString(value) } + var aboutAppSpecial1Description: String? = null + @StringRes var aboutAppSpecial1DescriptionRes = 0 + set(value) { aboutAppSpecial1Description = context.getString(value) } + var aboutAppSpecial2: String? = null + @StringRes var aboutAppSpecial2Res = 0 + set(value) { aboutAppSpecial2 = context.getString(value) } + var aboutAppSpecial2Description: String? = null + @StringRes var aboutAppSpecial2DescriptionRes = 0 + set(value) { aboutAppSpecial2Description = context.getString(value) } + var aboutAppSpecial3: String? = null + @StringRes var aboutAppSpecial3Res = 0 + set(value) { aboutAppSpecial3 = context.getString(value) } + var aboutAppSpecial3Description: String? = null + @StringRes var aboutAppSpecial3DescriptionRes = 0 + set(value) { aboutAppSpecial3Description = context.getString(value) } + var aboutDescription: String? = null + @StringRes var aboutDescriptionRes = 0 + set(value) { aboutDescription = context.getString(value) } + var aboutMinimalDesign = false + var aboutShowIcon = true + var aboutShowVersion = true + var aboutShowVersionCode = true + var aboutShowVersionName = true + var aboutVersionString = "" + @StringRes var aboutVersionStringRes = 0 + set(value) { aboutVersionString = context.getString(value) } + var autoDetect = true + var checkCachedDetection = true - var fields: Array = emptyArray() - var internalLibraries: Array = emptyArray() - var excludeLibraries: Array = emptyArray() + + var fields = emptyArray() + + var internalLibraries = emptyArray() + + var excludeLibraries = emptyArray() + var libraryComparator: Comparator? = null + var ownLibsActivityClass: Class<*> = LibsActivity::class.java + var showLicense = false + var showLicenseDialog = true + var showLoadingProgress = true + var showVersion = true + var sort = true init { diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleListPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleListPreference.kt index 6ee3e9a8..77914a67 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleListPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleListPreference.kt @@ -4,23 +4,43 @@ package com.chillibits.simplesettings.item +import android.content.Context import android.graphics.drawable.Drawable +import androidx.annotation.ArrayRes import androidx.annotation.DrawableRes import androidx.annotation.LayoutRes +import androidx.annotation.StringRes +import androidx.core.content.ContextCompat class SimpleListPreference( + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var defaultIndex = 0 + var dialogTitle = "" + @StringRes + var dialogTitleRes = 0 + set(value) { dialogTitle = context.getString(value) } + var dialogMessage: String? = null + @StringRes + var dialogMessageRes = 0 + set(value) { dialogMessage = context.getString(value) } + + var dialogIcon: Drawable? = null @DrawableRes var dialogIconRes = 0 - var dialogIcon: Drawable? = null + set(value) { dialogIcon = ContextCompat.getDrawable(context, value) } + @LayoutRes var dialogLayoutRes = 0 + var simpleSummaryProvider = false + var entries: List = emptyList() + @ArrayRes var entriesRes = 0 + set(value) { entries = context.resources.getStringArray(value).toList() } } \ No newline at end of file diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleMSListPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleMSListPreference.kt index 765f6090..94d296d3 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleMSListPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleMSListPreference.kt @@ -4,23 +4,44 @@ package com.chillibits.simplesettings.item +import android.content.Context import android.graphics.drawable.Drawable +import androidx.annotation.ArrayRes import androidx.annotation.DrawableRes import androidx.annotation.LayoutRes +import androidx.annotation.StringRes +import androidx.core.content.ContextCompat class SimpleMSListPreference( + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var defaultIndex = emptySet() + var dialogTitle = "" + @StringRes + var dialogTitleRes = 0 + set(value) { dialogTitle = context.getString(value) } + var dialogMessage: String? = null + @StringRes + var dialogMessageRes = 0 + set(value) { dialogMessage = context.getString(value) } + + var dialogIcon: Drawable? = null @DrawableRes var dialogIconRes = 0 - var dialogIcon: Drawable? = null + set(value) { dialogIcon = ContextCompat.getDrawable(context, value) } + @LayoutRes var dialogLayoutRes = 0 + var simpleSummaryProvider = false + var entries: List = emptyList() + @ArrayRes + var entriesRes = 0 + set(value) { entries = context.resources.getStringArray(value).toList() } } \ No newline at end of file diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimplePreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimplePreference.kt index 9eedce01..12c5d8fe 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimplePreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimplePreference.kt @@ -4,22 +4,44 @@ package com.chillibits.simplesettings.item +import android.content.Context import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import androidx.preference.Preference abstract class SimplePreference( + private val context: Context, iconSpaceReservedByDefault: Boolean ) { // Attributes var key = "" + @StringRes + var keyRes = 0 + set(value) { key = context.getString(value) } + var title = "" + @StringRes + var titleRes = 0 + set(value) { title = context.getString(value) } + var summary = "" + @StringRes + var summaryRes = 0 + set(value) { summary = context.getString(value) } + var dependency = "" + @StringRes + var dependencyRes = 0 + set(value) { dependency = context.getString(value) } + var enabled = true + @DrawableRes var icon: Int = 0 + var iconSpaceReserved = iconSpaceReservedByDefault + var onClick: Preference.OnPreferenceClickListener? = null companion object { diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSeekBarPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSeekBarPreference.kt index ccbf8d7e..499cfeae 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSeekBarPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSeekBarPreference.kt @@ -4,14 +4,19 @@ package com.chillibits.simplesettings.item +import android.content.Context + class SimpleSeekBarPreference( + context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var min = 0 + var max = 100 + var defaultValue = 0 - var showValue = false + var showValue = false } \ No newline at end of file diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSwitchPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSwitchPreference.kt index 8e0eb36b..702b3281 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSwitchPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleSwitchPreference.kt @@ -4,14 +4,26 @@ package com.chillibits.simplesettings.item +import android.content.Context +import androidx.annotation.StringRes + class SimpleSwitchPreference( + private val context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) { +): SimplePreference(context, iconSpaceReservedByDefault) { // Attributes var defaultValue = OFF + var summaryOn = "" + @StringRes + var summaryOnRes = 0 + set(value) { summaryOn = context.getString(value) } + var summaryOff = "" + @StringRes + var summaryOffRes = 0 + set(value) { summaryOff = context.getString(value) } companion object { const val OFF = false diff --git a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleTextPreference.kt b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleTextPreference.kt index 28d7ea0c..d839bcb3 100644 --- a/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleTextPreference.kt +++ b/simplesettings/src/main/java/com/chillibits/simplesettings/item/SimpleTextPreference.kt @@ -4,6 +4,9 @@ package com.chillibits.simplesettings.item +import android.content.Context + class SimpleTextPreference( + context: Context, iconSpaceReservedByDefault: Boolean -): SimplePreference(iconSpaceReservedByDefault) \ No newline at end of file +): SimplePreference(context, iconSpaceReservedByDefault) \ No newline at end of file From fc3a16a95ab3935aacd39ebeb020b19bb375b856 Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sat, 13 Feb 2021 19:53:34 +0100 Subject: [PATCH 10/10] Bump version to 1.1.1 --- README.md | 4 +++- .../java/com/chillibits/simplesettingssample/MainActivity.kt | 2 +- build.gradle | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4f8ea6ab..e740329e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If you want to test the library, please visit the sample app on [Google Play](ht ## Usage The first step for using this library is, to add it to the dependency section in your project: ```gradle -implementation 'com.chillibits:simplesettings:1.1.0' +implementation 'com.chillibits:simplesettings:1.1.1' // Required dependencies implementation 'com.google.android.material:material:' @@ -67,6 +67,8 @@ SimpleSettings(this).show { ``` This is especially useful, when you need to generate your preferences at runtime. You can use loops and conditions as you can see above. +*Note: If you want to pass a string / drawable / layout with its resource id, please use the properties with the `Res` suffix. For example: `titleRes = R.string.app_name`.* + *Note: It is not mandatory to pass keys to each preference. In this cases, the library does auto-generate a key by converting the title of each preference to CamelCase.*
**Examples**: ``` diff --git a/app/src/main/java/com/chillibits/simplesettingssample/MainActivity.kt b/app/src/main/java/com/chillibits/simplesettingssample/MainActivity.kt index 00ab89fe..02b9f3a5 100644 --- a/app/src/main/java/com/chillibits/simplesettingssample/MainActivity.kt +++ b/app/src/main/java/com/chillibits/simplesettingssample/MainActivity.kt @@ -86,7 +86,7 @@ class MainActivity : AppCompatActivity(), SimpleSettingsConfig.OptionsItemSelect // Programmatic settings data (especially useful for generating settings options at runtime) SimpleSettings(this, config).show { Section { - title = "Section" + titleRes = R.string.app_name for (i in 1..numberOfSwitchPreferences) { SwitchPref { title = "SwitchPreference $i" diff --git a/build.gradle b/build.gradle index 505ddcb7..ddd018ba 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ */ buildscript { - ext.library_version = '1.1.0' - ext.library_version_code = 1100 + ext.library_version = '1.1.1' + ext.library_version_code = 1101 ext.kotlin_version = '1.4.30' repositories { google()