List of usage examples for android.view View SCROLLBARS_INSIDE_OVERLAY
int SCROLLBARS_INSIDE_OVERLAY
To view the source code for android.view View SCROLLBARS_INSIDE_OVERLAY.
Click Source Link
From source file:com.farmerbb.taskbar.service.StartMenuService.java
@SuppressLint("RtlHardcoded") private void drawStartMenu() { IconCache.getInstance(this).clearCache(); final SharedPreferences pref = U.getSharedPreferences(this); final boolean hasHardwareKeyboard = getResources() .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS; switch (pref.getString("show_search_bar", "keyboard")) { case "always": shouldShowSearchBox = true;// ww w.jav a 2 s . com break; case "keyboard": shouldShowSearchBox = hasHardwareKeyboard; break; case "never": shouldShowSearchBox = false; break; } // Initialize layout params windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); U.setCachedRotation(windowManager.getDefaultDisplay().getRotation()); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, shouldShowSearchBox ? 0 : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT); // Determine where to show the start menu on screen switch (U.getTaskbarPosition(this)) { case "bottom_left": layoutId = R.layout.start_menu_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case "bottom_vertical_left": layoutId = R.layout.start_menu_vertical_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case "bottom_right": layoutId = R.layout.start_menu_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; case "bottom_vertical_right": layoutId = R.layout.start_menu_vertical_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; case "top_left": layoutId = R.layout.start_menu_top_left; params.gravity = Gravity.TOP | Gravity.LEFT; break; case "top_vertical_left": layoutId = R.layout.start_menu_vertical_left; params.gravity = Gravity.TOP | Gravity.LEFT; break; case "top_right": layoutId = R.layout.start_menu_top_right; params.gravity = Gravity.TOP | Gravity.RIGHT; break; case "top_vertical_right": layoutId = R.layout.start_menu_vertical_right; params.gravity = Gravity.TOP | Gravity.RIGHT; break; } // Initialize views int theme = 0; switch (pref.getString("theme", "light")) { case "light": theme = R.style.AppTheme; break; case "dark": theme = R.style.AppTheme_Dark; break; } ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme); layout = (StartMenuLayout) LayoutInflater.from(wrapper).inflate(layoutId, null); startMenu = (GridView) layout.findViewById(R.id.start_menu); if ((shouldShowSearchBox && !hasHardwareKeyboard) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) layout.viewHandlesBackButton(); boolean scrollbar = pref.getBoolean("scrollbar", false); startMenu.setFastScrollEnabled(scrollbar); startMenu.setFastScrollAlwaysVisible(scrollbar); startMenu.setScrollBarStyle(scrollbar ? View.SCROLLBARS_OUTSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY); if (pref.getBoolean("transparent_start_menu", false)) startMenu.setBackgroundColor(0); searchView = (SearchView) layout.findViewById(R.id.search); int backgroundTint = U.getBackgroundTint(this); FrameLayout startMenuFrame = (FrameLayout) layout.findViewById(R.id.start_menu_frame); FrameLayout searchViewLayout = (FrameLayout) layout.findViewById(R.id.search_view_layout); startMenuFrame.setBackgroundColor(backgroundTint); searchViewLayout.setBackgroundColor(backgroundTint); if (shouldShowSearchBox) { if (!hasHardwareKeyboard) searchView.setIconifiedByDefault(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (!hasSubmittedQuery) { ListAdapter adapter = startMenu.getAdapter(); if (adapter != null) { hasSubmittedQuery = true; if (adapter.getCount() > 0) { View view = adapter.getView(0, null, startMenu); LinearLayout layout = (LinearLayout) view.findViewById(R.id.entry); layout.performClick(); } else { if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_TASKBAR")); else LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, query); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (intent.resolveActivity(getPackageManager()) != null) startActivity(intent); else { Uri uri = new Uri.Builder().scheme("https").authority("www.google.com") .path("search").appendQueryParameter("q", query).build(); intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(intent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } } } } return true; } @Override public boolean onQueryTextChange(String newText) { searchView.setIconified(false); View closeButton = searchView.findViewById(R.id.search_close_btn); if (closeButton != null) closeButton.setVisibility(View.GONE); refreshApps(newText, false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { new Handler().postDelayed(() -> { EditText editText = (EditText) searchView.findViewById(R.id.search_src_text); if (editText != null) { editText.requestFocus(); editText.setSelection(editText.getText().length()); } }, 50); } return true; } }); searchView.setOnQueryTextFocusChangeListener((view, b) -> { if (!hasHardwareKeyboard) { ViewGroup.LayoutParams params1 = startMenu.getLayoutParams(); params1.height = getResources().getDimensionPixelSize(b && !U.isServiceRunning(this, "com.farmerbb.secondscreen.service.DisableKeyboardService") ? R.dimen.start_menu_height_half : R.dimen.start_menu_height); startMenu.setLayoutParams(params1); } if (!b) { if (hasHardwareKeyboard && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); else { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } }); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); LinearLayout powerButton = (LinearLayout) layout.findViewById(R.id.power_button); powerButton.setOnClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(location); }); powerButton.setOnGenericMotionListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(location); } return false; }); searchViewLayout.setOnClickListener(view -> searchView.setIconified(false)); startMenu.setOnItemClickListener((parent, view, position, id) -> { hideStartMenu(); AppEntry entry = (AppEntry) parent.getAdapter().getItem(position); U.launchApp(StartMenuService.this, entry.getPackageName(), entry.getComponentName(), entry.getUserId(StartMenuService.this), null, false, false); }); if (pref.getBoolean("transparent_start_menu", false)) layout.findViewById(R.id.search_view_child_layout).setBackgroundColor(0); } else searchViewLayout.setVisibility(View.GONE); textView = (TextView) layout.findViewById(R.id.no_apps_found); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiverAlt); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver, new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU")); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiverAlt, new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU_ALT")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_START_MENU")); handler = new Handler(); refreshApps(true); windowManager.addView(layout, params); }
From source file:com.sourcey.materiallogindemo.PostItemActivity.java
private void DialogMap() { View dialogBoxView = View.inflate(this, R.layout.activity_map, null); final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView); String url = getString(R.string.url_map) + "index.php?poinFrom=" + strStart + "&poinTo=" + strEnd; map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);//from www . j a v a 2s . c o m AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("?"); builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false) .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }
From source file:com.muzima.view.forms.FormWebViewActivity.java
private void setupWebView() { webView = (WebView) findViewById(R.id.webView); webView.setWebChromeClient(createWebChromeClient()); getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); getSettings().setJavaScriptEnabled(true); getSettings().setDatabaseEnabled(true); getSettings().setDomStorageEnabled(true); FormInstance formInstance = new FormInstance(form, formTemplate); webView.addJavascriptInterface(formInstance, FORM_INSTANCE); FormController formController = ((MuzimaApplication) getApplication()).getFormController(); webView.addJavascriptInterface(new FormDataStore(this, formController, formData), REPOSITORY); barCodeComponent = new BarCodeComponent(this); imagingComponent = new ImagingComponent(this); audioComponent = new AudioComponent(this); videoComponent = new VideoComponent(this); webView.addJavascriptInterface(barCodeComponent, BARCODE); webView.addJavascriptInterface(imagingComponent, IMAGE); webView.addJavascriptInterface(audioComponent, AUDIO); webView.addJavascriptInterface(videoComponent, VIDEO); webView.addJavascriptInterface(/* w w w .jav a 2 s . c o m*/ new ZiggyFileLoader("www/ziggy", getApplicationContext().getAssets(), formInstance.getModelJson()), ZIGGY_FILE_LOADER); webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (isFormComplete()) { webView.setOnTouchListener(createCompleteFormListenerToDisableInput()); } webView.loadUrl("file:///android_asset/www/enketo/template.html"); }
From source file:com.sourcey.materiallogindemo.MainActivity.java
private void DialogMap() { View dialogBoxView = View.inflate(this, R.layout.activity_map, null); final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView); String url = getString(R.string.url_map) + "index.php?poinFrom=" + txtStart.getText().toString().trim() + "&poinTo=" + txtEnd.getText().toString().trim(); map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);//www. j av a 2 s . c o m AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("Map"); builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false) .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
protected void updateMessageDetail(final boolean isUpdate) { T.UI();//from w w w . j a va 2 s .co 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); }
From source file:com.audiokernel.euphonyrmt.fragments.BrowseFragment.java
/** * This is required because setting the fast scroll prior to KitKat was * important because of a bug. This bug has since been corrected, but the * opposite order is now required or the fast scroll will not show. * * @param shouldShowFastScroll If the fast scroll should be shown or not *//*from w w w. j av a 2 s .c om*/ protected void refreshFastScrollStyle(final boolean shouldShowFastScroll) { if (shouldShowFastScroll) { refreshFastScrollStyle(View.SCROLLBARS_INSIDE_INSET, true); } else { refreshFastScrollStyle(View.SCROLLBARS_INSIDE_OVERLAY, false); } }
From source file:android.webkit.cts.WebViewTest.java
@UiThreadTest public void testSetScrollBarStyle() { if (!NullWebViewUtils.isWebViewAvailable()) { return;/*from ww w . jav a2 s . co m*/ } mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); assertFalse(mWebView.overlayHorizontalScrollbar()); assertFalse(mWebView.overlayVerticalScrollbar()); mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); assertTrue(mWebView.overlayHorizontalScrollbar()); assertTrue(mWebView.overlayVerticalScrollbar()); mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET); assertFalse(mWebView.overlayHorizontalScrollbar()); assertFalse(mWebView.overlayVerticalScrollbar()); mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); assertTrue(mWebView.overlayHorizontalScrollbar()); assertTrue(mWebView.overlayVerticalScrollbar()); }
From source file:com.muzima.view.forms.HTMLFormWebViewActivity.java
private void setupWebView() { webView = (WebView) findViewById(R.id.webView); webView.setWebChromeClient(createWebChromeClient()); getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); getSettings().setJavaScriptEnabled(true); getSettings().setDatabaseEnabled(true); getSettings().setDomStorageEnabled(true); getSettings().setBuiltInZoomControls(true); FormInstance formInstance = new FormInstance(form, formTemplate); webView.addJavascriptInterface(formInstance, FORM_INSTANCE); barCodeComponent = new BarCodeComponent(this); imagingComponent = new ImagingComponent(this); audioComponent = new AudioComponent(this); videoComponent = new VideoComponent(this); webView.addJavascriptInterface(barCodeComponent, BARCODE); webView.addJavascriptInterface(imagingComponent, IMAGE); webView.addJavascriptInterface(audioComponent, AUDIO); webView.addJavascriptInterface(videoComponent, VIDEO); webView.addJavascriptInterface(/*from www. ja v a2 s. co m*/ new HTMLFormDataStore(this, formController, locationController, formData, providerController), HTML_DATA_STORE); webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (isFormComplete()) { webView.setOnTouchListener(createCompleteFormListenerToDisableInput()); } webView.loadDataWithBaseURL("file:///android_asset/www/forms/", prePopulateData(), "text/html", "UTF-8", ""); }
From source file:com.free.searcher.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup viewContainer, Bundle savedInstanceState) { super.onCreateView(inflater, viewContainer, savedInstanceState); this.activity = getActivity(); actionBar = activity.getActionBar(); View v = inflater.inflate(R.layout.main, viewContainer, false); v.setOnSystemUiVisibilityChangeListener(this); webView = (WebView) v.findViewById(R.id.webView1); statusView = (TextView) v.findViewById(R.id.statusView); if (webViewBundle != null) { webView.restoreState(webViewBundle); Log.d("onCreateView.webView.restoreState", webViewBundle + ""); } else if (currentUrl.length() > 0) { Log.d("onCreateView.locX, locY", locX + ", " + locY + ", " + currentUrl); webView.loadUrl(currentUrl);// w ww . j a v a 2s . c om webView.setScrollX(locX); webView.setScrollY(locY); Log.d("currentUrl 8", currentUrl); } statusView.setText(status); Log.d("onCreateView.savedInstanceState", savedInstanceState + "vvv"); mNotificationManager = (NotificationManager) activity.getSystemService(activity.NOTIFICATION_SERVICE); webView.setFocusable(true); webView.setFocusableInTouchMode(true); webView.requestFocus(); webView.requestFocusFromTouch(); webView.getSettings().setAllowContentAccess(false); webView.getSettings().setPluginState(WebSettings.PluginState.OFF); // webView.setBackgroundColor(LIGHT_BLUE); webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); webView.setBackgroundColor(getResources().getColor(R.color.lightyellow)); webView.setOnLongClickListener(this); statusView.setOnLongClickListener(this); webView.setWebViewClient(new WebViewClient() { private void jumpTo(final int xLocation, final int yLocation) { webView.postDelayed(new Runnable() { @Override public void run() { Log.d("jumpTo1.locX, locY", xLocation + ", " + yLocation + ", " + currentUrl); try { webView.scrollTo(xLocation, yLocation); webView.setScrollX(xLocation); webView.setScrollY(yLocation); // locX = 0; // locY = 0; } catch (RuntimeException e) { Log.e("error jumpTo2.locX, locY", locX + ", " + locY + ", " + currentUrl); } } }, 100); } @Override public boolean shouldOverrideUrlLoading(WebView view, final String url) { if (currentZipFileName.length() > 0 && (extractFile == null || extractFile.isClosed())) { try { extractFile = new ExtractFile(currentZipFileName, MainFragment.PRIVATE_PATH + currentZipFileName); } catch (RarException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } int ind = url.indexOf("?deleteFile="); if (ind >= 0) { if (dupTask == null) { showToast("Please do duplicate finding again."); return true; } String urlStatus = Util.getUrlStatus(url); final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteFile=") + 12, urlStatus.length()); Log.d("deleteFile", "url=" + url + ", urlStatus=" + urlStatus); AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setTitle("Delete File?"); alert.setMessage("Do you really want to delete file \"" + selectedFile + "\"?"); alert.setCancelable(true); alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { locX = webView.getScrollX(); locY = webView.getScrollY(); webView.loadUrl( new File(dupTask.deleteFile(selectedFile)).toURI().toURL().toString()); } catch (IOException e) { statusView.setText(e.getMessage()); Log.d("deleteFile", e.getMessage(), e); } } }); alert.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); return true; } ind = url.indexOf("?deleteGroup="); if (ind >= 0) { if (dupTask == null) { showToast("Please do duplicate finding again."); return true; } String urlStatus = Util.getUrlStatus(url); final String groupFile = urlStatus.substring(urlStatus.indexOf("?deleteGroup=") + 13, urlStatus.length()); int indexOf = groupFile.indexOf(","); final int group = Integer.parseInt(groupFile.substring(0, indexOf)); final String selectedFile = groupFile.substring(indexOf + 1); Log.d("groupFile", ",groupFile=" + groupFile + ", url=" + url + ", urlStatus=" + urlStatus); AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setTitle("Delete Group of Files?"); alert.setMessage( "Do you really want to delete this group, except file \"" + selectedFile + "\"?"); alert.setCancelable(true); alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { locX = webView.getScrollX(); locY = webView.getScrollY(); webView.postDelayed(new Runnable() { @Override public void run() { try { webView.loadUrl(new File(dupTask.deleteGroup(group, selectedFile)).toURI() .toURL().toString()); } catch (Throwable e) { statusView.setText(e.getMessage()); Log.e("Delete Group", e.getMessage(), e); Log.e("Delete Group", locX + ", " + locY + ", " + currentUrl); } } }, 0); } }); alert.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); return true; } ind = url.indexOf("?deleteFolder="); if (ind >= 0) { if (dupTask == null) { showToast("Please do duplicate finding again."); return true; } String urlStatus = Util.getUrlStatus(url); final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteFolder=") + 14, urlStatus.length()); Log.d("deleteFolder", ",deleteFolder=" + selectedFile + ", url=" + url + ", urlStatus=" + urlStatus); AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setTitle("Delete folder?"); alert.setMessage("Do you really want to delete duplicate in folder \"" + selectedFile.substring(0, selectedFile.lastIndexOf("/")) + "\"?"); alert.setCancelable(true); alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { locX = webView.getScrollX(); locY = webView.getScrollY(); webView.postDelayed(new Runnable() { @Override public void run() { try { webView.loadUrl(new File(dupTask.deleteFolder(selectedFile)).toURI().toURL() .toString()); } catch (Throwable e) { statusView.setText(e.getMessage()); Log.e("Delete folder", e.getMessage(), e); Log.e("Delete folder", locX + ", " + locY + ", " + currentUrl); } } }, 0); } }); alert.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); return true; } ind = url.indexOf("?deleteSub="); if (ind >= 0) { if (dupTask == null) { showToast("Please do duplicate finding again."); return true; } String urlStatus = Util.getUrlStatus(url); final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteSub=") + 11, urlStatus.length()); Log.d("deleteSub", ",deleteSub=" + selectedFile + ", url=" + url + ", urlStatus=" + urlStatus); AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setTitle("Delete sub folder?"); alert.setMessage("Do you really want to delete duplicate files in sub folder of \"" + selectedFile.substring(0, selectedFile.lastIndexOf("/")) + "\"?"); alert.setCancelable(true); alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { locX = webView.getScrollX(); locY = webView.getScrollY(); webView.postDelayed(new Runnable() { @Override public void run() { try { webView.loadUrl(new File(dupTask.deleteSubFolder(selectedFile)).toURI() .toURL().toString()); } catch (Throwable e) { statusView.setText(e.getMessage()); Log.e("Delete sub folder", e.getMessage(), e); Log.e("Delete sub folder", locX + ", " + locY + ", " + currentUrl); } } }, 0); } }); alert.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); return true; } ind = url.indexOf("?viewName"); if (ind >= 0) { if (dupTask == null) { showToast("Please do duplicate finding again."); return true; } nameOrder = !nameOrder; locX = 0; locY = 0; Log.d("url=", url + ", viewName"); try { webView.loadUrl(new File(dupTask.genFile(dupTask.groupList, dupTask.NAME_VIEW)).toURI() .toURL().toString()); } catch (IOException e) { Log.e("viewName", e.getMessage(), e); } return true; } ind = url.indexOf("?viewGroup"); if (ind >= 0) { if (dupTask == null) { showToast("Please do duplicate finding again."); return true; } groupViewChanged = true; locX = 0; locY = 0; Log.d("url=", url + ", viewGroup"); try { webView.loadUrl(new File(dupTask.genFile(dupTask.groupList, dupTask.GROUP_VIEW)).toURI() .toURL().toString()); } catch (IOException e) { Log.e("viewGroup", e.getMessage(), e); } return true; } if (zextr == null) { locX = 0; locY = 0; } else { zextr = null; } if (MainActivity.popup) { final MainFragment frag = ((MainActivity) activity).addFragmentToStack(); frag.status = Util.getUrlStatus(url); frag.load = load; frag.currentSearching = currentSearching; frag.selectedFiles = selectedFiles; frag.files = files; frag.currentZipFileName = currentZipFileName; if (extractFile != null) { try { frag.extractFile = new ExtractFile(); extractFile.copyTo(frag.extractFile); } catch (RarException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } frag.home = home; // if (mSearchView != null && mSearchView.getQuery().length() > 0) { // frag.mSearchView.setQuery(mSearchView.getQuery(), false); // } view.getHandler().postDelayed(new Runnable() { @Override public void run() { frag.webTask = new WebTask(MainFragment.this); frag.webTask.init(frag.webView, url); frag.webTask.execute(); frag.statusView.setText(frag.status); } }, 100); } else { currentUrl = url; Log.d("currentUrl 19", currentUrl); status = Util.getUrlStatus(url); statusView.setText("Opening " + url + "..."); webTask = new WebTask(MainFragment.this, webView, url, status.toString()); webTask.execute(); } // setNavVisibility(false); return true; } // @Override // public WebResourceResponse shouldInterceptRequest(WebView view, String url) { // } @Override public void onPageFinished(WebView view, String url) { if (container != null) { if (showFind) { container.setVisibility(View.VISIBLE); webView.findAllAsync(findBox.getText().toString()); } else { container.setVisibility(View.INVISIBLE); } } Log.d("onPageFinished", locX + ", " + locY + ", currentUrl=" + currentUrl + ", url=" + url); setNavVisibility(false); if (!backForward) { //if (zextr != null) { // zextr = null; jumpTo(locX, locY); } else { backForward = false; } // locX = 0; // locY = 0; Log.d("onPageFinished", url); /* This call inject JavaScript into the page which just finished loading. */ // webView.loadUrl("javascript:window.HTMLOUT.processHTML(" + // "'<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');"); } }); WebSettings settings = webView.getSettings(); // webView.setWebViewClient(new WebViewClient()); // webView.setWebChromeClient(new WebChromeClient()); // webView.addJavascriptInterface(new HtmlSourceViewJavaScriptInterface(), "HTMLOUT"); settings.setMinimumFontSize(13); settings.setJavaScriptEnabled(true); settings.setDefaultTextEncodingName("UTF-8"); settings.setBuiltInZoomControls(true); // settings.setSansSerifFontFamily("Tahoma"); settings.setEnableSmoothTransition(true); return v; }
From source file:com.mobicage.rogerthat.plugins.friends.ActionScreenActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface", "NewApi" }) @Override/*from www . jav a2s. co m*/ public void onCreate(Bundle savedInstanceState) { if (CloudConstants.isContentBrandingApp()) { super.setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen); } super.onCreate(savedInstanceState); setContentView(R.layout.action_screen); mBranding = (WebView) findViewById(R.id.branding); WebSettings brandingSettings = mBranding.getSettings(); brandingSettings.setJavaScriptEnabled(true); brandingSettings.setCacheMode(WebSettings.LOAD_DEFAULT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { brandingSettings.setAllowFileAccessFromFileURLs(true); } mBrandingHttp = (WebView) findViewById(R.id.branding_http); mBrandingHttp.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); WebSettings brandingSettingsHttp = mBrandingHttp.getSettings(); brandingSettingsHttp.setJavaScriptEnabled(true); brandingSettingsHttp.setCacheMode(WebSettings.LOAD_DEFAULT); if (CloudConstants.isContentBrandingApp()) { mSoundThread = new HandlerThread("rogerthat_actionscreenactivity_sound"); mSoundThread.start(); Looper looper = mSoundThread.getLooper(); mSoundHandler = new Handler(looper); int cameraPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (cameraPermission == PackageManager.PERMISSION_GRANTED) { mQRCodeScanner = QRCodeScanner.getInstance(this); final LinearLayout previewHolder = (LinearLayout) findViewById(R.id.preview_view); previewHolder.addView(mQRCodeScanner.view); } mBranding.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initFullScreenForContentBranding(); } }); mBrandingHttp.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initFullScreenForContentBranding(); } }); } final View brandingHeader = findViewById(R.id.branding_header_container); final ImageView brandingHeaderClose = (ImageView) findViewById(R.id.branding_header_close); final TextView brandingHeaderText = (TextView) findViewById(R.id.branding_header_text); brandingHeaderClose .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text))); brandingHeaderClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.onResume(); } brandingHeader.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl("about:blank"); } }); final View brandingFooter = findViewById(R.id.branding_footer_container); if (CloudConstants.isContentBrandingApp()) { brandingHeaderClose.setVisibility(View.GONE); final ImageView brandingFooterClose = (ImageView) findViewById(R.id.branding_footer_close); final TextView brandingFooterText = (TextView) findViewById(R.id.branding_footer_text); brandingFooterText.setText(getString(R.string.back)); brandingFooterClose .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text))); brandingFooter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.onResume(); } brandingHeader.setVisibility(View.GONE); brandingFooter.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl("about:blank"); } }); } final RelativeLayout openPreview = (RelativeLayout) findViewById(R.id.preview_holder); openPreview.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.previewHolderClicked(); } } }); mBranding.addJavascriptInterface(new JSInterface(this), "__rogerthat__"); mBranding.setWebChromeClient(new WebChromeClient() { @Override public void onConsoleMessage(String message, int lineNumber, String sourceID) { if (sourceID != null) { try { sourceID = new File(sourceID).getName(); } catch (Exception e) { L.d("Could not get fileName of sourceID: " + sourceID, e); } } if (mIsHtmlContent) { L.i("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message); } else { L.d("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message); } } }); mBranding.setWebViewClient(new WebViewClient() { private boolean isExternalUrl(String url) { for (String regularExpression : mBrandingResult.externalUrlPatterns) { if (url.matches(regularExpression)) { return true; } } return false; } @SuppressLint("DefaultLocale") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.i("Branding is loading url: " + url); Uri uri = Uri.parse(url); String lowerCaseUrl = url.toLowerCase(); if (lowerCaseUrl.startsWith("tel:") || lowerCaseUrl.startsWith("mailto:") || isExternalUrl(url)) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); return true; } else if (lowerCaseUrl.startsWith(POKE)) { String tag = url.substring(POKE.length()); poke(tag); return true; } else if (lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://")) { if (mQRCodeScanner != null) { mQRCodeScanner.onPause(); } brandingHeaderText.setText(getString(R.string.loading)); brandingHeader.setVisibility(View.VISIBLE); if (CloudConstants.isContentBrandingApp()) { brandingFooter.setVisibility(View.VISIBLE); } mBranding.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl(url); return true; } else { brandingHeader.setVisibility(View.GONE); brandingFooter.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); } return false; } @Override public void onPageFinished(WebView view, String url) { L.i("onPageFinished " + url); if (!mInfoSet && mService != null && mIsHtmlContent) { Map<String, Object> info = mFriendsPlugin.getRogerthatUserAndServiceInfo(mServiceEmail, mServiceFriend); executeJS(true, "if (typeof rogerthat !== 'undefined') rogerthat._setInfo(%s)", JSONValue.toJSONString(info)); mInfoSet = true; } } @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { L.i("Checking access to: '" + url + "'"); final URL parsedUrl; try { parsedUrl = new URL(url); } catch (MalformedURLException e) { L.d("Webview tried to load malformed URL"); return new WebResourceResponse("text/plain", "UTF-8", null); } if (!parsedUrl.getProtocol().equals("file")) { return null; } File urlPath = new File(parsedUrl.getPath()); if (urlPath.getAbsolutePath().startsWith(mBrandingResult.dir.getAbsolutePath())) { return null; } L.d("404: Webview tries to load outside its sandbox."); return new WebResourceResponse("text/plain", "UTF-8", null); } }); mBrandingHttp.setWebViewClient(new WebViewClient() { @SuppressLint("DefaultLocale") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.i("BrandingHttp is loading url: " + url); return false; } @Override public void onPageFinished(WebView view, String url) { brandingHeaderText.setText(view.getTitle()); L.i("onPageFinished " + url); } }); Intent intent = getIntent(); mBrandingKey = intent.getStringExtra(BRANDING_KEY); mServiceEmail = intent.getStringExtra(SERVICE_EMAIL); mItemTagHash = intent.getStringExtra(ITEM_TAG_HASH); mItemLabel = intent.getStringExtra(ITEM_LABEL); mItemCoords = intent.getLongArrayExtra(ITEM_COORDS); mRunInBackground = intent.getBooleanExtra(RUN_IN_BACKGROUND, true); }