Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10861bf1 authored by Rahul Banerjee's avatar Rahul Banerjee Committed by Android (Google) Code Review
Browse files

Merge "Migrate Controls{ProviderSelector,Favoriting,Editing}Activities" into tm-qpr-dev

parents 90cac42c 326c2507
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ android_library {
        "androidx.dynamicanimation_dynamicanimation",
        "androidx-constraintlayout_constraintlayout",
        "androidx.exifinterface_exifinterface",
        "androidx.test.ext.junit",
        "com.google.android.material_material",
        "kotlin-reflect",
        "kotlinx_coroutines_android",
+24 −2
Original line number Diff line number Diff line
@@ -20,11 +20,14 @@ import android.app.ActivityOptions
import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.view.ViewStub
import android.widget.Button
import android.widget.TextView
import android.window.OnBackInvokedCallback
import android.window.OnBackInvokedDispatcher
import androidx.activity.ComponentActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.ItemTouchHelper
@@ -42,7 +45,7 @@ import javax.inject.Inject
/**
 * Activity for rearranging and removing controls for a given structure
 */
class ControlsEditingActivity @Inject constructor(
open class ControlsEditingActivity @Inject constructor(
    private val controller: ControlsControllerImpl,
    private val broadcastDispatcher: BroadcastDispatcher,
    private val customIconCache: CustomIconCache,
@@ -50,8 +53,9 @@ class ControlsEditingActivity @Inject constructor(
) : ComponentActivity() {

    companion object {
        private const val DEBUG = false
        private const val TAG = "ControlsEditingActivity"
        private const val EXTRA_STRUCTURE = ControlsFavoritingActivity.EXTRA_STRUCTURE
        const val EXTRA_STRUCTURE = ControlsFavoritingActivity.EXTRA_STRUCTURE
        private val SUBTITLE_ID = R.string.controls_favorite_rearrange
        private val EMPTY_TEXT_ID = R.string.controls_favorite_removed
    }
@@ -73,6 +77,13 @@ class ControlsEditingActivity @Inject constructor(
        }
    }

    private val mOnBackInvokedCallback = OnBackInvokedCallback {
        if (DEBUG) {
            Log.d(TAG, "Predictive Back dispatcher called mOnBackInvokedCallback")
        }
        onBackPressed()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

@@ -94,11 +105,22 @@ class ControlsEditingActivity @Inject constructor(
        setUpList()

        currentUserTracker.startTracking()

        if (DEBUG) {
            Log.d(TAG, "Registered onBackInvokedCallback")
        }
        onBackInvokedDispatcher.registerOnBackInvokedCallback(
                OnBackInvokedDispatcher.PRIORITY_DEFAULT, mOnBackInvokedCallback)
    }

    override fun onStop() {
        super.onStop()
        currentUserTracker.stopTracking()

        if (DEBUG) {
            Log.d(TAG, "Unregistered onBackInvokedCallback")
        }
        onBackInvokedDispatcher.unregisterOnBackInvokedCallback(mOnBackInvokedCallback)
    }

    override fun onBackPressed() {
+27 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
@@ -32,6 +33,8 @@ import android.widget.Button
import android.widget.FrameLayout
import android.widget.TextView
import android.widget.Toast
import android.window.OnBackInvokedCallback
import android.window.OnBackInvokedDispatcher
import androidx.activity.ComponentActivity
import androidx.viewpager2.widget.ViewPager2
import com.android.systemui.Prefs
@@ -50,7 +53,7 @@ import java.util.concurrent.Executor
import java.util.function.Consumer
import javax.inject.Inject

class ControlsFavoritingActivity @Inject constructor(
open class ControlsFavoritingActivity @Inject constructor(
    @Main private val executor: Executor,
    private val controller: ControlsControllerImpl,
    private val listingController: ControlsListingController,
@@ -59,6 +62,7 @@ class ControlsFavoritingActivity @Inject constructor(
) : ComponentActivity() {

    companion object {
        private const val DEBUG = false
        private const val TAG = "ControlsFavoritingActivity"

        // If provided and no structure is available, use as the title
@@ -67,7 +71,7 @@ class ControlsFavoritingActivity @Inject constructor(
        // If provided, show this structure page first
        const val EXTRA_STRUCTURE = "extra_structure"
        const val EXTRA_SINGLE_STRUCTURE = "extra_single_structure"
        internal const val EXTRA_FROM_PROVIDER_SELECTOR = "extra_from_provider_selector"
        const val EXTRA_FROM_PROVIDER_SELECTOR = "extra_from_provider_selector"
        private const val TOOLTIP_PREFS_KEY = Prefs.Key.CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT
        private const val TOOLTIP_MAX_SHOWN = 2
    }
@@ -102,6 +106,13 @@ class ControlsFavoritingActivity @Inject constructor(
        }
    }

    private val mOnBackInvokedCallback = OnBackInvokedCallback {
        if (DEBUG) {
            Log.d(TAG, "Predictive Back dispatcher called mOnBackInvokedCallback")
        }
        onBackPressed()
    }

    private val listingCallback = object : ControlsListingController.ControlsListingCallback {

        override fun onServicesUpdated(serviceInfos: List<ControlsServiceInfo>) {
@@ -353,6 +364,12 @@ class ControlsFavoritingActivity @Inject constructor(

        listingController.addCallback(listingCallback)
        currentUserTracker.startTracking()

        if (DEBUG) {
            Log.d(TAG, "Registered onBackInvokedCallback")
        }
        onBackInvokedDispatcher.registerOnBackInvokedCallback(
                OnBackInvokedDispatcher.PRIORITY_DEFAULT, mOnBackInvokedCallback)
    }

    override fun onResume() {
@@ -372,6 +389,12 @@ class ControlsFavoritingActivity @Inject constructor(

        listingController.removeCallback(listingCallback)
        currentUserTracker.stopTracking()

        if (DEBUG) {
            Log.d(TAG, "Unregistered onBackInvokedCallback")
        }
        onBackInvokedDispatcher.unregisterOnBackInvokedCallback(
                mOnBackInvokedCallback)
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
+23 −2
Original line number Diff line number Diff line
@@ -20,16 +20,18 @@ import android.app.ActivityOptions
import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewStub
import android.widget.Button
import android.widget.TextView
import android.window.OnBackInvokedCallback
import android.window.OnBackInvokedDispatcher
import androidx.activity.ComponentActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
import com.android.systemui.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.controls.controller.ControlsController
@@ -44,7 +46,7 @@ import javax.inject.Inject
/**
 * Activity to select an application to favorite the [Control] provided by them.
 */
class ControlsProviderSelectorActivity @Inject constructor(
open class ControlsProviderSelectorActivity @Inject constructor(
    @Main private val executor: Executor,
    @Background private val backExecutor: Executor,
    private val listingController: ControlsListingController,
@@ -54,6 +56,7 @@ class ControlsProviderSelectorActivity @Inject constructor(
) : ComponentActivity() {

    companion object {
        private const val DEBUG = false
        private const val TAG = "ControlsProviderSelectorActivity"
        const val BACK_SHOULD_EXIT = "back_should_exit"
    }
@@ -70,6 +73,13 @@ class ControlsProviderSelectorActivity @Inject constructor(
        }
    }

    private val mOnBackInvokedCallback = OnBackInvokedCallback {
        if (DEBUG) {
            Log.d(TAG, "Predictive Back dispatcher called mOnBackInvokedCallback")
        }
        onBackPressed()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

@@ -141,11 +151,22 @@ class ControlsProviderSelectorActivity @Inject constructor(
                }
            })
        }

        if (DEBUG) {
            Log.d(TAG, "Registered onBackInvokedCallback")
        }
        onBackInvokedDispatcher.registerOnBackInvokedCallback(
                OnBackInvokedDispatcher.PRIORITY_DEFAULT, mOnBackInvokedCallback)
    }

    override fun onStop() {
        super.onStop()
        currentUserTracker.stopTracking()

        if (DEBUG) {
            Log.d(TAG, "Unregistered onBackInvokedCallback")
        }
        onBackInvokedDispatcher.unregisterOnBackInvokedCallback(mOnBackInvokedCallback)
    }

    /**
+15 −0
Original line number Diff line number Diff line
@@ -93,6 +93,21 @@
            android:excludeFromRecents="true"
            />

        <activity android:name="com.android.systemui.controls.management.ControlsEditingActivityTest$TestableControlsEditingActivity"
            android:exported="false"
            android:excludeFromRecents="true"
            />

        <activity android:name="com.android.systemui.controls.management.ControlsFavoritingActivityTest$TestableControlsFavoritingActivity"
            android:exported="false"
            android:excludeFromRecents="true"
            />

        <activity android:name="com.android.systemui.controls.management.ControlsProviderSelectorActivityTest$TestableControlsProviderSelectorActivity"
            android:exported="false"
            android:excludeFromRecents="true"
            />

        <activity android:name="com.android.systemui.screenshot.ScrollViewActivity"
                  android:exported="false" />

Loading