geekdroid: remove AppCompat, migrate AppCompatActivity to ComponentActivity
authorDa Risk <da_risk@geekorum.com>
Tue, 16 Jan 2024 17:42:28 -0400
changeset 66 0bcd943bb51c
parent 65 262e1b65de7d
child 67 882d271b5297
geekdroid: remove AppCompat, migrate AppCompatActivity to ComponentActivity
geekdroid/build.gradle.kts
geekdroid/src/main/java/com/geekorum/geekdroid/accounts/AccountAuthenticatorAppCompatActivity.kt
geekdroid/src/main/java/com/geekorum/geekdroid/accounts/AccountAuthenticatorComponentActivity.kt
geekdroid/src/main/java/com/geekorum/geekdroid/app/BottomSheetDialogActivity.kt
--- a/geekdroid/build.gradle.kts	Tue Jan 16 17:05:53 2024 -0400
+++ b/geekdroid/build.gradle.kts	Tue Jan 16 17:42:28 2024 -0400
@@ -79,7 +79,6 @@
 
 dependencies {
     api(libs.recyclerview)
-    api(libs.appcompat)
     api(libs.material)
     api(libs.constraintlayout)
     api(libs.coordinatorlayout)
--- a/geekdroid/src/main/java/com/geekorum/geekdroid/accounts/AccountAuthenticatorAppCompatActivity.kt	Tue Jan 16 17:05:53 2024 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Geekdroid is a utility library for development on the Android
- * Platform.
- *
- * Copyright (C) 2017-2024 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekdroid.
- *
- * Geekdroid 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.
- *
- * Geekdroid 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 Geekdroid.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.geekdroid.accounts
-
-import android.accounts.AccountAuthenticatorActivity
-import android.accounts.AccountAuthenticatorResponse
-import android.accounts.AccountManager
-import android.os.Bundle
-import androidx.appcompat.app.AppCompatActivity
-import androidx.core.content.IntentCompat
-
-/**
- * An [AccountAuthenticatorActivity] that supports and AppCompat theme
- */
-open class AccountAuthenticatorAppCompatActivity : AppCompatActivity() {
-
-    private var accountAuthenticatorResponse: AccountAuthenticatorResponse? = null
-    var accountAuthenticatorResult: Bundle? = null
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        accountAuthenticatorResponse = IntentCompat.getParcelableExtra(intent, AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, AccountAuthenticatorResponse::class.java)
-        accountAuthenticatorResponse?.onRequestContinued()
-    }
-
-    override fun finish() {
-        accountAuthenticatorResponse?.apply {
-            if (accountAuthenticatorResult != null) {
-                onResult(accountAuthenticatorResult)
-            } else {
-                onError(AccountManager.ERROR_CODE_CANCELED, "cancelled")
-            }
-        }
-        super.finish()
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/geekdroid/src/main/java/com/geekorum/geekdroid/accounts/AccountAuthenticatorComponentActivity.kt	Tue Jan 16 17:42:28 2024 -0400
@@ -0,0 +1,55 @@
+/*
+ * Geekdroid is a utility library for development on the Android
+ * Platform.
+ *
+ * Copyright (C) 2017-2024 by Frederic-Charles Barthelery.
+ *
+ * This file is part of Geekdroid.
+ *
+ * Geekdroid 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.
+ *
+ * Geekdroid 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 Geekdroid.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.geekorum.geekdroid.accounts
+
+import android.accounts.AccountAuthenticatorActivity
+import android.accounts.AccountAuthenticatorResponse
+import android.accounts.AccountManager
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.core.content.IntentCompat
+
+/**
+ * An [AccountAuthenticatorActivity] that enables composition of higher level components.
+ */
+open class AccountAuthenticatorComponentActivity : ComponentActivity() {
+
+    private var accountAuthenticatorResponse: AccountAuthenticatorResponse? = null
+    var accountAuthenticatorResult: Bundle? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        accountAuthenticatorResponse = IntentCompat.getParcelableExtra(intent, AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, AccountAuthenticatorResponse::class.java)
+        accountAuthenticatorResponse?.onRequestContinued()
+    }
+
+    override fun finish() {
+        accountAuthenticatorResponse?.apply {
+            if (accountAuthenticatorResult != null) {
+                onResult(accountAuthenticatorResult)
+            } else {
+                onError(AccountManager.ERROR_CODE_CANCELED, "cancelled")
+            }
+        }
+        super.finish()
+    }
+}
--- a/geekdroid/src/main/java/com/geekorum/geekdroid/app/BottomSheetDialogActivity.kt	Tue Jan 16 17:05:53 2024 -0400
+++ b/geekdroid/src/main/java/com/geekorum/geekdroid/app/BottomSheetDialogActivity.kt	Tue Jan 16 17:42:28 2024 -0400
@@ -22,25 +22,26 @@
 package com.geekorum.geekdroid.app
 
 import android.annotation.SuppressLint
-import android.os.Build
+import android.app.Activity
 import android.os.Bundle
-import androidx.core.view.AccessibilityDelegateCompat
-import androidx.core.view.ViewCompat
-import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
 import android.view.View
 import android.view.ViewGroup
 import android.view.WindowManager
 import android.widget.FrameLayout
-import androidx.appcompat.app.AppCompatActivity
+import androidx.activity.ComponentActivity
 import androidx.core.content.res.use
+import androidx.core.view.AccessibilityDelegateCompat
+import androidx.core.view.ViewCompat
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
 import com.geekorum.geekdroid.databinding.ActivityBottomSheetDialogBinding
 import com.google.android.material.bottomsheet.BottomSheetBehavior
+import com.google.android.material.bottomsheet.BottomSheetDialogFragment
 
 /**
- * React like a [android.support.design.widget.BottomSheetDialogFragment] but is a separate [Activity].
+ * React like a [BottomSheetDialogFragment] but is a separate [Activity].
  * This allows you to launch the bottom sheet easily from another external activity.
  */
-abstract class BottomSheetDialogActivity : AppCompatActivity() {
+abstract class BottomSheetDialogActivity : ComponentActivity() {
 
     private lateinit var binding: ActivityBottomSheetDialogBinding
     private lateinit var behavior: BottomSheetBehavior<FrameLayout>