diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2014-03-22 12:05:11 +0100 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-31 14:35:03 -0700 |
commit | 8ba391bda6a43231f3e04556fca72990c31a3837 (patch) | |
tree | 45daca7c595502036f5a59c0d79d3bbc57bb3e61 /src/com/android/providers | |
parent | a44bb73fa0a03f69f037e77833621ca4fe3d62a3 (diff) | |
download | android_packages_providers_MediaProvider-8ba391bda6a43231f3e04556fca72990c31a3837.tar.gz android_packages_providers_MediaProvider-8ba391bda6a43231f3e04556fca72990c31a3837.tar.bz2 android_packages_providers_MediaProvider-8ba391bda6a43231f3e04556fca72990c31a3837.zip |
mediaprovider: Add theme support to Ringtone activity
Usage:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DIALOG_THEME, R.style.CustomDialogTheme); <<< Add your custom dialog theme here
startActivityForResult(intent, 0);
Style Usage:
Define an style that inherits from an android base theme
<style name="CustomDialogThemeDark" parent="@*android:style/Theme.Holo.Dialog.Alert">
or
<style name="CustomDialogThemeLight" parent="@*android:style/Theme.Holo.Light.Dialog.Alert">
or define your own dialog style
Depends on http://review.cyanogenmod.org/#/c/61392
Change-Id: I409eba2674f68386cdd20b74fc3ea42b8e81d111
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/com/android/providers')
-rw-r--r-- | src/com/android/providers/media/RingtonePickerActivity.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/android/providers/media/RingtonePickerActivity.java b/src/com/android/providers/media/RingtonePickerActivity.java index 872ba41c..c96a647b 100644 --- a/src/com/android/providers/media/RingtonePickerActivity.java +++ b/src/com/android/providers/media/RingtonePickerActivity.java @@ -18,6 +18,9 @@ package com.android.providers.media; import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Resources; +import android.content.res.Resources.Theme; import android.database.Cursor; import android.media.AudioAttributes; import android.media.Ringtone; @@ -135,6 +138,21 @@ public final class RingtonePickerActivity extends AlertActivity implements Intent intent = getIntent(); + // Set custom theme + int themeExtra = intent.getIntExtra(RingtoneManager.EXTRA_RINGTONE_DIALOG_THEME, 0); + if (themeExtra != 0) { + try { + Resources resources = getPackageManager().getResourcesForApplication( + getCallingPackage()); + Theme theme = resources.newTheme(); + theme.applyStyle(themeExtra, true); + getTheme().setTo(theme); + + } catch (NameNotFoundException e) { + // Resource not available. Fall-through default theme + } + } + /* * Get whether to show the 'Default' item, and the URI to play when the * default is clicked |