blob: a1f5ecd9a8b41991b782a8fe1d2ec22514e72916 [file] [log] [blame]
Amith Yamasanid7993472010-08-18 13:59:28 -07001/*
2 * Copyright (C) 2010 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
17package com.android.settings;
18
19import android.app.Dialog;
20import android.app.DialogFragment;
Daisuke Miyakawab5647c52010-09-10 18:04:02 -070021import android.app.Fragment;
Amith Yamasanid7993472010-08-18 13:59:28 -070022import android.content.ContentResolver;
Amith Yamasani350938e2013-04-09 10:22:47 -070023import android.content.Context;
Hung-ying Tyan0ee51e02011-01-25 16:42:14 +080024import android.content.DialogInterface;
Amith Yamasanid7993472010-08-18 13:59:28 -070025import android.content.pm.PackageManager;
Fabrice Di Meglioc853a422014-04-18 19:40:40 -070026import android.database.DataSetObserver;
Fabrice Di Meglio6602d022014-04-15 16:45:20 -070027import android.graphics.drawable.Drawable;
Amith Yamasanid7993472010-08-18 13:59:28 -070028import android.os.Bundle;
Amith Yamasani9627a8e2012-09-23 12:54:14 -070029import android.preference.Preference;
Amith Yamasanid7993472010-08-18 13:59:28 -070030import android.preference.PreferenceFragment;
Fabrice Di Meglioc1457322014-04-04 19:07:50 -070031import android.preference.PreferenceGroupAdapter;
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070032import android.text.TextUtils;
Amith Yamasanid7993472010-08-18 13:59:28 -070033import android.util.Log;
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070034import android.view.Menu;
35import android.view.MenuInflater;
36import android.view.MenuItem;
Fabrice Di Megliof2a52262014-04-17 17:20:27 -070037import android.view.View;
38import android.view.ViewGroup;
Daisuke Miyakawa9c8bde52010-08-25 11:58:37 -070039import android.widget.Button;
Fabrice Di Meglioc1457322014-04-04 19:07:50 -070040import android.widget.ListAdapter;
Fabrice Di Meglio6602d022014-04-15 16:45:20 -070041import android.widget.ListView;
Amith Yamasanid7993472010-08-18 13:59:28 -070042
Daisuke Miyakawaf58090d2010-09-12 17:27:33 -070043/**
Amith Yamasanid7993472010-08-18 13:59:28 -070044 * Base class for Settings fragments, with some helper functions and dialog management.
45 */
Gilles Debunne64650542011-08-23 11:01:35 -070046public class SettingsPreferenceFragment extends PreferenceFragment implements DialogCreatable {
Amith Yamasanid7993472010-08-18 13:59:28 -070047
48 private static final String TAG = "SettingsPreferenceFragment";
49
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070050 private static final int MENU_HELP = Menu.FIRST + 100;
Fabrice Di Meglioc853a422014-04-18 19:40:40 -070051 private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 400;
Fabrice Di Meglio6602d022014-04-15 16:45:20 -070052
53 private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070054
Amith Yamasanid7993472010-08-18 13:59:28 -070055 private SettingsDialogFragment mDialogFragment;
56
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070057 private String mHelpUrl;
58
Amith Yamasani350938e2013-04-09 10:22:47 -070059 // Cache the content resolver for async callbacks
60 private ContentResolver mContentResolver;
61
Fabrice Di Megliof2a52262014-04-17 17:20:27 -070062 private String mPreferenceKey;
Fabrice Di Meglio6602d022014-04-15 16:45:20 -070063 private boolean mPreferenceHighlighted = false;
64
Fabrice Di Meglio829c8fb2014-04-21 11:40:21 -070065 private boolean mIsDataSetObserverRegistered = false;
Fabrice Di Meglioc853a422014-04-18 19:40:40 -070066 private DataSetObserver mDataSetObserver = new DataSetObserver() {
67 @Override
68 public void onChanged() {
69 highlightPreferenceIfNeeded();
70 }
71
72 @Override
73 public void onInvalidated() {
74 highlightPreferenceIfNeeded();
75 }
76 };
77
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070078 @Override
79 public void onCreate(Bundle icicle) {
80 super.onCreate(icicle);
81
Fabrice Di Meglio6602d022014-04-15 16:45:20 -070082 if (icicle != null) {
83 mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
84 }
85
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070086 // Prepare help url and enable menu if necessary
87 int helpResource = getHelpResource();
88 if (helpResource != 0) {
89 mHelpUrl = getResources().getString(helpResource);
Amith Yamasanib0b37ae2012-04-23 15:35:36 -070090 }
91 }
92
Daisuke Miyakawab5647c52010-09-10 18:04:02 -070093 @Override
Fabrice Di Meglio6602d022014-04-15 16:45:20 -070094 public void onSaveInstanceState(Bundle outState) {
95 super.onSaveInstanceState(outState);
96
97 outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mPreferenceHighlighted);
98 }
99
100 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700101 public void onActivityCreated(Bundle savedInstanceState) {
102 super.onActivityCreated(savedInstanceState);
Amith Yamasanib3a593e2012-04-23 18:03:52 -0700103 if (!TextUtils.isEmpty(mHelpUrl)) {
104 setHasOptionsMenu(true);
105 }
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700106
107 final Bundle args = getArguments();
108 if (args != null) {
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700109 mPreferenceKey = args.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
110 highlightPreferenceIfNeeded();
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700111 }
112 }
113
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700114 @Override
115 protected void onBindPreferences() {
Fabrice Di Meglio405febf2014-04-24 10:13:59 -0700116 registerObserverIfNeeded();
117 }
118
119 @Override
120 public void onStop() {
121 super.onStop();
122
123 unregisterObserverIfNeeded();
124 }
125
126 public void registerObserverIfNeeded() {
Fabrice Di Meglio829c8fb2014-04-21 11:40:21 -0700127 if (!mIsDataSetObserverRegistered) {
128 getPreferenceScreen().getRootAdapter().registerDataSetObserver(mDataSetObserver);
129 mIsDataSetObserverRegistered = true;
130 }
Fabrice Di Meglioc853a422014-04-18 19:40:40 -0700131 }
132
Fabrice Di Meglio405febf2014-04-24 10:13:59 -0700133 public void unregisterObserverIfNeeded() {
Fabrice Di Meglio829c8fb2014-04-21 11:40:21 -0700134 if (mIsDataSetObserverRegistered) {
135 getPreferenceScreen().getRootAdapter().unregisterDataSetObserver(mDataSetObserver);
136 mIsDataSetObserverRegistered = false;
137 }
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700138 }
Fabrice Di Meglio6602d022014-04-15 16:45:20 -0700139
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700140 public void highlightPreferenceIfNeeded() {
Fabrice Di Meglioc853a422014-04-18 19:40:40 -0700141 if (isAdded() && !mPreferenceHighlighted &&!TextUtils.isEmpty(mPreferenceKey)) {
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700142 highlightPreference(mPreferenceKey);
Fabrice Di Meglio6602d022014-04-15 16:45:20 -0700143 }
Fabrice Di Meglio6602d022014-04-15 16:45:20 -0700144 }
145
146 private Drawable getHighlightDrawable() {
Fabrice Di Meglio676751e2014-05-21 13:58:46 -0700147 return getActivity().getDrawable(R.drawable.preference_highlight);
Fabrice Di Meglio6602d022014-04-15 16:45:20 -0700148 }
149
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700150 /**
151 * Return a valid ListView position or -1 if none is found
152 */
153 private int canUseListViewForHighLighting(String key) {
154 if (!hasListView()) {
155 return -1;
156 }
157
158 ListView listView = getListView();
159 ListAdapter adapter = listView.getAdapter();
160
161 if (adapter != null && adapter instanceof PreferenceGroupAdapter) {
162 return findListPositionFromKey(adapter, key);
163 }
164
165 return -1;
166 }
167
168 private void highlightPreference(String key) {
169 final Drawable highlight = getHighlightDrawable();
170
171 final int position = canUseListViewForHighLighting(key);
172 if (position >= 0) {
173 final ListView listView = getListView();
174 final ListAdapter adapter = listView.getAdapter();
175
176 ((PreferenceGroupAdapter) adapter).setHighlightedDrawable(highlight);
177 ((PreferenceGroupAdapter) adapter).setHighlighted(position);
178
179 listView.post(new Runnable() {
180 @Override
181 public void run() {
182 listView.setSelection(position);
183 listView.postDelayed(new Runnable() {
184 @Override
185 public void run() {
Alan Viveretteba348ca2014-05-19 15:10:36 -0700186 final View v = listView.getChildAt(0);
187 final int centerX = v.getWidth() / 2;
188 final int centerY = v.getHeight() / 2;
189 highlight.setHotspot(centerX, centerY);
190 v.setPressed(true);
191 v.setPressed(false);
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700192 ((PreferenceGroupAdapter) adapter).setHighlighted(-1);
193 }
194 }, DELAY_HIGHLIGHT_DURATION_MILLIS);
195
196 mPreferenceHighlighted = true;
197 }
198 });
199 } else {
200 // Try locating the Preference View thru its tag
201 View preferenceView = findPreferenceViewForKey(getView(), key);
202 if (preferenceView != null ) {
203 preferenceView.setBackground(highlight);
204 final int centerX = preferenceView.getWidth() / 2;
205 final int centerY = preferenceView.getHeight() / 2;
Alan Viveretteba348ca2014-05-19 15:10:36 -0700206 highlight.setHotspot(centerX, centerY);
207 preferenceView.setPressed(true);
208 preferenceView.setPressed(false);
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700209 }
210 }
211 }
212
213 private int findListPositionFromKey(ListAdapter adapter, String key) {
214 final int count = adapter.getCount();
215 for (int n = 0; n < count; n++) {
216 final Object item = adapter.getItem(n);
217 if (item instanceof Preference) {
218 Preference preference = (Preference) item;
219 final String preferenceKey = preference.getKey();
220 if (preferenceKey != null && preferenceKey.equals(key)) {
221 return n;
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700222 }
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700223 }
224 }
225 return -1;
Amith Yamasanid7993472010-08-18 13:59:28 -0700226 }
227
Fabrice Di Megliof2a52262014-04-17 17:20:27 -0700228 private View findPreferenceViewForKey(View root, String key) {
229 if (checkTag(root, key)) {
230 return root;
231 }
232 if (root instanceof ViewGroup) {
233 final ViewGroup group = (ViewGroup) root;
234 final int count = group.getChildCount();
235 for (int n = 0; n < count; n++) {
236 final View child = group.getChildAt(n);
237 final View view = findPreferenceViewForKey(child, key);
238 if (view != null) {
239 return view;
240 }
241 }
242 }
243 return null;
244 }
245
246 private boolean checkTag(View view, String key) {
247 final Object tag = view.getTag();
248 if (tag == null || !(tag instanceof String)) {
249 return false;
250 }
251 final String prefKey = (String) tag;
252 return (!TextUtils.isEmpty(prefKey) && prefKey.equals(key));
253 }
254
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700255 protected void removePreference(String key) {
256 Preference pref = findPreference(key);
257 if (pref != null) {
258 getPreferenceScreen().removePreference(pref);
259 }
260 }
261
Amith Yamasanib0b37ae2012-04-23 15:35:36 -0700262 /**
263 * Override this if you want to show a help item in the menu, by returning the resource id.
264 * @return the resource id for the help url
265 */
266 protected int getHelpResource() {
267 return 0;
268 }
269
270 @Override
271 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Amith Yamasaniaeb57ed2012-12-06 14:40:51 -0800272 if (mHelpUrl != null && getActivity() != null) {
Amith Yamasanib0b37ae2012-04-23 15:35:36 -0700273 MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label);
Amith Yamasaniaeb57ed2012-12-06 14:40:51 -0800274 HelpUtils.prepareHelpMenuItem(getActivity(), helpItem, mHelpUrl);
Amith Yamasanib0b37ae2012-04-23 15:35:36 -0700275 }
276 }
277
Daisuke Miyakawab5647c52010-09-10 18:04:02 -0700278 /*
279 * The name is intentionally made different from Activity#finish(), so that
280 * users won't misunderstand its meaning.
281 */
282 public final void finishFragment() {
283 getActivity().onBackPressed();
284 }
285
Amith Yamasanid7993472010-08-18 13:59:28 -0700286 // Some helpers for functions used by the settings fragments when they were activities
287
288 /**
289 * Returns the ContentResolver from the owning Activity.
290 */
291 protected ContentResolver getContentResolver() {
Amith Yamasani350938e2013-04-09 10:22:47 -0700292 Context context = getActivity();
293 if (context != null) {
294 mContentResolver = context.getContentResolver();
295 }
296 return mContentResolver;
Amith Yamasanid7993472010-08-18 13:59:28 -0700297 }
298
299 /**
300 * Returns the specified system service from the owning Activity.
301 */
302 protected Object getSystemService(final String name) {
303 return getActivity().getSystemService(name);
304 }
305
306 /**
Amith Yamasanid7993472010-08-18 13:59:28 -0700307 * Returns the PackageManager from the owning Activity.
308 */
309 protected PackageManager getPackageManager() {
310 return getActivity().getPackageManager();
311 }
312
Dianne Hackborn0385cf12011-01-24 16:22:13 -0800313 @Override
314 public void onDetach() {
315 if (isRemoving()) {
316 if (mDialogFragment != null) {
317 mDialogFragment.dismiss();
318 mDialogFragment = null;
319 }
320 }
321 super.onDetach();
322 }
323
Amith Yamasanid7993472010-08-18 13:59:28 -0700324 // Dialog management
325
326 protected void showDialog(int dialogId) {
327 if (mDialogFragment != null) {
328 Log.e(TAG, "Old dialog fragment not null!");
329 }
330 mDialogFragment = new SettingsDialogFragment(this, dialogId);
Fabrice Di Meglio377dd622014-02-12 20:05:57 -0800331 mDialogFragment.show(getChildFragmentManager(), Integer.toString(dialogId));
Amith Yamasanid7993472010-08-18 13:59:28 -0700332 }
333
334 public Dialog onCreateDialog(int dialogId) {
335 return null;
336 }
337
338 protected void removeDialog(int dialogId) {
Hung-ying Tyanadc83d82011-01-24 15:05:27 +0800339 // mDialogFragment may not be visible yet in parent fragment's onResume().
340 // To be able to dismiss dialog at that time, don't check
341 // mDialogFragment.isVisible().
342 if (mDialogFragment != null && mDialogFragment.getDialogId() == dialogId) {
Amith Yamasanid7993472010-08-18 13:59:28 -0700343 mDialogFragment.dismiss();
344 }
345 mDialogFragment = null;
346 }
347
Hung-ying Tyan0ee51e02011-01-25 16:42:14 +0800348 /**
349 * Sets the OnCancelListener of the dialog shown. This method can only be
350 * called after showDialog(int) and before removeDialog(int). The method
351 * does nothing otherwise.
352 */
353 protected void setOnCancelListener(DialogInterface.OnCancelListener listener) {
354 if (mDialogFragment != null) {
355 mDialogFragment.mOnCancelListener = listener;
356 }
357 }
358
359 /**
360 * Sets the OnDismissListener of the dialog shown. This method can only be
361 * called after showDialog(int) and before removeDialog(int). The method
362 * does nothing otherwise.
363 */
364 protected void setOnDismissListener(DialogInterface.OnDismissListener listener) {
365 if (mDialogFragment != null) {
366 mDialogFragment.mOnDismissListener = listener;
367 }
368 }
369
Amith Yamasanic861cf82012-10-02 14:51:46 -0700370 public void onDialogShowing() {
371 // override in subclass to attach a dismiss listener, for instance
372 }
373
Amith Yamasani43c69782010-12-01 09:04:36 -0800374 public static class SettingsDialogFragment extends DialogFragment {
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800375 private static final String KEY_DIALOG_ID = "key_dialog_id";
376 private static final String KEY_PARENT_FRAGMENT_ID = "key_parent_fragment_id";
377
Amith Yamasanid7993472010-08-18 13:59:28 -0700378 private int mDialogId;
379
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800380 private Fragment mParentFragment;
381
Hung-ying Tyan0ee51e02011-01-25 16:42:14 +0800382 private DialogInterface.OnCancelListener mOnCancelListener;
383 private DialogInterface.OnDismissListener mOnDismissListener;
384
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800385 public SettingsDialogFragment() {
386 /* do nothing */
387 }
Amith Yamasanid7993472010-08-18 13:59:28 -0700388
Amith Yamasani43c69782010-12-01 09:04:36 -0800389 public SettingsDialogFragment(DialogCreatable fragment, int dialogId) {
Amith Yamasanid7993472010-08-18 13:59:28 -0700390 mDialogId = dialogId;
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800391 if (!(fragment instanceof Fragment)) {
392 throw new IllegalArgumentException("fragment argument must be an instance of "
393 + Fragment.class.getName());
394 }
395 mParentFragment = (Fragment) fragment;
396 }
397
398 @Override
Dianne Hackborn300768f2011-01-27 20:39:21 -0800399 public void onSaveInstanceState(Bundle outState) {
400 super.onSaveInstanceState(outState);
401 if (mParentFragment != null) {
402 outState.putInt(KEY_DIALOG_ID, mDialogId);
403 outState.putInt(KEY_PARENT_FRAGMENT_ID, mParentFragment.getId());
404 }
405 }
406
407 @Override
Amith Yamasanic861cf82012-10-02 14:51:46 -0700408 public void onStart() {
409 super.onStart();
410
411 if (mParentFragment != null && mParentFragment instanceof SettingsPreferenceFragment) {
412 ((SettingsPreferenceFragment) mParentFragment).onDialogShowing();
413 }
414 }
415
416 @Override
Dianne Hackborn300768f2011-01-27 20:39:21 -0800417 public Dialog onCreateDialog(Bundle savedInstanceState) {
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800418 if (savedInstanceState != null) {
419 mDialogId = savedInstanceState.getInt(KEY_DIALOG_ID, 0);
Fabrice Di Meglio377dd622014-02-12 20:05:57 -0800420 mParentFragment = getParentFragment();
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800421 int mParentFragmentId = savedInstanceState.getInt(KEY_PARENT_FRAGMENT_ID, -1);
Fabrice Di Meglio377dd622014-02-12 20:05:57 -0800422 if (!(mParentFragment instanceof DialogCreatable)) {
423 throw new IllegalArgumentException(
424 (mParentFragment != null
425 ? mParentFragment.getClass().getName()
426 : mParentFragmentId)
427 + " must implement "
428 + DialogCreatable.class.getName());
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800429 }
Amith Yamasani8875ede2011-01-31 12:46:57 -0800430 // This dialog fragment could be created from non-SettingsPreferenceFragment
431 if (mParentFragment instanceof SettingsPreferenceFragment) {
432 // restore mDialogFragment in mParentFragment
433 ((SettingsPreferenceFragment) mParentFragment).mDialogFragment = this;
434 }
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800435 }
Svetoslav Ganov749ba652010-12-09 14:53:02 -0800436 return ((DialogCreatable) mParentFragment).onCreateDialog(mDialogId);
Amith Yamasanid7993472010-08-18 13:59:28 -0700437 }
438
Hung-ying Tyan0ee51e02011-01-25 16:42:14 +0800439 @Override
440 public void onCancel(DialogInterface dialog) {
441 super.onCancel(dialog);
442 if (mOnCancelListener != null) {
443 mOnCancelListener.onCancel(dialog);
444 }
445 }
446
447 @Override
448 public void onDismiss(DialogInterface dialog) {
449 super.onDismiss(dialog);
450 if (mOnDismissListener != null) {
451 mOnDismissListener.onDismiss(dialog);
452 }
453 }
Amith Yamasani8875ede2011-01-31 12:46:57 -0800454
Amith Yamasanid7993472010-08-18 13:59:28 -0700455 public int getDialogId() {
456 return mDialogId;
457 }
Hung-ying Tyan18eb39d2011-01-28 16:17:27 +0800458
459 @Override
460 public void onDetach() {
461 super.onDetach();
462
Amith Yamasani8875ede2011-01-31 12:46:57 -0800463 // This dialog fragment could be created from non-SettingsPreferenceFragment
464 if (mParentFragment instanceof SettingsPreferenceFragment) {
465 // in case the dialog is not explicitly removed by removeDialog()
466 if (((SettingsPreferenceFragment) mParentFragment).mDialogFragment == this) {
467 ((SettingsPreferenceFragment) mParentFragment).mDialogFragment = null;
468 }
Hung-ying Tyan18eb39d2011-01-28 16:17:27 +0800469 }
470 }
Amith Yamasanid7993472010-08-18 13:59:28 -0700471 }
Daisuke Miyakawa9c8bde52010-08-25 11:58:37 -0700472
473 protected boolean hasNextButton() {
Daisuke Miyakawa79c5fd92011-01-15 14:58:00 -0800474 return ((ButtonBarHandler)getActivity()).hasNextButton();
Daisuke Miyakawa9c8bde52010-08-25 11:58:37 -0700475 }
476
477 protected Button getNextButton() {
Daisuke Miyakawa79c5fd92011-01-15 14:58:00 -0800478 return ((ButtonBarHandler)getActivity()).getNextButton();
Daisuke Miyakawa9c8bde52010-08-25 11:58:37 -0700479 }
480
Daisuke Miyakawa6ebf8612010-09-10 09:48:51 -0700481 public void finish() {
482 getActivity().onBackPressed();
483 }
484
Daisuke Miyakawab5647c52010-09-10 18:04:02 -0700485 public boolean startFragment(
486 Fragment caller, String fragmentClass, int requestCode, Bundle extras) {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800487 if (getActivity() instanceof SettingsActivity) {
488 SettingsActivity sa = (SettingsActivity) getActivity();
489 sa.startPreferencePanel(fragmentClass, extras,
Gilles Debunne64650542011-08-23 11:01:35 -0700490 R.string.lock_settings_picker_title, null, caller, requestCode);
Daisuke Miyakawa25af1502010-09-24 11:29:31 -0700491 return true;
Daisuke Miyakawab5647c52010-09-10 18:04:02 -0700492 } else {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800493 Log.w(TAG, "Parent isn't Settings activity, thus there's no way to launch the "
Daisuke Miyakawa25af1502010-09-24 11:29:31 -0700494 + "given Fragment (name: " + fragmentClass + ", requestCode: " + requestCode
495 + ")");
Daisuke Miyakawab5647c52010-09-10 18:04:02 -0700496 return false;
497 }
498 }
499
Amith Yamasanid7993472010-08-18 13:59:28 -0700500}