use of com.moez.QKSMS.ui.view.QKSwitchPreference in project qksms by moezbhatti.
the class BubblePreferenceDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
mResources = mContext.getResources();
View view = mContext.getLayoutInflater().inflate(R.layout.dialog_bubbles, null);
final QKTextView in1 = (QKTextView) view.findViewById(R.id.in_1);
in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes());
in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
final QKTextView in2 = (QKTextView) view.findViewById(R.id.in_2);
in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes());
in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
final QKTextView out1 = (QKTextView) view.findViewById(R.id.out_1);
out1.setBackgroundResource(ThemeManager.getSentBubbleRes());
out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
final QKTextView out2 = (QKTextView) view.findViewById(R.id.out_2);
out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes());
out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
Preference.OnPreferenceClickListener onPreferenceClickListener = new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Log.d(TAG, preference.getKey());
switch(preference.getKey()) {
case SettingsFragment.BUBBLES_NEW:
ThemeManager.setBubbleStyleNew(((QKSwitchPreference) preference).isChecked());
in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes());
in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes());
in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
out1.setBackgroundResource(ThemeManager.getSentBubbleRes());
out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes());
out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
return true;
case SettingsFragment.COLOR_RECEIVED:
ThemeManager.setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked());
in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
return true;
case SettingsFragment.COLOR_SENT:
ThemeManager.setSentBubbleColored(((QKSwitchPreference) preference).isChecked());
out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
return true;
}
return false;
}
};
LinearLayout prefsLayout = (LinearLayout) view.findViewById(R.id.prefs);
prefsLayout.addView(new QKSwitchPreference(mContext, onPreferenceClickListener, SettingsFragment.BUBBLES_NEW, prefs, true, R.string.pref_bubble_style_new, 0).getView());
prefsLayout.addView(new QKSwitchPreference(mContext, onPreferenceClickListener, SettingsFragment.COLOR_RECEIVED, prefs, false, R.string.pref_color_received, 0).getView());
prefsLayout.addView(new QKSwitchPreference(mContext, onPreferenceClickListener, SettingsFragment.COLOR_SENT, prefs, true, R.string.pref_color_sent, 0).getView());
setTitle(R.string.pref_bubbles);
setCustomView(view);
setPositiveButton(R.string.okay, null);
return super.onCreateDialog(savedInstanceState);
}
use of com.moez.QKSMS.ui.view.QKSwitchPreference in project qksms by moezbhatti.
the class ConversationSettingsDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
setTitle(getArguments().getString(ARG_NAME));
mThreadId = getArguments().getLong(ARG_THREAD_ID);
mRes = getActivity().getResources();
mConversationPrefs = new ConversationPrefsHelper(getActivity(), mThreadId);
mLedColors = new int[] { mRes.getColor(R.color.blue_light), mRes.getColor(R.color.purple_light), mRes.getColor(R.color.green_light), mRes.getColor(R.color.yellow_light), mRes.getColor(R.color.red_light), mRes.getColor(R.color.white_pure) };
int padding = Units.dpToPx(getActivity(), 16);
QKTextView premiumWarning = new QKTextView(getActivity());
premiumWarning.setLayoutParams(mLayoutParams);
premiumWarning.setPadding(padding, padding, padding, padding);
LinearLayout list = new LinearLayout(getActivity());
list.setOrientation(LinearLayout.VERTICAL);
list.addView(new QKPreference(getActivity(), this, SettingsFragment.THEME, R.string.pref_theme, R.string.pref_theme_summary_alt).getView());
list.addView(new QKSwitchPreference(getActivity(), this, SettingsFragment.NOTIFICATION_LED, mConversationPrefs.getConversationPrefs(), mConversationPrefs.getNotificationLedEnabled(), R.string.pref_led, 0).getView());
list.addView(new QKPreference(getActivity(), this, SettingsFragment.NOTIFICATION_LED_COLOR, R.string.pref_theme_led, 0).getView());
list.addView(new QKSwitchPreference(getActivity(), this, SettingsFragment.WAKE, mConversationPrefs.getConversationPrefs(), mConversationPrefs.getWakePhoneEnabled(), R.string.pref_wake, R.string.pref_wake_summary).getView());
list.addView(new QKSwitchPreference(getActivity(), this, SettingsFragment.NOTIFICATION_TICKER, mConversationPrefs.getConversationPrefs(), mConversationPrefs.getTickerEnabled(), R.string.pref_ticker, R.string.pref_ticker_summary).getView());
list.addView(new QKSwitchPreference(getActivity(), this, SettingsFragment.NOTIFICATION_VIBRATE, mConversationPrefs.getConversationPrefs(), mConversationPrefs.getVibrateEnabled(), R.string.pref_vibration, R.string.pref_vibration_summary).getView());
list.addView(new QKRingtonePreference(getActivity(), this, SettingsFragment.NOTIFICATION_TONE, R.string.pref_ringtone, R.string.pref_ringtone_summary).getView());
list.addView(new QKSwitchPreference(getActivity(), this, SettingsFragment.NOTIFICATION_CALL_BUTTON, mConversationPrefs.getConversationPrefs(), mConversationPrefs.getCallButtonEnabled(), R.string.pref_notification_call, R.string.pref_notification_call_summary).getView());
setCustomView(list);
return super.onCreateDialog(savedInstanceState);
}
Aggregations