Skip to content

Commit

Permalink
[WIP] SystemUI: More smartspace changes
Browse files Browse the repository at this point in the history
Change-Id: Ie94d458d6150303829140b1d571d9f5140f30013
  • Loading branch information
markakash committed Oct 4, 2024
1 parent 39645c8 commit fb2c10e
Show file tree
Hide file tree
Showing 14 changed files with 470 additions and 15 deletions.
17 changes: 17 additions & 0 deletions packages/SystemUI/bcsmartspace/res/layout/weather.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='utf-8' ?>
<com.google.android.systemui.smartspace.WeatherSmartspaceView
android:id="@+id/weather_smartspace_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">

<com.google.android.systemui.smartspace.DoubleShadowTextView
android:id="@+id/weather_text_view"
android:textColor="?android:attr/textColorPrimary"
android:focusable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/enhanced_smartspace_base_action_icon_margin"
style="@style/DateWeatherText" />

</com.google.android.systemui.smartspace.WeatherSmartspaceView>
20 changes: 20 additions & 0 deletions packages/SystemUI/bcsmartspace/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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.
-->

<resources>
<declare-styleable name="WeatherSmartspaceView">
</declare-styleable>
</resources>
1 change: 1 addition & 0 deletions packages/SystemUI/bcsmartspace/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<dimen name="enhanced_smartspace_secondary_card_start_margin">1dp</dimen>
<dimen name="enhanced_smartspace_subtitle_margin_top">9dp</dimen>
<dimen name="enhanced_smartspace_subtitle_size">16sp</dimen>
<dimen name="enhanced_smartspace_text_size_medium">16.0sp</dimen>
<dimen name="enhanced_smartspace_title_size">20sp</dimen>
<dimen name="key_text_shadow_dx">0.5dip</dimen>
<dimen name="key_text_shadow_dy">0.5dip</dimen>
Expand Down
4 changes: 4 additions & 0 deletions packages/SystemUI/bcsmartspace/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
<item name="android:lineHeight">24.0sp</item>
</style>
<style name="DateWeatherText" parent="@style/EnhancedSmartspaceTextTitle">
<item name="android:textSize">@dimen/enhanced_smartspace_text_size_medium</item>
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
</style>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,26 @@ public static void setOnClickListener(BcSmartspaceCardSecondary bcSmartspaceCard
setOnClickListener(bcSmartspaceCardSecondary, smartspaceTarget, tapAction, smartspaceEventNotifier, str, bcSmartspaceCardLoggingInfo, 0);
}

public static void setOnClickListener(View view, SmartspaceTarget smartspaceTarget, SmartspaceAction smartspaceAction, BcSmartspaceDataPlugin.SmartspaceEventNotifier smartspaceEventNotifier, String str, BcSmartspaceCardLoggingInfo bcSmartspaceCardLoggingInfo) {
setOnClickListener(view, smartspaceTarget, smartspaceAction, smartspaceEventNotifier, str, bcSmartspaceCardLoggingInfo, 0);
}

public static Drawable getIconDrawable(Context context, Icon icon) {
return getIconDrawableWithCustomSize(icon, context, context.getResources().getDimensionPixelSize(R.dimen.enhanced_smartspace_icon_size));
}

public static Drawable getIconDrawableWithCustomSize(Icon icon, Context context, int i) {
Drawable bitmapDrawable;
if (icon == null) {
return null;
}
if (icon.getType() == 1 || icon.getType() == 5) {
bitmapDrawable = new BitmapDrawable(context.getResources(), icon.getBitmap());
} else {
if (icon.getType() != 1 && icon.getType() != 5) {
bitmapDrawable = icon.loadDrawable(context);
} else {
bitmapDrawable = new BitmapDrawable(context.getResources(), icon.getBitmap());
}
if (bitmapDrawable != null) {
int dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.enhanced_smartspace_icon_size);
bitmapDrawable.setBounds(0, 0, dimensionPixelSize, dimensionPixelSize);
bitmapDrawable.setBounds(0, 0, i, i);
}
return bitmapDrawable;
}
Expand Down Expand Up @@ -186,6 +193,29 @@ public static String getDimensionRatio(Bundle bundle) {
return null;
}

public static int getLoggingDisplaySurface(float f, String str) {
if (str == null) {
return 0;
}

if (str.equals(BcSmartspaceDataPlugin.UI_SURFACE_HOME_SCREEN)) {
return 1;
} else if (str.equals(BcSmartspaceDataPlugin.UI_SURFACE_DREAM)) {
return 5;
} else if (str.equals(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)) {
if (f == 1.0f) {
return 3;
} else if (f == 0.0f) {
return 2;
} else {
return -1;
}
} else {
return 0;
}
}


