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

Commit 8eca6f5e authored by Sam Mortimer's avatar Sam Mortimer
Browse files

LineageParts LightSettingsDialog: Use an mContext member variable

Introduce an mContext class member variable and rewrite
all getContext() references to use it.

Change-Id: If063673d87c8e3bf0ea617808c05fb3851c27a20
parent c1e85029
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ public class LightSettingsDialog extends AlertDialog implements
    private int mLedLastSpeedOn;
    private int mLedLastSpeedOff;

    private Context mContext;

    /**
     * @param context
     * @param initialColor
@@ -109,8 +111,9 @@ public class LightSettingsDialog extends AlertDialog implements

    private void init(Context context, int color, int speedOn, int speedOff,
            boolean onOffChangeable) {
        mContext = context;
        mNotificationManager =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
                (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

        mReadyForLed = false;
        mLedLastColor = 0;
@@ -130,8 +133,7 @@ public class LightSettingsDialog extends AlertDialog implements
     */
    /*
    private void setUp(int color, int speedOn, int speedOff, boolean onOffChangeable) {
        mInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = mInflater.inflate(R.layout.dialog_light_settings, null);

        mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
@@ -303,14 +305,14 @@ public class LightSettingsDialog extends AlertDialog implements
        final Bundle b = new Bundle();
        b.putBoolean(Notification.EXTRA_FORCE_SHOW_LIGHTS, true);

        final Notification.Builder builder = new Notification.Builder(getContext());
        final Notification.Builder builder = new Notification.Builder(mContext);
        builder.setLights(color, speedOn, speedOff);
        builder.setExtras(b);

        // Set a notification
        builder.setSmallIcon(R.drawable.ic_settings_24dp);
        builder.setContentTitle(getContext().getString(R.string.led_notification_title));
        builder.setContentText(getContext().getString(R.string.led_notification_text));
        builder.setContentTitle(mContext.getString(R.string.led_notification_title));
        builder.setContentText(mContext.getString(R.string.led_notification_text));
        builder.setOngoing(true);

        mNotificationManager.notify(1, builder.build());
@@ -329,8 +331,8 @@ public class LightSettingsDialog extends AlertDialog implements
        public PulseSpeedAdapter(int timeNamesResource, int timeValuesResource) {
            times = new ArrayList<Pair<String, Integer>>();

            String[] time_names = getContext().getResources().getStringArray(timeNamesResource);
            String[] time_values = getContext().getResources().getStringArray(timeValuesResource);
            String[] time_names = mContext.getResources().getStringArray(timeNamesResource);
            String[] time_values = mContext.getResources().getStringArray(timeValuesResource);

            for(int i = 0; i < time_values.length; ++i) {
                times.add(new Pair<String, Integer>(time_names[i], Integer.decode(time_values[i])));
@@ -355,7 +357,7 @@ public class LightSettingsDialog extends AlertDialog implements

            // Check if we also need to add the custom value entry
            if (getTimePosition(customTime) == -1) {
                times.add(new Pair<String, Integer>(getContext().getResources()
                times.add(new Pair<String, Integer>(mContext.getResources()
                        .getString(R.string.custom_time), customTime));
            }
        }
@@ -439,8 +441,8 @@ public class LightSettingsDialog extends AlertDialog implements
    public void onFocusChange(View v, boolean hasFocus) {
        if (!hasFocus) {
            mHexColorInput.removeTextChangedListener(this);
            InputMethodManager inputMethodManager = (InputMethodManager) getContext()
                    .getSystemService(Activity.INPUT_METHOD_SERVICE);
            InputMethodManager inputMethodManager =
                    (InputMethodManager) mContext.getSystemService(Activity.INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
        } else {
            mHexColorInput.addTextChangedListener(this);