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

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

Merge "[PM] Support better transition in PIA V2 (5/N)" into main

parents d2a8494a fc4951a0
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
  -->
  -->


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


        <ProgressBar
        <ProgressBar
            android:id="@+id/progress_bar"
            android:id="@+id/indeterminate_progress_bar"
            android:indeterminate="true"
            android:indeterminate="true"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_marginTop="@dimen/dialog_inter_element_margin"
            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"
            android:paddingVertical="4dp"
            style="?android:attr/progressBarStyleHorizontal"
            style="?android:attr/progressBarStyleHorizontal"
            android:visibility="gone" />
            android:visibility="gone" />
+10 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
  -->
  -->


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


        <com.google.android.material.progressindicator.LinearProgressIndicator
        <com.google.android.material.progressindicator.LinearProgressIndicator
            android:id="@+id/progress_bar"
            android:id="@+id/indeterminate_progress_bar"
            android:indeterminate="true"
            android:indeterminate="true"
            android:layout_marginTop="@dimen/dialog_inter_element_margin"
            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:paddingVertical="4dp"
            android:visibility="gone"
            android:visibility="gone"
            style="@style/PackageInstaller.ProgressBarStyle.Linear"/>
            style="@style/PackageInstaller.ProgressBarStyle.Linear"/>
+2 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,8 @@
    <dimen name="dialog_inter_element_vertical_margin">12dp</dimen>
    <dimen name="dialog_inter_element_vertical_margin">12dp</dimen>
    <dimen name="alert_dialog_radius">28dp</dimen>
    <dimen name="alert_dialog_radius">28dp</dimen>
    <dimen name="alert_dialog_dim_amount">0.6</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 -->
    <!-- 364dp for the portrait mode -->
    <dimen name="alert_dialog_min_width_minor">96.5%</dimen>
    <dimen name="alert_dialog_min_width_minor">96.5%</dimen>
    <!-- Override the values for the buttonbar paddings in M3 MaterialAlertDialog -->
    <!-- Override the values for the buttonbar paddings in M3 MaterialAlertDialog -->
+0 −14
Original line number Original line Diff line number Diff line
@@ -113,20 +113,6 @@ public class UiUtil {
                /* themeResId= */ 0);
                /* 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
     * If material design is enabled, return the MaterialAlertDialog. Otherwise, return the
     * system AlertDialog.
     * system AlertDialog.
+44 −12
Original line number Original line Diff line number Diff line
@@ -65,7 +65,9 @@ public class InstallationFragment extends DialogFragment {
    private TextView mAppLabelTextView = null;
    private TextView mAppLabelTextView = null;
    private View mAppSnippet = null;
    private View mAppSnippet = null;
    private TextView mCustomMessageTextView = null;
    private TextView mCustomMessageTextView = null;
    private View mCustomViewPanel = null;
    private ProgressBar mProgressBar = null;
    private ProgressBar mProgressBar = null;
    private ProgressBar mIndeterminateProgressBar = null;
    private View mTitleTemplate = null;
    private View mTitleTemplate = null;


    @Override
    @Override
@@ -87,6 +89,8 @@ public class InstallationFragment extends DialogFragment {
        mAppSnippet = dialogView.requireViewById(R.id.app_snippet);
        mAppSnippet = dialogView.requireViewById(R.id.app_snippet);
        mAppIcon = dialogView.requireViewById(R.id.app_icon);
        mAppIcon = dialogView.requireViewById(R.id.app_icon);
        mAppLabelTextView = dialogView.requireViewById(R.id.app_label);
        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);
        mProgressBar = dialogView.requireViewById(R.id.progress_bar);
        mCustomMessageTextView = dialogView.requireViewById(R.id.custom_message);
        mCustomMessageTextView = dialogView.requireViewById(R.id.custom_message);


@@ -156,6 +160,14 @@ public class InstallationFragment extends DialogFragment {
            mCustomMessageTextView.setPadding(0, 0, 0, 0);
            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()) {
        switch (installStage.getStageCode()) {
            case InstallStage.STAGE_ABORTED -> {
            case InstallStage.STAGE_ABORTED -> {
                updateInstallAbortedUI(mDialog, (InstallAborted) installStage);
                updateInstallAbortedUI(mDialog, (InstallAborted) installStage);
@@ -179,8 +191,10 @@ public class InstallationFragment extends DialogFragment {
    }
    }


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

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


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


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

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


        Log.i(LOG_TAG, "Installation status code: " + installStage.getLegacyCode());
        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) {
    private void updateInstallInstallingUI(Dialog dialog, InstallInstalling installStage) {
        mProgressBar.setVisibility(View.VISIBLE);
        mAppSnippet.setVisibility(View.VISIBLE);
        mCustomMessageTextView.setVisibility(View.GONE);
        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
        // Set the app icon, label and progress bar
        mAppIcon.setImageDrawable(installStage.getAppIcon());
        mAppIcon.setImageDrawable(installStage.getAppIcon());
        mAppLabelTextView.setText(installStage.getAppLabel());
        mAppLabelTextView.setText(installStage.getAppLabel());
        mProgressBar.setIndeterminate(true);


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


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

        mProgressBar.setVisibility(View.VISIBLE);


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


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


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


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

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


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


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

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


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


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

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


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


    private void updateInstallConfirmationUI(Dialog dialog,
    private void updateInstallConfirmationUI(Dialog dialog,
            InstallUserActionRequired installStage) {
            InstallUserActionRequired installStage) {
        mAppSnippet.setVisibility(View.VISIBLE);
        mProgressBar.setVisibility(View.GONE);
        mCustomMessageTextView.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
        // Set the app icon and label
        mAppIcon.setImageDrawable(installStage.getAppIcon());
        mAppIcon.setImageDrawable(installStage.getAppIcon());