74 lines
2.7 KiB
Kotlin
74 lines
2.7 KiB
Kotlin
/*
|
|
* Pupil, Hitomi.la viewer for Android
|
|
* Copyright (C) 2019 tom5079
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package xyz.quaver.pupil.ui
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.app.Activity
|
|
import android.content.Intent
|
|
import android.content.pm.PackageManager
|
|
import android.os.Bundle
|
|
import android.view.MenuItem
|
|
import android.view.WindowManager
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import com.google.android.material.snackbar.Snackbar
|
|
import kotlinx.serialization.decodeFromString
|
|
import kotlinx.serialization.json.Json
|
|
import xyz.quaver.pupil.R
|
|
import xyz.quaver.pupil.favorites
|
|
import xyz.quaver.pupil.ui.fragment.LockSettingsFragment
|
|
import xyz.quaver.pupil.ui.fragment.SettingsFragment
|
|
import xyz.quaver.pupil.util.Preferences
|
|
import xyz.quaver.pupil.util.normalizeID
|
|
import java.nio.charset.Charset
|
|
|
|
class SettingsActivity : BaseActivity() {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.settings_activity)
|
|
supportFragmentManager
|
|
.beginTransaction()
|
|
.replace(R.id.settings, SettingsFragment())
|
|
.commit()
|
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
}
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
when (item.itemId) {
|
|
android.R.id.home -> onBackPressed()
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
@SuppressLint("InlinedApi")
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
|
when (requestCode) {
|
|
R.id.request_write_permission_and_saf.normalizeID() -> {
|
|
if (grantResults.firstOrNull() == PackageManager.PERMISSION_GRANTED) {
|
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply {
|
|
putExtra("android.content.extra.SHOW_ADVANCED", true)
|
|
}
|
|
|
|
startActivityForResult(intent, R.id.request_download_folder.normalizeID())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |