From 167989e29b85261ba8374399669ee0b47fce96f9 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 10 May 2022 22:05:15 +0200 Subject: [PATCH 1/4] New Settings Activity --- app/src/main/AndroidManifest.xml | 4 + .../java/com/github/libretube/MainActivity.kt | 5 +- .../com/github/libretube/SettingsActivity.kt | 316 ++++++++++++++++++ app/src/main/res/drawable/ic_arrow_back.xml | 5 + app/src/main/res/layout/activity_settings.xml | 9 + app/src/main/res/values/strings.xml | 1 + 6 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/github/libretube/SettingsActivity.kt create mode 100644 app/src/main/res/drawable/ic_arrow_back.xml create mode 100644 app/src/main/res/layout/activity_settings.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 31c00cbde..4cee2a677 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,6 +27,10 @@ android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:configChanges="orientation|screenSize" /> + + } + + override fun onCreate(savedInstanceState: Bundle?) { + getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? -> + + if (uri != null) { + try { + // Open a specific media item using ParcelFileDescriptor. + val resolver: ContentResolver = + requireActivity() + .contentResolver + + // "rw" for read-and-write; + // "rwt" for truncating or overwriting existing file contents. + //val readOnlyMode = "r" + // uri - I have got from onActivityResult + val type = resolver.getType(uri) + + var inputStream: InputStream? = resolver.openInputStream(uri) + val channels = ArrayList() + if(type == "application/json"){ + val json = inputStream?.bufferedReader()?.readLines()?.get(0) + val jsonObject = JSONTokener(json).nextValue() as JSONObject + Log.e(TAG,jsonObject.getJSONArray("subscriptions").toString()) + for (i in 0 until jsonObject.getJSONArray("subscriptions").length()) { + var url = jsonObject.getJSONArray("subscriptions").getJSONObject(i).getString("url") + url = url.replace("https://www.youtube.com/channel/","") + Log.e(TAG,url) + channels.add(url) + } + }else { + if (type == "application/zip") { + val zis = ZipInputStream(inputStream) + var entry: ZipEntry? = zis.nextEntry + while (entry != null) { + if (entry.name.endsWith(".csv")) { + inputStream = zis + break + } + entry = zis.nextEntry + } + } + + inputStream?.bufferedReader()?.readLines()?.forEach { + if (it.isNotBlank()) { + val channelId = it.substringBefore(",") + if (channelId.length == 24) + channels.add(channelId) + } + } + } + inputStream?.close() + + subscribe(channels) + } catch (e: Exception) { + Log.e(TAG, e.toString()) + Toast.makeText( + context, + R.string.error, + Toast.LENGTH_SHORT + ).show() + } + } + + + } + super.onCreate(savedInstanceState) + } + + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.settings, rootKey) + val instance = findPreference("instance") + fetchInstance() + instance?.setOnPreferenceChangeListener { _, newValue -> + RetrofitInstance.url = newValue.toString() + RetrofitInstance.lazyMgr.reset() + val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) + if (sharedPref?.getString("token", "") != "") { + with(sharedPref!!.edit()) { + putString("token", "") + apply() + } + Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show() + } + true + } + + val login = findPreference("login_register") + login?.setOnPreferenceClickListener { + val newFragment = LoginDialog() + newFragment.show(childFragmentManager, "Login") + true + } + + val importFromYt = findPreference("import_from_yt") + importFromYt?.setOnPreferenceClickListener { + val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) + val token = sharedPref?.getString("token", "")!! + //check StorageAccess + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + Log.d("myz", "" + Build.VERSION.SDK_INT) + if (ContextCompat.checkSelfPermission( + this.requireContext(), + Manifest.permission.READ_EXTERNAL_STORAGE + ) + != PackageManager.PERMISSION_GRANTED + ) { + ActivityCompat.requestPermissions( + this.requireActivity(), arrayOf( + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.MANAGE_EXTERNAL_STORAGE + ), 1 + ) //permission request code is just an int + } else if (token != "") { + getContent.launch("*/*") + } else { + Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() + } + } else { + if (ActivityCompat.checkSelfPermission( + requireContext(), + Manifest.permission.READ_EXTERNAL_STORAGE + ) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission( + requireContext(), + Manifest.permission.WRITE_EXTERNAL_STORAGE + ) != PackageManager.PERMISSION_GRANTED + ) { + ActivityCompat.requestPermissions( + this.requireActivity(), + arrayOf( + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE + ), + 1 + ) + } else if (token != "") { + getContent.launch("*/*") + } else { + Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() + } + } + true + } + + val themeToggle = findPreference("theme_togglee") + themeToggle?.setOnPreferenceChangeListener { _, newValue -> + when (newValue.toString()) { + "A" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) + "L" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) + "D" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) + } + true + } + + val changeLanguage = findPreference("language") + changeLanguage?.setOnPreferenceChangeListener { _, _ -> + val refresh = Intent(context, MainActivity::class.java) + startActivity(refresh) + true + } + + val about = findPreference("about") + about?.setOnPreferenceClickListener { + val uri = Uri.parse("https://libre-tube.github.io/") + val intent = Intent(Intent.ACTION_VIEW).setData(uri) + startActivity(intent) + true + } + } + + private fun fetchInstance() { + lifecycleScope.launchWhenCreated { + val response = try { + RetrofitInstance.api.getInstances("https://instances.tokhmi.xyz/") + } catch (e: IOException) { + println(e) + Log.e("settings", "IOException, you might not have internet connection") + return@launchWhenCreated + } catch (e: HttpException) { + Log.e("settings", "HttpException, unexpected response $e") + return@launchWhenCreated + } catch (e: Exception) { + Log.e("settings", e.toString()) + return@launchWhenCreated + } + val listEntries: MutableList = ArrayList() + val listEntryValues: MutableList = ArrayList() + for (item in response) { + listEntries.add(item.name!!) + listEntryValues.add(item.api_url!!) + } + val entries = listEntries.toTypedArray() + val entryValues = listEntryValues.toTypedArray() + runOnUiThread { + val instance = findPreference("instance") + instance?.entries = entries + instance?.entryValues = entryValues + instance?.summaryProvider = + Preference.SummaryProvider { preference -> + val text = preference.entry + if (TextUtils.isEmpty(text)) { + "kavin.rocks (Official)" + } else { + text + } + } + } + } + } + + private fun Fragment?.runOnUiThread(action: () -> Unit) { + this ?: return + if (!isAdded) return // Fragment not attached to an Activity + activity?.runOnUiThread(action) + } + + + private fun subscribe(channels: List) { + fun run() { + lifecycleScope.launchWhenCreated { + val response = try { + val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) + RetrofitInstance.api.importSubscriptions( + false, + sharedPref?.getString("token", "")!!, + channels + ) + } catch (e: IOException) { + Log.e(TAG, "IOException, you might not have internet connection") + return@launchWhenCreated + } catch (e: HttpException) { + Log.e(TAG, "HttpException, unexpected response$e") + return@launchWhenCreated + } + if (response.message == "ok") { + Toast.makeText( + context, + R.string.importsuccess, + Toast.LENGTH_SHORT + ).show() + } + } + } + run() + } + } + + override fun onDestroy() { + super.onDestroy() + PreferenceManager.getDefaultSharedPreferences(this) + .unregisterOnSharedPreferenceChangeListener(this) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_arrow_back.xml b/app/src/main/res/drawable/ic_arrow_back.xml new file mode 100644 index 000000000..8452791cf --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_back.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 000000000..de6591a20 --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 48c6e8bc7..08919c958 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -63,4 +63,5 @@ Light Theme Dark Theme %1$s subscribers + Settings From 88cfa349e78f3c3c04d766afcf29cbd368a3bad6 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 10 May 2022 22:40:29 +0200 Subject: [PATCH 2/4] Setting Categories --- .../com/github/libretube/SettingsActivity.kt | 5 +--- app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/settings.xml | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index ea93901dd..0e98205cb 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -44,16 +44,13 @@ class SettingsActivity : AppCompatActivity(), .replace(R.id.settings, SettingsFragment()) .commit() } - supportActionBar?.setDisplayHomeAsUpEnabled(true) PreferenceManager.getDefaultSharedPreferences(this) .registerOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { - - } + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, rootKey: String?) {} class SettingsFragment : PreferenceFragmentCompat() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08919c958..4e108ab0d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,4 +64,7 @@ Dark Theme %1$s subscribers Settings + Location + Instance + Theming diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index caa6994ce..e9b39d6e5 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -1,6 +1,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 9b1193f7759628bee055bf19c24ab98a93e3c878 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 10 May 2022 22:47:02 +0200 Subject: [PATCH 3/4] About Category --- app/src/main/res/drawable/ic_arrow_back.xml | 5 ----- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/settings.xml | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_arrow_back.xml diff --git a/app/src/main/res/drawable/ic_arrow_back.xml b/app/src/main/res/drawable/ic_arrow_back.xml deleted file mode 100644 index 8452791cf..000000000 --- a/app/src/main/res/drawable/ic_arrow_back.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4e108ab0d..13f03b859 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -67,4 +67,5 @@ Location Instance Theming + Website diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index e9b39d6e5..8ed387a90 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -93,10 +93,10 @@ - + From bfae8ab49f7c53d0d2c13622c6cd6e4b55524943 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 11 May 2022 10:04:48 +0200 Subject: [PATCH 4/4] Reload Activity on Back Pressed --- .../java/com/github/libretube/MainActivity.kt | 3 +- .../java/com/github/libretube/Settings.kt | 290 ------------------ .../com/github/libretube/SettingsActivity.kt | 11 +- app/src/main/res/navigation/nav.xml | 2 +- app/src/main/res/values/strings.xml | 6 +- app/src/main/res/xml/settings.xml | 6 +- 6 files changed, 17 insertions(+), 301 deletions(-) delete mode 100644 app/src/main/java/com/github/libretube/Settings.kt diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index c285433df..c607cef61 100644 --- a/app/src/main/java/com/github/libretube/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/MainActivity.kt @@ -27,7 +27,6 @@ import com.google.android.material.bottomnavigation.BottomNavigationView import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import androidx.preference.PreferenceManager -import com.github.libretube.SettingsActivity import com.google.android.material.color.DynamicColors import java.lang.Exception import java.util.* @@ -101,7 +100,7 @@ class MainActivity : AppCompatActivity() { toolbar.title= appName toolbar.setNavigationOnClickListener{ - //settings fragment stuff + //settings activity stuff val intent = Intent(this, SettingsActivity::class.java) startActivity(intent) true diff --git a/app/src/main/java/com/github/libretube/Settings.kt b/app/src/main/java/com/github/libretube/Settings.kt deleted file mode 100644 index 70cb900f2..000000000 --- a/app/src/main/java/com/github/libretube/Settings.kt +++ /dev/null @@ -1,290 +0,0 @@ -package com.github.libretube - -import android.Manifest -import android.content.ContentResolver -import android.content.Context -import android.content.Intent -import android.content.pm.PackageManager -import android.net.Uri -import android.os.Build -import android.os.Bundle -import android.os.LocaleList -import android.text.TextUtils -import android.util.Log -import android.widget.Toast -import androidx.activity.result.ActivityResultLauncher -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AppCompatDelegate -import androidx.core.app.ActivityCompat -import androidx.core.content.ContextCompat -import androidx.core.os.LocaleListCompat -import androidx.fragment.app.Fragment -import androidx.lifecycle.lifecycleScope -import androidx.preference.ListPreference -import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat -import org.json.JSONArray -import org.json.JSONObject -import org.json.JSONTokener -import retrofit2.HttpException -import java.io.IOException -import java.io.InputStream -import java.util.* -import java.util.zip.ZipEntry -import java.util.zip.ZipInputStream -import kotlin.collections.ArrayList - - -class Settings : PreferenceFragmentCompat() { - val TAG = "Settings" - - companion object { - lateinit var getContent: ActivityResultLauncher - } - - override fun onCreate(savedInstanceState: Bundle?) { - getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? -> - - if (uri != null) { - try { - // Open a specific media item using ParcelFileDescriptor. - val resolver: ContentResolver = - requireActivity() - .contentResolver - - // "rw" for read-and-write; - // "rwt" for truncating or overwriting existing file contents. - //val readOnlyMode = "r" - // uri - I have got from onActivityResult - val type = resolver.getType(uri) - - var inputStream: InputStream? = resolver.openInputStream(uri) - val channels = ArrayList() - if(type == "application/json"){ - val json = inputStream?.bufferedReader()?.readLines()?.get(0) - val jsonObject = JSONTokener(json).nextValue() as JSONObject - Log.e(TAG,jsonObject.getJSONArray("subscriptions").toString()) - for (i in 0 until jsonObject.getJSONArray("subscriptions").length()) { - var url = jsonObject.getJSONArray("subscriptions").getJSONObject(i).getString("url") - url = url.replace("https://www.youtube.com/channel/","") - Log.e(TAG,url) - channels.add(url) - } - }else { - if (type == "application/zip") { - val zis = ZipInputStream(inputStream) - var entry: ZipEntry? = zis.nextEntry - while (entry != null) { - if (entry.name.endsWith(".csv")) { - inputStream = zis - break - } - entry = zis.nextEntry - } - } - - inputStream?.bufferedReader()?.readLines()?.forEach { - if (it.isNotBlank()) { - val channelId = it.substringBefore(",") - if (channelId.length == 24) - channels.add(channelId) - } - } - } - inputStream?.close() - - subscribe(channels) - } catch (e: Exception) { - Log.e(TAG, e.toString()) - Toast.makeText( - context, - R.string.error, - Toast.LENGTH_SHORT - ).show() - } - } - - - } - super.onCreate(savedInstanceState) - } - - override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - setPreferencesFromResource(R.xml.settings, rootKey) - val instance = findPreference("instance") - fetchInstance() - instance?.setOnPreferenceChangeListener { _, newValue -> - RetrofitInstance.url = newValue.toString() - RetrofitInstance.lazyMgr.reset() - val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) - if (sharedPref?.getString("token", "") != "") { - with(sharedPref!!.edit()) { - putString("token", "") - apply() - } - Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show() - } - true - } - - val login = findPreference("login_register") - login?.setOnPreferenceClickListener { - val newFragment = LoginDialog() - newFragment.show(childFragmentManager, "Login") - true - } - - val importFromYt = findPreference("import_from_yt") - importFromYt?.setOnPreferenceClickListener { - val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) - val token = sharedPref?.getString("token", "")!! - //check StorageAccess - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - Log.d("myz", "" + Build.VERSION.SDK_INT) - if (ContextCompat.checkSelfPermission( - this.requireContext(), - Manifest.permission.READ_EXTERNAL_STORAGE - ) - != PackageManager.PERMISSION_GRANTED - ) { - ActivityCompat.requestPermissions( - this.requireActivity(), arrayOf( - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.MANAGE_EXTERNAL_STORAGE - ), 1 - ) //permission request code is just an int - } else if (token != "") { - getContent.launch("*/*") - } else { - Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() - } - } else { - if (ActivityCompat.checkSelfPermission( - requireContext(), - Manifest.permission.READ_EXTERNAL_STORAGE - ) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission( - requireContext(), - Manifest.permission.WRITE_EXTERNAL_STORAGE - ) != PackageManager.PERMISSION_GRANTED - ) { - ActivityCompat.requestPermissions( - this.requireActivity(), - arrayOf( - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE - ), - 1 - ) - } else if (token != "") { - getContent.launch("*/*") - } else { - Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() - } - } - true - } - - val themeToggle = findPreference("theme_togglee") - themeToggle?.setOnPreferenceChangeListener { _, newValue -> - when (newValue.toString()) { - "A" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) - "L" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) - "D" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) - } - true - } - - val changeLanguage = findPreference("language") - changeLanguage?.setOnPreferenceChangeListener { _, _ -> - val refresh = Intent(context, MainActivity::class.java) - startActivity(refresh) - true - } - - val about = findPreference("about") - about?.setOnPreferenceClickListener { - val uri = Uri.parse("https://libre-tube.github.io/") - val intent = Intent(Intent.ACTION_VIEW).setData(uri) - startActivity(intent) - true - } - } - - private fun fetchInstance() { - lifecycleScope.launchWhenCreated { - val response = try { - RetrofitInstance.api.getInstances("https://instances.tokhmi.xyz/") - } catch (e: IOException) { - println(e) - Log.e("settings", "IOException, you might not have internet connection") - return@launchWhenCreated - } catch (e: HttpException) { - Log.e("settings", "HttpException, unexpected response $e") - return@launchWhenCreated - } catch (e: Exception) { - Log.e("settings", e.toString()) - return@launchWhenCreated - } - val listEntries: MutableList = ArrayList() - val listEntryValues: MutableList = ArrayList() - for (item in response) { - listEntries.add(item.name!!) - listEntryValues.add(item.api_url!!) - } - val entries = listEntries.toTypedArray() - val entryValues = listEntryValues.toTypedArray() - runOnUiThread { - val instance = findPreference("instance") - instance?.entries = entries - instance?.entryValues = entryValues - instance?.summaryProvider = - Preference.SummaryProvider { preference -> - val text = preference.entry - if (TextUtils.isEmpty(text)) { - "kavin.rocks (Official)" - } else { - text - } - } - } - } - } - - private fun Fragment?.runOnUiThread(action: () -> Unit) { - this ?: return - if (!isAdded) return // Fragment not attached to an Activity - activity?.runOnUiThread(action) - } - - - private fun subscribe(channels: List) { - fun run() { - lifecycleScope.launchWhenCreated { - val response = try { - val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) - RetrofitInstance.api.importSubscriptions( - false, - sharedPref?.getString("token", "")!!, - channels - ) - } catch (e: IOException) { - Log.e(TAG, "IOException, you might not have internet connection") - return@launchWhenCreated - } catch (e: HttpException) { - Log.e(TAG, "HttpException, unexpected response$e") - return@launchWhenCreated - } - if (response.message == "ok") { - Toast.makeText( - context, - R.string.importsuccess, - Toast.LENGTH_SHORT - ).show() - } - } - } - run() - } -} - - diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index 0e98205cb..0fb13644e 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -11,6 +11,7 @@ import android.os.Build import android.os.Bundle import android.text.TextUtils import android.util.Log +import android.view.View import android.widget.Toast import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts @@ -37,6 +38,10 @@ class SettingsActivity : AppCompatActivity(), override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + overridePendingTransition(50, 50); + val view = this.findViewById(android.R.id.content) + view.setAlpha(0F); + view.animate().alpha(1F).setDuration(300); setContentView(R.layout.activity_settings) if (savedInstanceState == null) { supportFragmentManager @@ -305,9 +310,11 @@ class SettingsActivity : AppCompatActivity(), } } - override fun onDestroy() { - super.onDestroy() + override fun onBackPressed() { PreferenceManager.getDefaultSharedPreferences(this) .unregisterOnSharedPreferenceChangeListener(this) + intent = Intent(this, MainActivity::class.java) + startActivity(intent) } + } \ No newline at end of file diff --git a/app/src/main/res/navigation/nav.xml b/app/src/main/res/navigation/nav.xml index f164bbb0c..eabf2f9bc 100644 --- a/app/src/main/res/navigation/nav.xml +++ b/app/src/main/res/navigation/nav.xml @@ -46,6 +46,6 @@ \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 13f03b859..9d84ddf17 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,8 +64,8 @@ Dark Theme %1$s subscribers Settings - Location - Instance - Theming + Location + Instance + Customization Website diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 8ed387a90..56ae14456 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -2,7 +2,7 @@ - + - + - +