From 0587b3e08d9db87b36b47b13d0ab86be71bc22fd Mon Sep 17 00:00:00 2001
From: MM20 <15646950+MM2-0@users.noreply.github.com>
Date: Sun, 30 Jan 2022 13:42:37 +0100
Subject: [PATCH] Remove legacy SettingsActivity
---
app/src/main/AndroidManifest.xml | 20 --
.../launcher2/activity/SettingsActivity.kt | 69 -------
.../fragment/PreferencesAppearanceFragment.kt | 107 -----------
.../fragment/PreferencesCardFragment.kt | 93 ---------
.../fragment/PreferencesEasterEggFragment.kt | 26 ---
.../fragment/PreferencesMainFragment.kt | 44 -----
.../fragment/PreferencesSearchFragment.kt | 174 -----------------
.../fragment/PreferencesServicesFragment.kt | 176 ------------------
owncloud/src/main/AndroidManifest.xml | 4 +-
.../launcher2/ui/launcher/search/SearchBar.kt | 18 --
10 files changed, 2 insertions(+), 729 deletions(-)
delete mode 100644 app/src/main/java/de/mm20/launcher2/activity/SettingsActivity.kt
delete mode 100644 app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt
delete mode 100644 app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt
delete mode 100644 app/src/main/java/de/mm20/launcher2/fragment/PreferencesEasterEggFragment.kt
delete mode 100644 app/src/main/java/de/mm20/launcher2/fragment/PreferencesMainFragment.kt
delete mode 100644 app/src/main/java/de/mm20/launcher2/fragment/PreferencesSearchFragment.kt
delete mode 100644 app/src/main/java/de/mm20/launcher2/fragment/PreferencesServicesFragment.kt
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1f21b862..89abd467 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -41,26 +41,6 @@
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
-
-
-
-
-
-
-
-
-
-
PreferencesServicesFragment()
- else -> PreferencesMainFragment()
- }
- }
-
- private fun setupActionBar() {
- actionBar?.setDisplayHomeAsUpEnabled(true)
- }
-
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- val id = item.itemId
- if (id == android.R.id.home) {
- if (supportFragmentManager.backStackEntryCount == 0) {
- finish()
- startActivity(Intent(this, LauncherActivity::class.java))
- } else {
- supportFragmentManager.popBackStack()
- }
- return true
- }
- return super.onOptionsItemSelected(item)
- }
-
- override fun onBackPressed() {
- if (supportFragmentManager.backStackEntryCount > 0) {
- supportFragmentManager.popBackStack()
- } else {
- finish()
- startActivity(Intent(this, LauncherActivity::class.java))
- }
- }
-
- companion object {
- const val RESULT_NEED_RESTART = 0x09
- const val FRAGMENT_WEATHER: String = "weather"
- const val FRAGMENT_CALENDAR: String = "calendar"
- const val FRAGMENT_SERVICES: String = "services"
- const val FRAGMENT: String = "fragment"
- }
-}
diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt
deleted file mode 100644
index c1deece7..00000000
--- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesAppearanceFragment.kt
+++ /dev/null
@@ -1,107 +0,0 @@
-package de.mm20.launcher2.fragment
-
-import android.content.Intent
-import android.graphics.drawable.ColorDrawable
-import android.os.Build
-import android.os.Bundle
-import android.view.View
-import android.widget.LinearLayout
-import android.widget.TextView
-import androidx.appcompat.app.AppCompatActivity
-import androidx.lifecycle.lifecycleScope
-import androidx.preference.ListPreference
-import androidx.preference.Preference
-import androidx.preference.PreferenceCategory
-import androidx.preference.PreferenceFragmentCompat
-import com.afollestad.materialdialogs.MaterialDialog
-import com.afollestad.materialdialogs.customview.customView
-import de.mm20.launcher2.R
-import de.mm20.launcher2.icons.IconPackManager
-import de.mm20.launcher2.icons.IconRepository
-import de.mm20.launcher2.icons.LauncherIcon
-import kotlinx.coroutines.launch
-import org.koin.android.ext.android.inject
-
-class PreferencesAppearanceFragment : PreferenceFragmentCompat() {
-
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_appearance)
-
- findPreference("card_background")?.setOnPreferenceChangeListener { _, newValue ->
- requireActivity().recreate()
- true
- }
-
- findPreference("wallpaper")?.setOnPreferenceClickListener {
- requireContext().startActivity(Intent.createChooser(Intent(Intent.ACTION_SET_WALLPAPER), null))
- true
- }
- findPreference("cards")?.setOnPreferenceClickListener {
- requireFragmentManager().beginTransaction()
- .setCustomAnimations(R.anim.preference_fragment_child_enter, R.anim.preference_fragment_parent_exit,
- R.anim.preference_fragment_parent_enter, R.anim.preference_fragment_child_exit)
- .replace(android.R.id.content, PreferencesCardFragment())
- .addToBackStack(null)
- .commit()
- true
- }
-
- val iconPackManager: IconPackManager by inject()
- val iconRepository: IconRepository by inject()
- lifecycleScope.launch {
- val packs = iconPackManager.getInstalledIconPacks()
- findPreference("icon_pack")?.apply {
- entries = packs.map { it.name }.toMutableList().apply { add(0, "System") }.toTypedArray()
- entryValues = (-1 until packs.size).map { it.toString() }.toTypedArray()
- if (packs.isEmpty()) {
- isEnabled = false
- setSummary(R.string.preference_icon_pack_summary_empty)
- } else {
- isEnabled = true
- summary = "%s"
- }
- setOnPreferenceChangeListener { _, newValue ->
- val index = (newValue as String).toInt()
- true
- }
- }
- }
-
- findPreference("legacy_icon_bg")?.setOnPreferenceChangeListener { _, _ ->
- true
- }
-
- findPreference("themed_icons")?.setOnPreferenceChangeListener { _, _ ->
- true
- }
-
- val shapePreference = findPreference("icon_shape")!!
- shapePreference.setOnPreferenceClickListener {
- val launcherIcon = LauncherIcon(
- foreground = requireContext().getDrawable(R.mipmap.ic_launcher_foreground)!!,
- background = ColorDrawable(requireContext().getColor(R.color.ic_launcher_background))
- )
- val iconShapeList = LinearLayout(requireContext())
- iconShapeList.orientation = LinearLayout.VERTICAL
- val layoutParams = LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT)
- val dialog = MaterialDialog(requireContext())
-
- dialog.customView(view = iconShapeList, scrollable = true)
- .title(R.string.preference_icon_shape)
- .negativeButton(android.R.string.cancel) {
- dialog.cancel()
- }
- .show()
- true
- }
- }
-
-
- override fun onResume() {
- super.onResume()
- (activity as AppCompatActivity).supportActionBar
- ?.setTitle(R.string.preference_screen_appearance)
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt
deleted file mode 100644
index 6662d34f..00000000
--- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesCardFragment.kt
+++ /dev/null
@@ -1,93 +0,0 @@
-package de.mm20.launcher2.fragment
-
-import android.animation.Animator
-import android.animation.ObjectAnimator
-import android.app.WallpaperManager
-import android.graphics.*
-import android.os.Bundle
-import android.view.View
-import androidx.core.content.res.ResourcesCompat
-import androidx.core.view.doOnNextLayout
-import androidx.fragment.app.Fragment
-import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
-import de.mm20.launcher2.R
-import de.mm20.launcher2.ktx.dp
-import de.mm20.launcher2.ui.legacy.view.LauncherCardView
-import kotlin.math.roundToInt
-
-class PreferencesCardFragment : Fragment(R.layout.fragment_card_settings) {
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- val previewCard = view.findViewById(R.id.previewCard)
-
- val prefFragment = PreferenesCardInnerFragment()
-
- prefFragment.onPreferencesReady = {
- findPreference("card_radius")?.let {
- it.setOnPreferenceChangeListener { pref, newValue ->
- val value = newValue as Int
- previewCard.radius = value * dp
- pref.summary = value.toString()
- true
- }
- }
- findPreference("card_opacity")?.let {
- it.setOnPreferenceChangeListener { pref, newValue ->
- val value = newValue as Int
- previewCard.backgroundOpacity = value
- previewCard.cardElevation = if (value == 0xFF) resources.getDimension(R.dimen.card_elevation) else 0f
- pref.summary = value.toString()
- true
- }
- }
- findPreference("card_stroke_width")?.let {
- it.setOnPreferenceChangeListener { pref, newValue ->
- val value = newValue as Int
- previewCard.strokeWidth = (value * dp).roundToInt()
- pref.summary = value.toString()
- true
- }
- }
- }
-
- childFragmentManager.beginTransaction()
- .replace(R.id.preferencesView, prefFragment)
- .commit()
-
-
- }
-
- private var animator: Animator? = null
- override fun onStart() {
- super.onStart()
- val content = activity?.findViewById(android.R.id.content) ?: return
- animator = ObjectAnimator.ofArgb(content, "backgroundColor", ResourcesCompat.getColor(resources, R.color.settings_window_background, null), Color.TRANSPARENT)
- .apply {
- duration = 200
- startDelay = resources.getInteger(android.R.integer.config_shortAnimTime).toLong()
- start()
- }
-
-
- content.doOnNextLayout {
- WallpaperManager.getInstance(requireContext()).setWallpaperOffsets(it.windowToken, 0.5f, 0.5f)
- }
- }
-
- override fun onStop() {
- super.onStop()
- if (animator?.isRunning == true) animator?.end()
- activity?.findViewById(android.R.id.content)?.setBackgroundColor(ResourcesCompat.getColor(resources, R.color.settings_window_background, null))
- }
-}
-
-class PreferenesCardInnerFragment : PreferenceFragmentCompat() {
- var onPreferencesReady: (PreferenesCardInnerFragment.() -> Unit)? = null
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_cards)
- onPreferencesReady?.invoke(this)
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesEasterEggFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesEasterEggFragment.kt
deleted file mode 100644
index c5ca1003..00000000
--- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesEasterEggFragment.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-package de.mm20.launcher2.fragment
-
-import android.animation.ObjectAnimator
-import android.animation.ValueAnimator
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.FrameLayout
-import android.widget.Toast
-import android.widget.ToggleButton
-import androidx.fragment.app.Fragment
-import de.mm20.launcher2.R
-
-class PreferencesEasterEggFragment : Fragment() {
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- val view = inflater.inflate(R.layout.fragment_easteregg, null, false)
- val root = view.findViewById(R.id.easterEggRoot)
- val toggle = view.findViewById(R.id.magicModeToggle)
- toggle.setOnCheckedChangeListener { _, isChecked ->
- Toast.makeText(requireContext(), if (isChecked) R.string.easter_egg_activated else R.string.easter_egg_deactivated, Toast.LENGTH_SHORT).show()
- }
- return view
- }
-
-}
diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesMainFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesMainFragment.kt
deleted file mode 100644
index d8ba4907..00000000
--- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesMainFragment.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-package de.mm20.launcher2.fragment
-
-import android.content.Context
-import android.graphics.Color
-import android.os.Bundle
-import android.view.View
-import androidx.appcompat.app.AppCompatActivity
-import androidx.fragment.app.Fragment
-import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
-import de.mm20.launcher2.R
-
-class PreferencesMainFragment : PreferenceFragmentCompat() {
-
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_main)
- findPreference("screen_appearance")?.setOnPreferenceClickListener {
- setSettingsScreen(PreferencesAppearanceFragment())
- true
- }
- findPreference("screen_services")?.setOnPreferenceClickListener {
- setSettingsScreen(PreferencesServicesFragment())
- true
- }
- findPreference("screen_search")?.setOnPreferenceClickListener {
- setSettingsScreen(PreferencesSearchFragment())
- true
- }
- }
-
- private fun setSettingsScreen(fragment: Fragment) {
- parentFragmentManager.beginTransaction()
- .setCustomAnimations(R.anim.preference_fragment_child_enter, R.anim.preference_fragment_parent_exit,
- R.anim.preference_fragment_parent_enter, R.anim.preference_fragment_child_exit)
- .replace(android.R.id.content, fragment)
- .addToBackStack(null)
- .commit()
- }
-
- override fun onResume() {
- super.onResume()
- (activity as AppCompatActivity).supportActionBar?.setTitle(R.string.title_activity_settings)
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesSearchFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesSearchFragment.kt
deleted file mode 100644
index d6a183be..00000000
--- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesSearchFragment.kt
+++ /dev/null
@@ -1,174 +0,0 @@
-package de.mm20.launcher2.fragment
-
-import android.Manifest
-import android.os.Bundle
-import android.view.View
-import androidx.appcompat.app.AppCompatActivity
-import androidx.core.app.ActivityCompat
-import androidx.fragment.app.Fragment
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
-import de.mm20.launcher2.R
-import de.mm20.launcher2.gservices.GoogleApiHelper
-import de.mm20.launcher2.ktx.checkPermission
-import de.mm20.launcher2.msservices.MicrosoftGraphApiHelper
-import de.mm20.launcher2.nextcloud.NextcloudApiHelper
-import de.mm20.launcher2.owncloud.OwncloudClient
-import kotlinx.coroutines.launch
-import org.koin.android.ext.android.inject
-
-class PreferencesSearchFragment : PreferenceFragmentCompat() {
-
- private val googleApiHelper: GoogleApiHelper by inject()
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- lifecycleScope.launch {
- viewLifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
- updateGoogleDrive()
- updateOneDrive()
- }
- }
- }
-
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_search)
- findPreference("search_activities")?.summary =
- getString(
- R.string.preference_search_activities_summary,
- requireActivity().componentName.flattenToShortString()
- )
- findPreference("search_files")?.setOnPreferenceChangeListener { _, newValue ->
- if (newValue == true &&
- requireContext().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
- ) {
- ActivityCompat.requestPermissions(
- requireActivity(),
- arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
- 0
- )
- }
- true
- }
- }
-
- private suspend fun updateGoogleDrive() {
- val googleApiHelper = GoogleApiHelper.getInstance(context ?: return)
- val account = googleApiHelper.getAccount()
- val pref = findPreference("search_gdrive")!!
- if (account == null) {
- pref.apply {
- setSummary(R.string.preference_summary_not_logged_in)
- }
- } else {
- pref.apply {
- summary = context.getString(R.string.preference_search_gdrive_summary, account.name)
- }
- }
- val isSignedIn = account != null
- pref.setOnPreferenceChangeListener { _, value ->
- val newVal = value as Boolean
- if (newVal && !isSignedIn) {
- googleLogin()
- }
- true
- }
- }
-
- private suspend fun updateOneDrive() {
- val oneDrivePref = findPreference("search_onedrive")!!
- val user = MicrosoftGraphApiHelper.getInstance(requireContext()).getUser()
- if (user == null) {
- oneDrivePref.setSummary(R.string.preference_summary_not_logged_in)
- oneDrivePref.setOnPreferenceChangeListener { _, value ->
- if (value as Boolean) {
- lifecycleScope.launch launch2@{
- MicrosoftGraphApiHelper.getInstance(requireContext())
- .login(requireActivity())
- updateOneDrive()
- }
- }
- true
- }
- } else {
- oneDrivePref.summary =
- context?.getString(R.string.preference_search_onedrive_summary, user.name)
- }
- }
-
- private fun updateNextcloud() {
- val nextcloudPref = findPreference("search_nextcloud")!!
- val client = NextcloudApiHelper(context ?: return)
- lifecycleScope.launch {
- val user = client.getLoggedInUser()
- if (user == null) {
- nextcloudPref.setSummary(R.string.preference_summary_not_logged_in)
- nextcloudPref.setOnPreferenceChangeListener { _, value ->
- if (value as Boolean) {
- lifecycleScope.launch launch2@{
- updateNextcloud()
- }
- }
- true
- }
- } else {
- nextcloudPref.summary = context?.getString(
- R.string.preference_search_cloud_summary,
- user.displayName
- )
- }
- }
- }
-
- private fun updateOwncloud() {
- val owncloudPref = findPreference("search_owncloud")!!
- lifecycleScope.launch {
- val client = OwncloudClient(context ?: return@launch)
- val user = client.getLoggedInUser()
- if (user == null) {
- owncloudPref.setSummary(R.string.preference_summary_not_logged_in)
- owncloudPref.setOnPreferenceChangeListener { _, value ->
- if (value as Boolean) {
- lifecycleScope.launch launch2@{
- client.login(requireActivity(), 0)
- updateOwncloud()
- }
- }
- true
- }
- } else {
- owncloudPref.summary = context?.getString(
- R.string.preference_search_cloud_summary,
- user.displayName,
- )
- }
- }
- }
-
- private fun googleLogin() {
- lifecycleScope.launch {
- GoogleApiHelper.getInstance(requireContext()).login(requireActivity())
- }
- }
-
- private fun setSettingsScreen(fragment: Fragment) {
- parentFragmentManager.beginTransaction()
- .setCustomAnimations(
- R.anim.preference_fragment_child_enter, R.anim.preference_fragment_parent_exit,
- R.anim.preference_fragment_parent_enter, R.anim.preference_fragment_child_exit
- )
- .replace(android.R.id.content, fragment)
- .addToBackStack(null)
- .commit()
- }
-
- override fun onResume() {
- super.onResume()
- (activity as AppCompatActivity).supportActionBar?.setTitle(R.string.preference_screen_search)
- updateNextcloud()
- updateOwncloud()
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesServicesFragment.kt b/app/src/main/java/de/mm20/launcher2/fragment/PreferencesServicesFragment.kt
deleted file mode 100644
index d339c4e0..00000000
--- a/app/src/main/java/de/mm20/launcher2/fragment/PreferencesServicesFragment.kt
+++ /dev/null
@@ -1,176 +0,0 @@
-package de.mm20.launcher2.fragment
-
-import android.os.Bundle
-import android.view.View
-import androidx.appcompat.app.AppCompatActivity
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
-import de.mm20.launcher2.R
-import de.mm20.launcher2.gservices.GoogleApiHelper
-import de.mm20.launcher2.msservices.MicrosoftGraphApiHelper
-import de.mm20.launcher2.nextcloud.NextcloudApiHelper
-import de.mm20.launcher2.owncloud.OwncloudClient
-import kotlinx.coroutines.launch
-
-class PreferencesServicesFragment : PreferenceFragmentCompat() {
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- lifecycleScope.launch {
- viewLifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
- updateGooglePreferences()
- updateMicrosoftPreferences()
- updateNextcloudPreferences()
- }
- }
- }
-
-
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- addPreferencesFromResource(R.xml.preferences_services)
- }
-
- private suspend fun updateGooglePreferences() {
- val pref = findPreference("google_signin")!!
- val googleApiHelper = GoogleApiHelper.getInstance(requireContext())
- if (!googleApiHelper.isAvailable()) {
- pref.isEnabled = false
- pref.summary = context?.getString(R.string.feature_not_available, context?.getString(R.string.app_name))
- return
- }
- val account = googleApiHelper.getAccount()
- if (account == null) {
- pref.apply {
- setTitle(R.string.preference_google_signin)
- setSummary(R.string.preference_google_signin_summary)
- setOnPreferenceClickListener {
- lifecycleScope.launch {
- googleApiHelper.login(requireActivity())
- }
- true
- }
- }
- } else {
- pref.apply {
- title = context.getString(R.string.preference_signin_logout)
- summary = context.getString(R.string.preference_signin_user, account.name)
- setOnPreferenceClickListener {
- googleApiHelper.logout()
- lifecycleScope.launch {
- updateGooglePreferences()
- }
- true
- }
- }
- }
- }
-
- private suspend fun updateMicrosoftPreferences() {
- val pref = findPreference("ms_signin")!!
- val msApiHelper = MicrosoftGraphApiHelper.getInstance(requireContext())
- if (!msApiHelper.isAvailable()) {
- pref.isEnabled = false
- pref.summary = context?.getString(R.string.feature_not_available, context?.getString(R.string.app_name))
- return
- }
- val user = MicrosoftGraphApiHelper.getInstance(requireContext()).getUser()
- if (user == null) {
- pref.setTitle(R.string.preference_ms_signin)
- pref.setSummary(R.string.preference_ms_signin_summary)
- pref.setOnPreferenceClickListener {
- lifecycleScope.launch {
- msApiHelper.login(requireActivity())
- updateMicrosoftPreferences()
- }
- true
- }
- } else {
- pref.setTitle(R.string.preference_signin_logout)
- pref.summary = context?.getString(R.string.preference_signin_user, user.name)
- pref.setOnPreferenceClickListener {
- lifecycleScope.launch {
- msApiHelper.logout()
- updateMicrosoftPreferences()
- }
- true
- }
-
- }
- }
-
- private suspend fun updateNextcloudPreferences() {
- val nextcloud = NextcloudApiHelper(requireContext())
- val user = nextcloud.getLoggedInUser()
- if (user == null) {
- findPreference("nextcloud_signin")?.let {
- it.setOnPreferenceClickListener {
- nextcloud.login(requireActivity())
- true
- }
- it.setTitle(R.string.preference_nextcloud_signin)
- it.setSummary(R.string.preference_nextcloud_signin_summary)
- }
- } else {
- findPreference("nextcloud_signin")?.let {
- it.setOnPreferenceClickListener {
- lifecycleScope.launch {
- nextcloud.logout()
- updateNextcloudPreferences()
- }
- true
- }
- it.setTitle(R.string.preference_signin_logout)
- it.summary = context?.getString(
- R.string.preference_signin_user_nextcloud,
- user.displayName
- )
- }
- }
- }
-
- private fun updateOwncloudPreferences() {
- val client = OwncloudClient(context ?: return)
- lifecycleScope.launch {
- val user = client.getLoggedInUser()
- if (user == null) {
- findPreference("owncloud_signin")?.let {
- it.setOnPreferenceClickListener {
- OwncloudClient(requireContext()).login(
- requireActivity(),
- REQUEST_OWNCLOUD_LOGIN
- )
- true
- }
- it.setTitle(R.string.preference_owncloud_signin)
- it.setSummary(R.string.preference_owncloud_signin_summary)
- }
- } else {
- findPreference("owncloud_signin")?.let {
- it.setOnPreferenceClickListener {
- OwncloudClient(requireContext()).logout()
- updateOwncloudPreferences()
- true
- }
- it.setTitle(R.string.preference_signin_logout)
- it.summary = context?.getString(
- R.string.preference_signin_user_nextcloud,
- user.displayName,
- )
- }
- }
- }
- }
-
- override fun onResume() {
- super.onResume()
- (activity as AppCompatActivity).supportActionBar?.setTitle(R.string.preference_screen_services)
- updateOwncloudPreferences()
- }
-
- companion object {
- const val REQUEST_OWNCLOUD_LOGIN = 581
- }
-}
\ No newline at end of file
diff --git a/owncloud/src/main/AndroidManifest.xml b/owncloud/src/main/AndroidManifest.xml
index f654c652..3b333ea8 100644
--- a/owncloud/src/main/AndroidManifest.xml
+++ b/owncloud/src/main/AndroidManifest.xml
@@ -6,11 +6,11 @@
android:name=".LoginActivity"
android:label="@string/preference_category_services_nextcloud"
android:taskAffinity="de.mm20.launcher2.nextcloud"
- android:parentActivityName=".activity.SettingsActivity"
+ android:parentActivityName="de.mm20.launcher2.ui.settings.SettingsActivity"
android:theme="@style/OwncloudLoginTheme" >
+ android:value="de.mm20.launcher2.ui.settings.SettingsActivity" />
diff --git a/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/SearchBar.kt b/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/SearchBar.kt
index c7f6024b..4f63d470 100644
--- a/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/SearchBar.kt
+++ b/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/SearchBar.kt
@@ -1,8 +1,6 @@
package de.mm20.launcher2.ui.launcher.search
-import android.content.ComponentName
import android.content.Intent
-import android.util.Log
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColor
import androidx.compose.animation.core.animateDp
@@ -20,7 +18,6 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
-import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.icons.Icons
@@ -31,9 +28,7 @@ import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
-import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
-import androidx.compose.ui.focus.onFocusEvent
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
@@ -43,7 +38,6 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import coil.compose.rememberImagePainter
import de.mm20.launcher2.ktx.tryStartActivity
import de.mm20.launcher2.preferences.LauncherDataStore
-import de.mm20.launcher2.preferences.Settings
import de.mm20.launcher2.preferences.Settings.SearchBarSettings
import de.mm20.launcher2.search.data.Websearch
import de.mm20.launcher2.ui.R
@@ -113,18 +107,6 @@ fun SearchBar(
}) {
Text(stringResource(R.string.settings))
}
- DropdownMenuItem(onClick = {
- context.startActivity(Intent().also {
- it.component = ComponentName(
- context.packageName,
- "de.mm20.launcher2.activity.SettingsActivity"
- )
- it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
- })
- onDismissRequest()
- }) {
- Text("Legacy Settings")
- }
}
},
onFocus = onFocus,