mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-06-14 03:38:45 +02:00
4076d84efc
* NCA decryption * Remove unnecessary new lines * Remove loader error dialog * Always show ROMs * Address CRs * Add subtitle padding in grid mode
40 lines
1.3 KiB
Kotlin
40 lines
1.3 KiB
Kotlin
/*
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
|
*/
|
|
|
|
package emu.skyline.preference
|
|
|
|
import android.app.Activity
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.net.Uri
|
|
import android.util.AttributeSet
|
|
import androidx.preference.Preference
|
|
import androidx.preference.Preference.SummaryProvider
|
|
import androidx.preference.R
|
|
|
|
/**
|
|
* This preference shows the decoded URI of it's preference and launches [DocumentActivity]
|
|
*/
|
|
class FolderPreference @JvmOverloads constructor(context : Context?, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.preferenceStyle) : Preference(context, attrs, defStyleAttr), ActivityResultDelegate {
|
|
override var requestCode = 0
|
|
|
|
init {
|
|
summaryProvider = SummaryProvider<FolderPreference> { preference ->
|
|
Uri.decode(preference.getPersistedString(""))
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This launches [DocumentActivity] on click to change the directory
|
|
*/
|
|
override fun onClick() {
|
|
(context as Activity).startActivityForResult(Intent(context, FolderActivity::class.java).apply { putExtra(DocumentActivity.KEY_NAME, key) }, requestCode)
|
|
}
|
|
|
|
override fun onActivityResult(requestCode : Int, resultCode : Int, data : Intent?) {
|
|
if (requestCode == requestCode) notifyChanged()
|
|
}
|
|
}
|