Search in sources :

Example 1 with QKDialog

use of com.moez.QKSMS.ui.dialog.QKDialog in project qksms by moezbhatti.

the class DialogHelper method showDeleteFailedMessagesDialog.

public static void showDeleteFailedMessagesDialog(final MainActivity context, final Set<Long> threadIds) {
    new DefaultSmsHelper(context, R.string.not_default_delete).showIfNotDefault(null);
    // Make a copy so the list isn't reset when multi-select is disabled
    Set<Long> threads = new HashSet<>(threadIds);
    new QKDialog().setContext(context).setTitle(R.string.delete_all_failed).setMessage(context.getString(R.string.delete_all_failed_confirmation, threads.size())).setPositiveButton(R.string.yes, v -> {
        new Thread(() -> {
            for (long threadId : threads) {
                SmsHelper.deleteFailedMessages(context, threadId);
            }
        }).start();
    }).setNegativeButton(R.string.cancel, null).show();
}
Also used : QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) DefaultSmsHelper(com.moez.QKSMS.ui.dialog.DefaultSmsHelper) HashSet(java.util.HashSet)

Example 2 with QKDialog

use of com.moez.QKSMS.ui.dialog.QKDialog in project qksms by moezbhatti.

the class SettingsFragment method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String key = preference.getKey();
    String valueString = newValue == null ? "null" : newValue.toString();
    if (key.equals(NOTIFICATION_LED_COLOR)) {
        // Format the color as a nice string if it's the LED color.
        valueString = ThemeManager.getColorString(Integer.parseInt(valueString));
    }
    Log.d(TAG, "onPreferenceChange key:" + key + " newValue: " + valueString);
    AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, key, valueString);
    switch(key) {
        case BACKGROUND:
            ThemeManager.setTheme(ThemeManager.Theme.fromString((String) newValue));
            break;
        case STATUS_TINT:
            ThemeManager.setStatusBarTintEnabled(mContext, (Boolean) newValue);
            break;
        case NAVIGATION_TINT:
            ThemeManager.setNavigationBarTintEnabled(mContext, (Boolean) newValue);
            break;
        case FONT_FAMILY:
            preference.setSummary(mFontFamilies[Integer.parseInt("" + newValue)]);
            break;
        case FONT_SIZE:
            preference.setSummary(mFontSizes[Integer.parseInt("" + newValue)]);
            break;
        case FONT_WEIGHT:
            int i = Integer.parseInt("" + newValue);
            preference.setSummary(mFontWeights[i == 2 ? 0 : 1]);
            break;
        case COLOR_SENT:
            ThemeManager.setSentBubbleColored((Boolean) newValue);
            break;
        case COLOR_RECEIVED:
            ThemeManager.setReceivedBubbleColored((Boolean) newValue);
            break;
        case NIGHT_AUTO:
            updateAlarmManager(mContext, (Boolean) newValue);
            break;
        case DAY_START:
        case NIGHT_START:
            updateAlarmManager(mContext, true);
            break;
        case DELETE_OLD_MESSAGES:
            if ((Boolean) newValue) {
                new QKDialog().setContext(mContext).setTitle(R.string.pref_delete_old_messages).setMessage(R.string.dialog_delete_old_messages).setPositiveButton(R.string.yes, v -> {
                    QKPreferences.setBoolean(QKPreference.AUTO_DELETE, true);
                    ((CheckBoxPreference) preference).setChecked(true);
                    DeleteOldMessagesService.setupAutoDeleteAlarm(mContext);
                    mContext.makeToast(R.string.toast_deleting_old_messages);
                }).setNegativeButton(R.string.cancel, null).show();
                return false;
            }
            break;
        case DELETE_UNREAD_MESSAGES:
            preference.setSummary(mContext.getString(R.string.pref_delete_old_messages_unread_summary, newValue));
            break;
        case DELETE_READ_MESSAGES:
            preference.setSummary(mContext.getString(R.string.pref_delete_old_messages_read_summary, newValue));
            break;
        case YAPPY:
            if ((Boolean) newValue) {
                try {
                    EndlessJabberInterface.EnableIntegration(mContext, EndlessJabber.class, true, false);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!EndlessJabberInterface.IsInstalled(mContext)) {
                    EndlessJabberInterface.OpenGooglePlayLink(mContext);
                }
            } else {
                try {
                    EndlessJabberInterface.DisableIntegration(mContext, EndlessJabber.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            break;
        case QUICKCOMPOSE:
            NotificationManager.initQuickCompose(getActivity(), (Boolean) newValue, !(Boolean) newValue);
            break;
        case MMSC_URL:
        case MMS_PROXY:
        case MMS_PORT:
            preference.setSummary(newValue.toString());
            break;
        case MAX_MMS_ATTACHMENT_SIZE:
            // Update the summary in the list preference
            ListPreference listpref = (ListPreference) preference;
            int index = listpref.findIndexOfValue((String) newValue);
            preference.setSummary(mMaxMmsAttachmentSizes[index]);
            // Update the SMS helper static class with the new option
            SmsHelper.setMaxAttachmentSizeSetting(mContext, (String) newValue);
            break;
        case DELAY_DURATION:
            try {
                int duration = Integer.parseInt((String) newValue);
                if (duration < 1 || duration > 30)
                    throw new Exception("Duration out of bounds");
            } catch (Exception e) {
                Toast.makeText(mContext, R.string.delayed_duration_bounds_error, Toast.LENGTH_SHORT).show();
            }
            break;
    }
    return true;
}
Also used : QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) ParseException(java.text.ParseException)

Example 3 with QKDialog

use of com.moez.QKSMS.ui.dialog.QKDialog 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;
}
Also used : DateFormatter(com.moez.QKSMS.common.utils.DateFormatter) Arrays(java.util.Arrays) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) MMSSetupFragment(com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment) QKTextView(com.moez.QKSMS.ui.view.QKTextView) Uri(android.net.Uri) PendingIntent(android.app.PendingIntent) PreferenceScreen(android.preference.PreferenceScreen) EditTextPreference(android.preference.EditTextPreference) ListviewHelper(com.moez.QKSMS.common.ListviewHelper) Handler(android.os.Handler) LiveViewManager(com.moez.QKSMS.common.LiveViewManager) ColorPickerSwatch(com.moez.QKSMS.ui.view.colorpicker.ColorPickerSwatch) View(android.view.View) AdapterView(android.widget.AdapterView) PreferenceManager(android.preference.PreferenceManager) DonationManager(com.moez.QKSMS.common.DonationManager) ParseException(java.text.ParseException) PackageUtils(com.moez.QKSMS.common.utils.PackageUtils) Log(android.util.Log) BlockedNumberDialog(com.moez.QKSMS.ui.dialog.BlockedNumberDialog) Set(java.util.Set) AnalyticsManager(com.moez.QKSMS.common.AnalyticsManager) ListPreference(android.preference.ListPreference) PreferenceFragment(android.preference.PreferenceFragment) EndlessJabber(com.moez.QKSMS.transaction.EndlessJabber) ListView(android.widget.ListView) DeleteOldMessagesService(com.moez.QKSMS.service.DeleteOldMessagesService) QKPreferences(com.moez.QKSMS.common.QKPreferences) BubblePreferenceDialog(com.moez.QKSMS.ui.dialog.BubblePreferenceDialog) Context(android.content.Context) QKPreference(com.moez.QKSMS.enums.QKPreference) PreferenceCategory(android.preference.PreferenceCategory) SimpleDateFormat(java.text.SimpleDateFormat) Intent(android.content.Intent) CheckBoxPreference(android.preference.CheckBoxPreference) PackageInfo(android.content.pm.PackageInfo) QKActivity(com.moez.QKSMS.ui.base.QKActivity) Stack(java.util.Stack) KeyboardUtils(com.moez.QKSMS.common.utils.KeyboardUtils) ArrayList(java.util.ArrayList) R(com.moez.QKSMS.R) HashSet(java.util.HashSet) Calendar(java.util.Calendar) ColorPickerDialog(com.moez.QKSMS.ui.view.colorpicker.ColorPickerDialog) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) DialogHelper(com.moez.QKSMS.common.DialogHelper) Build(android.os.Build) Fragment(android.app.Fragment) ThemeManager(com.moez.QKSMS.ui.ThemeManager) AlarmManager(android.app.AlarmManager) EndlessJabberInterface(com.mariussoft.endlessjabber.sdk.EndlessJabberInterface) NotificationManager(com.moez.QKSMS.transaction.NotificationManager) SharedPreferences(android.content.SharedPreferences) Preference(android.preference.Preference) SmsHelper(com.moez.QKSMS.transaction.SmsHelper) Collections(java.util.Collections) Resources(android.content.res.Resources) NightModeAutoReceiver(com.moez.QKSMS.receiver.NightModeAutoReceiver) CheckBoxPreference(android.preference.CheckBoxPreference) Bundle(android.os.Bundle) Handler(android.os.Handler) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) MMSSetupFragment(com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment) PreferenceFragment(android.preference.PreferenceFragment) Fragment(android.app.Fragment) MMSSetupFragment(com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment) QKTextView(com.moez.QKSMS.ui.view.QKTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) BubblePreferenceDialog(com.moez.QKSMS.ui.dialog.BubblePreferenceDialog) AdapterView(android.widget.AdapterView)

