Loading packages/SystemUI/res/layout/controls_icon.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2020, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="28dp" android:layout_height="28dp" android:scaleType="fitCenter" android:layout_marginLeft="2dp" android:layout_marginRight="2dp" /> packages/SystemUI/res/layout/controls_no_favorites.xml +43 −9 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2020, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/controls_title" android:text="@string/quick_controls_title" <LinearLayout android:id="@+id/controls_no_favorites_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:gravity="center" android:textSize="25dp" android:orientation="vertical" android:paddingTop="40dp" android:paddingBottom="40dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="@drawable/control_no_favorites_background"> <LinearLayout android:id="@+id/controls_icon_row" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" android:paddingBottom="8dp" /> <TextView android:id="@+id/controls_title" android:text="@string/quick_controls_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_gravity="center" android:textSize="25sp" android:textColor="@*android:color/foreground_material_dark" android:fontFamily="@*android:string/config_headlineFontFamily" android:background="@drawable/control_no_favorites_background"/> android:fontFamily="@*android:string/config_headlineFontFamily" /> </LinearLayout> </merge> packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ import com.android.systemui.R const val MIN_LEVEL = 0 const val MAX_LEVEL = 10000 private const val UPDATE_DELAY_IN_MILLIS = 2000L private const val UPDATE_DELAY_IN_MILLIS = 3000L class ControlViewHolder( val layout: ViewGroup, Loading packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +50 −7 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.ServiceConnection import android.graphics.drawable.Drawable import android.os.IBinder import android.service.controls.Control import android.service.controls.TokenProvider Loading @@ -29,19 +30,24 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import android.widget.Space import android.widget.TextView import com.android.settingslib.widget.CandidateInfo import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.controller.ControlInfo import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.management.ControlsProviderSelectorActivity import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.R import com.android.systemui.util.concurrency.DelayableExecutor import dagger.Lazy import java.text.Collator import javax.inject.Inject import javax.inject.Singleton Loading Loading @@ -110,7 +116,9 @@ private data class ControlKey(val componentName: ComponentName, val controlId: S class ControlsUiControllerImpl @Inject constructor ( val controlsController: Lazy<ControlsController>, val context: Context, @Main val uiExecutor: DelayableExecutor @Main val uiExecutor: DelayableExecutor, @Background val bgExecutor: DelayableExecutor, val controlsListingController: Lazy<ControlsListingController> ) : ControlsUiController { private lateinit var controlInfos: List<ControlInfo> Loading @@ -121,6 +129,22 @@ class ControlsUiControllerImpl @Inject constructor ( override val available: Boolean get() = controlsController.get().available private val listingCallback = object : ControlsListingController.ControlsListingCallback { override fun onServicesUpdated(candidates: List<CandidateInfo>) { bgExecutor.execute { val collator = Collator.getInstance(context.getResources() .getConfiguration().locale) val localeComparator = compareBy<CandidateInfo, CharSequence>(collator) { it.loadLabel() } val mList = candidates.toMutableList() mList.sortWith(localeComparator) loadInitialSetupViewIcons(mList.map { it.loadLabel() to it.loadIcon() }) } } } override fun show(parent: ViewGroup) { Log.d(TAG, "show()") Loading Loading @@ -153,8 +177,26 @@ class ControlsUiControllerImpl @Inject constructor ( val inflater = LayoutInflater.from(context) inflater.inflate(R.layout.controls_no_favorites, parent, true) val textView = parent.requireViewById(R.id.controls_title) as TextView textView.setOnClickListener(launchSelectorActivityListener(context)) val viewGroup = parent.requireViewById(R.id.controls_no_favorites_group) as ViewGroup viewGroup.setOnClickListener(launchSelectorActivityListener(context)) controlsListingController.get().addCallback(listingCallback) } private fun loadInitialSetupViewIcons(icons: List<Pair<CharSequence, Drawable>>) { uiExecutor.execute { val viewGroup = parent.requireViewById(R.id.controls_icon_row) as ViewGroup viewGroup.removeAllViews() val inflater = LayoutInflater.from(context) icons.forEach { val imageView = inflater.inflate(R.layout.controls_icon, viewGroup, false) as ImageView imageView.setContentDescription(it.first) imageView.setImageDrawable(it.second) viewGroup.addView(imageView) } } } private fun launchSelectorActivityListener(context: Context): (View) -> Unit { Loading Loading @@ -206,6 +248,7 @@ class ControlsUiControllerImpl @Inject constructor ( parent.removeAllViews() controlsById.clear() controlViewsById.clear() controlsListingController.get().removeCallback(listingCallback) } override fun onRefreshState(componentName: ComponentName, controls: List<Control>) { Loading @@ -231,9 +274,9 @@ class ControlsUiControllerImpl @Inject constructor ( } } private fun createRow(inflater: LayoutInflater, parent: ViewGroup): ViewGroup { val row = inflater.inflate(R.layout.controls_row, parent, false) as ViewGroup parent.addView(row) private fun createRow(inflater: LayoutInflater, listView: ViewGroup): ViewGroup { val row = inflater.inflate(R.layout.controls_row, listView, false) as ViewGroup listView.addView(row) return row } } Loading
packages/SystemUI/res/layout/controls_icon.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2020, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="28dp" android:layout_height="28dp" android:scaleType="fitCenter" android:layout_marginLeft="2dp" android:layout_marginRight="2dp" />
packages/SystemUI/res/layout/controls_no_favorites.xml +43 −9 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2020, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/controls_title" android:text="@string/quick_controls_title" <LinearLayout android:id="@+id/controls_no_favorites_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:gravity="center" android:textSize="25dp" android:orientation="vertical" android:paddingTop="40dp" android:paddingBottom="40dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="@drawable/control_no_favorites_background"> <LinearLayout android:id="@+id/controls_icon_row" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" android:paddingBottom="8dp" /> <TextView android:id="@+id/controls_title" android:text="@string/quick_controls_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_gravity="center" android:textSize="25sp" android:textColor="@*android:color/foreground_material_dark" android:fontFamily="@*android:string/config_headlineFontFamily" android:background="@drawable/control_no_favorites_background"/> android:fontFamily="@*android:string/config_headlineFontFamily" /> </LinearLayout> </merge>
packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ import com.android.systemui.R const val MIN_LEVEL = 0 const val MAX_LEVEL = 10000 private const val UPDATE_DELAY_IN_MILLIS = 2000L private const val UPDATE_DELAY_IN_MILLIS = 3000L class ControlViewHolder( val layout: ViewGroup, Loading
packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +50 −7 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.ServiceConnection import android.graphics.drawable.Drawable import android.os.IBinder import android.service.controls.Control import android.service.controls.TokenProvider Loading @@ -29,19 +30,24 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import android.widget.Space import android.widget.TextView import com.android.settingslib.widget.CandidateInfo import com.android.systemui.controls.controller.ControlsController import com.android.systemui.controls.controller.ControlInfo import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.management.ControlsProviderSelectorActivity import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.R import com.android.systemui.util.concurrency.DelayableExecutor import dagger.Lazy import java.text.Collator import javax.inject.Inject import javax.inject.Singleton Loading Loading @@ -110,7 +116,9 @@ private data class ControlKey(val componentName: ComponentName, val controlId: S class ControlsUiControllerImpl @Inject constructor ( val controlsController: Lazy<ControlsController>, val context: Context, @Main val uiExecutor: DelayableExecutor @Main val uiExecutor: DelayableExecutor, @Background val bgExecutor: DelayableExecutor, val controlsListingController: Lazy<ControlsListingController> ) : ControlsUiController { private lateinit var controlInfos: List<ControlInfo> Loading @@ -121,6 +129,22 @@ class ControlsUiControllerImpl @Inject constructor ( override val available: Boolean get() = controlsController.get().available private val listingCallback = object : ControlsListingController.ControlsListingCallback { override fun onServicesUpdated(candidates: List<CandidateInfo>) { bgExecutor.execute { val collator = Collator.getInstance(context.getResources() .getConfiguration().locale) val localeComparator = compareBy<CandidateInfo, CharSequence>(collator) { it.loadLabel() } val mList = candidates.toMutableList() mList.sortWith(localeComparator) loadInitialSetupViewIcons(mList.map { it.loadLabel() to it.loadIcon() }) } } } override fun show(parent: ViewGroup) { Log.d(TAG, "show()") Loading Loading @@ -153,8 +177,26 @@ class ControlsUiControllerImpl @Inject constructor ( val inflater = LayoutInflater.from(context) inflater.inflate(R.layout.controls_no_favorites, parent, true) val textView = parent.requireViewById(R.id.controls_title) as TextView textView.setOnClickListener(launchSelectorActivityListener(context)) val viewGroup = parent.requireViewById(R.id.controls_no_favorites_group) as ViewGroup viewGroup.setOnClickListener(launchSelectorActivityListener(context)) controlsListingController.get().addCallback(listingCallback) } private fun loadInitialSetupViewIcons(icons: List<Pair<CharSequence, Drawable>>) { uiExecutor.execute { val viewGroup = parent.requireViewById(R.id.controls_icon_row) as ViewGroup viewGroup.removeAllViews() val inflater = LayoutInflater.from(context) icons.forEach { val imageView = inflater.inflate(R.layout.controls_icon, viewGroup, false) as ImageView imageView.setContentDescription(it.first) imageView.setImageDrawable(it.second) viewGroup.addView(imageView) } } } private fun launchSelectorActivityListener(context: Context): (View) -> Unit { Loading Loading @@ -206,6 +248,7 @@ class ControlsUiControllerImpl @Inject constructor ( parent.removeAllViews() controlsById.clear() controlViewsById.clear() controlsListingController.get().removeCallback(listingCallback) } override fun onRefreshState(componentName: ComponentName, controls: List<Control>) { Loading @@ -231,9 +274,9 @@ class ControlsUiControllerImpl @Inject constructor ( } } private fun createRow(inflater: LayoutInflater, parent: ViewGroup): ViewGroup { val row = inflater.inflate(R.layout.controls_row, parent, false) as ViewGroup parent.addView(row) private fun createRow(inflater: LayoutInflater, listView: ViewGroup): ViewGroup { val row = inflater.inflate(R.layout.controls_row, listView, false) as ViewGroup listView.addView(row) return row } }