Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
a8640f52
Commit
a8640f52
authored
Jan 15, 2022
by
vvb2060
Committed by
John Wu
Jan 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge into one file
parent
0f4e44c3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
147 additions
and
180 deletions
+147
-180
BooleanProperty.kt
...a/com/topjohnwu/magisk/data/preference/BooleanProperty.kt
+0
-30
FloatProperty.kt
...ava/com/topjohnwu/magisk/data/preference/FloatProperty.kt
+0
-30
IntProperty.kt
.../java/com/topjohnwu/magisk/data/preference/IntProperty.kt
+0
-30
LongProperty.kt
...java/com/topjohnwu/magisk/data/preference/LongProperty.kt
+0
-30
Property.kt
...ain/java/com/topjohnwu/magisk/data/preference/Property.kt
+147
-0
StringProperty.kt
...va/com/topjohnwu/magisk/data/preference/StringProperty.kt
+0
-30
StringSetProperty.kt
...com/topjohnwu/magisk/data/preference/StringSetProperty.kt
+0
-30
No files found.
app/src/main/java/com/topjohnwu/magisk/data/preference/BooleanProperty.kt
deleted
100644 → 0
View file @
0f4e44c3
package
com.topjohnwu.magisk.data.preference
import
androidx.core.content.edit
import
com.topjohnwu.magisk.ktx.trimEmptyToNull
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
class
BooleanProperty
(
private
val
name
:
String
,
private
val
default
:
Boolean
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Boolean
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Boolean
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Boolean
)
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
app/src/main/java/com/topjohnwu/magisk/data/preference/FloatProperty.kt
deleted
100644 → 0
View file @
0f4e44c3
package
com.topjohnwu.magisk.data.preference
import
androidx.core.content.edit
import
com.topjohnwu.magisk.ktx.trimEmptyToNull
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
class
FloatProperty
(
private
val
name
:
String
,
private
val
default
:
Float
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Float
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Float
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Float
)
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
app/src/main/java/com/topjohnwu/magisk/data/preference/IntProperty.kt
deleted
100644 → 0
View file @
0f4e44c3
package
com.topjohnwu.magisk.data.preference
import
androidx.core.content.edit
import
com.topjohnwu.magisk.ktx.trimEmptyToNull
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
class
IntProperty
(
private
val
name
:
String
,
private
val
default
:
Int
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Int
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Int
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Int
)
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
app/src/main/java/com/topjohnwu/magisk/data/preference/LongProperty.kt
deleted
100644 → 0
View file @
0f4e44c3
package
com.topjohnwu.magisk.data.preference
import
androidx.core.content.edit
import
com.topjohnwu.magisk.ktx.trimEmptyToNull
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
class
LongProperty
(
private
val
name
:
String
,
private
val
default
:
Long
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Long
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Long
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Long
)
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
app/src/main/java/com/topjohnwu/magisk/data/preference/Property.kt
View file @
a8640f52
package
com.topjohnwu.magisk.data.preference
import
android.content.SharedPreferences
import
androidx.core.content.edit
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
abstract
class
Property
{
...
...
@@ -19,3 +22,147 @@ abstract class Property {
fun
SharedPreferences
.
get
(
name
:
String
,
value
:
Set
<
String
>)
=
getStringSet
(
name
,
value
)
?:
value
}
class
BooleanProperty
(
private
val
name
:
String
,
private
val
default
:
Boolean
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Boolean
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Boolean
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Boolean
)
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
class
FloatProperty
(
private
val
name
:
String
,
private
val
default
:
Float
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Float
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Float
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Float
)
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
class
IntProperty
(
private
val
name
:
String
,
private
val
default
:
Int
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Int
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Int
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Int
)
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
class
LongProperty
(
private
val
name
:
String
,
private
val
default
:
Long
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Long
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Long
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Long
)
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
class
StringProperty
(
private
val
name
:
String
,
private
val
default
:
String
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
String
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
String
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
String
)
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
class
StringSetProperty
(
private
val
name
:
String
,
private
val
default
:
Set
<
String
>,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Set
<
String
>>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Set
<
String
>
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Set
<
String
>
)
{
val
prefName
=
name
.
ifBlank
{
property
.
name
}
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
app/src/main/java/com/topjohnwu/magisk/data/preference/StringProperty.kt
deleted
100644 → 0
View file @
0f4e44c3
package
com.topjohnwu.magisk.data.preference
import
androidx.core.content.edit
import
com.topjohnwu.magisk.ktx.trimEmptyToNull
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
class
StringProperty
(
private
val
name
:
String
,
private
val
default
:
String
,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
String
>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
String
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
String
)
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
app/src/main/java/com/topjohnwu/magisk/data/preference/StringSetProperty.kt
deleted
100644 → 0
View file @
0f4e44c3
package
com.topjohnwu.magisk.data.preference
import
androidx.core.content.edit
import
com.topjohnwu.magisk.ktx.trimEmptyToNull
import
kotlin.properties.ReadWriteProperty
import
kotlin.reflect.KProperty
class
StringSetProperty
(
private
val
name
:
String
,
private
val
default
:
Set
<
String
>,
private
val
commit
:
Boolean
)
:
Property
(),
ReadWriteProperty
<
PreferenceModel
,
Set
<
String
>>
{
override
operator
fun
getValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>
):
Set
<
String
>
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
return
thisRef
.
prefs
.
get
(
prefName
,
default
)
}
override
operator
fun
setValue
(
thisRef
:
PreferenceModel
,
property
:
KProperty
<
*
>,
value
:
Set
<
String
>
)
{
val
prefName
=
name
.
trimEmptyToNull
()
?:
property
.
name
thisRef
.
prefs
.
edit
(
commit
)
{
put
(
prefName
,
value
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment