List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
@Override public void onNewIntent(Intent intent) { setIntent(intent); // onNewIntent doesn't autoset our "internal" intent removeFragments();// ww w .j a v a2 s .c om mUnreadMessageCount = 0; String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT); mAccount = Preferences.getPreferences(this).getAccount(accountUuid); // if (mAccount == null) { // // This shouldn't normally happen. But apparently it does. See issue // 2261. // finish(); // return; // } if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) && !K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) { onOpenFolder(mAccount.getAutoExpandFolderName()); finish(); } else { initializeActivityView(); } if (mFirstBackStackId >= 0) { getFragmentManager().popBackStackImmediate(mFirstBackStackId, FragmentManager.POP_BACK_STACK_INCLUSIVE); mFirstBackStackId = -1; } removeMessageListFragment(); removeMessageViewFragment(); mMessageReference = null; mSearch = null; mFolderName = null; if (!decodeExtras(intent)) { return; } initializeDisplayMode(null); initializeFragments(); displayViews(); refresh(); }
From source file:com.tct.mail.compose.ComposeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //TS: zheng.zou 2015-12-03 EMAIL BUGFIX_1030520 ADD_S if (mHasNoPermission) { return;/*w w w . j a v a 2 s. c o m*/ } //TS: zheng.zou 2015-12-03 EMAIL BUGFIX_1030520 ADD_E //AM: peng-zhang 2015-02-27 EMAIL BUGFIX_955421 MOD_S if (savedInstanceState != null) { bcc_text = savedInstanceState.getString("BCC_SAVE"); Changed = savedInstanceState.getBoolean("BCC_CHANGED"); // TS: junwei-xu 2015-06-30 EMAIL BUGFIX-1030195 ADD_S mPriorityFlag = savedInstanceState.getInt(KEY_PRIORITY_SAVED_STATE); // TS: junwei-xu 2015-06-30 EMAIL BUGFIX-1030195 ADD_E // TS: junwei-xu 2015-07-17 EMAIL BUGFIX-1029180 ADD_S mTextChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_TEXT_CHANGED); mAttachmentsChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_ATTACHMENT_CHANGED); mReplyFromChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_REPLY_FROM_CHANGED); mProrityChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_PRIORITY_CHANGED); // TS: junwei-xu 2015-07-17 EMAIL BUGFIX-1029180 ADD_E //TS: yanhua.chen 2015-7-29 EMAIL BUGFIX_1053132 ADD_S attLargeWarning = savedInstanceState.getBoolean(KEY_SAVED_STATE_ATTLARGEWARNING_CHANGED); //TS: yanhua.chen 2015-7-29 EMAIL BUGFIX_1053132 ADD_E //TS: yanhua.chen 2015-9-1 EMAIL CD_551912 ADD_S //mIsClickIcon = savedInstanceState.getBoolean(KEY_SAVED_STATE_ISCLICKICON_CHANGED);//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535 mChangeAccount = savedInstanceState.getBoolean(KEY_SAVED_STATE_CHANGEACCOUNT_CHANGED); mEditDraft = savedInstanceState.getBoolean(KEY_SAVED_STATE_EDITDRAFT_CHANGED); //TS: yanhua.chen 2015-9-1 EMAIL CD_551912 ADD_E } //AM: peng-zhang 2015-02-27 EMAIL BUGFIX_955421 MOD_E setContentView(R.layout.compose); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Hide the app icon. actionBar.setIcon(null); actionBar.setDisplayUseLogoEnabled(false); } mInnerSavedState = (savedInstanceState != null) ? savedInstanceState.getBundle(KEY_INNER_SAVED_STATE) : null; //[FEATURE]-Add-BEGIN by TSNJ,Zhenhua.Fan,06/11/2014,FR-622609 if (EmailApplication.isOrangeImapFeatureOn()) { Intent i = getIntent(); if (i != null && i.getBooleanExtra(EXTRA_FROM_DRAFT_VIEW, false)) { isFromView = true; } } //[FEATURE]-Add-END by TSNJ,Zhenhua.Fan checkValidAccounts(); // TS: jian.xu 2015-06-05 EMAIL BUGFIX-1006499 ADD_S LinearLayout tmp = (LinearLayout) findViewById(R.id.content); tmp.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Rect r = new Rect(); //get the cutrent visibale disrict. ComposeActivity.this.getWindow().getDecorView().getWindowVisibleDisplayFrame(r); //get the screen height int screenHeight = ComposeActivity.this.getWindow().getDecorView().getRootView().getHeight(); Rect textRect = new Rect(); int keyboardHeight = screenHeight - r.bottom; // the number 100 means that the keyboard is showing. if (keyboardHeight > 100) { android.os.Message msg = mHandler.obtainMessage(SET_LISTPOPUPWINDOW_HEIGHT); mHandler.sendMessage(msg); } } }); // TS: jian.xu 2015-06-05 EMAIL BUGFIX-1006499 ADD_E }
From source file:de.lespace.apprtc.activity.ConnectActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_connect); // Get setting keys. PreferenceManager.setDefaultValues(this, R.xml.preferences, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); keyprefFrom = getString(R.string.pref_from_key); keyprefVideoCallEnabled = getString(R.string.pref_videocall_key); keyprefResolution = getString(R.string.pref_resolution_key); keyprefFps = getString(R.string.pref_fps_key); keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key); keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key); keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key); keyprefVideoCodec = getString(R.string.pref_videocodec_key); keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key); keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key); keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key); keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key); keyprefAudioCodec = getString(R.string.pref_audiocodec_key); keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key); keyprefAecDump = getString(R.string.pref_aecdump_key); keyprefOpenSLES = getString(R.string.pref_opensles_key); keyprefDisplayHud = getString(R.string.pref_displayhud_key); keyprefTracing = getString(R.string.pref_tracing_key); keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key); keyprefRoomList = getString(R.string.pref_room_list_key); // Video call enabled flag. boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled, Boolean.valueOf(getString(R.string.pref_videocall_default))); String wssUrl = sharedPref.getString(keyprefRoomServerUrl, getString(R.string.pref_room_server_url_default)); from = sharedPref.getString(keyprefFrom, getString(R.string.pref_from_default)); // Get default codecs. String videoCodec = sharedPref.getString(keyprefVideoCodec, getString(R.string.pref_videocodec_default)); String audioCodec = sharedPref.getString(keyprefAudioCodec, getString(R.string.pref_audiocodec_default)); // Check HW codec flag. boolean hwCodec = sharedPref.getBoolean(keyprefHwCodecAcceleration, Boolean.valueOf(getString(R.string.pref_hwcodec_default))); // Check Capture to texture. boolean captureToTexture = sharedPref.getBoolean(keyprefCaptureToTexture, Boolean.valueOf(getString(R.string.pref_capturetotexture_default))); // Check Disable Audio Processing flag. boolean noAudioProcessing = sharedPref.getBoolean(keyprefNoAudioProcessingPipeline, Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default))); // Check Disable Audio Processing flag. boolean aecDump = sharedPref.getBoolean(keyprefAecDump, Boolean.valueOf(getString(R.string.pref_aecdump_default))); // Check OpenSL ES enabled flag. boolean useOpenSLES = sharedPref.getBoolean(keyprefOpenSLES, Boolean.valueOf(getString(R.string.pref_opensles_default))); // Check for mandatory permissions. missingPermissions = new ArrayList(); for (String permission : MANDATORY_PERMISSIONS) { if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(permission); }//from www.j ava 2 s. co m } requestPermission(); networkchangeBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getFlags() == 0) { SignalingService.appRTCClient.resetWebsocket(); } if (intent.getFlags() == 1) { SignalingService.appRTCClient.reconnect(); Toast.makeText(context, "network is online:" + intent.getFlags(), Toast.LENGTH_LONG).show(); } } }; // Registering BroadcastReceiver registerNetworkChangeReceiver(); // Get video resolution from settings. int videoWidth = 0; int videoHeight = 0; String resolution = sharedPref.getString(keyprefResolution, getString(R.string.pref_resolution_default)); String[] dimensions = resolution.split("[ x]+"); if (dimensions.length == 2) { try { videoWidth = Integer.parseInt(dimensions[0]); videoHeight = Integer.parseInt(dimensions[1]); } catch (NumberFormatException e) { videoWidth = 0; videoHeight = 0; Log.e(TAG, "Wrong video resolution setting: " + resolution); } } // Get camera fps from settings. int cameraFps = 0; String fps = sharedPref.getString(keyprefFps, getString(R.string.pref_fps_default)); String[] fpsValues = fps.split("[ x]+"); if (fpsValues.length == 2) { try { cameraFps = Integer.parseInt(fpsValues[0]); } catch (NumberFormatException e) { Log.e(TAG, "Wrong camera fps setting: " + fps); } } // Check capture quality slider flag. boolean captureQualitySlider = sharedPref.getBoolean(keyprefCaptureQualitySlider, Boolean.valueOf(getString(R.string.pref_capturequalityslider_default))); // Get video and audio start bitrate. int videoStartBitrate = 0; String bitrateTypeDefault = getString(R.string.pref_startvideobitrate_default); String bitrateType = sharedPref.getString(keyprefVideoBitrateType, bitrateTypeDefault); if (!bitrateType.equals(bitrateTypeDefault)) { String bitrateValue = sharedPref.getString(keyprefVideoBitrateValue, getString(R.string.pref_startvideobitratevalue_default)); videoStartBitrate = Integer.parseInt(bitrateValue); } int audioStartBitrate = 0; bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default); bitrateType = sharedPref.getString(keyprefAudioBitrateType, bitrateTypeDefault); if (!bitrateType.equals(bitrateTypeDefault)) { String bitrateValue = sharedPref.getString(keyprefAudioBitrateValue, getString(R.string.pref_startaudiobitratevalue_default)); audioStartBitrate = Integer.parseInt(bitrateValue); } // Check statistics display option. boolean displayHud = sharedPref.getBoolean(keyprefDisplayHud, Boolean.valueOf(getString(R.string.pref_displayhud_default))); boolean tracing = sharedPref.getBoolean(keyprefTracing, Boolean.valueOf(getString(R.string.pref_tracing_default))); // Log.d(TAG, "Connecting from " + from + " at URL " + wssUrl); if (validateUrl(wssUrl)) { Uri uri = Uri.parse(wssUrl); intent = new Intent(this, ConnectActivity.class); intent.setData(uri); intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled); intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth); intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight); intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps); intent.putExtra(CallActivity.EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED, captureQualitySlider); intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, videoStartBitrate); intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec); intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec); intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, captureToTexture); intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED, noAudioProcessing); intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump); intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES); intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate); intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec); intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud); intent.putExtra(CallActivity.EXTRA_TRACING, tracing); intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs); } roomListView = (ListView) findViewById(R.id.room_listview); roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); connectButton = (ImageButton) findViewById(R.id.connect_button); connectButton.setOnClickListener(connectListener); // If an implicit VIEW intent is launching the app, go directly to that URL. //final Intent intent = getIntent(); Uri wsurl = Uri.parse(wssUrl); //intent.getData(); // Log.d(TAG, "connecting to:" + wsurl.toString()); if (wsurl == null) { logAndToast(getString(R.string.missing_wsurl)); Log.e(TAG, "Didn't get any URL in intent!"); setResult(RESULT_CANCELED); finish(); return; } if (from == null || from.length() == 0) { logAndToast(getString(R.string.missing_from)); Log.e(TAG, "Incorrect from in intent!"); setResult(RESULT_CANCELED); finish(); return; } peerConnectionParameters = new PeerConnectionClient.PeerConnectionParameters(videoCallEnabled, tracing, videoWidth, videoHeight, cameraFps, videoStartBitrate, videoCodec, hwCodec, captureToTexture, audioStartBitrate, audioCodec, noAudioProcessing, aecDump, useOpenSLES); Intent intent = getIntent(); Log.i(TAG, "created apprtc with uri:" + wsurl.toString() + " from:" + from); Log.i(TAG, "intent.EXTRA_TO:" + intent.getStringExtra(RTCConnection.EXTRA_TO)); Log.i(TAG, "intent.EXTRA_FROM:" + intent.getStringExtra(RTCConnection.EXTRA_FROM)); Log.i(TAG, "intent.EXTRA_INITIATOR:" + intent.getBooleanExtra(RTCConnection.EXTRA_INITIATOR, false)); if (intent.getStringExtra(RTCConnection.EXTRA_TO) != null && !intent.getStringExtra(RTCConnection.EXTRA_TO).equals("")) { RTCConnection.to = intent.getStringExtra(RTCConnection.EXTRA_TO); RTCConnection.from = intent.getStringExtra(RTCConnection.EXTRA_FROM); RTCConnection.initiator = intent.getBooleanExtra(RTCConnection.EXTRA_INITIATOR, false); ; connectToUser(); } /* if(intent.getStringExtra(RTCConnection.EXTRA_TO)!=null && !intent.getStringExtra(RTCConnection.EXTRA_TO).equals("")){ RTCConnection.to = intent.getStringExtra(RTCConnection.EXTRA_TO); // RTCConnection.from = intent.getStringExtra(RTCConnection.EXTRA_FROM); RTCConnection.initiator = intent.getBooleanExtra(RTCConnection.EXTRA_INITIATOR,false);; Intent serviceIntent = new Intent(this,SignalingService.class); serviceIntent.putExtra(RTCConnection.EXTRA_FROM, RTCConnection.to); //WebRTC-Signaling startService(intent); }*/ }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void initActivityState(Bundle bundle) { Intent intent = getIntent(); if (bundle != null) { setIntent(getIntent().setAction(Intent.ACTION_VIEW)); String recipients = bundle.getString(RECIPIENTS); if (LogTag.VERBOSE) log("get mConversation by recipients " + recipients); mConversation = Conversation.get(this, ContactList.getByNumbers(recipients, false /* don't block */, true /* replace number */), false);/*from w w w . j a va 2 s. c o m*/ addRecipientsListeners(); mSendDiscreetMode = bundle.getBoolean(KEY_EXIT_ON_SENT, false); mForwardMessageMode = bundle.getBoolean(KEY_FORWARDED_MESSAGE, false); if (mSendDiscreetMode) { mMsgListView.setVisibility(View.INVISIBLE); } mWorkingMessage.readStateFromBundle(bundle); return; } // If we have been passed a thread_id, use that to find our conversation. long threadId = intent.getLongExtra(THREAD_ID, 0); if (threadId > 0) { if (LogTag.VERBOSE) log("get mConversation by threadId " + threadId); mConversation = Conversation.get(this, threadId, false); } else { Uri intentData = intent.getData(); if (intentData != null) { // try to get a conversation based on the data URI passed to our intent. if (LogTag.VERBOSE) log("get mConversation by intentData " + intentData); mConversation = Conversation.get(this, intentData, false); mWorkingMessage.setText(getBody(intentData)); } else { // special intent extra parameter to specify the address String address = intent.getStringExtra("address"); if (!TextUtils.isEmpty(address)) { if (LogTag.VERBOSE) log("get mConversation by address " + address); mConversation = Conversation.get(this, ContactList.getByNumbers(address, false /* don't block */, true /* replace number */), false); } else { if (LogTag.VERBOSE) log("create new conversation"); mConversation = Conversation.createNew(this); } } } addRecipientsListeners(); updateThreadIdIfRunning(); mSendDiscreetMode = intent.getBooleanExtra(KEY_EXIT_ON_SENT, false); mForwardMessageMode = intent.getBooleanExtra(KEY_FORWARDED_MESSAGE, false); if (mSendDiscreetMode) { mMsgListView.setVisibility(View.INVISIBLE); } if (intent.hasExtra("sms_body")) { mWorkingMessage.setText(intent.getStringExtra("sms_body")); } mWorkingMessage.setSubject(intent.getStringExtra("subject"), false); }
From source file:com.android.deskclock.timer.TimerReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { if (Timers.LOGGING) { Log.v(TAG, "Received intent " + intent.toString()); }/* ww w . ja va 2s .co m*/ String actionType = intent.getAction(); // This action does not need the timers data if (Timers.NOTIF_IN_USE_CANCEL.equals(actionType)) { cancelInUseNotification(context); return; } // Get the updated timers data. if (mTimers == null) { mTimers = new ArrayList<>(); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); TimerObj.getTimersFromSharedPrefs(prefs, mTimers); if (AlarmService.PRE_SHUTDOWN_ACTION.equals(actionType)) { // Stop Ringtone if all timers are not in times-up status TimerObj timerRing = Timers.findExpiredTimer(mTimers); if (timerRing != null) { timerRing.mState = TimerObj.STATE_STOPPED; stopRingtoneIfNoTimesup(context); } return; } // These actions do not provide a timer ID, but do use the timers data if (Timers.NOTIF_IN_USE_SHOW.equals(actionType)) { showInUseNotification(context); return; } else if (Timers.NOTIF_TIMES_UP_SHOW.equals(actionType)) { showTimesUpNotification(context); return; } else if (Timers.NOTIF_TIMES_UP_CANCEL.equals(actionType)) { cancelTimesUpNotification(context); return; } // Remaining actions provide a timer Id if (!intent.hasExtra(Timers.TIMER_INTENT_EXTRA)) { // No data to work with, do nothing Log.e(TAG, "got intent without Timer data"); return; } // Get the timer out of the Intent int timerId = intent.getIntExtra(Timers.TIMER_INTENT_EXTRA, -1); if (timerId == -1) { Log.d(TAG, "OnReceive:intent without Timer data for " + actionType); } TimerObj t = Timers.findTimer(mTimers, timerId); if (Timers.TIMES_UP.equals(actionType)) { // Find the timer (if it doesn't exists, it was probably deleted). if (t == null) { Log.d(TAG, " timer not found in list - do nothing"); return; } t.setState(TimerObj.STATE_TIMESUP); t.writeToSharedPref(prefs); Events.sendEvent(R.string.category_timer, R.string.action_fire, 0); /// M: We acquire the lock here because in some rare scenario, the wake lock is release /// by alarm before it could be acquired by Timer activity causing state to be suspended AlarmAlertWakeLock.acquireScreenCpuWakeLock(context); // Play ringtone by using TimerRingService service with a default alarm. Log.d(TAG, "playing ringtone"); Intent si = new Intent(); si.setClass(context, TimerRingService.class); context.startService(si); // Update the in-use notification if (getNextRunningTimer(mTimers, false, Utils.getTimeNow()) == null) { // Found no running timers. cancelInUseNotification(context); } else { showInUseNotification(context); } /** * M: To show time up notification to avoid the case: pausing the * current activity(eg: touch home key) when time is up, it cause * the TimerAlertFullScreen can not be started, and this cause no * notification in status bar but the timer has sound. @{ */ Utils.showTimesUpNotifications(context); /** @} */ // Start the TimerAlertFullScreen activity. Intent timersAlert = new Intent(context, TimerAlertFullScreen.class); timersAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); context.startActivity(timersAlert); } else if (Timers.RESET_TIMER.equals(actionType) || Timers.DELETE_TIMER.equals(actionType) || Timers.TIMER_DONE.equals(actionType)) { // Stop Ringtone if all timers are not in times-up status stopRingtoneIfNoTimesup(context); if (t != null) { cancelTimesUpNotification(context, t); } } else if (Timers.NOTIF_TIMES_UP_STOP.equals(actionType)) { // Find the timer (if it doesn't exists, it was probably deleted). if (t == null) { Log.d(TAG, "timer to stop not found in list - do nothing"); return; } else if (t.mState != TimerObj.STATE_TIMESUP) { Log.d(TAG, "action to stop but timer not in times-up state - do nothing"); return; } // Update timer state t.setState(t.getDeleteAfterUse() ? TimerObj.STATE_DELETED : TimerObj.STATE_RESTART); t.mTimeLeft = t.mOriginalLength = t.mSetupLength; t.writeToSharedPref(prefs); // Flag to tell DeskClock to re-sync with the database prefs.edit().putBoolean(Timers.REFRESH_UI_WITH_LATEST_DATA, true).apply(); cancelTimesUpNotification(context, t); // Done with timer - delete from data base if (t.getDeleteAfterUse()) { t.deleteFromSharedPref(prefs); } // Stop Ringtone if no timers are in times-up status stopRingtoneIfNoTimesup(context); } else if (Timers.NOTIF_TIMES_UP_PLUS_ONE.equals(actionType)) { // Find the timer (if it doesn't exists, it was probably deleted). if (t == null) { Log.d(TAG, "timer to +1m not found in list - do nothing"); return; } else if (t.mState != TimerObj.STATE_TIMESUP) { Log.d(TAG, "action to +1m but timer not in times up state - do nothing"); return; } // Restarting the timer with 1 minute left. t.setState(TimerObj.STATE_RUNNING); t.mStartTime = Utils.getTimeNow(); t.mTimeLeft = t.mOriginalLength = TimerObj.MINUTE_IN_MILLIS; t.writeToSharedPref(prefs); // Flag to tell DeskClock to re-sync with the database prefs.edit().putBoolean(Timers.REFRESH_UI_WITH_LATEST_DATA, true).apply(); cancelTimesUpNotification(context, t); // If the app is not open, refresh the in-use notification if (!prefs.getBoolean(Timers.NOTIF_APP_OPEN, false)) { showInUseNotification(context); } // Stop Ringtone if no timers are in times-up status stopRingtoneIfNoTimesup(context); } else if (Timers.TIMER_UPDATE.equals(actionType)) { // Find the timer (if it doesn't exists, it was probably deleted). if (t == null) { Log.d(TAG, " timer to update not found in list - do nothing"); return; } // Refresh buzzing notification if (t.mState == TimerObj.STATE_TIMESUP) { // Must cancel the previous notification to get all updates displayed correctly cancelTimesUpNotification(context, t); showTimesUpNotification(context, t); } } if (intent.getBooleanExtra(Timers.UPDATE_NEXT_TIMESUP, true)) { // Update the next "Times up" alarm unless explicitly told not to. updateNextTimesup(context); } }
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
private boolean decodeExtras(Intent intent) { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null) { Uri uri = intent.getData();/*from w w w . j a v a 2 s . co m*/ List<String> segmentList = uri.getPathSegments(); String accountId = segmentList.get(0); Collection<Account> accounts = Preferences.getPreferences(this).getAvailableAccounts(); for (Account account : accounts) { if (String.valueOf(account.getAccountNumber()).equals(accountId)) { mMessageReference = new MessageReference(); mMessageReference.accountUuid = account.getUuid(); mMessageReference.folderName = segmentList.get(1); mMessageReference.uid = segmentList.get(2); break; } } } else if (ACTION_SHORTCUT.equals(action)) { // Handle shortcut intents String specialFolder = intent.getStringExtra(EXTRA_SPECIAL_FOLDER); if (SearchAccount.UNIFIED_INBOX.equals(specialFolder)) { mSearch = SearchAccount.createUnifiedInboxAccount(this).getRelatedSearch(); } else if (SearchAccount.ALL_MESSAGES.equals(specialFolder)) { mSearch = SearchAccount.createAllMessagesAccount(this).getRelatedSearch(); } } else if (intent.getStringExtra(SearchManager.QUERY) != null) { // check if this intent comes from the system search ( remote ) if (Intent.ACTION_SEARCH.equals(intent.getAction())) { // Query was received from Search Dialog String query = intent.getStringExtra(SearchManager.QUERY); mSearch = new LocalSearch(getString(R.string.search_results)); mSearch.setManualSearch(true); mNoThreading = true; mSearch.or(new SearchCondition(Searchfield.SENDER, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(Searchfield.SUBJECT, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(Searchfield.MESSAGE_CONTENTS, Attribute.CONTAINS, query)); Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA); if (appData != null) { mSearch.addAccountUuid(appData.getString(EXTRA_SEARCH_ACCOUNT)); // searches started from a folder list activity will provide // an account, but no folder if (appData.getString(EXTRA_SEARCH_FOLDER) != null) { mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER)); } } else { mSearch.addAccountUuid(SearchSpecification.ALL_ACCOUNTS); } } } else { // regular LocalSearch object was passed mSearch = intent.getParcelableExtra(EXTRA_SEARCH); mNoThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false); } if (mMessageReference == null) { mMessageReference = intent.getParcelableExtra(EXTRA_MESSAGE_REFERENCE); } if (mMessageReference != null) { mSearch = new LocalSearch(); mSearch.addAccountUuid(mMessageReference.accountUuid); mSearch.addAllowedFolder(mMessageReference.folderName); } if (mSearch == null) { // We've most likely been started by an old unread widget String accountUuid = intent.getStringExtra("account"); String folderName = intent.getStringExtra("folder"); mSearch = new LocalSearch(folderName); mSearch.addAccountUuid((accountUuid == null) ? "invalid" : accountUuid); if (folderName != null) { mSearch.addAllowedFolder(folderName); } } Preferences prefs = Preferences.getPreferences(getApplicationContext()); String[] accountUuids = mSearch.getAccountUuids(); if (mSearch.searchAllAccounts()) { Account[] accounts = prefs.getAccounts(); mSingleAccountMode = (accounts.length == 1); if (mSingleAccountMode) { mAccount = accounts[0]; } } else { mSingleAccountMode = (accountUuids.length == 1); if (mSingleAccountMode) { mAccount = prefs.getAccount(accountUuids[0]); } } mSingleFolderMode = mSingleAccountMode && (mSearch.getFolderNames().size() == 1); if (mSingleAccountMode && (mAccount == null || !mAccount.isAvailable(this))) { Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account"); onAccountUnavailable(); return false; } if (mSingleFolderMode) { mFolderName = mSearch.getFolderNames().get(0); } // now we know if we are in single account mode and need a subtitle mActionBarSubTitle.setVisibility((!mSingleFolderMode) ? View.GONE : View.VISIBLE); return true; }
From source file:com.android.mms.ui.ComposeMessageActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (LogTag.VERBOSE) { log("onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode + ", data=" + data); }// w w w . j a v a2 s.com mWaitingForSubActivity = false; // We're back! mShouldLoadDraft = false; if (mWorkingMessage.isFakeMmsForDraft()) { // We no longer have to fake the fact we're an Mms. At this point we are or we aren't, // based on attachments and other Mms attrs. mWorkingMessage.removeFakeMmsForDraft(); } if (requestCode == REQUEST_CODE_PICK) { mWorkingMessage.asyncDeleteDraftSmsMessage(mConversation); } if (requestCode == REQUEST_CODE_ADD_CONTACT) { // The user might have added a new contact. When we tell contacts to add a contact // and tap "Done", we're not returned to Messaging. If we back out to return to // messaging after adding a contact, the resultCode is RESULT_CANCELED. Therefore, // assume a contact was added and get the contact and force our cached contact to // get reloaded with the new info (such as contact name). After the // contact is reloaded, the function onUpdate() in this file will get called // and it will update the title bar, etc. if (mAddContactIntent != null) { String address = mAddContactIntent.getStringExtra(ContactsContract.Intents.Insert.EMAIL); if (address == null) { address = mAddContactIntent.getStringExtra(ContactsContract.Intents.Insert.PHONE); } if (address != null) { Contact contact = Contact.get(address, false); if (contact != null) { contact.reload(); } } } } if (resultCode != RESULT_OK) { if (LogTag.VERBOSE) log("bail due to resultCode=" + resultCode); return; } switch (requestCode) { case REQUEST_CODE_CREATE_SLIDESHOW: if (data != null) { WorkingMessage newMessage = WorkingMessage.load(this, data.getData()); if (newMessage != null) { // Here we should keep the subject from the old mWorkingMessage. setNewMessageSubject(newMessage); mWorkingMessage = newMessage; mWorkingMessage.setConversation(mConversation); updateThreadIdIfRunning(); drawTopPanel(false); drawBottomPanel(); updateSendButtonState(); } } break; case REQUEST_CODE_TAKE_PICTURE: { // create a file based uri and pass to addImage(). We want to read the JPEG // data directly from file (using UriImage) instead of decoding it into a Bitmap, // which takes up too much memory and could easily lead to OOM. File file = new File(TempFileProvider.getScrapPath(this)); Uri uri = Uri.fromFile(file); // Remove the old captured picture's thumbnail from the cache MmsApp.getApplication().getThumbnailManager().removeThumbnail(uri); addImageAsync(uri, false); break; } case REQUEST_CODE_ATTACH_IMAGE: { if (data != null) { addImageAsync(data.getData(), false); } break; } case REQUEST_CODE_TAKE_VIDEO: Uri videoUri = TempFileProvider.renameScrapFile(".3gp", null, this); // Remove the old captured video's thumbnail from the cache MmsApp.getApplication().getThumbnailManager().removeThumbnail(videoUri); addVideoAsync(videoUri, false); // can handle null videoUri break; case REQUEST_CODE_ATTACH_VIDEO: if (data != null) { addVideoAsync(data.getData(), false); } break; case REQUEST_CODE_ATTACH_SOUND: { // Attempt to add the audio to the attachment. Uri uri = (Uri) data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri == null) { uri = data.getData(); } else if (Settings.System.DEFAULT_RINGTONE_URI.equals(uri)) { break; } addAudio(uri); break; } case REQUEST_CODE_RECORD_SOUND: if (data != null) { addAudio(data.getData()); } break; case REQUEST_CODE_ECM_EXIT_DIALOG: boolean outOfEmergencyMode = data.getBooleanExtra(EXIT_ECM_RESULT, false); if (outOfEmergencyMode) { sendMessage(false); } break; case REQUEST_CODE_PICK: if (data != null) { processPickResult(data); } break; case REQUEST_CODE_ADD_RECIPIENTS: insertNumbersIntoRecipientsEditor(data.getStringArrayListExtra(SelectRecipientsList.EXTRA_RECIPIENTS)); break; default: if (LogTag.VERBOSE) log("bail due to unknown requestCode=" + requestCode); break; } }
From source file:com.juick.android.ThreadActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { JuickAdvancedApplication.maybeEnableAcceleration(this); JuickAdvancedApplication.setupTheme(this); //requestWindowFeature(Window.FEATURE_NO_TITLE); //getSherlock().requestFeature(Window.FEATURE_NO_TITLE); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); super.onCreate(savedInstanceState); handler = new Handler(); Intent i = getIntent(); mid = (MessageID) i.getSerializableExtra("mid"); if (mid == null) { finish();//from w w w .ja va 2s .c o m } messagesSource = (MessagesSource) i.getSerializableExtra("messagesSource"); if (sp.getBoolean("fullScreenThread", false)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } setContentView(R.layout.thread); /* findViewById(R.id.gotoMain).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(ThreadActivity.this, MainActivity.class)); } }); */ final View buttons = findViewById(R.id.buttons); bSend = (ImageButton) findViewById(R.id.buttonSend); bSend.setOnClickListener(this); bAttach = (ImageButton) findViewById(R.id.buttonAttachment); bAttach.setOnClickListener(this); etMessage = (EditText) findViewById(R.id.editMessage); if (sp.getBoolean("helvNueFonts", false)) { etMessage.setTypeface(JuickAdvancedApplication.helvNue); /* TextView oldTitle = (TextView)findViewById(R.id.old_title); oldTitle.setTypeface(JuickAdvancedApplication.helvNue); */ } Button cancel = (Button) findViewById(R.id.buttonCancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doCancel(); } }); tvReplyTo = (TextView) findViewById(R.id.textReplyTo); replyToContainer = (RelativeLayout) findViewById(R.id.replyToContainer); setHeight(replyToContainer, 0); showThread = (Button) findViewById(R.id.showThread); draftsButton = (Button) findViewById(R.id.drafts); etMessage.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { etMessage.setHint(""); setHeight(buttons, ActionBar.LayoutParams.WRAP_CONTENT); InputMethodManager inputMgr = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMgr.toggleSoftInput(0, 0); } else { etMessage.setHint(R.string.ClickToReply); setHeight(buttons, 0); } //To change body of implemented methods use File | Settings | File Templates. } }); draftsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { class Item { String label; long ts; int index; Item(String label, long ts, int index) { this.label = label; this.ts = ts; this.index = index; } } final ArrayList<Item> items = new ArrayList<Item>(); final SharedPreferences drafts = getSharedPreferences("drafts", MODE_PRIVATE); for (int q = 0; q < 1000; q++) { String msg = drafts.getString("message" + q, null); if (msg != null) { if (msg.length() > 50) msg = msg.substring(0, 50); items.add(new Item(msg, drafts.getLong("timestamp" + q, 0), q)); } } Collections.sort(items, new Comparator<Item>() { @Override public int compare(Item item, Item item2) { final long l = item2.ts - item.ts; return l == 0 ? 0 : l > 0 ? 1 : -1; } }); CharSequence[] arr = new CharSequence[items.size()]; for (int i1 = 0; i1 < items.size(); i1++) { Item item = items.get(i1); arr[i1] = item.label; } new AlertDialog.Builder(ThreadActivity.this).setItems(arr, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { final Runnable doPull = new Runnable() { @Override public void run() { pullDraft(null, drafts, items.get(which).index); updateDraftsButton(); } }; if (pulledDraft != null && pulledDraft.trim().equals(etMessage.getText().toString().trim())) { // no need to ask, user just looks at the drafts saveDraft(pulledDraftRid, pulledDraftMid, pulledDraftTs, pulledDraft); doPull.run(); } else { if (etMessage.getText().toString().length() > 0) { new AlertDialog.Builder(ThreadActivity.this) .setTitle(getString(R.string.ReplacingText)) .setMessage(getString(R.string.YourTextWillBeReplaced)) .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { doPull.run(); } }) .setNeutralButton( getString(pulledDraft != null ? R.string.SaveChangedDraft : R.string.SaveDraft), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (pulledDraft != null) { saveDraft(pulledDraftRid, pulledDraftMid, System.currentTimeMillis(), etMessage.getText().toString()); } else { saveDraft(rid, mid.toString(), System.currentTimeMillis(), etMessage.getText().toString()); } doPull.run(); } }) .setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .show(); } else { doPull.run(); } } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); } }); enableDrafts = (sp.getBoolean("enableDrafts", false)); if (sp.getBoolean("capitalizeReplies", false)) { etMessage.setInputType(etMessage.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); tf = new ThreadFragment(); tf.init(getLastCustomNonConfigurationInstance(), this); Bundle args = new Bundle(); args.putSerializable("mid", mid); args.putSerializable("messagesSource", messagesSource); args.putSerializable("prefetched", i.getSerializableExtra("prefetched")); args.putSerializable("originalMessage", i.getSerializableExtra("originalMessage")); args.putBoolean("scrollToBottom", i.getBooleanExtra("scrollToBottom", false)); tf.setArguments(args); ft.add(R.id.threadfragment, tf); ft.commit(); MainActivity.restyleChildrenOrWidget(getWindow().getDecorView()); detector = new GestureDetector(this, new GestureDetector.OnGestureListener() { @Override public boolean onDown(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (velocityX > 0 && Math.abs(velocityX) > 4 * Math.abs(velocityY) && Math.abs(velocityX) > 400) { if (etMessage.getText().toString().trim().length() == 0) { System.out.println("velocityX=" + velocityX + " velocityY" + velocityY); if (sp.getBoolean("swipeToClose", true)) { onBackPressed(); } } } return false; } }); com.actionbarsherlock.app.ActionBar actionBar = getSherlock().getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setHomeButtonEnabled(true); actionBar.setLogo(R.drawable.back_button); }