Files
app_Settings/src/com/android/settings/notification/ZenOnboardingActivity.java
Julia Reynolds 29ba3601b0 Update zen onboarding ui
Test: robotests
Bug: 78448988
Change-Id: I1e70bf8d28f392b93bb102622340da0af65f4718
2018-05-01 15:11:03 +00:00

81 lines
2.5 KiB
Java

/*
* Copyright (C) 2018 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.notification;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.view.View;
import android.widget.CheckBox;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
public class ZenOnboardingActivity extends Activity {
private NotificationManager mNm;
private MetricsLogger mMetrics;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setNotificationManager(getSystemService(NotificationManager.class));
setMetricsLogger(new MetricsLogger());
setupUI();
}
@VisibleForTesting
protected void setupUI() {
setContentView(R.layout.zen_onboarding);
mMetrics.visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING);
}
@VisibleForTesting
protected void setNotificationManager(NotificationManager nm) {
mNm = nm;
}
@VisibleForTesting
protected void setMetricsLogger(MetricsLogger ml) {
mMetrics = ml;
}
public void close(View button) {
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
finishAndRemoveTask();
}
public void save(View button) {
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
NotificationManager.Policy policy = mNm.getNotificationPolicy();
NotificationManager.Policy newPolicy = new NotificationManager.Policy(
policy.priorityCategories, NotificationManager.Policy.PRIORITY_SENDERS_STARRED,
policy.priorityMessageSenders,
NotificationManager.Policy.getAllSuppressedVisualEffects());
mNm.setNotificationPolicy(newPolicy);
finishAndRemoveTask();
}
}