Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e23b31d8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "base: Add theme support to Ringtone and Profile pickers activities"

parents cc0d661b 3e3d70f1
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class RingtonePreference extends Preference implements
    private int mRingtoneType;
    private boolean mShowDefault;
    private boolean mShowSilent;
    private int mDialogStyle;
    
    private int mRequestCode;
    private int mSubscriptionID = 0; /* Sub-1 by default */
@@ -62,6 +63,8 @@ public class RingtonePreference extends Preference implements
                true);
        mShowSilent = a.getBoolean(com.android.internal.R.styleable.RingtonePreference_showSilent,
                true);
        mDialogStyle = a.getResourceId(
                com.android.internal.R.styleable.RingtonePreference_dialogStyle, 0);
        a.recycle();
    }

@@ -158,6 +161,27 @@ public class RingtonePreference extends Preference implements
        mShowSilent = showSilent;
    }

    /**
     * Returns the resource id style of the ringtone dialog.
     *
     * @return The resource id of the style
     * @hide
     */
    public int getDialogStyle() {
        return mDialogStyle;
    }

    /**
     * Sets the resource id style of the ringtone dialog.
     *
     * @param dialogStyle The resource id of the style.
     * @see RingtoneManager#EXTRA_RINGTONE_DIALOG_THEME
     * @hide
     */
    public void setDialogStyle(int dialogStyle) {
        mDialogStyle = dialogStyle;
    }

    @Override
    protected void onClick() {
        // Launch the ringtone picker
@@ -193,6 +217,10 @@ public class RingtonePreference extends Preference implements
                    RingtoneManager.getDefaultUri(getRingtoneType()));
            }
        }
        if (mDialogStyle != 0) {
            ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DIALOG_THEME,
                    mDialogStyle);
        }

        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, mRingtoneType);
+3 −0
Original line number Diff line number Diff line
@@ -6509,6 +6509,9 @@
        <attr name="showDefault" format="boolean" />
        <!-- Whether to show an item for 'Silent'. -->
        <attr name="showSilent" format="boolean" />
        <!-- The style of the ringtone dialog.
             @hide -->
        <attr name="dialogStyle" format="reference" />
    </declare-styleable>

    <!-- Base attributes available to VolumePreference. -->
+10 −0
Original line number Diff line number Diff line
@@ -184,6 +184,16 @@ public class RingtoneManager {
    public static final String EXTRA_RINGTONE_PICKED_URI =
            "android.intent.extra.ringtone.PICKED_URI";

    /**
     * Set the resource id theme to use for the dialog picker activity.<br/>
     * The default theme is <code>com.android.internal.R.Theme_Holo_Dialog_Alert</code>.
     *
     * @see #ACTION_RINGTONE_PICKER
     * @hide
     */
    public static final String EXTRA_RINGTONE_DIALOG_THEME =
            "android.intent.extra.ringtone.DIALOG_THEME";
    
    // Make sure the column ordering and then ..._COLUMN_INDEX are in sync
    
    private static final String[] INTERNAL_COLUMNS = new String[] {
+18 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ import android.app.ProfileManager;
import android.content.Context;
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.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
@@ -82,6 +85,21 @@ public final class ProfilePickerActivity extends AlertActivity implements

        Intent intent = getIntent();

        // Set custom theme
        int themeExtra = intent.getIntExtra(ProfileManager.EXTRA_PROFILE_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
            }
        }

        if (savedInstanceState != null) {
            mClickedPos = savedInstanceState.getInt(SAVE_CLICKED_POS, -1);
        }