List of usage examples for android.app Activity getString
@NonNull public final String getString(@StringRes int resId)
From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java
/** * Check the data inserted into the form and it all the required fields are present, * then it adds the contact into DB/* w w w . jav a 2s . c o m*/ */ private boolean checkAndInsert() { final Activity activity = getActivity(); if (activity == null) { Log.e(TAG, "Not attached to Activity: cannot insert contact in DB"); return true; // We can close, there's nothing to do anyway } String email = null; ArrayList<String> name = new ArrayList<String>(1), organization = new ArrayList<String>(1), title = new ArrayList<String>(1); if (mNameEditText != null && mNameEditText.getText() != null) { name.add(mNameEditText.getText().toString()); } if (mEmailEditText != null && mEmailEditText.getText() != null) { email = mEmailEditText.getText().toString(); } if (mOrganizationEditText != null && mOrganizationEditText.getText() != null && TextUtils.isGraphic(mOrganizationEditText.getText())) { organization.add(mOrganizationEditText.getText().toString()); } if (mTitleEditText != null && mTitleEditText.getText() != null && TextUtils.isGraphic(mTitleEditText.getText())) { title.add(mTitleEditText.getText().toString()); } if (activity instanceof MainActivity) { final MainActivity mainActivity = (MainActivity) activity; if (!isValidEmailAddress(email)) { // Empty or invalid email field! showEmailError(activity.getString(R.string.error_emailinput_invalid), 1); return false; } if (DataHelper.isEmailAlreadyPresent(mainActivity, email)) { // We add each email only once showEmailError(activity.getString(R.string.error_emailinput_duplicate), 2); return false; } if (DataHelper.insertContact(mainActivity, name, email, organization, title)) { mainActivity.showCroutonNao(activity.getString(R.string.new_contact_added, email), Style.CONFIRM); mainActivity.updateParticipantsCount(); return true; } return false; } else { Log.e(TAG, "The parent Activity is not MainActivity! Wat is this I don't even"); if (DEBUG) Log.d(TAG, "Activity class: " + activity.getLocalClassName()); Toast.makeText(activity, activity.getString(R.string.insert_failed_wrong_parent), Toast.LENGTH_SHORT) .show(); return true; // We can close, there's nothing to do anyway } }
From source file:com.chuxin.family.widgets.CxImagePager.java
/** * // www. ja v a2s. co m * @param activity * @param imageUrl */ private void share(Activity activity, String imageUrl) { ShareSDK.initSDK(activity); CxLog.i("RkImagePager", "imageUrl=" + imageUrl); String comment = "?"; /* * * 1?qzone?texttitle?titleurl?site?siteurl * 2??title?text * */ final OnekeyShare oks = new OnekeyShare(); // qzone??(?zone?) String title = "??APP"; // if(comment==null || comment.equals("")){ // title = ""; // ?? // } // URL?? if (!TextUtils.isEmpty(imageUrl) && imageUrl.startsWith("http://")) { imageUrl = imageLoader.getFilePath(imageUrl); } oks.setNotification(R.drawable.cx_fa_app_icon, activity.getString(R.string.cx_fa_role_app_name)); oks.setTitle(title); oks.setTitleUrl("http://m.family.rekoo.net/dl/family"); oks.setText(comment); //oks.setImageUrl(imageUrl); oks.setImagePath(imageUrl); oks.setSilent(true); oks.setComment(comment); oks.setSite("?APP"); oks.setSiteUrl("http://m.family.rekoo.net/dl/family"); // ??Dialog? // oks.setDialogMode(); // ??OneKeyShareCallback oks.setCallback(new OneKeyShareCallback(activity)); // ???? // oks.setShareContentCustomizeCallback(new // ShareContentCustomizeDemo()); oks.show(activity); }
From source file:org.chromium.chrome.browser.payments.ui.PaymentRequestUI.java
/** * Prepares the PaymentRequestUI for initial display. * * TODO(dfalcantara): Ideally, everything related to the request and its views would just be put * into its own class but that'll require yanking out a lot of this class. * * @param activity Activity displaying the UI. * @param title Title of the page. * @param origin Host of the page.// ww w . j a va 2s . c om * @param canAddCards Whether new cards can be added. */ private void prepareRequestView(Activity activity, String title, String origin, boolean canAddCards) { mSpinnyLayout = mRequestView.findViewById(R.id.payment_request_spinny); // Indicate that we're preparing the dialog for display. TextView messageView = (TextView) mRequestView.findViewById(R.id.message); messageView.setText(R.string.payments_loading_message); ((TextView) mRequestView.findViewById(R.id.page_title)).setText(title); ((TextView) mRequestView.findViewById(R.id.hostname)).setText(origin); // Set up the buttons. mCloseButton = mRequestView.findViewById(R.id.close_button); mCloseButton.setOnClickListener(this); mPayButton = DualControlLayout.createButtonForLayout(activity, true, activity.getString(R.string.payments_pay_button), this); mEditButton = DualControlLayout.createButtonForLayout(activity, false, activity.getString(R.string.payments_edit_button), this); mButtonBar = (DualControlLayout) mRequestView.findViewById(R.id.button_bar); mButtonBar.setAlignment(DualControlLayout.ALIGN_END); mButtonBar.setStackedMargin( activity.getResources().getDimensionPixelSize(R.dimen.infobar_margin_between_stacked_buttons)); mButtonBar.addView(mPayButton); mButtonBar.addView(mEditButton); // Create all the possible sections. mSectionSeparators = new ArrayList<>(); mPaymentContainer = (ScrollView) mRequestView.findViewById(R.id.option_container); mPaymentContainerLayout = (LinearLayout) mRequestView.findViewById(R.id.payment_container_layout); mOrderSummarySection = new LineItemBreakdownSection(activity, activity.getString(R.string.payments_order_summary_label), this); mShippingSummarySection = new ExtraTextSection(activity, activity.getString(R.string.payments_shipping_summary_label), this); mShippingAddressSection = new OptionSection(activity, activity.getString(R.string.payments_shipping_address_label), this); mShippingOptionSection = new OptionSection(activity, activity.getString(R.string.payments_shipping_option_label), this); mContactDetailsSection = new OptionSection(activity, activity.getString(R.string.payments_contact_details_label), this); mPaymentMethodSection = new OptionSection(activity, activity.getString(R.string.payments_method_of_payment_label), this); // Some sections conditionally allow adding new options. mShippingOptionSection.setCanAddItems(false); mPaymentMethodSection.setCanAddItems(canAddCards); // Add the necessary sections to the layout. mPaymentContainerLayout.addView(mOrderSummarySection, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout)); if (mRequestShipping) { // The shipping breakout sections are only added if they are needed. mPaymentContainerLayout.addView(mShippingSummarySection, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout)); } mPaymentContainerLayout.addView(mPaymentMethodSection, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); if (mRequestContactDetails) { // Contact details are optional, depending on the merchant website. mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout)); mPaymentContainerLayout.addView(mContactDetailsSection, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } mRequestView.addOnLayoutChangeListener(new FadeInAnimator()); mRequestView.addOnLayoutChangeListener(new PeekingAnimator()); // Enabled in updatePayButtonEnabled() when the user has selected all payment options. mPayButton.setEnabled(false); }
From source file:de.azapps.mirakel.settings.model_settings.special_list.helper.SpecialListsConditionAdapter.java
public static SpecialListsConditionAdapter setUpListView(final @NonNull SpecialList list, final @NonNull DragSortListView listView, final @NonNull Activity activity, final @NonNull FragmentManager fm, final @NonNull ArrayList<Integer> backStack, @NonNull final EditDialogFragment.OnPropertyEditListener listener, @NonNull final Button add, final @NonNull List<Preference> topPrefernces) { final List<SpecialListsBaseProperty> conditions = new ArrayList<>(); final SpecialListsConjunctionList rootProperty = getRootProperty(list.getWhere(), conditions, backStack); final List<SpecialListsViewHelper> data = new ArrayList<>( Collections2.transform(topPrefernces, new Function<Preference, SpecialListsViewHelper>() { @Override/*from w w w . j a v a 2s .c om*/ public SpecialListsViewHelper apply(Preference input) { return new SpecialListsViewHelper(input, activity); } })); data.addAll(getTransformedCondition(activity, conditions)); final SpecialListsConditionAdapter adapter = new SpecialListsConditionAdapter(activity, 0, data); listView.setAdapter(adapter); listView.setDragEnabled(true); listView.setParts(topPrefernces.size()); listView.setRemoveListener(new DragSortListView.RemoveListener() { @Override public void remove(final int which) { adapter.cancleUndo(backStack); final SpecialListsBaseProperty property = adapter.getData().get(which).getCondition().get();// only conditions can be removed, so its safe to call this here final SpecialList listToSave = EditDialogFragment.execOnTree(list, backStack, new EditDialogFragment.WorkOnTree() { @Override public void onTreeExists(final int position, @NonNull final SpecialListsConjunctionList currentProperty) { currentProperty.getChilds().remove(which - adapter.preferencesCount); } @NonNull @Override public Optional<SpecialListsBaseProperty> onTreeNotExists() { return absent(); } }, 0); listToSave.save(); adapter.setNewList(listToSave, backStack); backStack.add(which - adapter.preferencesCount); if (backStack.size() < 2) { final UndoBarController.UndoBar undo = new UndoBarController.UndoBar(activity); adapter.setUndo(of(undo)); undo.message(activity.getString(R.string.Undo)) .listener(new UndoBarController.AdvancedUndoListener() { @Override public void onHide(final Parcelable parcelable) { adapter.cancleUndo(backStack); } @Override public void onClear() { } @Override public void onUndo(final Parcelable parcelable) { final SpecialList listToSave = EditDialogFragment.execOnTree(list, backStack, new EditDialogFragment.WorkOnTree() { @Override public void onTreeExists(final int position, @NonNull final SpecialListsConjunctionList currentProperty) { final List<SpecialListsBaseProperty> childs = new ArrayList<>(); final List<SpecialListsBaseProperty> oldChilds = currentProperty .getChilds(); boolean added = false; for (int j = 0; j < oldChilds.size(); j++) { if (!added && (j == backStack.get(position))) { childs.add(property); added = true; } childs.add(oldChilds.get(j)); } if (!added) { childs.add(property); } currentProperty.setChilds(childs); } @NonNull @Override public Optional<SpecialListsBaseProperty> onTreeNotExists() { return of(property); } }, 1); listToSave.save(); adapter.cancleUndo(backStack); adapter.setNewList(listToSave, backStack); } }).show(); } } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final SpecialListsViewHelper item = adapter.getItem(position); if (item.getType() == SpecialListsViewHelper.Type.CONDITION) { adapter.cancleUndo(backStack); backStack.add(position - adapter.preferencesCount); final SpecialListsBaseProperty property = item.getCondition().get(); EditDialogFragment.newInstance(list, property, backStack, listener, rootProperty).show(fm, "editdialog"); } else { final Preference pref = item.getPreference().get(); if (pref.getOnPreferenceClickListener() != null) { pref.getOnPreferenceClickListener().onPreferenceClick(pref); } } } }); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.cancleUndo(backStack); final SpecialListsDoneProperty property = new SpecialListsDoneProperty(false); backStack.add(NEW_PROPERTY); EditDialogFragment.newInstance(list, property, backStack, listener, rootProperty).show(fm, "editdialog"); } }); return adapter; }
From source file:org.xbmc.kore.utils.UIUtils.java
/** * Fills the standard cast info list, consisting of a {@link android.widget.GridLayout} * with actor images and a Textview with the name and the role of the additional cast. * The number of actor presented on the {@link android.widget.GridLayout} is controlled * through the global setting, and only actors with images are presented. * The rest are presented in the additionalCastView TextView * * @param activity Activity/* ww w . ja v a2s . c o m*/ * @param castList Cast list * @param castListView GridLayout on which too show actors that have images */ public static void setupCastInfo(final Activity activity, List<VideoType.Cast> castList, GridLayout castListView, final Intent allCastActivityLaunchIntent) { HostManager hostManager = HostManager.getInstance(activity); Resources resources = activity.getResources(); DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(displayMetrics); View.OnClickListener castListClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Utils.openImdbForPerson(activity, (String) v.getTag()); } }; castListView.removeAllViews(); int numColumns = castListView.getColumnCount(); int numRows = resources.getInteger(R.integer.cast_grid_view_rows); int maxCastPictures = numColumns * numRows; int layoutMarginPx = 2 * resources.getDimensionPixelSize(R.dimen.remote_content_hmargin); int imageMarginPx = 2 * resources.getDimensionPixelSize(R.dimen.image_grid_margin); int imageWidth = (displayMetrics.widthPixels - layoutMarginPx - numColumns * imageMarginPx) / numColumns; int imageHeight = (int) (imageWidth * 1.5); for (int i = 0; i < Math.min(castList.size(), maxCastPictures); i++) { VideoType.Cast actor = castList.get(i); View castView = LayoutInflater.from(activity).inflate(R.layout.grid_item_cast, castListView, false); ImageView castPicture = (ImageView) castView.findViewById(R.id.picture); TextView castName = (TextView) castView.findViewById(R.id.name); TextView castRole = (TextView) castView.findViewById(R.id.role); castView.getLayoutParams().width = imageWidth; castView.getLayoutParams().height = imageHeight; castView.setTag(actor.name); UIUtils.loadImageWithCharacterAvatar(activity, hostManager, actor.thumbnail, actor.name, castPicture, imageWidth, imageHeight); if ((i == maxCastPictures - 1) && (castList.size() > i + 1)) { View castNameGroup = castView.findViewById(R.id.cast_name_group); View allCastGroup = castView.findViewById(R.id.all_cast_group); TextView remainingCastCount = (TextView) castView.findViewById(R.id.remaining_cast_count); castNameGroup.setVisibility(View.GONE); allCastGroup.setVisibility(View.VISIBLE); remainingCastCount.setText(String.format(activity.getString(R.string.remaining_cast_count), castList.size() - maxCastPictures + 1)); castView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { activity.startActivity(allCastActivityLaunchIntent); activity.overridePendingTransition(R.anim.activity_in, R.anim.activity_out); } }); } else { castName.setText(actor.name); castRole.setText(actor.role); castView.setOnClickListener(castListClickListener); } castListView.addView(castView); } }
From source file:jp.mixi.android.sdk.MixiContainerImpl.java
@Override public void requestPayment(final Activity activity, final PaymentParameter param, final int activityCode, final CallbackListener listener) { mPaymentCallbackListener = listener; mPaymentRequestCode = activityCode;//from ww w . java2 s. c o m if (!validatePaymentParam(param)) { listener.onError(new ErrorInfo("parameter invalid", ErrorInfo.OTHER_ERROR)); return; } Intent intent = new Intent(); intent.setClassName(OFFICIAL_PACKAGE, PAYMENT_ACTIVITY); intent.putExtras(convertPaymentBundle(param)); if (!validateOfficialAppsForIntent(activity, intent, VALIDATE_OFFICIAL_FOR_ACTIVITY, PAYMENT_SUPPORTED_VERSION)) { listener.onFatal(new ErrorInfo(activity.getString(R.string.err_unsupported_versions), ErrorInfo.OFFICIAL_APP_NOT_FOUND)); return; } try { activity.startActivityForResult(intent, activityCode); } catch (ActivityNotFoundException e) { Log.v(TAG, e.getMessage()); listener.onFatal(new ErrorInfo(e)); } }
From source file:com.pemikir.youtubeplus.VideoItemDetailFragment.java
public void updateInfo(VideoInfo info) { Activity a = getActivity(); try {/* w ww .j ava2 s. c o m*/ ProgressBar progressBar = (ProgressBar) a.findViewById(R.id.detailProgressBar); TextView videoTitleView = (TextView) a.findViewById(R.id.detailVideoTitleView); TextView uploaderView = (TextView) a.findViewById(R.id.detailUploaderView); TextView viewCountView = (TextView) a.findViewById(R.id.detailViewCountView); TextView thumbsUpView = (TextView) a.findViewById(R.id.detailThumbsUpCountView); TextView thumbsDownView = (TextView) a.findViewById(R.id.detailThumbsDownCountView); TextView uploadDateView = (TextView) a.findViewById(R.id.detailUploadDateView); TextView descriptionView = (TextView) a.findViewById(R.id.detailDescriptionView); ImageView thumbnailView = (ImageView) a.findViewById(R.id.detailThumbnailView); ImageView uploaderThumbnailView = (ImageView) a.findViewById(R.id.detailUploaderThumbnailView); ImageView thumbsUpPic = (ImageView) a.findViewById(R.id.detailThumbsUpImgView); ImageView thumbsDownPic = (ImageView) a.findViewById(R.id.detailThumbsDownImgView); View textSeperationLine = a.findViewById(R.id.textSeperationLine); if (textSeperationLine != null) { textSeperationLine.setVisibility(View.VISIBLE); } progressBar.setVisibility(View.GONE); videoTitleView.setVisibility(View.VISIBLE); uploaderView.setVisibility(View.VISIBLE); uploadDateView.setVisibility(View.VISIBLE); viewCountView.setVisibility(View.VISIBLE); thumbsUpView.setVisibility(View.VISIBLE); thumbsDownView.setVisibility(View.VISIBLE); uploadDateView.setVisibility(View.VISIBLE); descriptionView.setVisibility(View.VISIBLE); thumbnailView.setVisibility(View.VISIBLE); uploaderThumbnailView.setVisibility(View.VISIBLE); thumbsUpPic.setVisibility(View.VISIBLE); thumbsDownPic.setVisibility(View.VISIBLE); switch (info.videoAvailableStatus) { case VideoInfo.VIDEO_AVAILABLE: { videoTitleView.setText(info.title); uploaderView.setText(info.uploader); viewCountView.setText(info.view_count + " " + a.getString(R.string.viewSufix)); thumbsUpView.setText(info.like_count); thumbsDownView.setText(info.dislike_count); uploadDateView.setText(a.getString(R.string.uploadDatePrefix) + " " + info.upload_date); descriptionView.setText(Html.fromHtml(info.description)); descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); ActionBarHandler.getHandler().setVideoInfo(info.webpage_url, info.title); // parse streams Vector<VideoInfo.VideoStream> streamsToUse = new Vector<>(); for (VideoInfo.VideoStream i : info.videoStreams) { if (useStream(i, streamsToUse)) { streamsToUse.add(i); } } VideoInfo.VideoStream[] streamList = new VideoInfo.VideoStream[streamsToUse.size()]; for (int i = 0; i < streamList.length; i++) { streamList[i] = streamsToUse.get(i); } ActionBarHandler.getHandler().setStreams(streamList, info.audioStreams); } break; case VideoInfo.VIDEO_UNAVAILABLE_GEMA: thumbnailView.setImageBitmap( BitmapFactory.decodeResource(getResources(), R.drawable.gruese_die_gema_unangebracht)); break; case VideoInfo.VIDEO_UNAVAILABLE: thumbnailView.setImageBitmap( BitmapFactory.decodeResource(getResources(), R.drawable.not_available_monkey)); break; default: Log.e(TAG, "Video Availeble Status not known."); } if (autoPlayEnabled) { ActionBarHandler.getHandler().playVideo(); } } catch (java.lang.NullPointerException e) { Log.w(TAG, "updateInfo(): Fragment closed before thread ended work... or else"); e.printStackTrace(); } }
From source file:im.vector.activity.VectorRoomActivity.java
/** * Start an IP call: audio call if aIsVideoCall is false or video call if aIsVideoCall * is true./*from ww w . j a v a2 s . co m*/ * @param aIsVideoCall true to video call, false to audio call */ private void startIpCall(final boolean aIsVideoCall) { enableActionBarHeader(HIDE_ACTION_BAR_HEADER); setProgressVisibility(View.VISIBLE); // create the call object mSession.mCallsManager.createCallInRoom(mRoom.getRoomId(), new ApiCallback<IMXCall>() { @Override public void onSuccess(final IMXCall call) { Log.d(LOG_TAG, "## startIpCall(): onSuccess"); VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { setProgressVisibility(View.GONE); call.setIsVideo(aIsVideoCall); call.setIsIncoming(false); final Intent intent = new Intent(VectorRoomActivity.this, VectorCallViewActivity.class); intent.putExtra(VectorCallViewActivity.EXTRA_MATRIX_ID, mSession.getCredentials().userId); intent.putExtra(VectorCallViewActivity.EXTRA_CALL_ID, call.getCallId()); VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { VectorRoomActivity.this.startActivity(intent); } }); } }); } private void onError() { VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { setProgressVisibility(View.GONE); Activity activity = VectorRoomActivity.this; CommonActivityUtils.displayToastOnUiThread(activity, activity.getString(R.string.cannot_start_call)); } }); } @Override public void onNetworkError(Exception e) { Log.e(LOG_TAG, "## startIpCall(): onNetworkError Msg=" + e.getMessage()); onError(); } @Override public void onMatrixError(MatrixError e) { Log.e(LOG_TAG, "## startIpCall(): onMatrixError Msg=" + e.getLocalizedMessage()); onError(); } @Override public void onUnexpectedError(Exception e) { Log.e(LOG_TAG, "## startIpCall(): onUnexpectedError Msg=" + e.getLocalizedMessage()); onError(); } }); }
From source file:com.nbplus.hybrid.BasicWebViewClient.java
/** * ??.//w ww. jav a 2 s. c o m * @param activity : context * @param view : ?? */ public BasicWebViewClient(Activity activity, WebView view, String alertTitleString, String confirmTitleString) { mWebView = view; mContext = activity; // This will handle downloading. It requires Gingerbread, though mDownloadManager = (DownloadManager) mContext.getSystemService(mContext.DOWNLOAD_SERVICE); mWebChromeClient = new BroadcastWebChromeClient(); // Enable remote debugging via chrome://inspect if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { mWebView.setWebContentsDebuggingEnabled(true); } mWebView.setWebChromeClient(mWebChromeClient); WebSettings webSettings = mWebView.getSettings(); webSettings.setGeolocationEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); // Use WideViewport and Zoom out if there is no viewport defined webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { webSettings.setMediaPlaybackRequiresUserGesture(false); } // Enable pinch to zoom without the zoom buttons webSettings.setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { // Hide the zoom controls for HONEYCOMB+ webSettings.setDisplayZoomControls(false); } webSettings.setAppCacheEnabled(true); mWebView.clearCache(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Sets whether the WebView should allow third party cookies to be set. // Allowing third party cookies is a per WebView policy and can be set differently on different WebView instances. // Apps that target KITKAT or below default to allowing third party cookies. // Apps targeting LOLLIPOP or later default to disallowing third party cookies. CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.setAcceptThirdPartyCookies(mWebView, true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mWebView.getSettings().setTextZoom(100); } if (StringUtils.isEmptyString(alertTitleString)) { mAlertTitleString = activity.getString(R.string.default_webview_alert_title); } else { mAlertTitleString = alertTitleString; } if (StringUtils.isEmptyString(confirmTitleString)) { mConfirmTitleString = activity.getString(R.string.default_webview_confirm_title); } else { mConfirmTitleString = confirmTitleString; } mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); mContext.startActivity(intent); } }); Log.d(TAG, ">> user agent = " + mWebView.getSettings().getUserAgentString()); }
From source file:im.neon.activity.VectorRoomActivity.java
/** * Start an IP call: audio call if aIsVideoCall is false or video call if aIsVideoCall * is true.// w ww.j av a 2s .c o m * * @param aIsVideoCall true to video call, false to audio call */ private void startIpCall(final boolean aIsVideoCall) { enableActionBarHeader(HIDE_ACTION_BAR_HEADER); setProgressVisibility(View.VISIBLE); // create the call object mSession.mCallsManager.createCallInRoom(mRoom.getRoomId(), new ApiCallback<IMXCall>() { @Override public void onSuccess(final IMXCall call) { Log.d(LOG_TAG, "## startIpCall(): onSuccess"); VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { setProgressVisibility(View.GONE); call.setIsVideo(aIsVideoCall); call.setIsIncoming(false); final Intent intent = new Intent(VectorRoomActivity.this, VectorCallViewActivity.class); intent.putExtra(VectorCallViewActivity.EXTRA_MATRIX_ID, mSession.getCredentials().userId); intent.putExtra(VectorCallViewActivity.EXTRA_CALL_ID, call.getCallId()); VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { VectorRoomActivity.this.startActivity(intent); } }); } }); } private void onError(final String errorMessage) { VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { setProgressVisibility(View.GONE); Activity activity = VectorRoomActivity.this; CommonActivityUtils.displayToastOnUiThread(activity, activity.getString(R.string.cannot_start_call) + " (" + errorMessage + ")"); } }); } @Override public void onNetworkError(Exception e) { Log.e(LOG_TAG, "## startIpCall(): onNetworkError Msg=" + e.getMessage()); onError(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { Log.e(LOG_TAG, "## startIpCall(): onMatrixError Msg=" + e.getLocalizedMessage()); if (e instanceof MXCryptoError) { MXCryptoError cryptoError = (MXCryptoError) e; if (MXCryptoError.UNKNOWN_DEVICES_CODE.equals(cryptoError.errcode)) { setProgressVisibility(View.GONE); CommonActivityUtils.displayUnknownDevicesDialog(mSession, VectorRoomActivity.this, (MXUsersDevicesMap<MXDeviceInfo>) cryptoError.mExceptionData, new VectorUnknownDevicesFragment.IUnknownDevicesSendAnywayListener() { @Override public void onSendAnyway() { startIpCall(aIsVideoCall); } }); return; } } onError(e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { Log.e(LOG_TAG, "## startIpCall(): onUnexpectedError Msg=" + e.getLocalizedMessage()); onError(e.getLocalizedMessage()); } }); }