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

Commit fc4951a0 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

[PM] Support better transition in PIA V2 (5/N)

Adjust the layout to reduce the size change of the dialog

Flag: android.content.pm.use_pia_v2
Test: manual. screenrecord
Bug: 274120822
Bug: 402448072
Change-Id: I1f42076fd12c1ae348cdc625341ad4c9dd83e9c7
parent ae7c1bed
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
  -->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/custom_view_panel"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="vertical"
@@ -29,11 +30,21 @@
        <include layout="@layout/app_snippet_layout" />

        <ProgressBar
            android:id="@+id/progress_bar"
            android:id="@+id/indeterminate_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="@dimen/indeterminate_progress_bar_padding"
            style="?android:attr/progressBarStyleHorizontal"
            android:visibility="gone" />

        <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_marginTop="@dimen/progress_bar_margin_top"
            android:max="100"
            android:paddingVertical="4dp"
            style="?android:attr/progressBarStyleHorizontal"
            android:visibility="gone" />
+10 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
  -->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/custom_view_panel"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="vertical"
@@ -29,9 +30,17 @@
        <include layout="@layout/app_snippet_layout" />

        <com.google.android.material.progressindicator.LinearProgressIndicator
            android:id="@+id/progress_bar"
            android:id="@+id/indeterminate_progress_bar"
            android:indeterminate="true"
            android:layout_marginTop="@dimen/dialog_inter_element_margin"
            android:paddingVertical="@dimen/indeterminate_progress_bar_padding"
            android:visibility="gone"
            style="@style/PackageInstaller.ProgressBarStyle.Linear"/>

        <com.google.android.material.progressindicator.LinearProgressIndicator
            android:id="@+id/progress_bar"
            android:layout_marginTop="@dimen/progress_bar_margin_top"
            android:max="100"
            android:paddingVertical="4dp"
            android:visibility="gone"
            style="@style/PackageInstaller.ProgressBarStyle.Linear"/>
+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@
    <dimen name="dialog_inter_element_vertical_margin">12dp</dimen>
    <dimen name="alert_dialog_radius">28dp</dimen>
    <dimen name="alert_dialog_dim_amount">0.6</dimen>
    <dimen name="indeterminate_progress_bar_padding">26dp</dimen>
    <dimen name="progress_bar_margin_top">32dp</dimen>
    <!-- 364dp for the portrait mode -->
    <dimen name="alert_dialog_min_width_minor">96.5%</dimen>
    <!-- Override the values for the buttonbar paddings in M3 MaterialAlertDialog -->
