Add Emergency info and Add user when locked to account dashboard.
Add two items to User & accounts dashboard, and refractor UserCapabilities so that it can be accessed in the new controller. Test: RunSettingsRoboTests Bug: 31801423 Change-Id: Ib446ad6c99d4cc6405a17cf82d2d86e044870b73
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.accounts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EmergencyInfoPreferenceController extends PreferenceController {
|
||||
|
||||
private static final String KEY_EMERGENCY_INFO = "emergency_info";
|
||||
private static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENGY_INFO";
|
||||
private static final String PACKAGE_NAME_EMERGENCY = "com.android.emergency";
|
||||
|
||||
public EmergencyInfoPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
|
||||
if (isAvailable()) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(mContext);
|
||||
final Resources res = mContext.getResources();
|
||||
data.title = res.getString(com.android.settings.R.string.emergency_info_title);
|
||||
data.screenTitle = res.getString(com.android.settings.R.string.emergency_info_title);
|
||||
rawData.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_EMERGENCY_INFO.equals(preference.getKey())) {
|
||||
Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage(PACKAGE_NAME_EMERGENCY);
|
||||
List<ResolveInfo> infos = mContext.getPackageManager().queryIntentActivities(intent, 0);
|
||||
return infos != null && !infos.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_EMERGENCY_INFO;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user