Clean up notification dialog class

This commit is contained in:
Moez Bhatti
2015-12-25 15:12:52 -05:00
parent a4338b0d32
commit 2ff75f347e
@@ -20,7 +20,6 @@ import com.moez.QKSMS.ui.view.QKRingtonePreference;
import com.moez.QKSMS.ui.view.QKSwitchPreference; import com.moez.QKSMS.ui.view.QKSwitchPreference;
import com.moez.QKSMS.ui.view.QKTextView; import com.moez.QKSMS.ui.view.QKTextView;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerDialog; import com.moez.QKSMS.ui.view.colorpicker.ColorPickerDialog;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerSwatch;
public class ConversationNotificationSettingsDialog extends QKDialog implements Preference.OnPreferenceClickListener { public class ConversationNotificationSettingsDialog extends QKDialog implements Preference.OnPreferenceClickListener {
private final String TAG = "ConversationNotificationSettingsDialog"; private final String TAG = "ConversationNotificationSettingsDialog";
@@ -33,7 +32,6 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
private ConversationPrefsHelper mConversationPrefs; private ConversationPrefsHelper mConversationPrefs;
private int[] mLedColors; private int[] mLedColors;
private ColorPickerDialog mLedColorPickerDialog;
private long mThreadId; private long mThreadId;
private ViewGroup.LayoutParams mLayoutParams = new LinearLayout.LayoutParams( private ViewGroup.LayoutParams mLayoutParams = new LinearLayout.LayoutParams(
@@ -67,17 +65,6 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
mRes.getColor(R.color.red_light), mRes.getColor(R.color.white_pure) mRes.getColor(R.color.red_light), mRes.getColor(R.color.white_pure)
}; };
mLedColorPickerDialog = new ColorPickerDialog();
mLedColorPickerDialog.initialize(R.string.pref_theme_led, mLedColors, Integer.parseInt(
mConversationPrefs.getNotificationLedColor()), 3, 2);
mLedColorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override
public void onColorSelected(int color) {
mConversationPrefs.putString(SettingsFragment.NOTIFICATION_LED_COLOR, "" + color);
}
});
int padding = Units.dpToPx(getActivity(), 16); int padding = Units.dpToPx(getActivity(), 16);
QKTextView premiumWarning = new QKTextView(getActivity()); QKTextView premiumWarning = new QKTextView(getActivity());
premiumWarning.setLayoutParams(mLayoutParams); premiumWarning.setLayoutParams(mLayoutParams);
@@ -117,12 +104,19 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
} }
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals(SettingsFragment.THEME)) { switch (preference.getKey()) {
case SettingsFragment.THEME:
mContext.makeToast(R.string.test); mContext.makeToast(R.string.test);
} else if (preference.getKey().equals(SettingsFragment.NOTIFICATION_LED_COLOR)) { break;
mLedColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker");
return true; case SettingsFragment.NOTIFICATION_LED_COLOR:
} else if (preference.getKey().equals(SettingsFragment.NOTIFICATION_TONE)) { ColorPickerDialog ledColorPickerDialog = new ColorPickerDialog();
ledColorPickerDialog.initialize(R.string.pref_theme_led, mLedColors, Integer.parseInt(mConversationPrefs.getNotificationLedColor()), 3, 2);
ledColorPickerDialog.setOnColorSelectedListener(color -> mConversationPrefs.putString(SettingsFragment.NOTIFICATION_LED_COLOR, "" + color));
ledColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker");
break;
case SettingsFragment.NOTIFICATION_TONE:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
Uri uri = Uri.parse(mConversationPrefs.getString(SettingsFragment.NOTIFICATION_TONE, "content://settings/system/notification_sound")); Uri uri = Uri.parse(mConversationPrefs.getString(SettingsFragment.NOTIFICATION_TONE, "content://settings/system/notification_sound"));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
@@ -134,7 +128,7 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
intent.putExtra(ARG_THREAD_ID, mThreadId); intent.putExtra(ARG_THREAD_ID, mThreadId);
((MainActivity) getActivity()).getResultForThreadId(mThreadId); ((MainActivity) getActivity()).getResultForThreadId(mThreadId);
getActivity().startActivityForResult(intent, RINGTONE_REQUEST_CODE); getActivity().startActivityForResult(intent, RINGTONE_REQUEST_CODE);
return true; break;
} }
return true; return true;