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

Commit c10cfff4 authored by Yanting Yang's avatar Yanting Yang Committed by Android (Google) Code Review
Browse files

Merge "Remove silky flag from Apps for official release" into sc-dev

parents bf99c924 ba8e5802
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -3317,15 +3317,6 @@
            </intent-filter>
            </intent-filter>
        </activity>
        </activity>


        <activity
            android:name=".Settings$AppAndNotificationDashboardActivity"
            android:label="@string/app_and_notification_dashboard_title"
            android:icon="@drawable/ic_homepage_apps"
            android:exported="true">
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.applications.AppAndNotificationDashboardFragment"/>
        </activity>

        <activity
        <activity
            android:name=".Settings$AppDashboardActivity"
            android:name=".Settings$AppDashboardActivity"
            android:label="@string/apps_dashboard_title"
            android:label="@string/apps_dashboard_title"

res/xml/app_and_notification.xml

deleted100644 → 0
+0 −114
Original line number Original line 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.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="apps_and_notification_screen"
    android:title="@string/app_and_notification_dashboard_title"
    settings:initialExpandedChildrenCount="4">
    <!-- the initial count should include the dynamic tiles -->

    <Preference
        android:key="all_app_info"
        android:title="@string/applications_settings"
        android:order="-999"
        android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
        settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"
        settings:keywords="@string/keywords_applications_settings"/>

    <com.android.settingslib.widget.LayoutPreference
        android:key="recent_open_apps"
        android:title="@string/recent_app_category_title"
        android:layout="@layout/app_entities_header"
        android:selectable="false"
        android:order="-998"
        settings:allowDividerBelow="true"
        settings:controller="com.android.settings.applications.RecentAppsPreferenceController"/>

    <!-- Empty category to draw divider -->
    <PreferenceCategory
        android:key="recent_apps_divider"
        android:layout="@layout/preference_category_no_label"
        android:order="-997"/>

    <Preference
        android:key="conversations"
        android:title="@string/conversations_category_title"
        android:order="-550"
        settings:controller="com.android.settings.notification.ConversationListSummaryPreferenceController"
        android:fragment="com.android.settings.notification.app.ConversationListSettings"
    />

    <Preference
        android:key="configure_notification_settings"
        android:title="@string/configure_notification_settings"
        android:summary="@string/notification_screen_summary"
        android:order="-440"
        android:fragment="com.android.settings.notification.ConfigureNotificationSettings"/>

    <!-- Notifications (appears before manage_perms), default apps (appears after) -->
    <PreferenceCategory
        android:key="dashboard_tile_placeholder"
        android:order="10"/>

    <Preference
        android:key="default_apps"
        android:title="@string/app_default_dashboard_title"
        android:order="11"
        settings:controller="com.android.settings.applications.DefaultAppsPreferenceController">
        <intent android:action="android.settings.MANAGE_DEFAULT_APPS_SETTINGS"/>
    </Preference>

    <Preference
        android:key="manage_perms"
        android:title="@string/app_permissions"
        android:summary="@string/runtime_permissions_summary_control_app_access"
        android:order="12"
        settings:keywords="@string/keywords_app_permissions">
        <intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
    </Preference>

    <Preference
        android:key="hibernated_apps"
        android:title="@string/unused_apps"
        android:summary="@string/summary_placeholder"
        android:order="13"
        settings:keywords="app_hibernation_key"
        settings:controller="com.android.settings.applications.HibernatedAppsPreferenceController">
        <intent android:action="android.intent.action.MANAGE_UNUSED_APPS"/>
    </Preference>

    <com.android.settingslib.RestrictedPreference
        android:key="app_and_notif_cell_broadcast_settings"
        android:title="@string/cell_broadcast_settings"
        android:order="15"
        settings:useAdminDisabledSummary="true">
        <intent
            android:action="android.intent.action.MAIN"
            android:targetPackage="@string/config_cell_broadcast_receiver_package"
            android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings"/>
    </com.android.settingslib.RestrictedPreference>

    <Preference
        android:key="special_access"
        android:fragment="com.android.settings.applications.specialaccess.SpecialAccessSettings"
        android:title="@string/special_access"
        android:order="20"
        settings:controller="com.android.settings.applications.SpecialAppAccessPreferenceController"/>

</PreferenceScreen>
+0 −73
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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.app.usage.UsageStats;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

import java.util.List;

public class AllAppsInfoPreferenceController extends BasePreferenceController
        implements RecentAppStatsMixin.RecentAppStatsListener {

    @VisibleForTesting
    Preference mPreference;

    public AllAppsInfoPreferenceController(Context context, String key) {
        super(context, key);
    }

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        mPreference = screen.findPreference(getPreferenceKey());
        // In most cases, device has recently opened apps. So, we hide it by default.
        mPreference.setVisible(false);
    }

    @Override
    public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
        // If device has recently opened apps, we don't show all apps preference.
        if (!recentApps.isEmpty()) {
            mPreference.setVisible(false);
            return;
        }

        mPreference.setVisible(true);
        // Show total number of installed apps as See all's summary.
        new InstalledAppCounter(mContext, InstalledAppCounter.IGNORE_INSTALL_REASON,
                mContext.getPackageManager()) {
            @Override
            protected void onCountComplete(int num) {
                mPreference.setSummary(mContext.getString(R.string.apps_summary, num));
            }
        }.execute();
    }
}
+0 −151
Original line number Original line Diff line number Diff line
/*
 * 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.
 */

