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.QKTextView;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerDialog;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerSwatch;
public class ConversationNotificationSettingsDialog extends QKDialog implements Preference.OnPreferenceClickListener {
private final String TAG = "ConversationNotificationSettingsDialog";
@@ -33,7 +32,6 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
private ConversationPrefsHelper mConversationPrefs;
private int[] mLedColors;
private ColorPickerDialog mLedColorPickerDialog;
private long mThreadId;
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)
};
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);
QKTextView premiumWarning = new QKTextView(getActivity());
premiumWarning.setLayoutParams(mLayoutParams);
@@ -117,24 +104,31 @@ public class ConversationNotificationSettingsDialog extends QKDialog implements
}
public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals(SettingsFragment.THEME)) {
mContext.makeToast(R.string.test);
} else if (preference.getKey().equals(SettingsFragment.NOTIFICATION_LED_COLOR)) {
mLedColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker");
return true;
} else if (preference.getKey().equals(SettingsFragment.NOTIFICATION_TONE)) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
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_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.pref_ringtone));
intent.putExtra(ARG_THREAD_ID, mThreadId);
((MainActivity) getActivity()).getResultForThreadId(mThreadId);
getActivity().startActivityForResult(intent, RINGTONE_REQUEST_CODE);
return true;
switch (preference.getKey()) {
case SettingsFragment.THEME:
mContext.makeToast(R.string.test);
break;
case SettingsFragment.NOTIFICATION_LED_COLOR:
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);
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_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.pref_ringtone));
intent.putExtra(ARG_THREAD_ID, mThreadId);
((MainActivity) getActivity()).getResultForThreadId(mThreadId);
getActivity().startActivityForResult(intent, RINGTONE_REQUEST_CODE);
break;
}
return true;