diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-24 14:48:48 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-25 17:24:18 -0700 |
commit | 769630c8956fa844545d964166da90cc802fabac (patch) | |
tree | ecb9c4f835c026f373f76ca85bf13868399cbf2b /src/com/android/settings/Utils.java | |
parent | 1102f76e5852d4cc482264e67c52cabf85d7a51d (diff) | |
download | packages_apps_Settings-769630c8956fa844545d964166da90cc802fabac.tar.gz packages_apps_Settings-769630c8956fa844545d964166da90cc802fabac.tar.bz2 packages_apps_Settings-769630c8956fa844545d964166da90cc802fabac.zip |
Settings new dashboard - part 2
Introduce the new Dashboard (a grid like presentation of
Settings top categories) per UX specification.
- the Dashboard is composed of "categories" and in each of them
you have "tiles"
- implement a new layout for showing top categories
(DashboardContainerView). This layout basically acts like a
grid
- depending on the device configuration make the grid with 1
column in portrait / 2 colums in landscape (phones) OR 2 columns
in portrait and 3 in landscape (tablets)
- take care of Accounts adding and removing (as it changes the
number of tiles to show)
Also remove all the old code related to Headers
Change-Id: Ie29944132c1b4c3f7b073d5a7d4453b8f5ec19a7
Diffstat (limited to 'src/com/android/settings/Utils.java')
-rw-r--r-- | src/com/android/settings/Utils.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index d743b6f0a..8abe30db0 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -19,6 +19,7 @@ package com.android.settings; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; +import android.app.Fragment; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; @@ -655,4 +656,51 @@ public class Utils { return ((UserManager) context.getSystemService(Context.USER_SERVICE)) .getUsers().size() > 1; } + + /** + * Start a new instance of the activity, showing only the given fragment. + * When launched in this mode, the given preference fragment will be instantiated and fill the + * entire activity. + * + * @param context The context. + * @param fragmentName The name of the fragment to display. + * @param args Optional arguments to supply to the fragment. + * @param resultTo Option fragment that should receive the result of + * the activity launch. + * @param resultRequestCode If resultTo is non-null, this is the request + * code in which to report the result. + * @param title String to display for the title of this set of preferences. + */ + public static void startWithFragment(Context context, String fragmentName, Bundle args, + Fragment resultTo, int resultRequestCode, CharSequence title) { + Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, title); + if (resultTo == null) { + context.startActivity(intent); + } else { + resultTo.startActivityForResult(intent, resultRequestCode); + } + } + + /** + * Build an Intent to launch a new activity showing the selected fragment. + * The implementation constructs an Intent that re-launches the current activity with the + * appropriate arguments to display the fragment. + * + * @param context The Context. + * @param fragmentName The name of the fragment to display. + * @param args Optional arguments to supply to the fragment. + * @param title Optional title to show for this item. + * @return Returns an Intent that can be launched to display the given + * fragment. + */ + public static Intent onBuildStartFragmentIntent(Context context, String fragmentName, + Bundle args, CharSequence title) { + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.setClass(context, SubSettings.class); + intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, fragmentName); + intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); + intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title); + intent.putExtra(SettingsActivity.EXTRA_NO_HEADERS, true); + return intent; + } } |