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

Commit e64f01cc authored by Arc Wang's avatar Arc Wang
Browse files

Cleanup Storage Settings

There is AOSP built in file browser for image/video/audio
file category, this change cleanup APP based category
for image/video/audio.

Bug: 183078080
Test: atest com.android.settings.deviceinfo
      atest com.android.settings.deviceinfo.storage
      make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.deviceinfo
      make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.deviceinfo.storage
Change-Id: I925fc9296b8c2df5bd793668f66a12beb7744469
parent 31a697eb
Loading
Loading
Loading
Loading

res/drawable/ic_headset_24dp.xml

deleted100644 → 0
+0 −25
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:fillColor="#FF000000"
        android:pathData="M19,15v3c0,0.55 -0.45,1 -1,1h-1v-4H19M7,15v4H6c-0.55,0 -1,-0.45 -1,-1v-3H7M12,2c-4.97,0 -9,4.03 -9,9v7c0,1.66 1.34,3 3,3h3v-8H5v-2c0,-3.87 3.13,-7 7,-7s7,3.13 7,7v2h-4v8h3c1.66,0 3,-1.34 3,-3v-7C21,6.03 16.97,2 12,2L12,2z"/>
</vector>
+0 −9
Original line number Diff line number Diff line
@@ -3573,8 +3573,6 @@
    <!-- Body of dialog confirming that user wants to forget an internal storage device [CHAR LIMIT=NONE]-->
    <string name="storage_internal_forget_confirm">All the apps, photos, and data stored on this <xliff:g id="name" example="SD card">^1</xliff:g> will be lost forever.</string>
    <!-- Item title describing storage used by images [CHAR LIMIT=48]-->
    <string name="storage_detail_images">Images</string>
    <!-- Body of dialog informing user about the storage used by the Android System [CHAR LIMIT=NONE]-->
    <string name="storage_detail_dialog_system">System includes files used to run Android version <xliff:g id="version" example="8.0">%s</xliff:g></string>
@@ -7599,10 +7597,6 @@
    <string name="help_uri_apps_manage_sources" translatable="false"></string>
    <!-- Help URI, manage apps games [DO NOT TRANSLATE] -->
    <string name="help_uri_apps_games" translatable="false"></string>
    <!-- Help URI, manage apps movies [DO NOT TRANSLATE] -->
    <string name="help_uri_apps_movies" translatable="false"></string>
    <!-- Help URI, manage apps photography [DO NOT TRANSLATE] -->
    <string name="help_uri_apps_photography" translatable="false"></string>
    <!-- Help URI, manage apps wifi access [DO NOT TRANSLATE] -->
    <string name="help_uri_apps_wifi_access" translatable="false"></string>
    <!-- Help URI, manage apps that have access to all files [DO NOT TRANSLATE] -->
@@ -11921,9 +11915,6 @@
    <!-- Title of games app storage screen [CHAR LIMIT=30] -->
    <string name="game_storage_settings">Games</string>
    <!-- Title for audio files preference. [CHAR LIMIT=50] -->
    <string name="audio_files_title">Audio files</string>
    <!-- Title for the installed app info storage page. The total storage space taken up by this app. [CHAR LIMIT=40]-->
    <string name="app_info_storage_title">Space used</string>
