List of usage examples for android.provider MediaStore EXTRA_OUTPUT
String EXTRA_OUTPUT
To view the source code for android.provider MediaStore EXTRA_OUTPUT.
Click Source Link
From source file:com.dycody.android.idealnote.DetailFragment.java
private void takeSketch(Attachment attachment) { File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_SKETCH_EXT); if (f == null) { Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show(); //mainActivity.showMessage(R.string.error, ONStyle.ALERT); return;/* ww w .j ava 2 s. c o m*/ } attachmentUri = Uri.fromFile(f); // Forces portrait orientation to this fragment only mainActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Fragments replacing FragmentTransaction transaction = mainActivity.getSupportFragmentManager().beginTransaction(); mainActivity.animateTransition(transaction, mainActivity.TRANSITION_HORIZONTAL); SketchFragment mSketchFragment = new SketchFragment(); Bundle b = new Bundle(); b.putParcelable(MediaStore.EXTRA_OUTPUT, attachmentUri); if (attachment != null) { b.putParcelable("base", attachment.getUri()); } mSketchFragment.setArguments(b); transaction.replace(R.id.fragment_container, mSketchFragment, mainActivity.FRAGMENT_SKETCH_TAG) .addToBackStack(mainActivity.FRAGMENT_DETAIL_TAG).commit(); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void video_click() { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("Video"); dialog.setMessage("Record a video?"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override//from www.j av a 2 s .c om public void onClick(DialogInterface dialog, int which) { if (GTConstants.videoFeed.equalsIgnoreCase("dvtel")) { //Launch the DVTel program - TruWitness Intent intent = getPackageManager().getLaunchIntentForPackage("com.dvtel.mobilecam"); if (intent != null) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } else if (GTConstants.videoFeed.equalsIgnoreCase("milestone")) { //Launch the DVTel program - TruWitness Intent intent = getPackageManager().getLaunchIntentForPackage("com.milestonesys.mobile"); if (intent != null) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } else { // Launch an intent to capture video from MediaStore Intent takeVideoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); String path = GTConstants.sendfileFolder + Utility.createFileName() + ".mpeg"; file_name = path; File file = new File(path); Uri outputFileUri = Uri.fromFile(file); takeVideoIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO); } } }); dialog.setNeutralButton("View", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, ACTIVITY_SELECT_VIDEO); } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void camera_click() { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("Camera"); dialog.setMessage("Snap a Picture?"); dialog.setPositiveButton("Snap", new DialogInterface.OnClickListener() { @Override/* ww w . j a va 2 s. c o m*/ public void onClick(DialogInterface dialog, int which) { try { //Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); String path = GTConstants.sendfileFolder + Utility.createFileName() + ".jpg"; file_name = path; File file = new File(path); Uri outputFileUri = Uri.fromFile(file); cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); } catch (Exception e) { } } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); dialog.setNeutralButton("View", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, ACTIVITY_SELECT_IMAGE); } }); dialog.show(); }
From source file:com.dish.browser.activity.BrowserActivity.java
@Override public void showFileChooser(ValueCallback<Uri[]> filePathCallback) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); }//from w ww . j a va2 s .co m mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = Utils.createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(Constants.TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); mActivity.startActivityForResult(chooserIntent, 1); }
From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java
private void handleTackPicture() { if (!FileAccessor.isExistExternalStore()) { return;//ww w . j a va 2 s . co m } Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = FileAccessor.getTackPicFilePath(); if (file != null) { Uri uri = Uri.fromFile(file); if (uri != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); } mFilePath = file.getAbsolutePath(); } startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
private void takePhoto() { final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { final File cache_dir = EnvironmentAccessor.getExternalCacheDir(this); final File file = new File(cache_dir, "tmp_photo_" + System.currentTimeMillis() + ".jpg"); mImageUri = Uri.fromFile(file);/*www . ja v a 2 s.com*/ intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); try { startActivityForResult(intent, REQUEST_TAKE_PHOTO); } catch (final ActivityNotFoundException e) { showErrorToast(this, null, e, false); } } }
From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java
private void startCamera() { try {// www . j a va2 s.com File f = setUpPhotoFile(); mCurrentPhotoPath = f.getAbsolutePath(); Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); startActivityForResult(takePictureIntent, PDUIImageUtils.PD_TAKE_PHOTO_REQUEST_CODE); /*this line causes a crash if client app has camera permission - need to ask for camera permission of it exists*/ } catch (IOException e) { e.printStackTrace(); mCurrentPhotoPath = null; } }
From source file:com.ranglerz.tlc.tlc.com.ranglerz.tlc.tlc.Summons.NewSummon.java
private void cameraIntent() { // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // startActivityForResult(intent, REQUEST_CAMERA); if (btnClicked == summonimg) { ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "New Picture"); values.put(MediaStore.Images.Media.DESCRIPTION, "From your Camera"); imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, REQUEST_CAMERA_summonimg); }//ww w . j a v a 2 s . c o m else if (btnClicked == complianceimg) { ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "New Picture"); values.put(MediaStore.Images.Media.DESCRIPTION, "From your Camera"); imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, REQUEST_CAMERA_complianceimg); } }
From source file:cl.gisred.android.InspActivity.java
private void tomarFoto(String name) { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); File photo = null;//from w ww.j av a 2 s.c om try { // place where to store camera taken picture photo = PhotoUtils.createFile(name, "jpg", InspActivity.this); photo.delete(); } catch (Exception e) { Log.v(getClass().getSimpleName(), "Can't create file to take picture!"); } mImageUri = Uri.fromFile(photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LOCKED); startActivityForResult(intent, ACTIVITY_SELECT_FROM_CAMERA); }
From source file:me.ububble.speakall.fragment.ConversationChatFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.icn_message_send: temporizadorAcept.setVisibility(View.INVISIBLE); String message = messageText.getText().toString(); Message msjNew = new Message(); Calendar fecha = Calendar.getInstance(); String id = u.id + contact.idContacto + fecha.getTimeInMillis() + Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID); msjNew.mensajeId = id;//from w ww . j ava 2s . c o m msjNew.emisor = u.id; msjNew.receptor = contact.idContacto; msjNew.mensaje = message; msjNew.emisorEmail = u.email; msjNew.receptorEmail = contact.email; msjNew.emisorLang = u.lang; msjNew.receptorLang = contact.lang; msjNew.emitedAt = fecha.getTimeInMillis(); msjNew.tipo = Integer.parseInt(getString(R.string.MSG_TYPE_TEXT)); if (tiempoMensaje) msjNew.delay = temporizadorSeek.getValue(); else msjNew.delay = 0; msjNew.translation = translate; if (SpeakSocket.mSocket != null) if (SpeakSocket.mSocket.connected()) { msjNew.status = 1; } else { msjNew.status = -1; } msjNew.save(); Chats chat = new Select().from(Chats.class).where("idContacto = ?", msjNew.receptor).executeSingle(); if (chat == null) { Contact contact = new Select().from(Contact.class).where("id_contact = ?", msjNew.receptor) .executeSingle(); Chats newChat = new Chats(); newChat.mensajeId = msjNew.mensajeId; newChat.idContacto = msjNew.receptor; newChat.isLockedConversation = false; newChat.lastStatus = msjNew.status; newChat.email = msjNew.receptorEmail; if (contact != null) { newChat.photo = contact.photo; newChat.fullName = contact.fullName; newChat.lang = contact.lang; newChat.screenName = contact.screenName; newChat.photoload = true; newChat.phone = contact.phone; } else { newChat.photo = null; newChat.photoload = false; newChat.fullName = msjNew.receptorEmail; newChat.lang = msjNew.receptorLang; newChat.screenName = msjNew.receptorEmail; newChat.phone = null; } newChat.emitedAt = msjNew.emitedAt; newChat.notRead = 0; newChat.lastMessage = msjNew.mensaje; newChat.show = true; newChat.save(); } else { if (!chat.photoload) { Contact contact = new Select().from(Contact.class).where("id_contact = ?", msjNew.emisor) .executeSingle(); if (contact != null) { chat.photo = contact.photo; chat.photoload = true; } else { chat.photo = null; chat.photoload = false; } } chat.mensajeId = msjNew.mensajeId; chat.lastStatus = msjNew.status; chat.emitedAt = msjNew.emitedAt; chat.notRead = 0; chat.lastMessage = msjNew.mensaje; chat.save(); } messageText.setText(""); showNewMessage(msjNew); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); tiempoMensaje = false; break; case R.id.message_text: SharedPreferences settings = getActivity().getSharedPreferences(Finder.STRING.APP_PREF.toString(), Context.MODE_PRIVATE); if (settings.getInt("INPUTKEY", 0) == 0) { customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); keyboardLayout.setVisibility(View.GONE); isShowCustomKeyboard = false; if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } isShowKeyboard = true; } else { if (!isShowKeyboard) { if (!isShowCustomKeyboard) { messagesListScroll.setVerticalScrollBarEnabled(false); final InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } imm.showSoftInput(messageText, 0); keyboardLayout.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set.setDuration(220).start(); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); keyboardLayout .setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); isShowKeyboard = true; ((MainActivity) activity).setOnBackPressedListener(null); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; } else { keyboardLayout.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set.setDuration(220).start(); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); ((MainActivity) activity).setOnBackPressedListener(null); messagesListScroll.setVerticalScrollBarEnabled(false); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } final InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(messageText, 0); keyboardLayout .setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); isShowKeyboard = true; customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; } } } break; case R.id.icn_message_translate: translate = !translate; if (translate) messageTranslate.setTextColor(getResources().getColor(R.color.speak_all_red)); else messageTranslate.setTextColor(getResources().getColor(R.color.speak_all_gray)); break; case R.id.icn_message_clock: tiempoMensaje = false; temporizadorAcept.setVisibility(View.INVISIBLE); temporizadorSeek.setInitPosition(0); SharedPreferences settings1 = getActivity().getSharedPreferences(Finder.STRING.APP_PREF.toString(), Context.MODE_PRIVATE); if (settings1.getInt("INPUTKEY", 0) != 0) { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); } if (!isShowCustomKeyboard) { if (!isShowKeyboard) { keyboardLayout.setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); } keyboardLayout.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set.setDuration(220).start(); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); customKeyboardLayout.setVisibility(View.VISIBLE); customKeyboardAudio.setVisibility(View.GONE); ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; ((MainActivity) activity).setOnBackPressedListener(null); } }); isShowCustomKeyboard = true; isShowKeyboard = false; } else { keyboardLayout.setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); keyboardLayout.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set.setDuration(220).start(); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); hideKeyBoard(); ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; ((MainActivity) activity).setOnBackPressedListener(null); } }); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); } customKeyboardLayout.setVisibility(View.VISIBLE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = true; isShowKeyboard = false; } } else { customKeyboardAudio.setVisibility(View.GONE); if (!customKeyboardLayout.isShown()) { customKeyboardLayout.setVisibility(View.VISIBLE); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } } else { temporizadorAcept.setVisibility(View.INVISIBLE); keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; tiempoMensaje = false; if (tiempoMensaje) { messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); } else { messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); } } } break; case R.id.temporizador_cancel: temporizadorAcept.setVisibility(View.INVISIBLE); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); temporizadorSeek.setInitPosition(0); isShowCustomKeyboard = false; tiempoMensaje = false; break; case R.id.temporizador_acept: temporizadorAcept.setVisibility(View.INVISIBLE); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; tiempoMensaje = true; if (!isShowKeyboard) { if (!isShowCustomKeyboard) { messagesListScroll.setVerticalScrollBarEnabled(false); final InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } imm.showSoftInput(messageText, 0); keyboardLayout.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set.setDuration(220).start(); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); keyboardLayout.setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); isShowKeyboard = true; ((MainActivity) activity).setOnBackPressedListener(null); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; } else { keyboardLayout.setVisibility(View.GONE); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set.setDuration(220).start(); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); ((MainActivity) activity).setOnBackPressedListener(null); messagesListScroll.setVerticalScrollBarEnabled(false); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } final InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(messageText, 0); keyboardLayout.setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); isShowKeyboard = true; customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; } } break; case R.id._1: temporizadorSeek.setInitPosition(15); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._2: temporizadorSeek.setInitPosition(30); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._3: temporizadorSeek.setInitPosition(45); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._4: temporizadorSeek.setInitPosition(60); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._5: temporizadorSeek.setInitPosition(75); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._6: temporizadorSeek.setInitPosition(90); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._7: temporizadorSeek.setInitPosition(105); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._8: temporizadorSeek.setInitPosition(120); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._9: temporizadorSeek.setInitPosition(135); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._10: temporizadorSeek.setInitPosition(150); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._11: temporizadorSeek.setInitPosition(165); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id._12: temporizadorSeek.setInitPosition(180); temporizadorAcept.setVisibility(View.VISIBLE); break; case R.id.adjunt_image: System.gc(); dontClose = true; ((MainActivity) activity).dontClose = true; hideKeyBoard(); Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, 1); menuAdjunt = false; adjuntLayout.setVisibility(View.GONE); break; case R.id.adjunt_contact: System.gc(); dontClose = true; ((MainActivity) activity).dontClose = true; hideKeyBoard(); Intent i = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(i, 34); menuAdjunt = false; adjuntLayout.setVisibility(View.GONE); break; case R.id.adjunt_audio: menuAdjunt = false; adjuntLayout.setVisibility(View.GONE); SharedPreferences settings2 = getActivity().getSharedPreferences(Finder.STRING.APP_PREF.toString(), Context.MODE_PRIVATE); if (settings2.getInt("INPUTKEY", 0) != 0) { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); } if (!isShowCustomKeyboard) { if (!isShowKeyboard) { keyboardLayout.setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); } keyboardLayout.setVisibility(View.GONE); AnimatorSet set4 = new AnimatorSet(); set4.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set4.setDuration(220).start(); set4.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.VISIBLE); ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; ((MainActivity) activity).setOnBackPressedListener(null); } }); isShowCustomKeyboard = true; isShowKeyboard = false; } else { keyboardLayout.setBackgroundColor(getResources().getColor(R.color.speak_all_ligh_gray_plus)); keyboardLayout.setVisibility(View.GONE); AnimatorSet set5 = new AnimatorSet(); set5.playTogether(ObjectAnimator.ofFloat(keyboardLayout, "alpha", 0, 1)); set5.setDuration(220).start(); set5.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { keyboardLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); hideKeyBoard(); ((MainActivity) activity).setOnBackPressedListener(new BackPressedListener(activity) { @Override public void doBack() { if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; ((MainActivity) activity).setOnBackPressedListener(null); } }); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); } customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.VISIBLE); isShowCustomKeyboard = true; isShowKeyboard = false; } } else { customKeyboardLayout.setVisibility(View.GONE); if (!customKeyboardAudio.isShown()) { customKeyboardAudio.setVisibility(View.VISIBLE); if (tiempoMensaje) { messageClock.setText(Finder.STRING.ICN_TEMPORIZER_FILL.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_red)); } else { messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray)); } } else { temporizadorAcept.setVisibility(View.INVISIBLE); keyboardLayout.setVisibility(View.GONE); customKeyboardLayout.setVisibility(View.GONE); customKeyboardAudio.setVisibility(View.GONE); isShowCustomKeyboard = false; } } break; case R.id.add_to_contacts: try { JSONArray jsonArr = new JSONArray(); JSONObject jsonObj = new JSONObject(); jsonObj.put(C.c_id_contact, contact.idContacto); RequestParams params = new RequestParams(); params.put("contacts", jsonArr.put(jsonObj)); addToContacts(params); } catch (JSONException e) { e.printStackTrace(); } break; case R.id.adjunt_photo: System.gc(); dontClose = true; ((MainActivity) activity).dontClose = true; hideKeyBoard(); File imagesFolder = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + "/SpeakOn/Image/Sent"); imagesFolder.mkdirs(); adjuntLayout.setVisibility(View.GONE); dateToCamera = Calendar.getInstance().getTimeInMillis(); File image = new File(imagesFolder, dateToCamera + ".png"); Uri uriSavedImage = Uri.fromFile(image); Intent pictureActionIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); pictureActionIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage); startActivityForResult(pictureActionIntent, 23); break; case R.id.adjunt_video: System.gc(); dontClose = true; ((MainActivity) activity).dontClose = true; hideKeyBoard(); Intent videoPickerIntent = new Intent(Intent.ACTION_PICK); videoPickerIntent.setType("video/*"); startActivityForResult(videoPickerIntent, 18); menuAdjunt = false; adjuntLayout.setVisibility(View.GONE); break; case R.id.adjunt_location: adjuntLayout.setVisibility(View.GONE); hideKeyBoard(); menuAdjunt = false; milocManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); List<String> allProviders = milocManager.getAllProviders(); boolean gpsProvider = false; boolean netProvider = false; for (String providerName : allProviders) { if (providerName.equals(LocationManager.GPS_PROVIDER)) { gpsProvider = true; } if (providerName.equals(LocationManager.NETWORK_PROVIDER)) { netProvider = true; } } checkCountryLocation(gpsProvider, netProvider); break; } }