Example usage for android.util Log isLoggable

List of usage examples for android.util Log isLoggable

Introduction

In this page you can find the example usage for android.util Log isLoggable.

Prototype

public static native boolean isLoggable(String tag, int level);

Source Link

Document

Checks to see whether or not a log for the specified tag is loggable at the specified level.

Usage

From source file:com.android.mms.ui.ComposeMessageActivity.java

public void initialize(Bundle savedInstanceState, long originalThreadId) {
    // Create a new empty working message.
    mWorkingMessage = WorkingMessage.createEmpty(this);

    // Read parameters or previously saved state of this activity. This will load a new
    // mConversation
    initActivityState(savedInstanceState);

    if (LogTag.SEVERE_WARNING && originalThreadId != 0 && originalThreadId == mConversation.getThreadId()) {
        LogTag.warnPossibleRecipientMismatch(
                "ComposeMessageActivity.initialize: " + " threadId didn't change from: " + originalThreadId,
                this);
    }/*from w ww  .  j a va 2 s .  c om*/

    log("savedInstanceState = " + savedInstanceState + " intent = " + getIntent() + " mConversation = "
            + mConversation);

    if (cancelFailedToDeliverNotification(getIntent(), this)) {
        // Show a pop-up dialog to inform user the message was
        // failed to deliver.
        undeliveredMessageDialog(getMessageDate(null));
    }
    cancelFailedDownloadNotification(getIntent(), this);

    // Set up the message history ListAdapter
    initMessageList();

    mShouldLoadDraft = true;

    // Load the draft for this thread, if we aren't already handling
    // existing data, such as a shared picture or forwarded message.
    boolean isForwardedMessage = false;
    // We don't attempt to handle the Intent.ACTION_SEND when saveInstanceState is non-null.
    // saveInstanceState is non-null when this activity is killed. In that case, we already
    // handled the attachment or the send, so we don't try and parse the intent again.
    if (savedInstanceState == null && (handleSendIntent() || handleForwardedMessage())) {
        mShouldLoadDraft = false;
    }

    // Let the working message know what conversation it belongs to
    mWorkingMessage.setConversation(mConversation);

    // Show the recipients editor if we don't have a valid thread. Hide it otherwise.
    if (mConversation.getThreadId() <= 0) {
        // Hide the recipients editor so the call to initRecipientsEditor won't get
        // short-circuited.
        hideRecipientEditor();
        initRecipientsEditor();
    } else {
        hideRecipientEditor();
    }

    updateSendButtonState();

    drawTopPanel(false);
    if (!mShouldLoadDraft) {
        // We're not loading a draft, so we can draw the bottom panel immediately.
        drawBottomPanel();
    }

    onKeyboardStateChanged();

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("update title, mConversation=" + mConversation.toString());
    }

    updateTitle(mConversation.getRecipients());

    if (isForwardedMessage && isRecipientsEditorVisible()) {
        // The user is forwarding the message to someone. Put the focus on the
        // recipient editor rather than in the message editor.
        mRecipientsEditor.requestFocus();
    }

    mMsgListAdapter.setIsGroupConversation(mConversation.getRecipients().size() > 1);
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    setIntent(intent);/*from   ww  w.  j  a v a 2 s. c  om*/

    Conversation conversation = null;
    mSentMessage = false;

    // If we have been passed a thread_id, use that to find our
    // conversation.

    // Note that originalThreadId might be zero but if this is a draft and we save the
    // draft, ensureThreadId gets called async from WorkingMessage.asyncUpdateDraftSmsMessage
    // the thread will get a threadId behind the UI thread's back.
    long originalThreadId = mConversation.getThreadId();
    long threadId = intent.getLongExtra(THREAD_ID, 0);
    Uri intentUri = intent.getData();

    boolean sameThread = false;
    if (threadId > 0) {
        conversation = Conversation.get(this, threadId, false);
    } else {
        if (mConversation.getThreadId() == 0) {
            // We've got a draft. Make sure the working recipients are synched
            // to the conversation so when we compare conversations later in this function,
            // the compare will work.
            mWorkingMessage.syncWorkingRecipients();
        }
        // Get the "real" conversation based on the intentUri. The intentUri might specify
        // the conversation by a phone number or by a thread id. We'll typically get a threadId
        // based uri when the user pulls down a notification while in ComposeMessageActivity and
        // we end up here in onNewIntent. mConversation can have a threadId of zero when we're
        // working on a draft. When a new message comes in for that same recipient, a
        // conversation will get created behind CMA's back when the message is inserted into
        // the database and the corresponding entry made in the threads table. The code should
        // use the real conversation as soon as it can rather than finding out the threadId
        // when sending with "ensureThreadId".
        conversation = Conversation.get(this, intentUri, false);
    }

    if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("onNewIntent: data=" + intentUri + ", thread_id extra is " + threadId + ", new conversation="
                + conversation + ", mConversation=" + mConversation);
    }

    // this is probably paranoid to compare both thread_ids and recipient lists,
    // but we want to make double sure because this is a last minute fix for Froyo
    // and the previous code checked thread ids only.
    // (we cannot just compare thread ids because there is a case where mConversation
    // has a stale/obsolete thread id (=1) that could collide against the new thread_id(=1),
    // even though the recipient lists are different)
    sameThread = ((conversation.getThreadId() == mConversation.getThreadId()
            || mConversation.getThreadId() == 0) && conversation.equals(mConversation));

    if (sameThread) {
        log("onNewIntent: same conversation");
        if (mConversation.getThreadId() == 0) {
            mConversation = conversation;
            mWorkingMessage.setConversation(mConversation);
            updateThreadIdIfRunning();
            invalidateOptionsMenu();
        }
    } else {
        if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            log("onNewIntent: different conversation");
        }
        saveDraft(false); // if we've got a draft, save it first

        initialize(null, originalThreadId);
    }
    loadMessagesAndDraft(0);
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onStart() {
    super.onStart();
    boolean isSmsEnabled = MmsConfig.isSmsEnabled(this);
    if (isSmsEnabled != mIsSmsEnabled) {
        mIsSmsEnabled = isSmsEnabled;/*  w  ww.j  a  v a 2  s .c o  m*/
        invalidateOptionsMenu();
    }

    initFocus();

    // Register a BroadcastReceiver to listen on HTTP I/O process.
    registerReceiver(mHttpProgressReceiver, mHttpProgressFilter);

    registerReceiver(mDelayedSendProgressReceiver, DELAYED_SEND_COUNTDOWN_FILTER);

    // figure out whether we need to show the keyboard or not.
    // if there is draft to be loaded for 'mConversation', we'll show the keyboard;
    // otherwise we hide the keyboard. In any event, delay loading
    // message history and draft (controlled by DEFER_LOADING_MESSAGES_AND_DRAFT).
    int mode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;

    if (DraftCache.getInstance().hasDraft(mConversation.getThreadId())) {
        mode |= WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE;
    } else if (mConversation.getThreadId() <= 0) {
        // For composing a new message, bring up the softkeyboard so the user can
        // immediately enter recipients. This call won't do anything on devices with
        // a hard keyboard.
        mode |= WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE;
    } else {
        mode |= WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
    }

    getWindow().setSoftInputMode(mode);

    // reset mMessagesAndDraftLoaded
    mMessagesAndDraftLoaded = false;
    long threadId = mWorkingMessage.getConversation().getThreadId();
    // Same recipient for ForwardMms will not load draft
    if (MessageUtils.sSameRecipientList.contains(threadId)) {
        mShouldLoadDraft = false;
    }

    if (!DEFER_LOADING_MESSAGES_AND_DRAFT) {
        loadMessagesAndDraft(1);
    } else {
        // HACK: force load messages+draft after max delay, if it's not already loaded.
        // this is to work around when coming out of sleep mode. WindowManager behaves
        // strangely and hides the keyboard when it should be shown, or sometimes initially
        // shows it when we want to hide it. In that case, we never get the onSizeChanged()
        // callback w/ keyboard shown, so we wouldn't know to load the messages+draft.
        mHandler.postDelayed(new Runnable() {
            public void run() {
                loadMessagesAndDraft(2);
            }
        }, LOADING_MESSAGES_AND_DRAFT_MAX_DELAY_MS);
    }

    // Update the fasttrack info in case any of the recipients' contact info changed
    // while we were paused. This can happen, for example, if a user changes or adds
    // an avatar associated with a contact.
    mWorkingMessage.syncWorkingRecipients();

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("update title, mConversation=" + mConversation.toString());
    }

    updateTitle(mConversation.getRecipients());

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

