1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.settings.gestures; 18 19 import android.app.AlertDialog; 20 import android.app.Dialog; 21 import android.app.settings.SettingsEnums; 22 import android.content.Context; 23 import android.os.Bundle; 24 25 import com.android.settings.R; 26 import com.android.settings.core.instrumentation.InstrumentedDialogFragment; 27 28 /** 29 * Dialog to notify user that gesture navigation is not available because of unsupported launcher. 30 */ 31 public class GestureNavigationNotAvailableDialog extends InstrumentedDialogFragment { 32 private static final String TAG = "GestureNavigationNotAvailableDialog"; 33 show(SystemNavigationGestureSettings parent)34 public static void show(SystemNavigationGestureSettings parent) { 35 if (!parent.isAdded()) { 36 return; 37 } 38 39 final GestureNavigationNotAvailableDialog dialog = 40 new GestureNavigationNotAvailableDialog(); 41 dialog.setTargetFragment(parent, 0); 42 dialog.show(parent.getFragmentManager(), TAG); 43 } 44 45 @Override getMetricsCategory()46 public int getMetricsCategory() { 47 return SettingsEnums.SETTINGS_GESTURE_NAV_NOT_AVAILABLE_DLG; 48 } 49 50 @Override onCreateDialog(Bundle savedInstanceState)51 public Dialog onCreateDialog(Bundle savedInstanceState) { 52 final Context context = getActivity(); 53 final String defaultHomeAppName = SystemNavigationPreferenceController 54 .getDefaultHomeAppName(context); 55 final String message = getString(R.string.gesture_not_supported_dialog_message, 56 defaultHomeAppName); 57 return new AlertDialog.Builder(context) 58 .setMessage(message) 59 .setPositiveButton(R.string.okay, null) 60 .create(); 61 } 62 }