Loading src/com/android/launcher3/apppairs/AppPairIcon.java +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class AppPairIcon extends FrameLayout implements DraggableView, Reorderab // Set up icon drawable area icon.mIconGraphic = icon.findViewById(R.id.app_pair_icon_graphic); icon.mIconGraphic.init(activity.getDeviceProfile(), icon); icon.mIconGraphic.init(activity, icon); icon.checkDisabledState(); Loading src/com/android/launcher3/apppairs/AppPairIconGraphic.kt +31 −4 Original line number Diff line number Diff line Loading @@ -25,17 +25,19 @@ import android.util.Log import android.view.Gravity import android.widget.FrameLayout import com.android.launcher3.DeviceProfile import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.FastBitmapDrawable import com.android.launcher3.icons.FastBitmapDrawable.getDisabledColorFilter import com.android.launcher3.util.Themes import com.android.launcher3.views.ActivityContext /** * A FrameLayout marking the area on an [AppPairIcon] where the visual icon will be drawn. One of * two child UI elements on an [AppPairIcon], along with a BubbleTextView holding the text title. */ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { FrameLayout(context, attrs), OnDeviceProfileChangeListener { private val TAG = "AppPairIconGraphic" companion object { Loading Loading @@ -66,14 +68,17 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr // The app pairs icon appears differently in portrait and landscape. var isLeftRightSplit = false private lateinit var activityContext: ActivityContext private lateinit var parentIcon: AppPairIcon private lateinit var appPairBackground: Drawable private lateinit var appIcon1: FastBitmapDrawable private lateinit var appIcon2: FastBitmapDrawable fun init(grid: DeviceProfile, icon: AppPairIcon) { fun init(activity: ActivityContext, icon: AppPairIcon) { activityContext = activity // Calculate device-specific measurements val defaultIconSize = grid.iconSizePx val defaultIconSize = activity.deviceProfile.iconSizePx outerPadding = OUTER_PADDING_SCALE * defaultIconSize innerPadding = INNER_PADDING_SCALE * defaultIconSize backgroundSize = defaultIconSize - outerPadding * 2 Loading @@ -81,8 +86,8 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr centerChannelSize = CENTER_CHANNEL_SCALE * defaultIconSize bigRadius = BIG_RADIUS_SCALE * defaultIconSize smallRadius = SMALL_RADIUS_SCALE * defaultIconSize isLeftRightSplit = grid.isLeftRightSplit parentIcon = icon updateOrientation() appPairBackground = AppPairIconBackground(context, this) appPairBackground.setBounds(0, 0, backgroundSize.toInt(), backgroundSize.toInt()) Loading @@ -98,6 +103,28 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr layoutParams = lp } override fun onAttachedToWindow() { super.onAttachedToWindow() activityContext.addOnDeviceProfileChangeListener(this) } override fun onDetachedFromWindow() { super.onDetachedFromWindow() activityContext.removeOnDeviceProfileChangeListener(this) } /** Checks the device orientation and updates isLeftRightSplit accordingly. */ private fun updateOrientation() { val activity: ActivityContext = ActivityContext.lookupContext(context) isLeftRightSplit = activity.deviceProfile.isLeftRightSplit } /** When device profile changes, update orientation */ override fun onDeviceProfileChanged(dp: DeviceProfile?) { updateOrientation() invalidate() } /** Sets up app pair member icons for drawing. */ fun applyIcons() { val apps = parentIcon.info.contents Loading Loading
src/com/android/launcher3/apppairs/AppPairIcon.java +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class AppPairIcon extends FrameLayout implements DraggableView, Reorderab // Set up icon drawable area icon.mIconGraphic = icon.findViewById(R.id.app_pair_icon_graphic); icon.mIconGraphic.init(activity.getDeviceProfile(), icon); icon.mIconGraphic.init(activity, icon); icon.checkDisabledState(); Loading
src/com/android/launcher3/apppairs/AppPairIconGraphic.kt +31 −4 Original line number Diff line number Diff line Loading @@ -25,17 +25,19 @@ import android.util.Log import android.view.Gravity import android.widget.FrameLayout import com.android.launcher3.DeviceProfile import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.FastBitmapDrawable import com.android.launcher3.icons.FastBitmapDrawable.getDisabledColorFilter import com.android.launcher3.util.Themes import com.android.launcher3.views.ActivityContext /** * A FrameLayout marking the area on an [AppPairIcon] where the visual icon will be drawn. One of * two child UI elements on an [AppPairIcon], along with a BubbleTextView holding the text title. */ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { FrameLayout(context, attrs), OnDeviceProfileChangeListener { private val TAG = "AppPairIconGraphic" companion object { Loading Loading @@ -66,14 +68,17 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr // The app pairs icon appears differently in portrait and landscape. var isLeftRightSplit = false private lateinit var activityContext: ActivityContext private lateinit var parentIcon: AppPairIcon private lateinit var appPairBackground: Drawable private lateinit var appIcon1: FastBitmapDrawable private lateinit var appIcon2: FastBitmapDrawable fun init(grid: DeviceProfile, icon: AppPairIcon) { fun init(activity: ActivityContext, icon: AppPairIcon) { activityContext = activity // Calculate device-specific measurements val defaultIconSize = grid.iconSizePx val defaultIconSize = activity.deviceProfile.iconSizePx outerPadding = OUTER_PADDING_SCALE * defaultIconSize innerPadding = INNER_PADDING_SCALE * defaultIconSize backgroundSize = defaultIconSize - outerPadding * 2 Loading @@ -81,8 +86,8 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr centerChannelSize = CENTER_CHANNEL_SCALE * defaultIconSize bigRadius = BIG_RADIUS_SCALE * defaultIconSize smallRadius = SMALL_RADIUS_SCALE * defaultIconSize isLeftRightSplit = grid.isLeftRightSplit parentIcon = icon updateOrientation() appPairBackground = AppPairIconBackground(context, this) appPairBackground.setBounds(0, 0, backgroundSize.toInt(), backgroundSize.toInt()) Loading @@ -98,6 +103,28 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr layoutParams = lp } override fun onAttachedToWindow() { super.onAttachedToWindow() activityContext.addOnDeviceProfileChangeListener(this) } override fun onDetachedFromWindow() { super.onDetachedFromWindow() activityContext.removeOnDeviceProfileChangeListener(this) } /** Checks the device orientation and updates isLeftRightSplit accordingly. */ private fun updateOrientation() { val activity: ActivityContext = ActivityContext.lookupContext(context) isLeftRightSplit = activity.deviceProfile.isLeftRightSplit } /** When device profile changes, update orientation */ override fun onDeviceProfileChanged(dp: DeviceProfile?) { updateOrientation() invalidate() } /** Sets up app pair member icons for drawing. */ fun applyIcons() { val apps = parentIcon.info.contents Loading