List of usage examples for android.content Intent getStringArrayExtra
public String[] getStringArrayExtra(String name)
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = virtualIntent; final String action = intent.getAction(); if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;//from www .j av a 2s . c o m } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_MANAGE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); }
From source file:cn.newgxu.android.notty.service.FetchService.java
@Override protected void onHandleIntent(Intent intent) { // int method = intent.getIntExtra("method", RESTMethod.GET); // switch (method) { // case RESTMethod.GET: // break; // case RESTMethod.POST: // Map<String, Object> params = new HashMap<String, Object>(); // params.put(C.notice.TITLE, intent.getStringExtra(C.notice.TITLE)); // params.put(C.notice.CONTENT, intent.getStringExtra(C.notice.CONTENT)); // L.d(TAG, "post result: %s", result); // ContentValues values = new ContentValues(); // values.put(C.notice.TITLE, intent.getStringExtra(C.notice.TITLE)); // values.put(C.notice.CONTENT, intent.getStringExtra(C.notice.CONTENT)); // getContentResolver().insert(Uri.parse(C.BASE_URI + C.NOTICES), values); // return; // default: // break; // }//from w ww.j a v a 2 s .co m if (NetworkUtils.connected(getApplicationContext())) { Cursor c = getContentResolver().query(Uri.parse(C.BASE_URI + C.NOTICES), C.notice.LATEST_NOTICE_ID, null, null, null); String uri = intent.getStringExtra(C.URI); if (c.moveToNext()) { uri += "&local_nid=" + c.getLong(0); } Log.d(TAG, String.format("uri: %s", uri)); JSONObject result = RESTMethod.get(uri); L.d(TAG, "json: %s", result); try { JSONArray notices = result.getJSONArray(C.NOTICES); ContentValues[] noticeValues = new ContentValues[notices.length()]; ContentValues[] userValues = new ContentValues[notices.length()]; for (int i = 0; i < userValues.length; i++) { JSONObject n = notices.getJSONObject(i); JSONObject u = n.getJSONObject(C.USER); noticeValues[i] = Processor.json2Notice(n); userValues[i] = Processor.json2User(u); } String[] uris = intent.getStringArrayExtra("uris"); getContentResolver().bulkInsert(Uri.parse(uris[0]), noticeValues); getContentResolver().bulkInsert(Uri.parse(uris[1]), userValues); final int newerCount = notices.length(); handler.post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), getString(R.string.newer_count, newerCount), Toast.LENGTH_SHORT).show(); } }); } catch (JSONException e) { throw new RuntimeException("ERROR when resolving json -> " + result, e); } } else { handler.post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), R.string.network_down, Toast.LENGTH_SHORT).show(); } }); } }
From source file:com.mobicage.rogerthat.plugins.friends.ActionScreenActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); final Session session = Session.getActiveSession(); if (session != null) { session.onActivityResult(this, requestCode, resultCode, data); }//from www .j a v a 2 s . c om if (requestCode == CHECKIN_REQUEST_CODE && data != null) { Bundle bundle = new Bundle(); @SuppressWarnings("unchecked") final Map<String, Object> postParams = (Map<String, Object>) JSONValue .parse(data.getStringExtra("postParamsStr")); for (Map.Entry<String, Object> entry : postParams.entrySet()) { if (entry.getValue() instanceof String) bundle.putString(entry.getKey(), (String) entry.getValue()); } String[] tags = data.getStringArrayExtra("tags"); if (tags.length > 0) { StringBuilder nameBuilder = new StringBuilder(); for (String n : tags) { nameBuilder.append(n + ","); } nameBuilder.deleteCharAt(nameBuilder.length() - 1); bundle.putString("tags", nameBuilder.toString()); } L.d("Bundle: " + bundle); final String requestId = data.getStringExtra("requestId"); Request request = new Request(Session.getActiveSession(), POST_ACTION_PATH_FEED, bundle, HttpMethod.POST, new Request.Callback() { @Override public void onCompleted(Response response) { try { FacebookRequestError fbError = response.getError(); if (fbError != null) { L.w("Failed to check in: " + fbError); Map<String, Object> error = new HashMap<String, Object>(); error.put("type", FACEBOOK_TYPE_ERROR); error.put("exception", fbError.getErrorMessage()); deliverFacebookResult(requestId, null, error); } GraphObject graphObject = response.getGraphObject(); if (graphObject == null) { deliverFacebookResult(requestId, null, FACEBOOK_MAP_CANCEL); return; } JSONObject jsonObject = graphObject.getInnerJSONObject(); final Map<String, Object> result = new HashMap<String, Object>(); result.put("postId", jsonObject.getString("id")); deliverFacebookResult(requestId, result, null); } catch (JSONException e) { e.printStackTrace(); } } }); request.executeAsync(); } }
From source file:com.fa.mastodon.activity.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); ButterKnife.bind(this); // Setup the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* ww w. j av a 2 s . co m*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } // Setup the interface buttons. floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSendClicked(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); takeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCameraApp(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); /* Initialise all the state, or restore it from a previous run, to determine a "starting" * state. */ SharedPreferences preferences = getPrivatePreferences(); String startingVisibility; boolean startingHideText; String startingContentWarning = null; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } /* If the composer is started up as a reply to another post, override the "starting" state * based on what the intent from the reply request passes. */ Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); if (inReplyToId != null) { startingHideText = !intent.getStringExtra("content_warning").equals(""); if (startingHideText) { startingContentWarning = intent.getStringExtra("content_warning"); } } } /* If the currently logged in account is locked, its posts should default to private. This * should override even the reply settings, so this must be done after those are set up. */ if (preferences.getBoolean("loggedInAccountLocked", false)) { startingVisibility = "private"; } // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); postProgress.setVisibility(View.INVISIBLE); updateNsfwButtonColor(); // Setup the main text field. setEditTextMimeTypes(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); SpanUtils.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { SpanUtils.highlightSpans(editable, mentionColour); } }); // Add any mentions to the text field when a reply is first composed. if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } // Initialise the content warning editor. contentWarningEditor.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); if (startingContentWarning != null) { contentWarningEditor.setText(startingContentWarning); } // Initialise the empty media queue state. mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } else if (intent != null && savedInstanceState == null) { /* Get incoming images being sent through a share action from another app. Only do this * when savedInstanceState is null, otherwise both the images from the intent and the * instance state will be re-queued. */ String type = intent.getType(); if (type != null) { if (type.startsWith("image/")) { List<Uri> uriList = new ArrayList<>(); switch (intent.getAction()) { case Intent.ACTION_SEND: { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { uriList.add(uri); } break; } case Intent.ACTION_SEND_MULTIPLE: { ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Uri uri : list) { if (uri != null) { uriList.add(uri); } } } break; } } for (Uri uri : uriList) { long mediaSize = getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); } } } } } }
From source file:com.android.contacts.ContactSaveService.java
private void deleteMultipleContacts(Intent intent) { final long[] contactIds = intent.getLongArrayExtra(EXTRA_CONTACT_IDS); if (contactIds == null) { Log.e(TAG, "Invalid arguments for deleteMultipleContacts request"); return;/* w ww .j av a2 s . com*/ } for (long contactId : contactIds) { final Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); getContentResolver().delete(contactUri, null, null); } final String[] names = intent.getStringArrayExtra(ContactSaveService.EXTRA_DISPLAY_NAME_ARRAY); final String deleteToastMessage; if (contactIds.length != names.length || names.length == 0) { deleteToastMessage = getResources().getQuantityString(R.plurals.contacts_deleted_toast, contactIds.length); } else if (names.length == 1) { deleteToastMessage = getResources().getString(R.string.contacts_deleted_one_named_toast, names); } else if (names.length == 2) { deleteToastMessage = getResources().getString(R.string.contacts_deleted_two_named_toast, names); } else { deleteToastMessage = getResources().getString(R.string.contacts_deleted_many_named_toast, names); } mMainHandler.post(new Runnable() { @Override public void run() { Toast.makeText(ContactSaveService.this, deleteToastMessage, Toast.LENGTH_LONG).show(); } }); }
From source file:com.easemob.chatuidemo.activity.GroupDetailsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); String st1 = getResources().getString(R.string.being_added); String st2 = getResources().getString(R.string.is_quit_the_group_chat); String st3 = getResources().getString(R.string.chatting_is_dissolution); String st4 = getResources().getString(R.string.are_empty_group_of_news); String st5 = getResources().getString(R.string.is_modify_the_group_name); final String st6 = getResources().getString(R.string.Modify_the_group_name_successful); final String st7 = getResources().getString(R.string.change_the_group_name_failed_please); String st8 = getResources().getString(R.string.Are_moving_to_blacklist); final String st9 = getResources().getString(R.string.failed_to_move_into); final String stsuccess = getResources().getString(R.string.Move_into_blacklist_success); if (resultCode == RESULT_OK) { if (progressDialog == null) { progressDialog = new ProgressDialog(GroupDetailsActivity.this); progressDialog.setMessage(st1); progressDialog.setCanceledOnTouchOutside(false); }/*from w ww . ja v a 2 s. c o m*/ switch (requestCode) { case REQUEST_CODE_ADD_USER:// ? final String[] newmembers = data.getStringArrayExtra("newmembers"); progressDialog.setMessage(st1); progressDialog.show(); addMembersToGroup(newmembers); break; case REQUEST_CODE_EXIT: // progressDialog.setMessage(st2); progressDialog.show(); exitGrop(); break; case REQUEST_CODE_EXIT_DELETE: // progressDialog.setMessage(st3); progressDialog.show(); deleteGrop(); break; case REQUEST_CODE_CLEAR_ALL_HISTORY: // ?? progressDialog.setMessage(st4); progressDialog.show(); clearGroupHistory(); break; case REQUEST_CODE_EDIT_GROUPNAME: //?? final String returnData = data.getStringExtra("data"); if (!TextUtils.isEmpty(returnData)) { progressDialog.setMessage(st5); progressDialog.show(); new Thread(new Runnable() { public void run() { try { EMGroupManager.getInstance().changeGroupName(groupId, returnData); runOnUiThread(new Runnable() { public void run() { ((TextView) findViewById(R.id.group_name)) .setText(returnData + "(" + group.getAffiliationsCount() + st); progressDialog.dismiss(); Toast.makeText(getApplicationContext(), st6, 0).show(); } }); } catch (EaseMobException e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { progressDialog.dismiss(); Toast.makeText(getApplicationContext(), st7, 0).show(); } }); } } }).start(); } break; case REQUEST_CODE_ADD_TO_BALCKLIST: progressDialog.setMessage(st8); progressDialog.show(); new Thread(new Runnable() { public void run() { try { EMGroupManager.getInstance().blockUser(groupId, longClickUsername); runOnUiThread(new Runnable() { public void run() { refreshMembers(); progressDialog.dismiss(); Toast.makeText(getApplicationContext(), stsuccess, 0).show(); } }); } catch (EaseMobException e) { runOnUiThread(new Runnable() { public void run() { progressDialog.dismiss(); Toast.makeText(getApplicationContext(), st9, 0).show(); } }); } } }).start(); break; default: break; } } }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
private boolean handleIntent(final Intent intent) { final String action = intent.getAction(); mShouldSaveAccounts = false;// ww w .ja v a2 s. co m mMentionUser = intent.getParcelableExtra(EXTRA_USER); mInReplyToStatus = intent.getParcelableExtra(EXTRA_STATUS); mInReplyToStatusId = mInReplyToStatus != null ? mInReplyToStatus.id : -1; if (INTENT_ACTION_REPLY.equals(action)) return handleReplyIntent(mInReplyToStatus); else if (INTENT_ACTION_QUOTE.equals(action)) return handleQuoteIntent(mInReplyToStatus); else if (INTENT_ACTION_EDIT_DRAFT.equals(action)) { mDraftItem = intent.getParcelableExtra(EXTRA_DRAFT); return handleEditDraftIntent(mDraftItem); } else if (INTENT_ACTION_MENTION.equals(action)) return handleMentionIntent(mMentionUser); else if (INTENT_ACTION_REPLY_MULTIPLE.equals(action)) { final String[] screenNames = intent.getStringArrayExtra(EXTRA_SCREEN_NAMES); final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); final long inReplyToUserId = intent.getLongExtra(EXTRA_IN_REPLY_TO_ID, -1); return handleReplyMultipleIntent(screenNames, accountId, inReplyToUserId); } else if (INTENT_ACTION_COMPOSE_TAKE_PHOTO.equals(action)) { takePhoto(); return true; } else if (INTENT_ACTION_COMPOSE_PICK_IMAGE.equals(action)) { pickImage(); return true; } // Unknown action or no intent extras return false; }
From source file:com.studyjams.mdvideo.PlayerModule.ExoPlayerV2.PlayerActivityV2.java
/**debug?**/ // @Override/*from w ww . j a v a 2s. c o m*/ // public void onClick(View view) { // if (view == retryButton) { // initializePlayer(); // } else if (view.getParent() == debugRootView) { // trackSelectionHelper.showSelectionDialog(this, ((Button) view).getText(), // trackSelector.getCurrentSelections().info, (int) view.getTag()); // } // } // PlaybackControlView.VisibilityListener implementation // // @Override // public void onVisibilityChange(int visibility) { // debugRootView.setVisibility(visibility); // } // Internal methods private void initializePlayer() { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); String intentType = intent.getStringExtra(CONTENT_TYPE_INTENT); if (Intent.ACTION_SEND.equals(action) && type.equals("video/*")) { mContentUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); mContentId = ""; mContentPosition = C.TIME_UNSET; mSubtitleUri = null; } else if (intentType.equals(D.TYPE_VIDEO)) { mContentUri = intent.getData(); mContentId = intent.getStringExtra(CONTENT_ID_EXTRA); mContentPosition = intent.getLongExtra(CONTENT_POSITION_EXTRA, 0); String subtitle = intent.getStringExtra(CONTENT_SUBTITLE_EXTRA); if (!TextUtils.isEmpty(subtitle)) { mSubtitleUri = Uri.parse(subtitle); } else { mSubtitleUri = null; } playerPosition = mContentPosition; } else if (intentType.equals(D.TYPE_SUBTITLE)) { mSubtitleUri = intent.getData(); } if (player == null) { boolean preferExtensionDecoders = intent.getBooleanExtra(PREFER_EXTENSION_DECODERS, false); UUID drmSchemeUuid = intent.hasExtra(DRM_SCHEME_UUID_EXTRA) ? UUID.fromString(intent.getStringExtra(DRM_SCHEME_UUID_EXTRA)) : null; DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null; if (drmSchemeUuid != null) { String drmLicenseUrl = intent.getStringExtra(DRM_LICENSE_URL); String[] keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES); Map<String, String> keyRequestProperties; if (keyRequestPropertiesArray == null || keyRequestPropertiesArray.length < 2) { keyRequestProperties = null; } else { keyRequestProperties = new HashMap<>(); for (int i = 0; i < keyRequestPropertiesArray.length - 1; i += 2) { keyRequestProperties.put(keyRequestPropertiesArray[i], keyRequestPropertiesArray[i + 1]); } } try { drmSessionManager = buildDrmSessionManager(drmSchemeUuid, drmLicenseUrl, keyRequestProperties); } catch (UnsupportedDrmException e) { int errorStringId = Util.SDK_INT < 18 ? R.string.error_drm_not_supported : (e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME ? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown); showToast(errorStringId); return; } } eventLogger = new EventLogger(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory( BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory); trackSelector.addListener(this); trackSelector.addListener(eventLogger); trackSelectionHelper = new TrackSelectionHelper(trackSelector, videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(), drmSessionManager, preferExtensionDecoders); player.addListener(this); player.addListener(eventLogger); player.setAudioDebugListener(eventLogger); player.setVideoDebugListener(eventLogger); player.setId3Output(eventLogger); simpleExoPlayerView.setPlayer(player); //?mediaController controller.setPlayer(player); controller.setTitle(mContentUri.getLastPathSegment()); // if (isTimelineStatic) { if (playerPosition == C.TIME_UNSET) { player.seekToDefaultPosition(playerWindow); } else { player.seekTo(playerWindow, playerPosition); } // } player.setPlayWhenReady(shouldAutoPlay); /**? debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.start();**/ playerNeedsSource = true; } if (playerNeedsSource) { // String action = intent.getAction(); Uri[] uris; String[] extensions; if (ACTION_VIEW.equals(action)) { // uris = new Uri[]{intent.getData()}; uris = new Uri[] { mContentUri }; extensions = new String[] { intent.getStringExtra(EXTENSION_EXTRA) }; } else if (ACTION_VIEW_LIST.equals(action)) { String[] uriStrings = intent.getStringArrayExtra(URI_LIST_EXTRA); uris = new Uri[uriStrings.length]; for (int i = 0; i < uriStrings.length; i++) { uris[i] = Uri.parse(uriStrings[i]); } extensions = intent.getStringArrayExtra(EXTENSION_LIST_EXTRA); if (extensions == null) { extensions = new String[uriStrings.length]; } } else { showToast(getString(R.string.unexpected_intent_action, action)); return; } if (Util.maybeRequestReadExternalStoragePermission(this, uris)) { // The player will be reinitialized if the permission is granted. return; } MediaSource[] mediaSources = new MediaSource[uris.length]; for (int i = 0; i < uris.length; i++) { mediaSources[i] = buildMediaSource(uris[i], extensions[i]); } MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0] : new ConcatenatingMediaSource(mediaSources); player.prepare(mediaSource, !isTimelineStatic, !isTimelineStatic); playerNeedsSource = false; // updateButtonVisibilities(); } }
From source file:net.maa123.tatuky.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); ButterKnife.bind(this); // Setup the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w . j a v a 2 s . co m*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } // Setup the interface buttons. floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSendClicked(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); takeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCameraApp(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); /* Initialise all the state, or restore it from a previous run, to determine a "starting" * state. */ SharedPreferences preferences = getPrivatePreferences(); String startingVisibility; boolean startingHideText; String startingContentWarning = null; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } /* If the composer is started up as a reply to another post, override the "starting" state * based on what the intent from the reply request passes. */ Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("direct") || replyVisibility.equals("direct")) { startingVisibility = "direct"; } else if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); if (inReplyToId != null) { startingHideText = !intent.getStringExtra("content_warning").equals(""); if (startingHideText) { startingContentWarning = intent.getStringExtra("content_warning"); } } } /* If the currently logged in account is locked, its posts should default to private. This * should override even the reply settings, so this must be done after those are set up. */ if (preferences.getBoolean("loggedInAccountLocked", false)) { startingVisibility = "private"; } // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); postProgress.setVisibility(View.INVISIBLE); updateNsfwButtonColor(); // Setup the main text field. setEditTextMimeTypes(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); SpanUtils.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { SpanUtils.highlightSpans(editable, mentionColour); } }); // Add any mentions to the text field when a reply is first composed. if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } // Initialise the content warning editor. contentWarningEditor.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); if (startingContentWarning != null) { contentWarningEditor.setText(startingContentWarning); } // Initialise the empty media queue state. mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } else if (intent != null && savedInstanceState == null) { /* Get incoming images being sent through a share action from another app. Only do this * when savedInstanceState is null, otherwise both the images from the intent and the * instance state will be re-queued. */ String type = intent.getType(); if (type != null) { if (type.startsWith("image/")) { List<Uri> uriList = new ArrayList<>(); switch (intent.getAction()) { case Intent.ACTION_SEND: { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { uriList.add(uri); } break; } case Intent.ACTION_SEND_MULTIPLE: { ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Uri uri : list) { if (uri != null) { uriList.add(uri); } } } break; } } for (Uri uri : uriList) { long mediaSize = getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); } } } } } }
From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java
private boolean handleIntent(final Intent intent) { final String action = intent.getAction(); mShouldSaveAccounts = false;//from w w w. jav a 2 s . c om mMentionUser = intent.getParcelableExtra(EXTRA_USER); mInReplyToStatus = intent.getParcelableExtra(EXTRA_STATUS); mInReplyToStatusId = mInReplyToStatus != null ? mInReplyToStatus.id : -1; switch (action) { case INTENT_ACTION_REPLY: { return handleReplyIntent(mInReplyToStatus); } case INTENT_ACTION_QUOTE: { return handleQuoteIntent(mInReplyToStatus); } case INTENT_ACTION_EDIT_DRAFT: { mDraftItem = intent.getParcelableExtra(EXTRA_DRAFT); return handleEditDraftIntent(mDraftItem); } case INTENT_ACTION_MENTION: { return handleMentionIntent(mMentionUser); } case INTENT_ACTION_REPLY_MULTIPLE: { final String[] screenNames = intent.getStringArrayExtra(EXTRA_SCREEN_NAMES); final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); final long inReplyToUserId = intent.getLongExtra(EXTRA_IN_REPLY_TO_ID, -1); return handleReplyMultipleIntent(screenNames, accountId, inReplyToUserId); } case INTENT_ACTION_COMPOSE_TAKE_PHOTO: { return takePhoto(); } case INTENT_ACTION_COMPOSE_PICK_IMAGE: { return pickImage(); } } // Unknown action or no intent extras return false; }