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

Commit 077c0e98 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ia729238b,Ia2889547,I38d21062,I09cf6381 into main

* changes:
  [PM] Enable optimize in the PackageInstaller
  [PM] Support material AlertDialog (11/N)
  [PM] Support material AlertDialog (10/N)
  [PM] Support material AlertDialog (9/N)
parents 579dda6e 6808c78d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ java_defaults {
    kotlin_plugins: ["kotlin-parcelize-compiler-plugin"],

    optimize: {
        optimize: true,
        shrink: true,
        shrink_resources: true,
    },
}
+2 −3
Original line number Diff line number Diff line
@@ -31,11 +31,10 @@
        <com.google.android.material.progressindicator.LinearProgressIndicator
            android:id="@+id/progress_bar"
            android:indeterminate="true"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_marginTop="@dimen/dialog_inter_element_margin"
            android:paddingVertical="4dp"
            android:visibility="gone" />
            android:visibility="gone"
            style="@style/PackageInstaller.ProgressBarStyle.Linear"/>

        <TextView
            style="?attr/textAppearanceInstallerCustomMessage"
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@
    <dimen name="button_min_height">40dp</dimen>
    <dimen name="dialog_inter_element_vertical_margin">12dp</dimen>
    <dimen name="alert_dialog_radius">28dp</dimen>
    <dimen name="alert_dialog_dim_amount">0.68</dimen>
    <dimen name="alert_dialog_dim_amount">0.6</dimen>
    <!-- 24dp + 364dp + 24dp for the portrait mode -->
    <dimen name="alert_dialog_min_width_minor">412dp</dimen>
    <!-- Override the values for the buttonbar paddings in M3 MaterialAlertDialog -->
+8 −0
Original line number Diff line number Diff line
@@ -168,4 +168,12 @@
    <style name="ShapeAppearance">
        <item name="cornerSize">@dimen/alert_dialog_radius</item>
    </style>

    <style name="PackageInstaller.ProgressBarStyle.Linear" parent="Widget.Material3.LinearProgressIndicator">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="indicatorColor">@color/primaryColor</item>
        <item name="trackColor">@color/outlineVariantColor</item>
        <item name="trackCornerRadius">50%</item>
    </style>
</resources>
+48 −18
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import com.android.packageinstaller.R;
import com.android.packageinstaller.v2.model.PackageUtil;
@@ -89,7 +91,19 @@ public class UiUtil {
     * system AlertDialog.
     */
    public static Dialog getAlertDialog(@NonNull Context context, @NonNull String title,
            @NonNull View contentView, int positiveBtnTextResId, int negativeBtnTextResId,
            @NonNull View contentView) {
        return getAlertDialog(context, title, contentView, /* positiveBtnText= */ null,
                /* negativeBtnText= */ null, /* positiveBtnListener= */ null,
                /* negativeBtnListener= */ null, /* themeResId= */ 0);
    }

    /**
     * If material design is enabled, return the MaterialAlertDialog. Otherwise, return the
     * system AlertDialog.
     */
    public static Dialog getAlertDialog(@NonNull Context context, @NonNull String title,
            @NonNull View contentView, @StringRes int positiveBtnTextResId,
            @StringRes int negativeBtnTextResId,
            @Nullable DialogInterface.OnClickListener positiveBtnListener,
            @Nullable DialogInterface.OnClickListener negativeBtnListener) {
        return getAlertDialog(context, title, contentView, positiveBtnTextResId,
@@ -116,12 +130,18 @@ public class UiUtil {
     * system AlertDialog.
     */
    public static Dialog getAlertDialog(@NonNull Context context,
            @NonNull String title, @NonNull View contentView, int positiveBtnTextResId,
            int negativeBtnTextResId, @Nullable DialogInterface.OnClickListener positiveBtnListener,
            @NonNull String title, @NonNull View contentView, @StringRes int positiveBtnTextResId,
            @StringRes int negativeBtnTextResId,
            @Nullable DialogInterface.OnClickListener positiveBtnListener,
            @Nullable DialogInterface.OnClickListener negativeBtnListener, int themeResId) {
        return getAlertDialog(context, title, contentView, context.getString(positiveBtnTextResId),
                context.getString(negativeBtnTextResId), positiveBtnListener, negativeBtnListener,
                themeResId);
        final String positiveBtnText =
                positiveBtnTextResId == Resources.ID_NULL ? null : context.getString(
                        positiveBtnTextResId);
        final String negativeBtnText =
                negativeBtnTextResId == Resources.ID_NULL ? null : context.getString(
                        negativeBtnTextResId);
        return getAlertDialog(context, title, contentView, positiveBtnText, negativeBtnText,
                positiveBtnListener, negativeBtnListener, themeResId);
    }

    /**
@@ -129,24 +149,34 @@ public class UiUtil {
     * system AlertDialog.
     */
    public static Dialog getAlertDialog(@NonNull Context context,
            @NonNull String title, @NonNull View contentView, @NonNull String positiveBtnText,
            @NonNull String negativeBtnText,
            @NonNull String title, @NonNull View contentView, @Nullable String positiveBtnText,
            @Nullable String negativeBtnText,
            @Nullable DialogInterface.OnClickListener positiveBtnListener,
            @Nullable DialogInterface.OnClickListener negativeBtnListener, int themeResId) {
        if (PackageUtil.isMaterialDesignEnabled(context)) {
            return new MaterialAlertDialogBuilder(context, themeResId)
            MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context, themeResId)
                    .setTitle(title)
                    .setView(contentView)
                    .setPositiveButton(positiveBtnText, positiveBtnListener)
                    .setNegativeButton(negativeBtnText, negativeBtnListener)
                    .create();
                    .setView(contentView);
            if (positiveBtnText != null) {
                builder.setPositiveButton(positiveBtnText, positiveBtnListener);
            }

            if (negativeBtnText != null) {
                builder.setNegativeButton(negativeBtnText, negativeBtnListener);
            }
            return builder.create();
        } else {
            return new AlertDialog.Builder(context, themeResId)
            AlertDialog.Builder builder = new AlertDialog.Builder(context, themeResId)
                    .setTitle(title)
                    .setView(contentView)
                    .setPositiveButton(positiveBtnText, positiveBtnListener)
                    .setNegativeButton(negativeBtnText, negativeBtnListener)
                    .create();
                    .setView(contentView);
            if (positiveBtnText != null) {
                builder.setPositiveButton(positiveBtnText, positiveBtnListener);
            }

            if (negativeBtnText != null) {
                builder.setNegativeButton(negativeBtnText, negativeBtnListener);
            }
            return builder.create();
        }
    }
}
Loading