+0 −14
Original line number Diff line number Diff line
@@ -113,20 +113,6 @@ public class UiUtil {
                /* 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, @NonNull String positiveBtnText,
            @NonNull String negativeBtnText,
            @Nullable DialogInterface.OnClickListener positiveBtnListener,
            @Nullable DialogInterface.OnClickListener negativeBtnListener) {
        return getAlertDialog(context, title, contentView, positiveBtnText,
                negativeBtnText, positiveBtnListener, negativeBtnListener,
                /* themeResId= */ 0);
    }

    /**
     * If material design is enabled, return the MaterialAlertDialog. Otherwise, return the
     * system AlertDialog.
+44 −12
Original line number Diff line number Diff line
@@ -65,7 +65,9 @@ public class InstallationFragment extends DialogFragment {
    private TextView mAppLabelTextView = null;
    private View mAppSnippet = null;
    private TextView mCustomMessageTextView = null;
    private View mCustomViewPanel = null;
    private ProgressBar mProgressBar = null;
    private ProgressBar mIndeterminateProgressBar = null;
    private View mTitleTemplate = null;

    @Override
@@ -87,6 +89,8 @@ public class InstallationFragment extends DialogFragment {
        mAppSnippet = dialogView.requireViewById(R.id.app_snippet);
        mAppIcon = dialogView.requireViewById(R.id.app_icon);
        mAppLabelTextView = dialogView.requireViewById(R.id.app_label);
        mCustomViewPanel = dialogView.requireViewById(R.id.custom_view_panel);
        mIndeterminateProgressBar = dialogView.requireViewById(R.id.indeterminate_progress_bar);
        mProgressBar = dialogView.requireViewById(R.id.progress_bar);
        mCustomMessageTextView = dialogView.requireViewById(R.id.custom_message);

@@ -156,6 +160,14 @@ public class InstallationFragment extends DialogFragment {
            mCustomMessageTextView.setPadding(0, 0, 0, 0);
        }

        // Reset the paddings of the custom view panel
        final int paddingHorizontal = mCustomViewPanel.getPaddingStart();
        final int paddingTop = mCustomViewPanel.getPaddingTop();
        final int paddingBottom =
                getResources().getDimensionPixelOffset(R.dimen.alert_dialog_inner_padding);
        mCustomViewPanel.setPadding(paddingHorizontal, paddingTop,
                paddingHorizontal, paddingBottom);

        switch (installStage.getStageCode()) {
            case InstallStage.STAGE_ABORTED -> {
                updateInstallAbortedUI(mDialog, (InstallAborted) installStage);
@@ -179,8 +191,10 @@ public class InstallationFragment extends DialogFragment {
    }

    private void updateInstallAbortedUI(Dialog dialog, InstallAborted installStage) {
        mProgressBar.setVisibility(View.GONE);
        mAppSnippet.setVisibility(View.GONE);
        mIndeterminateProgressBar.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mCustomMessageTextView.setVisibility(View.VISIBLE);

        // Set the message
@@ -212,9 +226,11 @@ public class InstallationFragment extends DialogFragment {
    }

    private void updateInstallFailedUI(Dialog dialog, InstallFailed installStage) {
        mIndeterminateProgressBar.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mAppSnippet.setVisibility(View.VISIBLE);
        mCustomMessageTextView.setVisibility(View.VISIBLE);
        mProgressBar.setVisibility(View.GONE);

        Log.i(LOG_TAG, "Installation status code: " + installStage.getLegacyCode());

@@ -286,14 +302,22 @@ public class InstallationFragment extends DialogFragment {
    }

    private void updateInstallInstallingUI(Dialog dialog, InstallInstalling installStage) {
        mProgressBar.setVisibility(View.VISIBLE);
        mAppSnippet.setVisibility(View.VISIBLE);
        mCustomMessageTextView.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mAppSnippet.setVisibility(View.VISIBLE);
        mIndeterminateProgressBar.setVisibility(View.VISIBLE);

        // Update the padding of the custom view panel
        final int paddingHorizontal = mCustomViewPanel.getPaddingStart();
        final int paddingTop = mCustomViewPanel.getPaddingTop();
        final int paddingBottom = 0;
        mCustomViewPanel.setPadding(paddingHorizontal, paddingTop,
                paddingHorizontal, paddingBottom);

        // Set the app icon, label and progress bar
        mAppIcon.setImageDrawable(installStage.getAppIcon());
        mAppLabelTextView.setText(installStage.getAppLabel());
        mProgressBar.setIndeterminate(true);

        // Set the title
        final int titleResId = installStage.isAppUpdating()
@@ -315,16 +339,16 @@ public class InstallationFragment extends DialogFragment {
    }

    private void updateInstallStagingUI(@NonNull Dialog dialog) {
        mProgressBar.setVisibility(View.VISIBLE);
        mAppSnippet.setVisibility(View.GONE);
        mCustomMessageTextView.setVisibility(View.GONE);
        mIndeterminateProgressBar.setVisibility(View.GONE);

        mProgressBar.setVisibility(View.VISIBLE);

        // Set the title
        dialog.setTitle(R.string.title_install_staging);

        // Set the progress bar
        mProgressBar.setIndeterminate(false);
        mProgressBar.setMax(100);
        mProgressBar.setProgress(0);

        // Hide the positive button
@@ -348,9 +372,11 @@ public class InstallationFragment extends DialogFragment {
    }

    private void updateInstallSuccessUI(Dialog dialog, InstallSuccess installStage) {
        mCustomMessageTextView.setVisibility(View.GONE);
        mIndeterminateProgressBar.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mAppSnippet.setVisibility(View.VISIBLE);
        mCustomMessageTextView.setVisibility(View.GONE);

        // Set the app icon and label
        mAppIcon.setImageDrawable(installStage.getAppIcon());
@@ -418,8 +444,10 @@ public class InstallationFragment extends DialogFragment {
    }

    private void updateUnknownSourceUI(Dialog dialog, InstallUserActionRequired installStage) {
        mAppSnippet.setVisibility(View.VISIBLE);
        mIndeterminateProgressBar.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mAppSnippet.setVisibility(View.VISIBLE);
        mCustomMessageTextView.setVisibility(View.VISIBLE);

        // Set the app icon and label
@@ -459,7 +487,9 @@ public class InstallationFragment extends DialogFragment {

    private void updateAnonymousSourceUI(Dialog dialog, InstallUserActionRequired installStage) {
        mAppSnippet.setVisibility(View.GONE);
        mIndeterminateProgressBar.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mCustomMessageTextView.setVisibility(View.VISIBLE);

        // Hide the title and set the message
@@ -505,9 +535,11 @@ public class InstallationFragment extends DialogFragment {

    private void updateInstallConfirmationUI(Dialog dialog,
            InstallUserActionRequired installStage) {
        mAppSnippet.setVisibility(View.VISIBLE);
        mProgressBar.setVisibility(View.GONE);
        mCustomMessageTextView.setVisibility(View.GONE);
        mIndeterminateProgressBar.setVisibility(View.GONE);
        mProgressBar.setVisibility(View.GONE);

        mAppSnippet.setVisibility(View.VISIBLE);

        // Set the app icon and label
        mAppIcon.setImageDrawable(installStage.getAppIcon());