package com.android.settings.applications;

import android.app.settings.SettingsEnums;
import android.app.usage.UsageStats;
import android.content.Context;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.util.FeatureFlagUtils;
import android.view.View;

import androidx.annotation.NonNull;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.EmergencyBroadcastPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.AppEntitiesHeaderController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SearchIndexable
public class AppAndNotificationDashboardFragment extends DashboardFragment
        implements RecentAppStatsMixin.RecentAppStatsListener {

    private static final String TAG = "AppAndNotifDashboard";

    private RecentAppStatsMixin mRecentAppStatsMixin;
    private RecentAppsPreferenceController mRecentAppsPreferenceController;
    private AllAppsInfoPreferenceController mAllAppsInfoPreferenceController;

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY;
    }

    @Override
    protected String getLogTag() {
        return TAG;
    }

    @Override
    public int getHelpResource() {
        return R.string.help_url_apps_and_notifications;
    }

    @Override
    protected int getPreferenceScreenResId() {
        return R.xml.app_and_notification;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        use(SpecialAppAccessPreferenceController.class).setSession(getSettingsLifecycle());

        mRecentAppStatsMixin = new RecentAppStatsMixin(context,
                AppEntitiesHeaderController.MAXIMUM_APPS);
        getSettingsLifecycle().addObserver(mRecentAppStatsMixin);
        mRecentAppStatsMixin.addListener(this);

        mRecentAppsPreferenceController = use(RecentAppsPreferenceController.class);
        mRecentAppsPreferenceController.setFragment(this /* fragment */);
        mRecentAppStatsMixin.addListener(mRecentAppsPreferenceController);

        mAllAppsInfoPreferenceController = use(AllAppsInfoPreferenceController.class);
        mRecentAppStatsMixin.addListener(mAllAppsInfoPreferenceController);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setPinnedHeaderView(R.layout.progress_header);
        showPinnedHeader(false);
    }

    @Override
    public void onStart() {
        super.onStart();
        showPinnedHeader(true);
    }

    @Override
    public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
        showPinnedHeader(false);
        if (!recentApps.isEmpty()) {
            Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(),
                    getListView());
        }
    }

    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        return buildPreferenceControllers(context);
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
        controllers.add(new EmergencyBroadcastPreferenceController(context,
                "app_and_notif_cell_broadcast_settings"));
        return controllers;
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {
                @Override
                public List<SearchIndexableResource> getXmlResourcesToIndex(
                        Context context, boolean enabled) {
                    final SearchIndexableResource sir = new SearchIndexableResource(context);
                    sir.xmlResId = R.xml.app_and_notification;
                    return Arrays.asList(sir);
                }

                @Override
                public List<AbstractPreferenceController> createPreferenceControllers(
                        Context context) {
                    return buildPreferenceControllers(context);
                }

                @Override
                protected boolean isPageSearchEnabled(Context context) {
                    // TODO(b/174964405): This method should be removed when silky home launched.
                    // This page is going to deprecate, we should make this page unsearchable
                    // when the silky home is enabled, otherwise search results will contain the
                    // old data and launch this page even if the silky home is enabled.
                    return !FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME);
                }
            };
}
+0 −20
Original line number Original line Diff line number Diff line
@@ -19,14 +19,11 @@ package com.android.settings.applications;
import android.app.settings.SettingsEnums;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Context;
import android.provider.SearchIndexableResource;
import android.provider.SearchIndexableResource;
import android.util.FeatureFlagUtils;


import com.android.settings.R;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.search.SearchIndexable;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -79,16 +76,6 @@ public class AppDashboardFragment extends DashboardFragment {
        return buildPreferenceControllers(context);
        return buildPreferenceControllers(context);
    }
    }


    @Override
    public String getCategoryKey() {
        // TODO(b/174964405): Remove this function when the silky flag was deprecated.
        // To include injection tiles, map this app fragment to the app category in the short term.
        // When we deprecate the silky flag, we have to:
        // 1. Remove this method.
        // 2. Update the mapping in DashboardFragmentRegistry.PARENT_TO_CATEGORY_KEY_MAP.
        return CategoryKey.CATEGORY_APPS;
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {
            new BaseSearchIndexProvider() {
                @Override
                @Override
@@ -104,12 +91,5 @@ public class AppDashboardFragment extends DashboardFragment {
                        Context context) {
                        Context context) {
                    return buildPreferenceControllers(context);
                    return buildPreferenceControllers(context);
                }
                }

                @Override
                protected boolean isPageSearchEnabled(Context context) {
                    // TODO(b/174964405): This method should be removed when silky home launched.
                    // Only allow this page can be searchable when silky home enabled.
                    return FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME);
                }
            };
            };
}
}
Loading