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

Commit 6f6e9563 authored by Fan Zhang's avatar Fan Zhang
Browse files

Remove old suggestion code.

Change-Id: I2ab9b32ea7622228b0d61b3a16f0695ab04597d7
Fixes: 110361022
Test: robotests
parent 11675ada
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.provider.Settings.Global;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.widget.RemoteViews;

import java.util.ArrayList;
import java.util.Collections;
@@ -96,11 +95,7 @@ public class TileUtils {
    /**
     * The key used to get the category from metadata of activities of action
     * {@link #EXTRA_SETTINGS_ACTION}
     * The value must be one of:
     * <li>com.android.settings.category.wireless</li>
     * <li>com.android.settings.category.device</li>
     * <li>com.android.settings.category.personal</li>
     * <li>com.android.settings.category.system</li>
     * The value must be from {@link CategoryKey}.
     */
    private static final String EXTRA_CATEGORY_KEY = "com.android.settings.category";

@@ -171,17 +166,6 @@ public class TileUtils {
    public static final String META_DATA_PREFERENCE_SUMMARY_URI =
            "com.android.settings.summary_uri";

    /**
     * Name of the meta-data item that should be set in the AndroidManifest.xml to specify the
     * custom view which should be displayed for the preference. The custom view will be inflated
     * as a remote view.
     *
     * This also can be used with {@link #META_DATA_PREFERENCE_SUMMARY_URI}, by setting the id
     * of the summary TextView to '@android:id/summary'.
     */
    public static final String META_DATA_PREFERENCE_CUSTOM_VIEW =
            "com.android.settings.custom_view";

    public static final String SETTING_PKG = "com.android.settings";

    /**
@@ -442,11 +426,6 @@ public class TileUtils {
                            keyHint = metaData.getString(META_DATA_PREFERENCE_KEYHINT);
                        }
                    }
                    if (metaData.containsKey(META_DATA_PREFERENCE_CUSTOM_VIEW)) {
                        int layoutId = metaData.getInt(META_DATA_PREFERENCE_CUSTOM_VIEW);
                        tile.remoteViews = new RemoteViews(applicationInfo.packageName, layoutId);
                        updateSummaryAndTitle(context, providerMap, tile);
                    }
                }
            } catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) {
                if (DEBUG) Log.d(LOG_TAG, "Couldn't find info", e);
+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.
 */

package com.android.settingslib.suggestions;

public class SuggestionCategory {
    public String category;
    public String pkg;
    public boolean multiple;
    public boolean exclusive;
    public long exclusiveExpireDaysInMillis;
}
+0 −85
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.settingslib.suggestions;

import android.content.Intent;
import android.util.ArrayMap;
import android.util.ArraySet;

import com.android.settingslib.drawer.Tile;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class SuggestionList {
    // Category -> list of suggestion map
    private final Map<SuggestionCategory, List<Tile>> mSuggestions;

    // A flatten list of all suggestions.
    private List<Tile> mSuggestionList;

    public SuggestionList() {
        mSuggestions = new ArrayMap<>();
    }

    public void addSuggestions(SuggestionCategory category, List<Tile> suggestions) {
        mSuggestions.put(category, suggestions);
    }

    public List<Tile> getSuggestions() {
        if (mSuggestionList != null) {
            return mSuggestionList;
        }
        mSuggestionList = new ArrayList<>();
        for (List<Tile> suggestions : mSuggestions.values()) {
            mSuggestionList.addAll(suggestions);
        }
        dedupeSuggestions(mSuggestionList);
        return mSuggestionList;
    }

    public boolean isExclusiveSuggestionCategory() {
        if (mSuggestions.size() != 1) {
            // If there is no category, or more than 1 category, it's not exclusive by definition.
            return false;
        }
        for (SuggestionCategory category : mSuggestions.keySet()) {
            if (category.exclusive) {
                return true;
            }
        }
        return false;
    }

    /**
     * Filter suggestions list so they are all unique.
     */
    private void dedupeSuggestions(List<Tile> suggestions) {
        final Set<String> intents = new ArraySet<>();
        for (int i = suggestions.size() - 1; i >= 0; i--) {
            final Tile suggestion = suggestions.get(i);
            final String intentUri = suggestion.intent.toUri(Intent.URI_INTENT_SCHEME);
            if (intents.contains(intentUri)) {
                suggestions.remove(i);
            } else {
                intents.add(intentUri);
            }
        }
    }
}
+0 −498

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −31
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.
-->

<optional-steps>
    <step category="com.android.settings.suggested.category.DEFERRED_SETUP"
        exclusive="true" />
    <step category="com.android.settings.suggested.category.LOCK_SCREEN" />
    <step category="com.android.settings.suggested.category.TRUST_AGENT" />
    <step category="com.android.settings.suggested.category.EMAIL" />
    <step category="com.android.settings.suggested.category.PARTNER_ACCOUNT"
        multiple="true" />
    <step category="com.android.settings.suggested.category.GESTURE" />
    <step category="com.android.settings.suggested.category.HOTWORD" />
    <step category="com.android.settings.suggested.category.DEFAULT"
        multiple="true" />
    <step category="com.android.settings.suggested.category.SETTINGS_ONLY"
        multiple="true" />
</optional-steps>
Loading