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,24 +104,31 @@ 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()) {
mContext.makeToast(R.string.test); case SettingsFragment.THEME:
} else if (preference.getKey().equals(SettingsFragment.NOTIFICATION_LED_COLOR)) { mContext.makeToast(R.string.test);
mLedColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker"); break;
return true;
} else if (preference.getKey().equals(SettingsFragment.NOTIFICATION_TONE)) { case SettingsFragment.NOTIFICATION_LED_COLOR:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); ColorPickerDialog ledColorPickerDialog = new ColorPickerDialog();
Uri uri = Uri.parse(mConversationPrefs.getString(SettingsFragment.NOTIFICATION_TONE, "content://settings/system/notification_sound")); ledColorPickerDialog.initialize(R.string.pref_theme_led, mLedColors, Integer.parseInt(mConversationPrefs.getNotificationLedColor()), 3, 2);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri); ledColorPickerDialog.setOnColorSelectedListener(color -> mConversationPrefs.putString(SettingsFragment.NOTIFICATION_LED_COLOR, "" + color));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); ledColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); break;
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); case SettingsFragment.NOTIFICATION_TONE:
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.pref_ringtone)); Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(ARG_THREAD_ID, mThreadId); Uri uri = Uri.parse(mConversationPrefs.getString(SettingsFragment.NOTIFICATION_TONE, "content://settings/system/notification_sound"));
((MainActivity) getActivity()).getResultForThreadId(mThreadId); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
getActivity().startActivityForResult(intent, RINGTONE_REQUEST_CODE); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
return 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; return true;