List of usage examples for android.webkit WebSettings setBlockNetworkImage
public abstract void setBlockNetworkImage(boolean flag);
From source file:net.niyonkuru.koodroid.webview.BlockingWebView.java
public static BlockingWebView createInstance(Context ctx) { BlockingWebView view = new BlockingWebView(ctx); WebSettings websettings = view.getSettings(); websettings.setJavaScriptEnabled(true); websettings.setDatabaseEnabled(false); websettings.setDomStorageEnabled(false); websettings.setSupportZoom(false);//ww w . java 2s.co m websettings.setSavePassword(false); websettings.setSupportMultipleWindows(false); websettings.setAppCacheEnabled(false); websettings.setCacheMode(WebSettings.LOAD_NO_CACHE); websettings.setBlockNetworkImage(true); return view; }
From source file:in.rab.bildkort.ImageFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override// ww w . j a v a2 s. c o m public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mWebView = (WebView) getView().findViewById(R.id.webView); final ProgressBar progress = (ProgressBar) getView().findViewById(R.id.image_progress); mWebView.setWebChromeClient(new WebChromeClient()); final WebSettings settings = mWebView.getSettings(); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setJavaScriptEnabled(true); // We replace the src urls in imagepicker.js::init(), so don't load // images twice. settings.setBlockNetworkImage(true); mWebView.setInitialScale(100); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { if (Objects.equals(url, GSTATIC_SERVER)) { settings.setBlockNetworkImage(false); progress.setVisibility(View.GONE); mWebView.setVisibility(View.VISIBLE); } else { view.loadUrl("javascript:" + getImagePickerJs() + "getPickerHtml();"); } } }); mWebView.addJavascriptInterface(new WcmJsObject(), "wcm"); mWebView.loadUrl("https://www.google.se/search?tbm=isch&q=" + getWord()); }
From source file:com.mobicage.rogerthat.FriendDetailActivity.java
private void showBrandedDescription(FriendTO friend) { if (friend.description == null || TextUtils.isEmptyOrWhitespace(friend.descriptionBranding)) return;/*from w w w .j a v a 2 s . com*/ BrandingResult br = null; try { FriendsPlugin plugin = mService.getPlugin(FriendsPlugin.class); br = plugin.getBrandingMgr().prepareBranding(friend); } catch (BrandingFailureException e) { L.bug("Could not display service detail with branding.", e); return; } mDescriptionView.setVisibility(View.GONE); if (br.displayType == BrandingMgr.DisplayType.NATIVE) { ServiceHeader.setupNative(mService, br, mHeaderContainer); mWebview.setVisibility(View.GONE); } else { WebSettings settings = mWebview.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); mWebview.loadUrl("file://" + br.file.getAbsolutePath()); mWebview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); mWebview.setVisibility(View.VISIBLE); } if (br.color == null) { mTopArea.setBackgroundResource(R.color.mc_background_color); mPokeArea.setBackgroundResource(R.color.mc_background_color); } else { mTopArea.setBackgroundColor(br.color); mPokeArea.setBackgroundColor(br.color); } int r = br.scheme == ColorScheme.LIGHT ? android.R.color.primary_text_light : android.R.color.primary_text_dark; ((TextView) findViewById(R.id.friend_name)).setTextColor(ContextCompat.getColor(this, r)); ((TextView) findViewById(R.id.email)).setTextColor(ContextCompat.getColor(this, r)); }
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
@SuppressLint("SetJavaScriptEnabled") public void loadContent() { final WebSettings settings = webView.getSettings(); settings.setDefaultTextEncodingName(HTTP.UTF_8); settings.setJavaScriptEnabled(true); settings.setDefaultFontSize(fontSize); settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); settings.setRenderPriority(RenderPriority.LOW); final StringBuffer content = new StringBuffer(); if (item.getState().isCached()) { settings.setBlockNetworkImage(true); content.append(DataUtils.readFromFile(new File(item.getFullContentStoragePath()))); } else {// www . j a va2s .c om final SettingImageFetching sImgFetch = new SettingImageFetching(dataMgr); if (NetworkUtils.checkImageFetchingNetworkStatus(context, sImgFetch.getData())) { settings.setBlockNetworkImage(false); content.append(DataUtils.readFromFile(new File(item.getOriginalContentStoragePath()))); } else { settings.setBlockNetworkImage(true); content.append(DataUtils.readFromFile(new File(item.getStrippedContentStoragePath()))); } } content.append(DataUtils.DEFAULT_JS); content.append( theme == SettingTheme.THEME_NORMAL ? DataUtils.DEFAULT_NORMAL_CSS : DataUtils.DEFAULT_DARK_CSS); webView.loadDataWithBaseURL("file://" + item.getStoragePath() + "/", content.toString(), null, "utf-8", null); }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java
private void populateScreen(final ServiceMenu menu) { menuBrandingHash = menu.branding;//from ww w .jav a 2s . c o m final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class); final MessagingPlugin messagingPlugin = mService.getPlugin(MessagingPlugin.class); final FriendStore store = friendsPlugin.getStore(); List<Cell> usedCells = new ArrayList<Cell>(); if (page == 0) { addAboutHandler(usedCells, menu.aboutLabel); addHistoryHandler(usedCells, store, menu.messagesLabel); addCallHandler(menu, usedCells, menu.callLabel); if (CloudConstants.isYSAAA()) { addScanHandler(menu, usedCells, null); } else { addShareHandler(menu, usedCells, menu.shareLabel); } } boolean[] rows = new boolean[] { false, false, false }; if (page == 0) rows[0] = true; for (final ServiceMenuItem item : menu.itemList) { rows[(int) item.coords[1]] = true; final Cell cell = cells[(int) item.coords[0]][(int) item.coords[1]]; View.OnClickListener onClickListener = new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { pressMenuItem(menu, messagingPlugin, store, item); } }; ((View) cell.icon.getParent()).setOnClickListener(onClickListener); cell.icon.setImageBitmap(BitmapFactory.decodeByteArray(item.icon, 0, item.icon.length)); cell.icon.setVisibility(View.VISIBLE); cell.label.setText(item.label); cell.label.setVisibility(View.VISIBLE); usedCells.add(cell); } for (int i = 2; i >= 0; i--) { if (rows[i]) break; tableRows[i].setVisibility(View.GONE); } boolean showBranded = false; boolean useDarkScheme = false; Integer menuItemColor = null; if (menu.branding != null) { try { BrandingMgr brandingMgr = messagingPlugin.getBrandingMgr(); Friend friend = store.getExistingFriend(email); if (brandingMgr.isBrandingAvailable(menu.branding)) { BrandingResult br = brandingMgr.prepareBranding(menu.branding, friend, false); WebSettings settings = branding.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); branding.setVisibility(View.VISIBLE); branding.setVerticalScrollBarEnabled(false); final int displayWidth = UIUtils.getDisplayWidth(this); final int calculatedHeight = BrandingMgr.calculateHeight(br, displayWidth); final long start = System.currentTimeMillis(); branding.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { int height = branding.getMeasuredHeight(); if (height > calculatedHeight * 90 / 100 || System.currentTimeMillis() - start > 3000) { if (calculatedHeight > 0) { setBrandingHeight(height); } else { mService.postDelayedOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { setBrandingHeight(branding.getMeasuredHeight()); } }, 100); } branding.getViewTreeObserver().removeOnPreDrawListener(this); } return false; } }); branding.loadUrl("file://" + br.file.getAbsolutePath()); if (br.color != null) { branding.setBackgroundColor(br.color); activity.setBackgroundColor(br.color); } if (br.scheme == ColorScheme.dark) { for (Cell cell : usedCells) { cell.label.setTextColor(darkSchemeTextColor); cell.label.setShadowLayer(2, 1, 1, Color.BLACK); } useDarkScheme = true; } menuItemColor = br.menuItemColor; final ImageView watermarkView = (ImageView) findViewById(R.id.watermark); if (br.watermark != null) { BitmapDrawable watermark = new BitmapDrawable(getResources(), BitmapFactory.decodeFile(br.watermark.getAbsolutePath())); watermark.setGravity(Gravity.BOTTOM | Gravity.RIGHT); watermarkView.setImageDrawable(watermark); final LayoutParams layoutParams = watermarkView.getLayoutParams(); layoutParams.width = layoutParams.height = displayWidth; } else { watermarkView.setImageDrawable(null); } showBranded = true; } else { friend.actionMenu = menu; friend.actionMenu.items = menu.itemList.toArray(new ServiceMenuItemTO[] {}); brandingMgr.queue(friend); } } catch (BrandingFailureException e) { L.bug("Could not display service action menu with branding.", e); } } if (!showBranded) { setNavigationBarVisible(AppConstants.SHOW_NAV_HEADER); setNavigationBarTitle(menu.name); title.setVisibility(View.GONE); title.setText(menu.name); } for (final Cell cell : usedCells) { final View p = (View) cell.icon.getParent(); final Drawable d = getResources().getDrawable( useDarkScheme ? R.drawable.mc_smi_background_light : R.drawable.mc_smi_background_dark); p.setBackgroundDrawable(d); } if (menuItemColor == null) menuItemColor = Color.parseColor("#646464"); for (Cell cell : new Cell[] { cells[0][0], cells[1][0], cells[2][0], cells[3][0] }) cell.faIcon.setTextColor(menuItemColor); if (menu.maxPage > 0) { for (int i = 0; i <= menu.maxPage; i++) { ImageView bolleke = (ImageView) getLayoutInflater().inflate(R.layout.page, pages, false); if (page == i) { if (useDarkScheme) { bolleke.setImageResource(R.drawable.current_page_dark); } else { bolleke.setImageResource(R.drawable.current_page_light); } } else { if (useDarkScheme) { bolleke.setImageResource(R.drawable.other_page_dark); } else { bolleke.setImageResource(R.drawable.other_page_light); } } pages.addView(bolleke); } pages.setVisibility(View.VISIBLE); } final int leftPage = page - 1; final int rightPage = page + 1; final String service = email; Slider instance = new Slider(this, this, page == menu.maxPage ? null : new Slider.Swiper() { @Override public Intent onSwipe() { return new Intent(ServiceActionMenuActivity.this, ServiceActionMenuActivity.class) .putExtra(SERVICE_EMAIL, service).putExtra(MENU_PAGE, rightPage); } }, page == 0 ? null : new Slider.Swiper() { @Override public Intent onSwipe() { return new Intent(ServiceActionMenuActivity.this, ServiceActionMenuActivity.class) .putExtra(SERVICE_EMAIL, service).putExtra(MENU_PAGE, leftPage); } }); mGestureScanner = new GestureDetector(this, instance); }
From source file:com.mobicage.rogerthat.plugins.friends.ActionScreenActivity.java
@SuppressWarnings("deprecation") @SuppressLint({ "SetJavaScriptEnabled", "Wakelock" }) private void displayBranding() { try {// w ww .j a v a2s. c om mServiceFriend = mFriendsPlugin.getStore().getExistingFriend(mServiceEmail); mBrandingResult = mMessagingPlugin.getBrandingMgr().prepareBranding(mBrandingKey, mServiceFriend, true); WebSettings settings = mBranding.getSettings(); settings.setJavaScriptEnabled(true); settings.setBlockNetworkImage(false); String fileOnDisk = "file://" + mBrandingResult.file.getAbsolutePath(); if (mBrandingResult.contentType != null && AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(mBrandingResult.contentType)) { mIsHtmlContent = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { settings.setAllowUniversalAccessFromFileURLs(true); } mBranding.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + fileOnDisk); } else { mIsHtmlContent = true; mBranding.loadUrl(fileOnDisk); mBranding.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (mBrandingResult.color != null) { mBranding.setBackgroundColor(mBrandingResult.color); } } mWakelockEnabled = mBrandingResult.wakelockEnabeld; L.d("wakelockEnabeld: " + mWakelockEnabled); if (mWakelockEnabled && mWakeLock == null) { mWakeLock = newWakeLock(); L.d("Acquiring wakelock " + mWakeLock.hashCode()); mWakeLock.acquire(); } else if (mWakeLock != null && !mWakelockEnabled) { mWakeLock.release(); } } catch (BrandingFailureException e) { UIUtils.showLongToast(this, getString(R.string.failed_to_show_action_screen)); finish(); mMessagingPlugin.getBrandingMgr().queue(mServiceFriend); L.e("Could not display menu item with screen branding.", e); return; } }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
protected void updateMessageDetail(final boolean isUpdate) { T.UI();/*from w w w. ja va 2 s.c o m*/ // Set sender avatar ImageView avatarImage = (ImageView) findViewById(R.id.avatar); String sender = mCurrentMessage.sender; setAvatar(avatarImage, sender); // Set sender name TextView senderView = (TextView) findViewById(R.id.sender); final String senderName = mFriendsPlugin.getName(sender); senderView.setText(senderName == null ? sender : senderName); // Set timestamp TextView timestampView = (TextView) findViewById(R.id.timestamp); timestampView.setText(TimeUtils.getDayTimeStr(this, mCurrentMessage.timestamp * 1000)); // Set clickable region on top to go to friends detail final RelativeLayout messageHeader = (RelativeLayout) findViewById(R.id.message_header); messageHeader.setOnClickListener(getFriendDetailOnClickListener(mCurrentMessage.sender)); messageHeader.setVisibility(View.VISIBLE); // Set message TextView messageView = (TextView) findViewById(R.id.message); WebView web = (WebView) findViewById(R.id.webview); FrameLayout flay = (FrameLayout) findViewById(R.id.message_details); Resources resources = getResources(); flay.setBackgroundColor(resources.getColor(R.color.mc_background)); boolean showBranded = false; int darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark); int lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light); senderView.setTextColor(lightSchemeTextColor); timestampView.setTextColor(lightSchemeTextColor); BrandingResult br = null; if (!TextUtils.isEmptyOrWhitespace(mCurrentMessage.branding)) { boolean brandingAvailable = false; try { brandingAvailable = mMessagingPlugin.getBrandingMgr().isBrandingAvailable(mCurrentMessage.branding); } catch (BrandingFailureException e1) { L.d(e1); } try { if (brandingAvailable) { br = mMessagingPlugin.getBrandingMgr().prepareBranding(mCurrentMessage); WebSettings settings = web.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); web.loadUrl("file://" + br.file.getAbsolutePath()); web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (br.color != null) { flay.setBackgroundColor(br.color); } if (!br.showHeader) { messageHeader.setVisibility(View.GONE); MarginLayoutParams mlp = (MarginLayoutParams) web.getLayoutParams(); mlp.setMargins(0, 0, 0, mlp.bottomMargin); } else if (br.scheme == ColorScheme.dark) { senderView.setTextColor(darkSchemeTextColor); timestampView.setTextColor(darkSchemeTextColor); } showBranded = true; } else { mMessagingPlugin.getBrandingMgr().queueGenericBranding(mCurrentMessage.branding); } } catch (BrandingFailureException e) { L.bug("Could not display message with branding: branding is available, but prepareBranding failed", e); } } if (showBranded) { web.setVisibility(View.VISIBLE); messageView.setVisibility(View.GONE); } else { web.setVisibility(View.GONE); messageView.setVisibility(View.VISIBLE); messageView.setText(mCurrentMessage.message); } // Add list of members who did not ack yet FlowLayout memberSummary = (FlowLayout) findViewById(R.id.member_summary); memberSummary.removeAllViews(); SortedSet<MemberStatusTO> memberSummarySet = new TreeSet<MemberStatusTO>(getMemberstatusComparator()); for (MemberStatusTO ms : mCurrentMessage.members) { if ((ms.status & MessagingPlugin.STATUS_ACKED) != MessagingPlugin.STATUS_ACKED && !ms.member.equals(mCurrentMessage.sender)) { memberSummarySet.add(ms); } } FlowLayout.LayoutParams flowLP = new FlowLayout.LayoutParams(2, 0); for (MemberStatusTO ms : memberSummarySet) { FrameLayout fl = new FrameLayout(this); fl.setLayoutParams(flowLP); memberSummary.addView(fl); fl.addView(createParticipantView(ms)); } memberSummary.setVisibility(memberSummarySet.size() < 2 ? View.GONE : View.VISIBLE); // Add members statuses final LinearLayout members = (LinearLayout) findViewById(R.id.members); members.removeAllViews(); final String myEmail = mService.getIdentityStore().getIdentity().getEmail(); boolean isMember = false; mSomebodyAnswered = false; for (MemberStatusTO ms : mCurrentMessage.members) { boolean showMember = true; View view = getLayoutInflater().inflate(R.layout.message_member_detail, null); // Set receiver avatar RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.avatar); rl.addView(createParticipantView(ms)); // Set receiver name TextView receiverView = (TextView) view.findViewById(R.id.receiver); final String memberName = mFriendsPlugin.getName(ms.member); receiverView.setText(memberName == null ? sender : memberName); // Set received timestamp TextView receivedView = (TextView) view.findViewById(R.id.received_timestamp); if ((ms.status & MessagingPlugin.STATUS_RECEIVED) == MessagingPlugin.STATUS_RECEIVED) { final String humanTime = TimeUtils.getDayTimeStr(this, ms.received_timestamp * 1000); if (ms.member.equals(mCurrentMessage.sender)) receivedView.setText(getString(R.string.sent_at, humanTime)); else receivedView.setText(getString(R.string.received_at, humanTime)); } else { receivedView.setText(R.string.not_yet_received); } // Set replied timestamp TextView repliedView = (TextView) view.findViewById(R.id.acked_timestamp); if ((ms.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED) { mSomebodyAnswered = true; String acked_timestamp = TimeUtils.getDayTimeStr(this, ms.acked_timestamp * 1000); if (ms.button_id != null) { ButtonTO button = null; for (ButtonTO b : mCurrentMessage.buttons) { if (b.id.equals(ms.button_id)) { button = b; break; } } if (button == null) { repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); } else { repliedView.setText(getString(R.string.replied_at, button.caption, acked_timestamp)); } } else { if (ms.custom_reply == null) { // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); } else repliedView.setText(getString(R.string.replied_at, ms.custom_reply, acked_timestamp)); } } else { repliedView.setText(R.string.not_yet_replied); showMember = !ms.member.equals(mCurrentMessage.sender); } if (br != null && br.scheme == ColorScheme.dark) { receiverView.setTextColor(darkSchemeTextColor); receivedView.setTextColor(darkSchemeTextColor); repliedView.setTextColor(darkSchemeTextColor); } else { receiverView.setTextColor(lightSchemeTextColor); receivedView.setTextColor(lightSchemeTextColor); repliedView.setTextColor(lightSchemeTextColor); } if (showMember) members.addView(view); isMember |= ms.member.equals(myEmail); } boolean isLocked = (mCurrentMessage.flags & MessagingPlugin.FLAG_LOCKED) == MessagingPlugin.FLAG_LOCKED; boolean canEdit = isMember && !isLocked; // Add attachments LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachment_layout); attachmentLayout.removeAllViews(); if (mCurrentMessage.attachments.length > 0) { attachmentLayout.setVisibility(View.VISIBLE); for (final AttachmentTO attachment : mCurrentMessage.attachments) { View v = getLayoutInflater().inflate(R.layout.attachment_item, null); ImageView attachment_image = (ImageView) v.findViewById(R.id.attachment_image); if (AttachmentViewerActivity.CONTENT_TYPE_JPEG.equalsIgnoreCase(attachment.content_type) || AttachmentViewerActivity.CONTENT_TYPE_PNG.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_img); } else if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_pdf); } else if (AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4 .equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_video); } else { attachment_image.setImageResource(R.drawable.attachment_unknown); L.d("attachment.content_type not known: " + attachment.content_type); } TextView attachment_text = (TextView) v.findViewById(R.id.attachment_text); attachment_text.setText(attachment.name); v.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { String downloadUrlHash = mMessagingPlugin .attachmentDownloadUrlHash(attachment.download_url); File attachmentsDir; try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), null); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } boolean attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); if (!attachmentAvailable) { try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), mCurrentMessage.key); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); } if (!mService.getNetworkConnectivityManager().isConnected() && !attachmentAvailable) { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(R.string.no_internet_connection_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } if (IOUtils.shouldCheckExternalStorageAvailable()) { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // Its all oke } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { if (!attachmentAvailable) { L.d("Unable to write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } else { L.d("Unable to read or write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } L.d("attachment.content_type: " + attachment.content_type); L.d("attachment.download_url: " + attachment.download_url); L.d("attachment.name: " + attachment.name); L.d("attachment.size: " + attachment.size); if (AttachmentViewerActivity.supportsContentType(attachment.content_type)) { Intent i = new Intent(ServiceMessageDetailActivity.this, AttachmentViewerActivity.class); i.putExtra("thread_key", mCurrentMessage.getThreadKey()); i.putExtra("message", mCurrentMessage.key); i.putExtra("content_type", attachment.content_type); i.putExtra("download_url", attachment.download_url); i.putExtra("name", attachment.name); i.putExtra("download_url_hash", downloadUrlHash); startActivity(i); } else { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(getString(R.string.attachment_can_not_be_displayed_in_your_version, getString(R.string.app_name))); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } }); attachmentLayout.addView(v); } } else { attachmentLayout.setVisibility(View.GONE); } LinearLayout widgetLayout = (LinearLayout) findViewById(R.id.widget_layout); if (mCurrentMessage.form == null) { widgetLayout.setVisibility(View.GONE); } else { widgetLayout.setVisibility(View.VISIBLE); widgetLayout.setEnabled(canEdit); displayWidget(widgetLayout, br); } // Add buttons TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons); tableLayout.removeAllViews(); for (final ButtonTO button : mCurrentMessage.buttons) { addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.form == null && (mCurrentMessage.flags & MessagingPlugin.FLAG_ALLOW_DISMISS) == MessagingPlugin.FLAG_ALLOW_DISMISS) { ButtonTO button = new ButtonTO(); button.caption = "Roger that!"; addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.broadcast_type != null) { L.d("Show broadcast spam control"); final RelativeLayout broadcastSpamControl = (RelativeLayout) findViewById(R.id.broadcast_spam_control); View broadcastSpamControlBorder = findViewById(R.id.broadcast_spam_control_border); final View broadcastSpamControlDivider = findViewById(R.id.broadcast_spam_control_divider); final LinearLayout broadcastSpamControlTextContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_text_container); TextView broadcastSpamControlText = (TextView) findViewById(R.id.broadcast_spam_control_text); final LinearLayout broadcastSpamControlSettingsContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_settings_container); TextView broadcastSpamControlSettingsText = (TextView) findViewById( R.id.broadcast_spam_control_settings_text); TextView broadcastSpamControlIcon = (TextView) findViewById(R.id.broadcast_spam_control_icon); broadcastSpamControlIcon.setTypeface(mFontAwesomeTypeFace); broadcastSpamControlIcon.setText(R.string.fa_bell); final FriendBroadcastInfo fbi = mFriendsPlugin.getFriendBroadcastFlowForMfr(mCurrentMessage.sender); if (fbi == null) { L.bug("BroadcastData was null for: " + mCurrentMessage.sender); collapseDetails(DETAIL_SECTIONS); return; } broadcastSpamControl.setVisibility(View.VISIBLE); broadcastSpamControlSettingsContainer.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { L.d("goto broadcast settings"); PressMenuIconRequestTO request = new PressMenuIconRequestTO(); request.coords = fbi.coords; request.static_flow_hash = fbi.staticFlowHash; request.hashed_tag = fbi.hashedTag; request.generation = fbi.generation; request.service = mCurrentMessage.sender; mContext = "MENU_" + UUID.randomUUID().toString(); request.context = mContext; request.timestamp = System.currentTimeMillis() / 1000; showTransmitting(null); Map<String, Object> userInput = new HashMap<String, Object>(); userInput.put("request", request.toJSONMap()); userInput.put("func", "com.mobicage.api.services.pressMenuItem"); MessageFlowRun mfr = new MessageFlowRun(); mfr.staticFlowHash = fbi.staticFlowHash; try { JsMfr.executeMfr(mfr, userInput, mService, true); } catch (EmptyStaticFlowException ex) { completeTransmit(null); AlertDialog.Builder builder = new AlertDialog.Builder(ServiceMessageDetailActivity.this); builder.setMessage(ex.getMessage()); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } } }); UIUtils.showHint(this, mService, HINT_BROADCAST, R.string.hint_broadcast, mCurrentMessage.broadcast_type, mFriendsPlugin.getName(mCurrentMessage.sender)); broadcastSpamControlText .setText(getString(R.string.broadcast_subscribed_to, mCurrentMessage.broadcast_type)); broadcastSpamControlSettingsText.setText(fbi.label); int ligthAlpha = 180; int darkAlpha = 70; int alpha = ligthAlpha; if (br != null && br.scheme == ColorScheme.dark) { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.black)); broadcastSpamControlBorder.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(darkSchemeTextColor); activity.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlText.setTextColor(lightSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(lightSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(lightSchemeTextColor), Color.green(lightSchemeTextColor), Color.blue(lightSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); alpha = darkAlpha; } else { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.white)); broadcastSpamControlBorder.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(lightSchemeTextColor); activity.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlText.setTextColor(darkSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(darkSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(darkSchemeTextColor), Color.green(darkSchemeTextColor), Color.blue(darkSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); } if (br != null && br.color != null) { int alphaColor = Color.argb(alpha, Color.red(br.color), Color.green(br.color), Color.blue(br.color)); broadcastSpamControl.setBackgroundColor(alphaColor); } mService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { int maxHeight = broadcastSpamControl.getHeight(); broadcastSpamControlDivider.getLayoutParams().height = maxHeight; broadcastSpamControlDivider.requestLayout(); broadcastSpamControlSettingsContainer.getLayoutParams().height = maxHeight; broadcastSpamControlSettingsContainer.requestLayout(); broadcastSpamControlTextContainer.getLayoutParams().height = maxHeight; broadcastSpamControlTextContainer.requestLayout(); int broadcastSpamControlWidth = broadcastSpamControl.getWidth(); android.view.ViewGroup.LayoutParams lp = broadcastSpamControlSettingsContainer .getLayoutParams(); lp.width = broadcastSpamControlWidth / 4; broadcastSpamControlSettingsContainer.setLayoutParams(lp); } }); } if (!isUpdate) collapseDetails(DETAIL_SECTIONS); }