Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: StringArrayListMDMSetting should check for String[] #527

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,26 @@ class StringMDMSetting(key: String, localizedTitle: String) :

class StringArrayListMDMSetting(key: String, localizedTitle: String) :
MDMSetting<List<String>?>(null, key, localizedTitle) {
override fun getFromBundle(bundle: Bundle) = bundle.getStringArrayList(key)
override fun getFromPrefs(prefs: SharedPreferences) =
prefs.getStringSet(key, HashSet<String>())?.toList()
override fun getFromBundle(bundle: Bundle): List<String>? {
// Try to retrieve the value as a String[] first
val stringArray = bundle.getStringArray(key)
if (stringArray != null) {
return stringArray.toList()
}

// Optionally, handle other types if necessary
val stringArrayList = bundle.getStringArrayList(key)
if (stringArrayList != null) {
return stringArrayList
}

// If neither String[] nor ArrayList<String> is found, return null
return null
}

override fun getFromPrefs(prefs: SharedPreferences): List<String>? {
return prefs.getStringSet(key, HashSet<String>())?.toList()
}
}

class AlwaysNeverUserDecidesMDMSetting(key: String, localizedTitle: String) :
Expand Down
Loading