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

Commit 2b00ecdd authored by Arc Wang's avatar Arc Wang
Browse files

Storage category UX changes in Storage Settings

- Change category types.
- Use Intent.ACTION_VIEW to show content of each category.
- Sort order of each category by storage size.

Bug: 170918505
Test: make RunSettingsRoboTests ROBOTEST_FILTER=StorageItemPreferenceTest
      make RunSettingsRoboTests ROBOTEST_FILTER=StorageItemPreferenceControllerTest
      manual
      Click each category in Storage Settings.
Change-Id: Ib7beb1779a0fcbfd7b8ec52446707b105fcebff5
parent 11ad3be0
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2021 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"
    android:viewportHeight="24">
  <path
      android:pathData="M15,3V4H20V6H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V6H4V4H9V3H15ZM7,19H17V6H7V19ZM9,8H11V17H9V8ZM15,8H13V17H15V8Z"
      android:fillColor="#5F6368"
      android:fillType="evenOdd"/>
</vector>
+13 −0
Original line number Diff line number Diff line
@@ -509,4 +509,17 @@

    <!-- Cell broacast receiver package name -->
    <string name="config_cell_broadcast_receiver_package" translatable="false">com.android.cellbroadcastreceiver.module</string>

    <!-- TODO(b/174964885): These media Uri are not defined in framework yet. Replace with framework defined variables once it's available. -->
    <!-- Media Uri to view images storage category. -->
    <string name="config_images_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/images_root</string>

    <!-- Media Uri to view videos storage category. -->
    <string name="config_videos_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/videos_root</string>

    <!-- Media Uri to view audios storage category. -->
    <string name="config_audios_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/audio_root</string>

    <!-- Media Uri to view documents & other storage category. -->
    <string name="config_documents_and_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
</resources>
+38 −42
Original line number Diff line number Diff line
@@ -21,68 +21,64 @@
    android:orderingFromXml="false">
    <com.android.settingslib.widget.SettingsSpinnerPreference
        android:key="storage_spinner"
        android:order="-2"
        android:order="1"
        settings:searchable="false"
        settings:controller="com.android.settings.deviceinfo.storage.StorageSelectionPreferenceController"/>
    <com.android.settingslib.widget.UsageProgressBarPreference
        android:key="storage_summary"
        android:order="-1"
        android:order="2"
        settings:searchable="false"
        settings:controller="com.android.settings.deviceinfo.storage.StorageUsageProgressBarPreferenceController"/>
    <Preference
        android:key="free_up_space"
        android:order="0"
        android:title="@string/storage_free_up_space_title"
        android:summary="@string/storage_free_up_space_summary"
        settings:allowDividerAbove="true"/>
        settings:controller="com.android.settings.deviceinfo.storage.StorageUsageProgressBarPreferenceController"
        settings:allowDividerBelow="true"/>
    <com.android.settings.widget.PrimarySwitchPreference
        android:fragment="com.android.settings.deletionhelper.AutomaticStorageManagerSettings"
        android:key="toggle_asm"
        android:title="@string/automatic_storage_manager_preference_title"
        android:icon="@drawable/ic_storage"
        android:order="1"
        android:order="3"
        settings:allowDividerAbove="true"
        settings:allowDividerBelow="true"
        settings:controller="com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController"/>
    <Preference
        android:key="free_up_space"
        android:order="4"
        android:title="@string/storage_free_up_space_title"
        android:summary="@string/storage_free_up_space_summary"/>
    <!-- Preference order 100~200 are 'ONLY' for storage category preferences below. -->
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_photos_videos"
        android:title="@string/storage_photos_videos"
        android:icon="@drawable/ic_photo_library"
        settings:allowDividerAbove="true"
        android:order="2" />
        android:key="pref_images"
        android:title="@string/storage_images"
        android:icon="@drawable/ic_photo_library"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_music_audio"
        android:title="@string/storage_music_audio"
        android:icon="@drawable/ic_media_stream"
        android:order="3" />
        android:key="pref_videos"
        android:title="@string/storage_videos"
        android:icon="@drawable/ic_local_movies"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_games"
        android:title="@string/storage_games"
        android:icon="@drawable/ic_videogame_vd_theme_24"
        android:order="4" />
        android:key="pref_audios"
        android:title="@string/storage_audios"
        android:icon="@drawable/ic_media_stream"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_movies"
        android:title="@string/storage_movies_tv"
        android:icon="@drawable/ic_local_movies"
        android:order="5" />
        android:key="pref_apps"
        android:title="@string/storage_apps"
        android:icon="@drawable/ic_storage_apps"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_other_apps"
        android:title="@string/storage_other_apps"
        android:icon="@drawable/ic_storage_apps"
        android:order="6" />
        android:key="pref_games"
        android:title="@string/storage_games"
        android:icon="@drawable/ic_videogame_vd_theme_24"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_files"
        android:title="@string/storage_files"
        android:icon="@drawable/ic_folder_vd_theme_24"
        android:order="7"
        settings:keywords="@string/keywords_storage_files"/>
        android:key="pref_documents_and_other"
        android:title="@string/storage_documents_and_other"
        android:icon="@drawable/ic_folder_vd_theme_24"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_system"
        android:title="@string/storage_detail_system"
        android:icon="@drawable/ic_system_update"
        android:order="100" />
        android:title="@string/storage_system"
        android:icon="@drawable/ic_system_update"/>
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_trash"
        android:title="@string/storage_trash"
        android:icon="@drawable/ic_trash_can"/>
    <!-- Preference order 100~200 are 'ONLY' for storage category preferences above. -->
    <PreferenceCategory
        android:key="pref_secondary_users"
        android:title="@string/storage_other_users"
        android:order="200" />
        android:order="201" />
</PreferenceScreen>
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class StorageItemPreference extends Preference {
    private ProgressBar mProgressBar;
    private static final int PROGRESS_MAX = 100;
    private int mProgressPercent = UNINITIALIZED;
    private long mStorageSize;

    public StorageItemPreference(Context context) {
        this(context, null);
@@ -47,6 +48,7 @@ public class StorageItemPreference extends Preference {
    }

    public void setStorageSize(long size, long total) {
        mStorageSize = size;
        setSummary(
                FileSizeFormatter.formatFileSize(
                        getContext(),
@@ -61,6 +63,10 @@ public class StorageItemPreference extends Preference {
        updateProgressBar();
    }

    public long getStorageSize() {
        return mStorageSize;
    }

    protected void updateProgressBar() {
        if (mProgressBar == null || mProgressPercent == UNINITIALIZED)
            return;
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.deviceinfo.storage;

import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.os.Bundle;

import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

/**
 * Dialog asks if users want to empty trash files.
 */
public class EmptyTrashFragment extends InstrumentedDialogFragment {
    private static final String TAG_EMPTY_TRASH = "empty_trash";

    /** Shows the empty trash dialog. */
    public static void show(Fragment parent) {
        final EmptyTrashFragment dialog = new EmptyTrashFragment();
        dialog.setTargetFragment(parent, 0 /* requestCode */);
        dialog.show(parent.getFragmentManager(), TAG_EMPTY_TRASH);
    }

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

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        return builder.setTitle(R.string.storage_trash_dialog_title)
                .setMessage(R.string.storage_trash_dialog_ask_message)
                .setPositiveButton(R.string.storage_trash_dialog_confirm, (dialog, which) -> {
                    // TODO(170918505): Implement the logic in worker thread.
                }).setNegativeButton(android.R.string.cancel, null)
                .create();
    }
}
Loading