+0 −4
Original line number Diff line number Diff line
@@ -199,10 +199,6 @@ public class Settings extends SettingsActivity {
    public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
    public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
    public static class GamesStorageActivity extends SettingsActivity { /* empty */ }
    public static class MoviesStorageActivity extends SettingsActivity { /* empty */ }
    public static class PhotosStorageActivity extends SettingsActivity {
        /* empty */
    }
    public static class GestureNavigationSettingsActivity extends SettingsActivity { /* empty */ }
    public static class InteractAcrossProfilesSettingsActivity extends SettingsActivity {
        /* empty */
+0 −49
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.settings.applications.manageapplications;

import androidx.fragment.app.Fragment;

/**
 * FileViewHolderController handles adapting the AppViewHolder to work as a general purpose
 * storage categorization preference in the ManageApplications view.
 */
public interface FileViewHolderController {
    /**
     * Begins a synchronous query for statistics for the files.
     */
    void queryStats();

    /**
     * Returns if the preference should be shown.
     */
    boolean shouldShow();

    /**
     * Initializes the view within an AppViewHolder.
     *
     * @param holder The holder to use to initialize.
     */
    void setupView(ApplicationViewHolder holder);

    /**
     * Handles the behavior when the view is clicked.
     *
     * @param fragment Fragment where the click originated.
     */
    void onClick(Fragment fragment);
}
+21 −110
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ import com.android.settings.Settings;
import com.android.settings.Settings.GamesStorageActivity;
import com.android.settings.Settings.HighPowerApplicationsActivity;
import com.android.settings.Settings.ManageExternalSourcesActivity;
import com.android.settings.Settings.MoviesStorageActivity;
import com.android.settings.Settings.OverlaySettingsActivity;
import com.android.settings.Settings.StorageUseActivity;
import com.android.settings.Settings.UsageAccessSettingsActivity;
@@ -130,7 +129,6 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
import com.android.settingslib.applications.ApplicationsState.CompoundFilter;
import com.android.settingslib.applications.ApplicationsState.VolumeFilter;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
@@ -182,9 +180,7 @@ public class ManageApplications extends InstrumentedFragment

    // Storage types. Used to determine what the extra item in the list of preferences is.
    public static final int STORAGE_TYPE_DEFAULT = 0; // Show all apps that are not categorized.
    public static final int STORAGE_TYPE_MUSIC = 1;
    public static final int STORAGE_TYPE_LEGACY = 2; // Show apps even if they can be categorized.
    public static final int STORAGE_TYPE_PHOTOS_VIDEOS = 3;
    public static final int STORAGE_TYPE_LEGACY = 1;  // Show apps even if they can be categorized.

    /**
     * Intents with action {@code android.settings.MANAGE_APP_OVERLAY_PERMISSION}
@@ -230,12 +226,10 @@ public class ManageApplications extends InstrumentedFragment
    public static final int LIST_TYPE_WRITE_SETTINGS = 7;
    public static final int LIST_TYPE_MANAGE_SOURCES = 8;
    public static final int LIST_TYPE_GAMES = 9;
    public static final int LIST_TYPE_MOVIES = 10;
    public static final int LIST_TYPE_PHOTOGRAPHY = 11;
    public static final int LIST_TYPE_WIFI_ACCESS = 13;
    public static final int LIST_MANAGE_EXTERNAL_STORAGE = 14;
    public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 15;
    public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 16;
    public static final int LIST_TYPE_WIFI_ACCESS = 10;
    public static final int LIST_MANAGE_EXTERNAL_STORAGE = 11;
    public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 12;
    public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 13;

    // List types that should show instant apps.
    public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -314,13 +308,6 @@ public class ManageApplications extends InstrumentedFragment
        } else if (className.equals(GamesStorageActivity.class.getName())) {
            mListType = LIST_TYPE_GAMES;
            mSortOrder = R.id.sort_order_size;
        } else if (className.equals(MoviesStorageActivity.class.getName())) {
            mListType = LIST_TYPE_MOVIES;
            mSortOrder = R.id.sort_order_size;
        } else if (className.equals(Settings.PhotosStorageActivity.class.getName())) {
            mListType = LIST_TYPE_PHOTOGRAPHY;
            mSortOrder = R.id.sort_order_size;
            mStorageType = args.getInt(EXTRA_STORAGE_TYPE, STORAGE_TYPE_DEFAULT);
        } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
            mListType = LIST_TYPE_WIFI_ACCESS;
            screenTitle = R.string.change_wifi_state_title;
@@ -429,24 +416,6 @@ public class ManageApplications extends InstrumentedFragment
                mApplications.mHasReceivedBridgeCallback =
                        savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
            }
            int userId = mIsWorkOnly ? mWorkUserId : UserHandle.myUserId();
            if (mStorageType == STORAGE_TYPE_MUSIC) {
                Context context = getContext();
                mApplications.setExtraViewController(
                        new MusicViewHolderController(
                                context,
                                new StorageStatsSource(context),
                                mVolumeUuid,
                                UserHandle.of(userId)));
            } else if (mStorageType == STORAGE_TYPE_PHOTOS_VIDEOS) {
                Context context = getContext();
                mApplications.setExtraViewController(
                        new PhotosViewHolderController(
                                context,
                                new StorageStatsSource(context),
                                mVolumeUuid,
                                UserHandle.of(userId)));
            }
            mRecyclerView = mListContainer.findViewById(R.id.apps_list);
            mRecyclerView.setItemAnimator(null);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(
@@ -508,19 +477,13 @@ public class ManageApplications extends InstrumentedFragment
    static AppFilter getCompositeFilter(int listType, int storageType, String volumeUuid) {
        AppFilter filter = new VolumeFilter(volumeUuid);
        if (listType == LIST_TYPE_STORAGE) {
            if (storageType == STORAGE_TYPE_MUSIC) {
                filter = new CompoundFilter(ApplicationsState.FILTER_AUDIO, filter);
            } else if (storageType == STORAGE_TYPE_DEFAULT) {
            if (storageType == STORAGE_TYPE_DEFAULT) {
                filter = new CompoundFilter(ApplicationsState.FILTER_APPS_EXCEPT_GAMES, filter);
            }
            return filter;
        }
        if (listType == LIST_TYPE_GAMES) {
            return new CompoundFilter(ApplicationsState.FILTER_GAMES, filter);
        } else if (listType == LIST_TYPE_MOVIES) {
            return new CompoundFilter(ApplicationsState.FILTER_MOVIES, filter);
        } else if (listType == LIST_TYPE_PHOTOGRAPHY) {
            return new CompoundFilter(ApplicationsState.FILTER_PHOTOS, filter);
        }
        return null;
    }
@@ -533,16 +496,9 @@ public class ManageApplications extends InstrumentedFragment
            case LIST_TYPE_NOTIFICATION:
                return SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS;
            case LIST_TYPE_STORAGE:
                if (mStorageType == STORAGE_TYPE_MUSIC) {
                    return SettingsEnums.APPLICATIONS_STORAGE_MUSIC;
                }
                return SettingsEnums.APPLICATIONS_STORAGE_APPS;
            case LIST_TYPE_GAMES:
                return SettingsEnums.APPLICATIONS_STORAGE_GAMES;
            case LIST_TYPE_MOVIES:
                return SettingsEnums.APPLICATIONS_STORAGE_MOVIES;
            case LIST_TYPE_PHOTOGRAPHY:
                return SettingsEnums.APPLICATIONS_STORAGE_PHOTOS;
            case LIST_TYPE_USAGE_ACCESS:
                return SettingsEnums.USAGE_ACCESS;
            case LIST_TYPE_HIGH_POWER:
@@ -668,12 +624,6 @@ public class ManageApplications extends InstrumentedFragment
            case LIST_TYPE_GAMES:
                startAppInfoFragment(AppStorageSettings.class, R.string.game_storage_settings);
                break;
            case LIST_TYPE_MOVIES:
                startAppInfoFragment(AppStorageSettings.class, R.string.storage_movies_tv);
                break;
            case LIST_TYPE_PHOTOGRAPHY:
                startAppInfoFragment(AppStorageSettings.class, R.string.storage_photos_videos);
                break;
            case LIST_TYPE_WIFI_ACCESS:
                startAppInfoFragment(ChangeWifiStateDetails.class,
                        R.string.change_wifi_state_title);
@@ -760,10 +710,6 @@ public class ManageApplications extends InstrumentedFragment
                return R.string.help_uri_apps_manage_sources;
            case LIST_TYPE_GAMES:
                return R.string.help_uri_apps_overlay;
            case LIST_TYPE_MOVIES:
                return R.string.help_uri_apps_movies;
            case LIST_TYPE_PHOTOGRAPHY:
                return R.string.help_uri_apps_photography;
            case LIST_TYPE_WIFI_ACCESS:
                return R.string.help_uri_apps_wifi_access;
            case LIST_MANAGE_EXTERNAL_STORAGE:
@@ -856,8 +802,6 @@ public class ManageApplications extends InstrumentedFragment
            mCurrentPkgName = entry.info.packageName;
            mCurrentUid = entry.info.uid;
            startApplicationDetailsActivity();
        } else {
            mApplications.mExtraViewController.onClick(this);
        }
    }

@@ -1046,7 +990,6 @@ public class ManageApplications extends InstrumentedFragment
        private AppFilter mCompositeFilter;
        private boolean mHasReceivedLoadEntries;
        private boolean mHasReceivedBridgeCallback;
        private FileViewHolderController mExtraViewController;
        private SearchFilter mSearchFilter;
        private PowerAllowlistBackend mBackend;

@@ -1146,18 +1089,6 @@ public class ManageApplications extends InstrumentedFragment
            }
        }

        public void setExtraViewController(FileViewHolderController extraViewController) {
            mExtraViewController = extraViewController;
            // Start to query extra view's stats on background, and once done post result to main
            // thread.
            ThreadUtils.postOnBackgroundThread(() -> {
                mExtraViewController.queryStats();
                ThreadUtils.postOnMainThread(() -> {
                    onExtraViewCompleted();
                });
            });
        }

        public void resume(int sort) {
            if (DEBUG) Log.i(TAG, "Resume!  mResumed=" + mResumed);
            if (!mResumed) {
@@ -1219,10 +1150,7 @@ public class ManageApplications extends InstrumentedFragment

        @Override
        public int getItemViewType(int position) {
            boolean isLastItem = (getItemCount() - 1) == position;
            return hasExtraView() && isLastItem
                    ? VIEW_TYPE_EXTRA_VIEW
                    : VIEW_TYPE_APP;
            return VIEW_TYPE_APP;
        }

        public void rebuild() {
@@ -1454,20 +1382,12 @@ public class ManageApplications extends InstrumentedFragment
            }
        }

        public void onExtraViewCompleted() {
            if (!hasExtraView()) {
                return;
            }
            // Update last item - this is assumed to be the extra view.
            notifyItemChanged(getItemCount() - 1);
        }

        @Override
        public int getItemCount() {
            if (mEntries == null) {
                return 0;
            }
            return mEntries.size() + (hasExtraView() ? 1 : 0);
            return mEntries.size();
        }

        public int getApplicationCount() {
@@ -1499,12 +1419,8 @@ public class ManageApplications extends InstrumentedFragment

        @Override
        public void onBindViewHolder(ApplicationViewHolder holder, int position) {
            if (mEntries != null && mExtraViewController != null && position == mEntries.size()) {
                // set up view for extra view controller
                mExtraViewController.setupView(holder);
            } else {
            // Bind the data efficiently with the holder
                ApplicationsState.AppEntry entry = mEntries.get(position);
            final ApplicationsState.AppEntry entry = mEntries.get(position);
            synchronized (entry) {
                holder.setTitle(entry.label);
                mState.ensureLabelDescription(entry);
@@ -1516,7 +1432,7 @@ public class ManageApplications extends InstrumentedFragment
                holder.updateDisableView(entry.info);
            }
            holder.setEnabled(isEnabled(position));
            }

            holder.itemView.setOnClickListener(mManageApplications);
        }

@@ -1589,11 +1505,6 @@ public class ManageApplications extends InstrumentedFragment
            }
        }

        private boolean hasExtraView() {
            return mExtraViewController != null
                    && mExtraViewController.shouldShow();
        }

        public static class OnScrollListener extends RecyclerView.OnScrollListener {
            private int mScrollState = SCROLL_STATE_IDLE;
            private boolean mDelayNotifyDataChange;
Loading