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

Commit 29a57b69 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Split layout for confirm step.

The activity is not split yet.

Test: Ran install/update types
Change-Id: I42c15d05dffc1f6db69c9f67148f7ceb6e8bd8ae
parent f412f5e9
Loading
Loading
Loading
Loading
+92 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2016 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.
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout android:id="@+id/app_snippet"
        android:background="?android:attr/colorPrimary"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:orientation="horizontal"
        android:elevation="@dimen/headerElevation"
        android:gravity="center_vertical">

        <ImageView android:id="@+id/app_icon"
            android:layout_marginStart="16dp"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:scaleType="fitCenter"
            android:src="@drawable/ic_file_download" />

        <TextView android:id="@+id/app_name"
            android:layout_marginStart="32dp"
            android:layout_marginEnd="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/titleTextStyle"
            android:singleLine="true"
            android:text="@string/app_name_unknown"
            android:ellipsize="end" />

    </LinearLayout>

    <ScrollView android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:padding="16dip">

        <TextView android:id="@+id/install_confirm_question"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium" />

    </ScrollView>

    <LinearLayout style="?android:attr/buttonBarStyle"
        android:background="?android:attr/windowBackground"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="8dp"
        android:measureWithLargestChild="true">

        <!-- spacer to push buttons to the right -->
        <View android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <Button android:id="@+id/cancel_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cancel"
            android:maxLines="2"
            style="?android:attr/buttonBarButtonStyle" />

        <Button android:id="@+id/ok_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/next"
            android:maxLines="2"
            android:filterTouchesWhenObscured="true"
            style="?android:attr/buttonBarButtonStyle" />

    </LinearLayout>

</LinearLayout>
+128 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->

<!--
  Defines the layout of the splash screen that displays the security
  settings required for an application and requests the confirmation of the
  user before it is installed.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!-- title bar -->
    <LinearLayout android:id="@+id/app_snippet"
        android:background="?android:attr/colorPrimary"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:orientation="horizontal"
        android:elevation="@dimen/headerElevation"
        android:gravity="center_vertical">

        <ImageView android:id="@+id/app_icon"
            android:layout_marginStart="16dp"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:scaleType="fitCenter" />

        <TextView android:id="@+id/app_name"
            android:layout_marginStart="32dp"
            android:layout_marginEnd="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/titleTextStyle"
            android:singleLine="true"
            android:ellipsize="end" />

    </LinearLayout>

    <TextView android:id="@+id/install_confirm_question"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?android:attr/colorPrimary"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/install_confirm_question"
        android:elevation="@dimen/headerElevation"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:paddingBottom="16dp"/>

    <!-- content -->
    <TabHost android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TabWidget android:id="@android:id/tabs"
                android:visibility="gone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <FrameLayout android:id="@android:id/tabcontent"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="0" />

            <android.support.v4.view.ViewPager android:id="@+id/pager"
                android:background="?android:attr/windowBackground"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

        </LinearLayout>

    </TabHost>

    <!-- Bottom buttons -->
    <LinearLayout style="?android:attr/buttonBarStyle"
        android:background="?android:attr/windowBackground"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="8dp"
        android:measureWithLargestChild="true">

        <!-- spacer to push buttons to the right -->
        <View android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <Button android:id="@+id/cancel_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cancel"
            android:maxLines="2"
            style="?android:attr/buttonBarButtonStyle" />

        <Button android:id="@+id/ok_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/next"
            android:maxLines="2"
            android:filterTouchesWhenObscured="true"
            style="?android:attr/buttonBarButtonStyle" />

    </LinearLayout>

</LinearLayout>

+154 −0
Original line number Diff line number Diff line
@@ -30,19 +30,18 @@
        android:background="?android:attr/colorPrimary"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
            android:orientation="horizontal">
        android:orientation="horizontal"
        android:gravity="center_vertical">

        <ImageView android:id="@+id/app_icon"
                android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            android:layout_width="24dp"
            android:layout_height="24dp"
                android:layout_gravity="center_vertical"
            android:scaleType="fitCenter" />

        <TextView android:id="@+id/app_name"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="32dp"
                android:layout_marginRight="16dp"
            android:layout_marginStart="32dp"
            android:layout_marginEnd="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/titleTextStyle"
@@ -51,26 +50,20 @@

    </LinearLayout>

    <!-- content -->
    <LinearLayout android:id="@+id/install_confirm_panel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

    <TextView android:id="@+id/install_confirm_question"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?android:attr/colorPrimary"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/install_confirm_question"
                android:paddingLeft="16dp"
                android:paddingRight="16dp" />
        android:paddingStart="16dp"
        android:paddingEnd="16dp" />

        <View android:id="@+id/spacer"
    <!-- content -->
    <LinearLayout android:id="@+id/install_confirm_panel"
        android:layout_width="match_parent"
                android:layout_height="16dp"
                android:visibility="gone"
                android:background="?android:attr/colorPrimary" />
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TabHost android:id="@android:id/tabhost"
            android:layout_width="match_parent"
@@ -86,6 +79,7 @@
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:fillViewport="true"
                    android:elevation="@dimen/headerElevation"
                    android:scrollbars="none">

                    <FrameLayout android:layout_width="match_parent"