Example 4 with QKDialog

use of com.moez.QKSMS.ui.dialog.QKDialog in project qksms by moezbhatti.

the class MessageListFragment method showMessageResendOptions.

private boolean showMessageResendOptions(final MessageItem msgItem) {
    final Cursor cursor = mAdapter.getCursorForItem(msgItem);
    if (cursor == null) {
        return false;
    }
    KeyboardUtils.hide(mContext, mComposeView);
    new QKDialog().setContext(mContext).setTitle(R.string.failed_message_title).setItems(R.array.resend_menu, (parent, view, position, id) -> {
        switch(position) {
            case // Resend message
            0:
                resendMessageItem(msgItem);
                break;
            case // Edit message
            1:
                editMessageItem(msgItem);
                break;
            case // Delete message
            2:
                confirmDeleteDialog(new DeleteMessageListener(msgItem), false);
                break;
        }
    }).show();
    return true;
}
Also used : Telephony(android.provider.Telephony) MessageListRecyclerView(com.moez.QKSMS.ui.view.MessageListRecyclerView) SensorManager(android.hardware.SensorManager) Bundle(android.os.Bundle) MmsConfig(com.moez.QKSMS.MmsConfig) Conversation(com.moez.QKSMS.data.Conversation) ConversationDetailsDialog(com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog) Ezvcard(ezvcard.Ezvcard) Uri(android.net.Uri) ContactOperations(com.moez.QKSMS.common.vcard.ContactOperations) ComposeView(com.moez.QKSMS.ui.view.ComposeView) WidgetProvider(com.moez.QKSMS.ui.widget.WidgetProvider) SQLiteException(android.database.sqlite.SQLiteException) ContentResolver(android.content.ContentResolver) LiveViewManager(com.moez.QKSMS.common.LiveViewManager) View(android.view.View) SensorEventListener(android.hardware.SensorEventListener) Contact(com.moez.QKSMS.data.Contact) AdapterView(android.widget.AdapterView) QKSMSApp(com.moez.QKSMS.QKSMSApp) Log(android.util.Log) DeliveryReportItem(com.moez.QKSMS.ui.delivery.DeliveryReportItem) LogTag(com.moez.QKSMS.LogTag) AsyncTask(android.os.AsyncTask) ContactList(com.moez.QKSMS.data.ContactList) IntegerRes(android.support.annotation.IntegerRes) ViewGroup(android.view.ViewGroup) AlertDialog(android.app.AlertDialog) List(java.util.List) MessageUtils(com.moez.QKSMS.common.utils.MessageUtils) Loader(android.content.Loader) ContentType(com.google.android.mms.ContentType) SettingsFragment(com.moez.QKSMS.ui.settings.SettingsFragment) QKPreferences(com.moez.QKSMS.common.QKPreferences) Context(android.content.Context) QKPreference(com.moez.QKSMS.enums.QKPreference) RecyclerCursorAdapter(com.moez.QKSMS.ui.base.RecyclerCursorAdapter) Intent(android.content.Intent) Linkify(android.text.util.Linkify) MainActivity(com.moez.QKSMS.ui.MainActivity) MenuItem(android.view.MenuItem) KeyboardUtils(com.moez.QKSMS.common.utils.KeyboardUtils) ActivityLauncher(com.moez.QKSMS.interfaces.ActivityLauncher) ArrayList(java.util.ArrayList) R(com.moez.QKSMS.R) HashSet(java.util.HashSet) R.attr.data(android.R.attr.data) SensorEvent(android.hardware.SensorEvent) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) QKFragment(com.moez.QKSMS.ui.base.QKFragment) QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) Sensor(android.hardware.Sensor) DialogHelper(com.moez.QKSMS.common.DialogHelper) LoaderManager(android.app.LoaderManager) CursorLoader(android.content.CursorLoader) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) VCard(ezvcard.VCard) URLSpan(android.text.style.URLSpan) ThemeManager(com.moez.QKSMS.ui.ThemeManager) SmoothLinearLayoutManager(com.moez.QKSMS.ui.view.SmoothLinearLayoutManager) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) CIELChEvaluator(com.moez.QKSMS.common.CIELChEvaluator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) NotificationManager(com.moez.QKSMS.transaction.NotificationManager) ConversationLegacy(com.moez.QKSMS.data.ConversationLegacy) RecyclerView(android.support.v7.widget.RecyclerView) DeliveryReportHelper(com.moez.QKSMS.ui.delivery.DeliveryReportHelper) SwipeBackLayout(com.moez.QKSMS.ui.SwipeBackLayout) SmsHelper(com.moez.QKSMS.transaction.SmsHelper) AsyncDialog(com.moez.QKSMS.ui.dialog.AsyncDialog) ConversationSettingsDialog(com.moez.QKSMS.ui.dialog.ConversationSettingsDialog) SqliteWrapper(android.database.sqlite.SqliteWrapper) Vibrator(android.os.Vibrator) ConversationPrefsHelper(com.moez.QKSMS.common.ConversationPrefsHelper) ContentUris(android.content.ContentUris) Message(com.moez.QKSMS.data.Message) QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) Cursor(android.database.Cursor)