/**
 * Load message history and draft. This method should be called from main thread.
 * @param debugFlag shows where this is being called from
 *///from  ww  w .  j  av a 2 s .c  o m
private void loadMessagesAndDraft(int debugFlag) {
    if (!mSendDiscreetMode && !mMessagesAndDraftLoaded) {
        if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            Log.v(TAG, "### CMA.loadMessagesAndDraft: flag=" + debugFlag);
        }
        loadMessageContent();
        boolean drawBottomPanel = true;
        if (mShouldLoadDraft) {
            if (loadDraft()) {
                drawBottomPanel = false;
            }
        }
        if (drawBottomPanel) {
            drawBottomPanel();
        }
        mMessagesAndDraftLoaded = true;
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onResume() {
    super.onResume();

    // OLD: get notified of presence updates to update the titlebar.
    // NEW: we are using ContactHeaderWidget which displays presence, but updating presence
    //      there is out of our control.
    //Contact.startPresenceObserver();

    addRecipientsListeners();/*ww w .j  av  a2s  .  c om*/

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("update title, mConversation=" + mConversation.toString());
    }

    // There seems to be a bug in the framework such that setting the title
    // here gets overwritten to the original title.  Do this delayed as a
    // workaround.
    mMessageListItemHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            ContactList recipients = isRecipientsEditorVisible()
                    ? mRecipientsEditor.constructContactsFromInput(false)
                    : getRecipients();
            updateTitle(recipients);
        }
    }, 100);

    // Load the selected input type
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences((Context) ComposeMessageActivity.this);
    mInputMethod = Integer.parseInt(prefs.getString(MessagingPreferenceActivity.INPUT_TYPE,
            Integer.toString(InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)));
    mTextEditor.setInputType(InputType.TYPE_CLASS_TEXT | mInputMethod | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);

    TelephonyManager tm = (TelephonyManager) getSystemService(Service.TELEPHONY_SERVICE);
    if (MessagingPreferenceActivity.getSmartCallEnabled((Context) ComposeMessageActivity.this)
            && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
        mMultiSensorManager.enable();
    }

    mIsRunning = true;
    updateThreadIdIfRunning();
    mConversation.markAsRead(true);
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onPause() {
    super.onPause();

    if (DEBUG) {/*  w ww. j  a v  a 2 s.  co  m*/
        Log.v(TAG, "onPause: setCurrentlyDisplayedThreadId: " + MessagingNotification.THREAD_NONE);
    }
    MessagingNotification.setCurrentlyDisplayedThreadId(MessagingNotification.THREAD_NONE);

    // OLD: stop getting notified of presence updates to update the titlebar.
    // NEW: we are using ContactHeaderWidget which displays presence, but updating presence
    //      there is out of our control.
    //Contact.stopPresenceObserver();

    removeRecipientsListeners();

    if (MessagingPreferenceActivity.getSmartCallEnabled((Context) ComposeMessageActivity.this)) {
        mMultiSensorManager.disable();
    }

    // remove any callback to display a progress spinner
    if (mAsyncDialog != null) {
        mAsyncDialog.clearPendingProgressDialog();
    }

    // Remember whether the list is scrolled to the end when we're paused so we can rescroll
    // to the end when resumed.
    if (mMsgListAdapter != null && mMsgListView.getLastVisiblePosition() >= mMsgListAdapter.getCount() - 1) {
        mSavedScrollPosition = Integer.MAX_VALUE;
    } else {
        mSavedScrollPosition = mMsgListView.getFirstVisiblePosition();
    }
    if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        Log.v(TAG, "onPause: mSavedScrollPosition=" + mSavedScrollPosition);
    }

    mConversation.markAsRead(true);
    mIsRunning = false;
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onStop() {
    super.onStop();

    // No need to do the querying when finished this activity
    mBackgroundQueryHandler.cancelOperation(MESSAGE_LIST_QUERY_TOKEN);

    // Allow any blocked calls to update the thread's read status.
    mConversation.blockMarkAsRead(false);

    if (mMsgListAdapter != null) {
        // Close the cursor in the ListAdapter if the activity stopped.
        Cursor cursor = mMsgListAdapter.getCursor();

        if (cursor != null && !cursor.isClosed()) {
            cursor.close();/*from   w  w  w.j a  v a 2s . co m*/
        }

        mMsgListAdapter.changeCursor(null);
        mMsgListAdapter.cancelBackgroundLoading();
    }

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("save draft");
    }
    saveDraft(true);

    // set 'mShouldLoadDraft' to true, so when coming back to ComposeMessageActivity, we would
    // load the draft, unless we are coming back to the activity after attaching a photo, etc,
    // in which case we should set 'mShouldLoadDraft' to false.
    mShouldLoadDraft = true;

    // Cleanup the BroadcastReceiver.
    unregisterReceiver(mHttpProgressReceiver);
    unregisterReceiver(mDelayedSendProgressReceiver);
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

