use of com.moez.QKSMS.ui.view.QKTextView in project qksms by moezbhatti.
the class QKDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(mContext);
Window window = dialog.getWindow();
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_material, null);
if (mTitleEnabled || mMessageEnabled) {
mContentPanel = (LinearLayout) view.findViewById(R.id.contentPanel);
mContentPanel.setVisibility(View.VISIBLE);
}
if (mTitleEnabled) {
mTitleView = (QKTextView) view.findViewById(R.id.alertTitle);
mTitleView.setVisibility(View.VISIBLE);
mTitleView.setText(mTitleText);
Log.d(TAG, "title enabled");
}
if (mMessageEnabled) {
mMessageView = (QKTextView) view.findViewById(R.id.message);
mMessageView.setVisibility(View.VISIBLE);
mMessageView.setText(mMessageText);
}
if (mCustomViewEnabled) {
mCustomPanel = (LinearLayout) view.findViewById(R.id.customPanel);
mCustomPanel.setVisibility(View.VISIBLE);
if (mCustomView instanceof ListView || mCustomView instanceof RecyclerView) {
mCustomPanel.addView(mCustomView);
} else {
ScrollView scrollView = new ScrollView(mContext);
scrollView.addView(mCustomView);
mCustomPanel.addView(scrollView);
}
}
if (mPositiveButtonEnabled || mNegativeButtonEnabled) {
mButtonBar = (LinearLayout) view.findViewById(R.id.buttonPanel);
mButtonBar.setVisibility(View.VISIBLE);
mButtonBar.setOrientation(mButtonBarOrientation);
}
if (mPositiveButtonEnabled) {
mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive);
mPositiveButtonView.setVisibility(View.VISIBLE);
mPositiveButtonView.setText(mPositiveButtonText);
mPositiveButtonView.setOnClickListener(mPositiveButtonClickListener);
LiveViewManager.registerView(QKPreference.THEME, mPositiveButtonView, key -> {
mPositiveButtonView.setTextColor(ThemeManager.getColor());
});
}
if (mNeutralButtonEnabled) {
mNeutralButtonView = (QKTextView) view.findViewById(R.id.buttonNeutral);
mNeutralButtonView.setVisibility(View.VISIBLE);
mNeutralButtonView.setText(mNeutralButtonText);
mNeutralButtonView.setOnClickListener(mNeutralButtonClickListener);
}
if (mNegativeButtonEnabled) {
mNegativeButtonView = (QKTextView) view.findViewById(R.id.buttonNegative);
mNegativeButtonView.setVisibility(View.VISIBLE);
mNegativeButtonView.setText(mNegativeButtonText);
mNegativeButtonView.setOnClickListener(mNegativeButtonClickListener);
}
dialog.setContentView(view);
return dialog;
}
use of com.moez.QKSMS.ui.view.QKTextView in project qksms by moezbhatti.
the class MMSDialogFragment method onCreateDialog.
/**
* Builds the dialog using all the View parameters.
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(mContext);
Window window = dialog.getWindow();
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_material, null);
if (mTitleEnabled || mMessageEnabled) {
mContentPanel = (LinearLayout) view.findViewById(R.id.contentPanel);
mContentPanel.setVisibility(View.VISIBLE);
}
if (mTitleEnabled) {
mTitleView = (QKTextView) view.findViewById(R.id.alertTitle);
mTitleView.setVisibility(View.VISIBLE);
mTitleView.setText(mTitleText);
}
if (mMessageEnabled) {
mMessageView = (QKTextView) view.findViewById(R.id.message);
mMessageView.setVisibility(View.VISIBLE);
mMessageView.setText(mMessageText);
}
if (mCustomViewEnabled) {
mCustomPanel = (LinearLayout) view.findViewById(R.id.customPanel);
mCustomPanel.setVisibility(View.VISIBLE);
if (mCustomView instanceof ListView) {
mCustomPanel.addView(mCustomView);
} else {
ScrollView scrollView = new ScrollView(mContext);
scrollView.addView(mCustomView);
mCustomPanel.addView(scrollView);
}
}
if (mPositiveButtonEnabled || mNeutralButtonEnabled || mNegativeButtonEnabled) {
mButtonBar = (LinearLayout) view.findViewById(R.id.buttonPanel);
mButtonBar.setVisibility(View.VISIBLE);
mButtonBar.setOrientation(mButtonBarOrientation);
}
if (mPositiveButtonEnabled) {
mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive);
mPositiveButtonView.setVisibility(View.VISIBLE);
mPositiveButtonView.setText(mPositiveButtonText);
mPositiveButtonView.setTextColor(ThemeManager.getColor());
mPositiveButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onResult(POSITIVE_BUTTON_RESULT);
}
});
}
if (mNeutralButtonEnabled) {
mNeutralButtonView = (QKTextView) view.findViewById(R.id.buttonNeutral);
mNeutralButtonView.setVisibility(View.VISIBLE);
mNeutralButtonView.setText(mNeutralButtonText);
mNeutralButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onResult(NEUTRAL_BUTTON_RESULT);
}
});
}
if (mNegativeButtonEnabled) {
mNegativeButtonView = (QKTextView) view.findViewById(R.id.buttonNegative);
mNegativeButtonView.setVisibility(View.VISIBLE);
mNegativeButtonView.setText(mNegativeButtonText);
mNegativeButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onResult(NEGATIVE_BUTTON_RESULT);
}
});
}
dialog.setContentView(view);
return dialog;
}
use of com.moez.QKSMS.ui.view.QKTextView in project qksms by moezbhatti.
the class SettingsFragment method onPreferenceClick.
@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey() != null ? preference.getKey() : "";
AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_PREFERENCE_CLICK, key, null);
// Categories
int resId = 0;
switch(key) {
case CATEGORY_APPEARANCE:
resId = R.xml.settings_appearance;
break;
case CATEGORY_GENERAL:
resId = R.xml.settings_general;
break;
case CATEGORY_NOTIFICATIONS:
resId = R.xml.settings_notifications;
break;
case CATEGORY_MMS:
resId = R.xml.settings_mms;
break;
case CATEGORY_QUICKREPLY:
resId = R.xml.settings_quickreply;
break;
case CATEGORY_QUICKCOMPOSE:
resId = R.xml.settings_quickcompose;
break;
case CATEGORY_ABOUT:
resId = R.xml.settings_about;
break;
}
if (resId != 0) {
Fragment fragment = SettingsFragment.newInstance(resId);
getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.content_frame, fragment, CATEGORY_TAG).commit();
}
switch(key) {
case THEME:
ThemeManager.showColorPickerDialog(mContext);
break;
case ICON:
ThemeManager.setIcon(mContext);
break;
case BUBBLES:
new BubblePreferenceDialog().setContext(mContext).show();
break;
case BLOCKED_FUTURE:
BlockedNumberDialog.showDialog(mContext);
break;
case SHOULD_I_ANSWER:
final String packageName = "org.mistergroup.muzutozvednout";
if (!PackageUtils.isAppInstalled(mContext, packageName)) {
String referrer = "referrer=utm_source%3Dqksms%26utm_medium%3Dapp%26utm_campaign%3Dqksmssettings";
new QKDialog().setContext(mContext).setTitle(R.string.dialog_should_i_answer_title).setMessage(R.string.dialog_should_i_answer_message).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.okay, v -> {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName + "&" + referrer)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName + "&" + referrer)));
}
}).show();
new Handler().postDelayed(() -> {
mPrefs.edit().putBoolean(SHOULD_I_ANSWER, false).commit();
((CheckBoxPreference) preference).setChecked(false);
}, 500);
}
break;
case NOTIFICATION_LED_COLOR:
mLedColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker");
break;
case DAY_START:
case NIGHT_START:
TimePickerFragment fragment = new TimePickerFragment();
fragment.setPreference(preference);
fragment.setOnPreferenceChangeListener(this);
fragment.show(getFragmentManager(), "timepicker");
break;
case QK_RESPONSES:
showQkResponseEditor();
break;
case AUTOMATICALLY_CONFIGURE_MMS:
// Show the MMS setup dialogs. See the MMSSetupDialog class for info about what the
// arguments mean.
MMSSetupFragment f = new MMSSetupFragment();
Bundle args = new Bundle();
args.putBoolean(MMSSetupFragment.ARG_ASK_FIRST, false);
args.putString(MMSSetupFragment.ARG_DONT_ASK_AGAIN_PREF, null);
f.setArguments(args);
getFragmentManager().beginTransaction().add(f, MMSSetupFragment.TAG).commit();
break;
case MMS_CONTACT_SUPPORT:
// Opens an email compose intent with MMS debugging information
MMSSetupFragment.contactSupport(getActivity());
break;
case CHANGELOG:
DialogHelper.showChangelog(mContext);
break;
case THANKS:
new QKDialog().setContext(mContext).setTitle(R.string.pref_about_thanks_title).setTripleLineItems(R.array.contributor_names, R.array.contributor_githubs, R.array.contributor_projects, new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String baseUrl = ((QKTextView) view.findViewById(R.id.list_item_subtitle)).getText().toString();
startBrowserIntent("https://" + baseUrl);
}
}).show();
break;
case DONATE:
DonationManager.getInstance(mContext).showDonateDialog();
break;
case GOOGLE_PLUS:
startBrowserIntent(GOOGLE_PLUS_URL);
break;
case GITHUB:
startBrowserIntent(GITHUB_URL);
break;
case CROWDIN:
startBrowserIntent(CROWDIN_URL);
break;
}
return false;
}
use of com.moez.QKSMS.ui.view.QKTextView in project qksms by moezbhatti.
the class ThemeManager method setColor.
public static void setColor(QKActivity activity, int color) {
AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, SettingsFragment.CATEGORY_THEME, getColorString(color));
int colorFrom = mActiveColor;
mColor = color;
mActiveColor = color;
mPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply();
setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOR_SENT, true));
setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOR_RECEIVED, false));
mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_primary : R.color.theme_light_text_primary);
mTextOnColorSecondary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new CIELChEvaluator(colorFrom, color), 0);
colorAnimation.setDuration(TRANSITION_LENGTH);
colorAnimation.setInterpolator(new DecelerateInterpolator());
colorAnimation.addUpdateListener(animation -> {
setActiveColor((Integer) animation.getAnimatedValue());
});
colorAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
WidgetProvider.notifyThemeChanged(mContext);
}
});
colorAnimation.start();
if (activity.findViewById(R.id.toolbar_title) != null) {
//final Toolbar toolbar = (Toolbar) mActivity.findViewById(R.id.title);
final QKTextView title = (QKTextView) activity.findViewById(R.id.toolbar_title);
if (title.getCurrentTextColor() != mTextOnColorPrimary) {
ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), mTextOnColorPrimary);
titleColorAnimation.setDuration(TRANSITION_LENGTH);
titleColorAnimation.setInterpolator(new DecelerateInterpolator());
titleColorAnimation.addUpdateListener(animation -> {
int color1 = (Integer) animation.getAnimatedValue();
title.setTextColor(color1);
activity.colorMenuIcons(activity.getMenu(), color1);
});
titleColorAnimation.start();
}
}
}
use of com.moez.QKSMS.ui.view.QKTextView 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);
}
Aggregations