Example 5 with QKDialog

use of com.moez.QKSMS.ui.dialog.QKDialog in project qksms by moezbhatti.

the class SettingsFragment method showQkResponseEditor.

public void showQkResponseEditor() {
    Set<String> defaultResponses = new HashSet<>(Arrays.asList(mContext.getResources().getStringArray(R.array.qk_responses)));
    Set<String> responseSet = mPrefs.getStringSet(SettingsFragment.QK_RESPONSES, defaultResponses);
    ArrayList<String> responses = new ArrayList<>();
    responses.addAll(responseSet);
    Collections.sort(responses);
    for (int i = responses.size(); i < 12; i++) {
        responses.add("");
    }
    final QKResponseAdapter adapter = new QKResponseAdapter(mContext, R.layout.list_item_qk_response, responses);
    ListView listView = new ListView(mContext);
    listView.setDividerHeight(0);
    listView.setAdapter(adapter);
    new QKDialog().setContext(mContext).setTitle(R.string.title_qk_responses).setCustomView(listView).setPositiveButton(R.string.save, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mPrefs.edit().putStringSet(SettingsFragment.QK_RESPONSES, new HashSet<>(adapter.getResponses())).apply();
        }
    }).setNegativeButton(R.string.cancel, null).show(getFragmentManager(), "qk_response");
}
Also used : ArrayList(java.util.ArrayList) QKTextView(com.moez.QKSMS.ui.view.QKTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) QKDialog(com.moez.QKSMS.ui.dialog.QKDialog) HashSet(java.util.HashSet)

Aggregations

QKDialog (com.moez.QKSMS.ui.dialog.QKDialog)15 View (android.view.View)7 QKTextView (com.moez.QKSMS.ui.view.QKTextView)5 Intent (android.content.Intent)4 Log (android.util.Log)4 R (com.moez.QKSMS.R)4 QKPreference (com.moez.QKSMS.enums.QKPreference)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Context (android.content.Context)3 Uri (android.net.Uri)3 AdapterView (android.widget.AdapterView)3 ImageView (android.widget.ImageView)3 ParseException (java.text.ParseException)3 SharedPreferences (android.content.SharedPreferences)2 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 CheckBoxPreference (android.preference.CheckBoxPreference)2