private void addImage(Uri uri, boolean append) {
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("addImage: append=" + append + ", uri=" + uri);
    }/* www  .j  a va 2  s  . c o m*/

    int result = mWorkingMessage.setAttachment(WorkingMessage.IMAGE, uri, append);

    if (result == WorkingMessage.IMAGE_TOO_LARGE || result == WorkingMessage.MESSAGE_SIZE_EXCEEDED) {
        if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            log("resize image " + uri);
        }
        MessageUtils.resizeImageAsync(ComposeMessageActivity.this, uri, mAttachmentEditorHandler,
                mResizeImageCallback, append);
        return;
    }
    handleAddAttachmentError(result, R.string.type_picture);
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

private boolean handleForwardedMessage() {
    Intent intent = getIntent();/* ww  w .  j  a va2s  .co m*/

    // If this is a forwarded message, it will have an Intent extra
    // indicating so.  If not, bail out.
    if (!mForwardMessageMode) {
        if (mConversation != null) {
            mConversation.setHasMmsForward(false);
        }
        return false;
    }

    if (mConversation != null) {
        mConversation.setHasMmsForward(true);
        String recipientNumber = intent.getStringExtra("msg_recipient");
        mConversation.setForwardRecipientNumber(recipientNumber);
    }
    Uri uri = intent.getParcelableExtra("msg_uri");

    if (Log.isLoggable(LogTag.APP, Log.DEBUG)) {
        log("" + uri);
    }

    if (uri != null) {
        mWorkingMessage = WorkingMessage.load(this, uri);
        mWorkingMessage.setSubject(intent.getStringExtra("subject"), false);
    } else {
        mWorkingMessage.setText(intent.getStringExtra("sms_body"));
    }

    // let's clear the message thread for forwarded messages
    mMsgListAdapter.changeCursor(null);

    return true;
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

/**
 * Initialize all UI elements from resources.
 *///from  w  w w .j  a v a 2 s  .com
private void initResourceRefs() {
    mMsgListView = (MessageListView) findViewById(R.id.history);
    mMsgListView.setDivider(null); // no divider so we look like IM conversation.

    // called to enable us to show some padding between the message list and the
    // input field but when the message list is scrolled that padding area is filled
    // in with message content
    mMsgListView.setClipToPadding(false);

    mMsgListView.setOnSizeChangedListener(new OnSizeChangedListener() {
        public void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                Log.v(TAG, "onSizeChanged: w=" + width + " h=" + height + " oldw=" + oldWidth + " oldh="
                        + oldHeight);
            }

            if (!mMessagesAndDraftLoaded && (oldHeight - height > SMOOTH_SCROLL_THRESHOLD)) {
                // perform the delayed loading now, after keyboard opens
                loadMessagesAndDraft(3);
            }

            // The message list view changed size, most likely because the keyboard
            // appeared or disappeared or the user typed/deleted chars in the message
            // box causing it to change its height when expanding/collapsing to hold more
            // lines of text.
            smoothScrollToEnd(false, height - oldHeight);
        }
    });

    mBottomPanel = findViewById(R.id.bottom_panel);
    mTextEditor = (EditText) findViewById(R.id.embedded_text_editor);
    mTextEditor.setOnEditorActionListener(this);
    mTextEditor.addTextChangedListener(mTextEditorWatcher);
    mTextEditor.setFilters(new InputFilter[] { new LengthFilter(MmsConfig.getMaxTextLimit()) });
    mTextCounter = (TextView) findViewById(R.id.text_counter);
    mSendButtonMms = (TextView) findViewById(R.id.send_button_mms);
    mSendButtonSms = (ImageButton) findViewById(R.id.send_button_sms);
    mSendButtonMms.setOnClickListener(this);
    mSendButtonSms.setOnClickListener(this);
    mTopPanel = findViewById(R.id.recipients_subject_linear);
    mTopPanel.setFocusable(false);
    mAttachmentEditor = (AttachmentEditor) findViewById(R.id.attachment_editor);
    mAttachmentEditor.setHandler(mAttachmentEditorHandler);
    mAttachmentEditorScrollView = findViewById(R.id.attachment_editor_scroll_view);
}