Fix notification setting summary
Bug: 25926406 Change-Id: I503f2d2def095e37f6b16ca345112fe81ef73e29
This commit is contained in:
@@ -2540,7 +2540,7 @@
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.device" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.ManageApplications" />
|
||||
android:value="com.android.settings.applications.NotificationApps" />
|
||||
</activity>
|
||||
|
||||
<!-- Show application-level notification settings (app passed in as extras) -->
|
||||
|
@@ -6971,6 +6971,12 @@
|
||||
<!-- Summary of data usage [CHAR LIMIT=NONE] -->
|
||||
<string name="data_usage_summary_format"><xliff:g id="amount" example="50%">%1$s</xliff:g> of data used</string>
|
||||
|
||||
<!-- Summary of notifications [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps blocked from sending</string>
|
||||
|
||||
<!-- Summary of notifications when no apps are blocked [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_summary_none">All apps allowed to send</string>
|
||||
|
||||
<!-- Summary of apps [CHAR LIMIT=NONE] -->
|
||||
<string name="apps_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps installed</string>
|
||||
<!-- Example summary of apps used in Setup Wizard preview screen [CHAR LIMIT=NONE] -->
|
||||
|
@@ -61,6 +61,7 @@ import com.android.settings.applications.DrawOverlayDetails;
|
||||
import com.android.settings.applications.InstalledAppDetails;
|
||||
import com.android.settings.applications.ManageApplications;
|
||||
import com.android.settings.applications.ManageAssist;
|
||||
import com.android.settings.applications.NotificationApps;
|
||||
import com.android.settings.applications.ProcessStatsSummary;
|
||||
import com.android.settings.applications.ProcessStatsUi;
|
||||
import com.android.settings.applications.UsageAccessDetails;
|
||||
@@ -259,6 +260,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
DisplaySettings.class.getName(),
|
||||
DeviceInfoSettings.class.getName(),
|
||||
ManageApplications.class.getName(),
|
||||
NotificationApps.class.getName(),
|
||||
ManageAssist.class.getName(),
|
||||
ProcessStatsUi.class.getName(),
|
||||
NotificationStation.class.getName(),
|
||||
|
@@ -63,11 +63,11 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
|
||||
|
||||
@Override
|
||||
public boolean filterApp(AppEntry info) {
|
||||
if (info == null) {
|
||||
return false;
|
||||
}
|
||||
if (info.extraInfo instanceof AppRow) {
|
||||
AppRow row = (AppRow) info.extraInfo;
|
||||
return row.banned;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
129
src/com/android/settings/applications/NotificationApps.java
Normal file
129
src/com/android/settings/applications/NotificationApps.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppStateBaseBridge.Callback;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.dashboard.SummaryLoader.SummaryProvider;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.applications.ApplicationsState.Callbacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Extension of ManageApplications with no changes other than having its own
|
||||
* SummaryProvider.
|
||||
*/
|
||||
public class NotificationApps extends ManageApplications {
|
||||
|
||||
private static class SummaryProvider implements SummaryLoader.SummaryProvider,
|
||||
Callbacks, Callback {
|
||||
|
||||
private final Context mContext;
|
||||
private final SummaryLoader mLoader;
|
||||
|
||||
private final ApplicationsState mAppState;
|
||||
private final ApplicationsState.Session mSession;
|
||||
private final NotificationBackend mNotifBackend;
|
||||
private final AppStateNotificationBridge mExtraInfoBridge;
|
||||
|
||||
private SummaryProvider(Context context, SummaryLoader loader) {
|
||||
mContext = context;
|
||||
mLoader = loader;
|
||||
mAppState =
|
||||
ApplicationsState.getInstance((Application) context.getApplicationContext());
|
||||
mSession = mAppState.newSession(this);
|
||||
mNotifBackend = new NotificationBackend();
|
||||
mExtraInfoBridge = new AppStateNotificationBridge(mContext.getPackageManager(),
|
||||
mAppState, this, mNotifBackend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListening(boolean listening) {
|
||||
if (listening) {
|
||||
mSession.resume();
|
||||
mExtraInfoBridge.resume();
|
||||
} else {
|
||||
mSession.pause();
|
||||
mExtraInfoBridge.pause();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSummary(ArrayList<AppEntry> apps) {
|
||||
if (apps == null) return;
|
||||
if (apps.size() == 0) {
|
||||
mLoader.setSummary(this, mContext.getString(R.string.notification_summary_none));
|
||||
} else {
|
||||
mLoader.setSummary(this, mContext.getString(R.string.notification_summary,
|
||||
apps.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRebuildComplete(ArrayList<AppEntry> apps) {
|
||||
updateSummary(apps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExtraInfoUpdated() {
|
||||
updateSummary(mSession.rebuild(
|
||||
AppStateNotificationBridge.FILTER_APP_NOTIFICATION_BLOCKED,
|
||||
ApplicationsState.ALPHA_COMPARATOR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageListChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLauncherInfoChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadEntriesCompleted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRunningStateChanged(boolean running) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageIconChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageSizeChanged(String packageName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllSizesComputed() {
|
||||
}
|
||||
}
|
||||
|
||||
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
|
||||
= new SummaryLoader.SummaryProviderFactory() {
|
||||
@Override
|
||||
public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
|
||||
SummaryLoader summaryLoader) {
|
||||
return new SummaryProvider(activity, summaryLoader);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user