Search in sources :

Example 6 with ConversationPrefsHelper

use of com.moez.QKSMS.common.ConversationPrefsHelper in project qksms by moezbhatti.

the class QKReplyActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    sThreadId = extras.getLong(EXTRA_THREAD_ID);
    mConversation = Conversation.get(this, sThreadId, false);
    mConversationLegacy = new ConversationLegacy(this, sThreadId);
    mConversationPrefsHelper = new ConversationPrefsHelper(this, sThreadId);
    // Set up the compose view.
    mComposeView = (ComposeView) findViewById(R.id.compose_view);
    mComposeView.setActivityLauncher(this);
    mComposeView.setOnSendListener(this);
    mComposeView.setLabel("QKReply");
    mAdapter = new QKReplyAdapter(this);
    mListView = (ListView) findViewById(R.id.popup_messages);
    mListView.setAdapter(mAdapter);
    // Set the conversation data objects. These are used to save drafts, send sms messages, etc.
    mComposeView.onOpenConversation(mConversation, mConversationLegacy);
    // requesting the focus on the reply text.
    if (extras.getBoolean(EXTRA_SHOW_KEYBOARD, false)) {
        mComposeView.requestReplyTextFocus();
    }
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            mConversationLegacy.getName(true);
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            setTitle(mConversationLegacy.getName(true));
            initLoaderManager();
        }
    }.execute((Void[]) null);
}
Also used : ConversationLegacy(com.moez.QKSMS.data.ConversationLegacy) Bundle(android.os.Bundle) ConversationPrefsHelper(com.moez.QKSMS.common.ConversationPrefsHelper)

Example 7 with ConversationPrefsHelper

use of com.moez.QKSMS.common.ConversationPrefsHelper in project qksms by moezbhatti.

the class ConversationListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ConversationListViewHolder holder, int position) {
    final Conversation conversation = getItem(position);
    holder.mData = conversation;
    holder.mContext = mContext;
    holder.mClickListener = mItemClickListener;
    holder.root.setOnClickListener(holder);
    holder.root.setOnLongClickListener(holder);
    holder.mutedView.setVisibility(new ConversationPrefsHelper(mContext, conversation.getThreadId()).getNotificationsEnabled() ? View.GONE : View.VISIBLE);
    holder.errorIndicator.setVisibility(conversation.hasError() ? View.VISIBLE : View.GONE);
    final boolean hasUnreadMessages = conversation.hasUnreadMessages();
    if (hasUnreadMessages) {
        holder.unreadView.setVisibility(View.VISIBLE);
        holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundPrimary());
        holder.dateView.setTextColor(ThemeManager.getColor());
        holder.fromView.setType(FontManager.TEXT_TYPE_PRIMARY_BOLD);
        holder.snippetView.setMaxLines(5);
    } else {
        holder.unreadView.setVisibility(View.GONE);
        holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundSecondary());
        holder.dateView.setTextColor(ThemeManager.getTextOnBackgroundSecondary());
        holder.fromView.setType(FontManager.TEXT_TYPE_PRIMARY);
        holder.snippetView.setMaxLines(1);
    }
    LiveViewManager.registerView(QKPreference.THEME, this, key -> {
        holder.dateView.setTextColor(hasUnreadMessages ? ThemeManager.getColor() : ThemeManager.getTextOnBackgroundSecondary());
    });
    if (isInMultiSelectMode()) {
        holder.mSelected.setVisibility(View.VISIBLE);
        if (isSelected(conversation.getThreadId())) {
            holder.mSelected.setImageResource(R.drawable.ic_selected);
            holder.mSelected.setColorFilter(ThemeManager.getColor());
            holder.mSelected.setAlpha(1f);
        } else {
            holder.mSelected.setImageResource(R.drawable.ic_unselected);
            holder.mSelected.setColorFilter(ThemeManager.getTextOnBackgroundSecondary());
            holder.mSelected.setAlpha(0.5f);
        }
    } else {
        holder.mSelected.setVisibility(View.GONE);
    }
    LiveViewManager.registerView(QKPreference.HIDE_AVATAR_CONVERSATIONS, this, key -> {
        holder.mAvatarView.setVisibility(QKPreferences.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE);
    });
    // Date
    holder.dateView.setText(DateFormatter.getConversationTimestamp(mContext, conversation.getDate()));
    // Subject
    String emojiSnippet = conversation.getSnippet();
    if (mPrefs.getBoolean(SettingsFragment.AUTO_EMOJI, false)) {
        emojiSnippet = EmojiRegistry.parseEmojis(emojiSnippet);
    }
    holder.snippetView.setText(emojiSnippet);
    Contact.addListener(holder);
    // Update the avatar and name
    holder.onUpdate(conversation.getRecipients().size() == 1 ? conversation.getRecipients().get(0) : null);
}
Also used : Conversation(com.moez.QKSMS.data.Conversation) ConversationPrefsHelper(com.moez.QKSMS.common.ConversationPrefsHelper)

Example 8 with ConversationPrefsHelper

use of com.moez.QKSMS.common.ConversationPrefsHelper 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);
}
Also used : QKPreference(com.moez.QKSMS.ui.view.QKPreference) QKTextView(com.moez.QKSMS.ui.view.QKTextView) LinearLayout(android.widget.LinearLayout) ConversationPrefsHelper(com.moez.QKSMS.common.ConversationPrefsHelper) QKSwitchPreference(com.moez.QKSMS.ui.view.QKSwitchPreference) QKRingtonePreference(com.moez.QKSMS.ui.view.QKRingtonePreference)

Aggregations

ConversationPrefsHelper (com.moez.QKSMS.common.ConversationPrefsHelper)8 Intent (android.content.Intent)2 Uri (android.net.Uri)2 Bundle (android.os.Bundle)2 Message (com.moez.QKSMS.data.Message)2 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 PowerManager (android.os.PowerManager)1 SmsMessage (android.telephony.SmsMessage)1 LinearLayout (android.widget.LinearLayout)1 CIELChEvaluator (com.moez.QKSMS.common.CIELChEvaluator)1 Conversation (com.moez.QKSMS.data.Conversation)1 ConversationLegacy (com.moez.QKSMS.data.ConversationLegacy)1 NotificationService (com.moez.QKSMS.service.NotificationService)1 DefaultSmsHelper (com.moez.QKSMS.ui.dialog.DefaultSmsHelper)1 ConversationDetailsDialog (com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog)1 QKReplyActivity (com.moez.QKSMS.ui.popup.QKReplyActivity)1 QKPreference (com.moez.QKSMS.ui.view.QKPreference)1 QKRingtonePreference (com.moez.QKSMS.ui.view.QKRingtonePreference)1 QKSwitchPreference (com.moez.QKSMS.ui.view.QKSwitchPreference)1