Using hourglass icons for DWB toast

Bug: 118319143
Change-Id: I67018db3ceb8b6c0d863a46c9a9148013c68c1f7
Tests: Manual
This commit is contained in:
vadimt 2019-01-18 11:22:39 -08:00
parent 4bf9336d5f
commit 534178c926
4 changed files with 55 additions and 7 deletions

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path android:pathData="M0,0H24V24H0Z M 0,0"/>
<path
android:fillColor="#FFFFFFFF"
android:pathData="M6,2V8H6l4,4L6,16H6v6H18V16h0l-4,-4,4,-4h0V2Zm6,9.5,-4,-4V4h8V7.5Z"/>
</group>
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path android:pathData="M0,0H24V24H0Z M 0,0"/>
<path
android:fillColor="#FFFFFFFF"
android:pathData="M6,2V8H6l4,4L6,16H6v6H18V16h0l-4,-4,4,-4h0V2ZM16,16.5V20H8V16.5l4,-4Z"/>
</group>
</vector>

View File

@ -40,12 +40,24 @@
android:layout_width="match_parent"
android:layout_height="48dp"
android:importantForAccessibility="noHideDescendants"
android:fontFamily="sans-serif"
android:textSize="14sp"
android:background="@drawable/bg_wellbeing_toast"
android:layout_gravity="bottom"
android:gravity="center"
android:textColor="@android:color/white"
android:visibility="gone"
android:visibility="gone">
<ImageView
android:id="@+id/digital_well_being_hourglass"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="8dp"
/>
<TextView
android:id="@+id/digital_well_being_remaining_time"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:fontFamily="sans-serif"
android:textSize="14sp"
android:textColor="@android:color/white"
android:gravity="center_vertical"
/>
</com.android.quickstep.views.DigitalWellBeingToast>
</com.android.quickstep.views.TaskView>

View File

@ -28,6 +28,8 @@ import android.icu.util.MeasureUnit;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.StringRes;
@ -41,8 +43,7 @@ import com.android.systemui.shared.recents.model.Task;
import java.time.Duration;
import java.util.Locale;
public final class DigitalWellBeingToast extends TextView {
public final class DigitalWellBeingToast extends LinearLayout {
public interface InitializeCallback {
void call(float saturation, String contentDescription);
}
@ -50,13 +51,22 @@ public final class DigitalWellBeingToast extends TextView {
private static final String TAG = DigitalWellBeingToast.class.getSimpleName();
private Task mTask;
private ImageView mImage;
private TextView mText;
public DigitalWellBeingToast(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutDirection(Utilities.isRtl(getResources()) ?
View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
setOnClickListener((view) -> openAppUsageSettings());
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mText = findViewById(R.id.digital_well_being_remaining_time);
mImage = findViewById(R.id.digital_well_being_hourglass);
}
public void initialize(Task task, InitializeCallback callback) {
@ -70,7 +80,9 @@ public final class DigitalWellBeingToast extends TextView {
setVisibility(GONE);
} else {
setVisibility(VISIBLE);
setText(getText(appRemainingTimeMs, isGroupLimit));
mText.setText(getText(appRemainingTimeMs, isGroupLimit));
mImage.setImageResource(appRemainingTimeMs > 0 ?
R.drawable.hourglass_top : R.drawable.hourglass_bottom);
}
callback.call(