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

Commit 09955c38 authored by Antony Sargent's avatar Antony Sargent
Browse files

Changes to installed app details screen for instant apps

Bug: 35098444
Test: make RunSettingsRoboTests

This implements the following changes to the app details screen:

-Suppresses the "Uninstall" and "Force Stop" buttons
-Adds "Install app" and "Clear app" buttons
-Adds a mechanism for showing a link to the store's app details
 page that can be different from the default for installed apps.

Change-Id: Icea83f7d1fde62d4101cb0c8a6d03849f6c56bca
parent d3505c76
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2017 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:id="@+id/instant_app_button_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="4dp"
    android:paddingStart="8dp"
    android:paddingEnd="8dp"
    android:visibility="gone">
    <Button
        android:id="@+id/install"
        style="@style/AppActionPrimaryButton"
        android:enabled="false"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/install_text"/>
    <Button
        android:id="@+id/clear_data"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/clear_instant_app_data"/>
</LinearLayout>
+3 −0
Original line number Diff line number Diff line
@@ -8491,6 +8491,9 @@
    <string name="storage_percent_full">full</string>
    <!-- Label for button allow user to clear the data for an instant app -->
    <string name="clear_instant_app_data">Clear app</string>
    <!-- Title of games app storage screen [CHAR LIMIT=30] -->
    <string name="game_storage_settings">Games</string>
+7 −1
Original line number Diff line number Diff line
@@ -23,11 +23,17 @@
        android:selectable="false"
        android:order="-10000"/>

    <com.android.settings.applications.LayoutPreference
        android:key="instant_app_buttons"
        android:layout="@layout/instant_app_buttons"
        android:selectable="false"
        android:order="-9999"/>

    <com.android.settings.applications.LayoutPreference
      android:key="action_buttons"
      android:layout="@layout/app_action_buttons"
      android:selectable="false"
      android:order="-9999"/>
      android:order="-9998"/>

    <Preference
        android:key="notification_settings"
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */

package com.android.settings.applications;


import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.util.Log;

// This class provides methods that help dealing with app stores.
public class AppStoreUtil {
    private static final String LOG_TAG = "AppStoreUtil";

    private static Intent resolveIntent(Context context, Intent i) {
        ResolveInfo result = context.getPackageManager().resolveActivity(i, 0);
        return result != null ? new Intent(i.getAction())
                .setClassName(result.activityInfo.packageName, result.activityInfo.name) : null;
    }

    // Returns the package name of the app which installed a given packageName, if one is
    // available.
    public static String getInstallerPackageName(Context context, String packageName) {
        String installerPackageName = null;
        try {
            installerPackageName =
                    context.getPackageManager().getInstallerPackageName(packageName);
        } catch (IllegalArgumentException e) {
            Log.e(LOG_TAG, "Exception while retrieving the package installer of " + packageName, e);
        }
        if (installerPackageName == null) {
            return null;
        }
        return installerPackageName;
    }

    // Returns a link to the installer app store for a given package name.
    public static Intent getAppStoreLink(Context context, String installerPackageName,
            String packageName) {
        Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO)
                .setPackage(installerPackageName);
        final Intent result = resolveIntent(context, intent);
        if (result != null) {
            result.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);
            return result;
        }
        return null;
    }

    // Convenience method that looks up the installerPackageName for you.
    public static Intent getAppStoreLink(Context context, String packageName) {
      String installerPackageName = getInstallerPackageName(context, packageName);
      return getAppStoreLink(context, installerPackageName, packageName);
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.settings.applications;

import com.android.settings.applications.instantapps.InstantAppButtonsController;

import android.app.Fragment;
import android.content.Intent;
import android.view.View;
@@ -29,6 +31,14 @@ public interface ApplicationFeatureProvider {
     */
    AppHeaderController newAppHeaderController(Fragment fragment, View appHeader);

    /**
     *
     *  Returns a new {@link InstantAppButtonsController} instance for showing buttons
     *  only relevant to instant apps.
     */
    InstantAppButtonsController newInstantAppButtonsController(Fragment fragment,
            View view);

    /**
     * Calculates the total number of apps installed on the device via policy across all users
     * and managed profiles.
Loading