+42 −33
Original line number Diff line number Diff line
@@ -88,14 +88,14 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
    // ApplicationInfo object primarily used for already existing applications
    private ApplicationInfo mAppInfo = null;

    // View for install progress
    View mInstallConfirm;
    // Buttons to indicate user acceptance
    private Button mOk;
    private Button mCancel;
    CaffeinatedScrollView mScrollView = null;
    private boolean mOkCanInstall = false;

    private PackageUtil.AppSnippet mAppSnippet;

    static final String PREFS_ALLOWED_SOURCES = "allowed_sources";

    private static final String TAB_ID_ALL = "all";
@@ -111,12 +111,17 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
    private static final int DLG_NOT_SUPPORTED_ON_WEAR = DLG_BASE + 7;

    private void startInstallConfirm() {
        // We might need to show permissions, load layout with permissions
        if (mAppInfo != null) {
            bindUi(R.layout.install_confirm_perm_update, true);
        } else {
            bindUi(R.layout.install_confirm_perm, true);
        }

        ((TextView) findViewById(R.id.install_confirm_question))
                .setText(R.string.install_confirm_question);
        findViewById(R.id.spacer).setVisibility(View.GONE);
        TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
        tabHost.setup();
        tabHost.setVisibility(View.VISIBLE);
        ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
        TabsAdapter adapter = new TabsAdapter(this, tabHost, viewPager);
        // If the app supports runtime permissions the new permissions will
@@ -155,9 +160,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
            }
            adapter.addTab(tabHost.newTabSpec(TAB_ID_NEW).setIndicator(
                    getText(R.string.newPerms)), mScrollView);
        } else  {
            findViewById(R.id.tabscontainer).setVisibility(View.GONE);
            findViewById(R.id.spacer).setVisibility(View.VISIBLE);
        }
        if (!supportsRuntimePermissions && N > 0) {
            permVisible = true;
@@ -179,20 +181,18 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
                msg = (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
                        ? R.string.install_confirm_question_update_system_no_perms
                        : R.string.install_confirm_question_update_no_perms;

                findViewById(R.id.spacer).setVisibility(View.VISIBLE);
            } else {
                // This is a new application with no permissions.
                msg = R.string.install_confirm_question_no_perms;
            }
            tabHost.setVisibility(View.INVISIBLE);

            // We do not need to show any permissions, load layout without permissions
            bindUi(R.layout.install_confirm, true);
            mScrollView = null;
        }
        if (msg != 0) {
            ((TextView)findViewById(R.id.install_confirm_question)).setText(msg);
        }
        mInstallConfirm.setVisibility(View.VISIBLE);
        mOk.setEnabled(true);
        if (mScrollView == null) {
            // There is nothing to scroll view, so the ok button is immediately
            // set to install.
@@ -444,21 +444,31 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
            return;
        }

        //set view
        setContentView(R.layout.install_start);
        mInstallConfirm = findViewById(R.id.install_confirm_panel);
        mInstallConfirm.setVisibility(View.INVISIBLE);
        boolean wasSetUp = processPackageUri(packageUri);
        if (!wasSetUp) {
            return;
        }

        // load dummy layout with OK button disabled until we override this layout in
        // startInstallConfirm
        bindUi(R.layout.install_confirm, false);

        checkIfAllowedAndInitiateInstall(false);
    }

    private void bindUi(int layout, boolean enableOk) {
        setContentView(layout);

        mOk = (Button) findViewById(R.id.ok_button);
        mCancel = (Button)findViewById(R.id.cancel_button);
        mOk.setOnClickListener(this);
        mCancel.setOnClickListener(this);

        boolean wasSetUp = processPackageUri(packageUri);
        if (!wasSetUp) {
            return;
        if (!enableOk) {
            mOk.setEnabled(false);
        }

        checkIfAllowedAndInitiateInstall(false);
        PackageUtil.initSnippetForNewApp(this, mAppSnippet, R.id.app_snippet);
    }

    /**
@@ -520,7 +530,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
        mPackageURI = packageUri;

        final String scheme = packageUri.getScheme();
        final PackageUtil.AppSnippet as;

        switch (scheme) {
            case SCHEME_PACKAGE: {
@@ -537,7 +546,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
                    setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK);
                    return false;
                }
                as = new PackageUtil.AppSnippet(mPm.getApplicationLabel(mPkgInfo.applicationInfo),
                mAppSnippet = new PackageUtil.AppSnippet(mPm.getApplicationLabel(mPkgInfo.applicationInfo),
                        mPm.getApplicationIcon(mPkgInfo.applicationInfo));
            } break;

@@ -555,7 +564,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
                mPkgInfo = PackageParser.generatePackageInfo(parsed, null,
                        PackageManager.GET_PERMISSIONS, 0, 0, null,
                        new PackageUserState());
                as = PackageUtil.getAppSnippet(this, mPkgInfo.applicationInfo, sourceFile);
                mAppSnippet = PackageUtil.getAppSnippet(this, mPkgInfo.applicationInfo, sourceFile);
            } break;

            case SCHEME_CONTENT: {
@@ -581,8 +590,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
            }
        }

        PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet);

        return true;
    }

@@ -672,6 +679,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen

    public void onClick(View v) {
        if (v == mOk) {
            if (mOk.isEnabled()) {
                if (mOkCanInstall || mScrollView == null) {
                    if (mSessionId != -1) {
                        mInstaller.setPermissionsResult(mSessionId, true);
@@ -682,6 +690,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
                } else {
                    mScrollView.pageScroll(View.FOCUS_DOWN);
                }
            }
        } else if (v == mCancel) {
            // Cancel and finish
            setResult(RESULT_CANCELED);