public static int getLoggingDisplaySurface(String str, boolean z, float f) {
if (str.equals("com.google.android.apps.nexuslauncher")) {
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public BcSmartspaceCardSecondary(Context context, AttributeSet attributeSet) {
this.mPrevSmartspaceTargetId = "";
}

public final void reset(String str) {
if (this.mPrevSmartspaceTargetId.equals(str)) {
return;
}
this.mPrevSmartspaceTargetId = str;
resetUi();
}

public void resetUi() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.viewpager.widget.ViewPager;
import com.android.systemui.bcsmartspace.R;
import com.android.systemui.plugins.BcSmartspaceConfigPlugin;
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
import com.android.systemui.plugins.FalsingManager;
import com.google.android.systemui.smartspace.CardPagerAdapter;
Expand All @@ -47,6 +48,7 @@ public class BcSmartspaceView extends FrameLayout implements BcSmartspaceDataPlu
public final CardPagerAdapter mAdapter;
public boolean mAnimateSmartspaceUpdate;
public final ContentObserver mAodObserver;
public BcSmartspaceConfigPlugin mConfigProvider;
public int mCardPosition;
public BcSmartspaceDataPlugin mDataProvider;
public boolean mIsAodEnabled;
Expand All @@ -60,6 +62,7 @@ public class BcSmartspaceView extends FrameLayout implements BcSmartspaceDataPlu

public BcSmartspaceView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mConfigProvider = new DefaultBcSmartspaceConfigProvider();
this.mLastReceivedTargets = new ArraySet<>();
this.mIsAodEnabled = false;
this.mCardPosition = 0;
Expand All @@ -71,7 +74,7 @@ public void onChange(boolean z) {
BcSmartspaceView.this.onSettingsChanged();
}
};
this.mAdapter = new CardPagerAdapter(this);
this.mAdapter = new CardPagerAdapter(this, this.mConfigProvider);
this.mOnPageChangeListener = new ViewPager.OnPageChangeListener() { // from class: com.google.android.systemui.smartspace.BcSmartspaceView.2
public void onPageScrollStateChanged(int state) {
List<? extends Parcelable> list;
Expand Down Expand Up @@ -126,6 +129,12 @@ public void onVisibilityAggregated(boolean isVisible) {
}
}

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
public final void registerConfigProvider(BcSmartspaceConfigPlugin bcSmartspaceConfigPlugin) {
this.mConfigProvider = bcSmartspaceConfigPlugin;
this.mAdapter.configProvider = bcSmartspaceConfigPlugin;
}

@Override // android.view.View
protected void onFinishInflate() {
super.onFinishInflate();
Expand Down Expand Up @@ -246,8 +255,10 @@ public void onSmartspaceTargetsUpdated(List<? extends Parcelable> list) {
this.mAdapter.mHasDifferentTargets = true;
}
});
this.mAdapter.addDefaultDateCardIfEmpty(this.mAdapter.mAODTargets);
this.mAdapter.addDefaultDateCardIfEmpty(this.mAdapter.mLockscreenTargets);
if (!this.mAdapter.configProvider.isDefaultDateWeatherDisabled()) {
this.mAdapter.addDefaultDateCardIfEmpty(this.mAdapter.mAODTargets);
this.mAdapter.addDefaultDateCardIfEmpty(this.mAdapter.mLockscreenTargets);
}
this.mAdapter.updateTargetVisibility();
this.mAdapter.notifyDataSetChanged();
int count = this.mAdapter.getCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.android.launcher3.icons.GraphicsUtils;
import com.android.systemui.bcsmartspace.R;
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
import com.android.systemui.plugins.BcSmartspaceConfigPlugin;
import com.google.android.systemui.smartspace.logging.BcSmartspaceCardLoggerUtil;
import com.google.android.systemui.smartspace.logging.BcSmartspaceCardLoggingInfo;
import com.google.android.systemui.smartspace.logging.BcSmartspaceSubcardLoggingInfo;
Expand All @@ -37,6 +38,7 @@ public class CardPagerAdapter extends PagerAdapter {
public static final int MIN_FEATURE_TYPE = -2;
public final View mRoot;
public BcSmartspaceDataPlugin mDataProvider;
public BcSmartspaceConfigPlugin configProvider;
public int mCurrentTextColor;
public int mPrimaryTextColor;
public ArrayList<SmartspaceTarget> mSmartspaceTargets = new ArrayList<>();
Expand All @@ -63,11 +65,12 @@ List<SmartspaceTarget> getTargets() {
return this.mSmartspaceTargets;
}

public CardPagerAdapter(View view) {
public CardPagerAdapter(View view, BcSmartspaceConfigPlugin bcSmartspaceConfigPlugin) {
this.mRoot = view;
int attrColor = GraphicsUtils.getAttrColor(view.getContext(), 16842806);
this.mPrimaryTextColor = attrColor;
this.mCurrentTextColor = attrColor;
this.configProvider = bcSmartspaceConfigPlugin;
}

public static int getBaseLegacyCardRes(int layout) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.google.android.systemui.smartspace;

import com.android.systemui.plugins.BcSmartspaceConfigPlugin;

public final class DefaultBcSmartspaceConfigProvider implements BcSmartspaceConfigPlugin {
@Override // com.android.systemui.plugins.BcSmartspaceConfigPlugin
public final boolean isDefaultDateWeatherDisabled() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ public class DoubleShadowIconDrawable extends Drawable {
public boolean mShowShadow;

public DoubleShadowIconDrawable(Context context) {
int dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.enhanced_smartspace_icon_size);
int dimensionPixelSize2 = context.getResources().getDimensionPixelSize(R.dimen.enhanced_smartspace_icon_inset);
this.mIconInsetSize = dimensionPixelSize2;
int i = (dimensionPixelSize2 * 2) + dimensionPixelSize;
this.mCanvasSize = i;
this(context, context.getResources().getDimensionPixelSize(R.dimen.enhanced_smartspace_icon_size), context.getResources().getDimensionPixelSize(R.dimen.enhanced_smartspace_icon_inset));
}

public DoubleShadowIconDrawable(Context context, int i, int i2) {
this.mShowShadow = true;
this.mIconInsetSize = i2;
int i3 = (i2 * 2) + i;
this.mCanvasSize = i3;
this.mAmbientShadowRadius = context.getResources().getDimensionPixelSize(R.dimen.ambient_text_shadow_radius);
this.mKeyShadowRadius = context.getResources().getDimensionPixelSize(R.dimen.key_text_shadow_radius);
this.mKeyShadowOffsetX = context.getResources().getDimensionPixelSize(R.dimen.key_text_shadow_dx);
this.mKeyShadowOffsetY = context.getResources().getDimensionPixelSize(R.dimen.key_text_shadow_dy);
setBounds(0, 0, i, i);
setBounds(0, 0, i3, i3);
}

@Override // android.graphics.drawable.Drawable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.google.android.systemui.smartspace;

import android.app.smartspace.SmartspaceTarget;
import android.app.smartspace.SmartspaceTargetEvent;
import android.os.Debug;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;

/* compiled from: go/retraceme 8fa908dd7f7cdf82919b81f8a849d2e4d6278999a179aaed94e232ba94c0a60d */
/* loaded from: /Users/aksrivas/Downloads/SystemUIGoogle_decompile_xml/.cache/classes2.dex */
public final class WeatherSmartspaceDataProvider implements BcSmartspaceDataPlugin {
public static final boolean DEBUG = Log.isLoggable("WeatherSSDataProvider", 3);
public final Set mSmartspaceTargetListeners = new HashSet();
public final List mSmartspaceTargets = new ArrayList();
public BcSmartspaceDataPlugin.SmartspaceEventNotifier mEventNotifier = null;

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin
public final BcSmartspaceDataPlugin.SmartspaceView getView(ViewGroup viewGroup) {
return (BcSmartspaceDataPlugin.SmartspaceView) LayoutInflater.from(viewGroup.getContext()).inflate(2131559195, viewGroup, false);
}

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin
public final void notifySmartspaceEvent(SmartspaceTargetEvent smartspaceTargetEvent) {
BcSmartspaceDataPlugin.SmartspaceEventNotifier smartspaceEventNotifier = this.mEventNotifier;
if (smartspaceEventNotifier != null) {
smartspaceEventNotifier.notifySmartspaceEvent(smartspaceTargetEvent);
}
}

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin
public final void onTargetsAvailable(List list) {
if (DEBUG) {
Log.d("WeatherSSDataProvider", this + " onTargetsAvailable called. Callers = " + Debug.getCallers(3));
StringBuilder sb = new StringBuilder(" targets.size() = ");
sb.append(list.size());
Log.d("WeatherSSDataProvider", sb.toString());
Log.d("WeatherSSDataProvider", " targets = " + list.toString());
}
List list2 = this.mSmartspaceTargets;
((ArrayList) list2).clear();
Iterator it = list.iterator();
while (it.hasNext()) {
SmartspaceTarget smartspaceTarget = (SmartspaceTarget) it.next();
if (smartspaceTarget.getFeatureType() == 1) {
((ArrayList) list2).add(smartspaceTarget);
}
}
this.mSmartspaceTargetListeners.forEach(new Consumer() { // from class: com.google.android.systemui.smartspace.WeatherSmartspaceDataProvider$$ExternalSyntheticLambda0
@Override // java.util.function.Consumer
public final void accept(Object obj) {
((BcSmartspaceDataPlugin.SmartspaceTargetListener) obj).onSmartspaceTargetsUpdated(WeatherSmartspaceDataProvider.this.mSmartspaceTargets);
}
});
}

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin
public final void registerListener(BcSmartspaceDataPlugin.SmartspaceTargetListener smartspaceTargetListener) {
((HashSet) this.mSmartspaceTargetListeners).add(smartspaceTargetListener);
smartspaceTargetListener.onSmartspaceTargetsUpdated(this.mSmartspaceTargets);
}

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin
public final void registerSmartspaceEventNotifier(BcSmartspaceDataPlugin.SmartspaceEventNotifier smartspaceEventNotifier) {
this.mEventNotifier = smartspaceEventNotifier;
}

@Override // com.android.systemui.plugins.BcSmartspaceDataPlugin
public final void unregisterListener(BcSmartspaceDataPlugin.SmartspaceTargetListener smartspaceTargetListener) {
((HashSet) this.mSmartspaceTargetListeners).remove(smartspaceTargetListener);
}
}
Loading

0 comments on commit fb2c10e

Please sign in to comment.