List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:edu.ptu.navpattern.tooltip.Tooltip.java
private View getContentView(final Builder builder) { GradientDrawable drawable = new GradientDrawable(); drawable.setColor(builder.mBackgroundColor); drawable.setCornerRadius(builder.mCornerRadius); LinearLayout vgContent = new LinearLayout(builder.mContext); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { vgContent.setBackground(drawable); } else {//from ww w.j a v a 2s. co m //noinspection deprecation vgContent.setBackgroundDrawable(drawable); } int padding = (int) builder.mPadding; vgContent.setPadding(padding, padding, padding, padding); vgContent.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); textViewParams.gravity = Gravity.CENTER; textViewParams.topMargin = 1; vgContent.setLayoutParams(textViewParams); vgContent.setDividerDrawable(vgContent.getResources().getDrawable(R.drawable.divider_line)); vgContent.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); if (builder.itemText != null && builder.itemText.length > 0) { for (int i = 0; i < builder.itemText.length; i++) { TextView textView = new TextView(builder.mContext); textView.setText(builder.itemText[i]); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 44); textView.setTextColor(0xffffffff); textView.setGravity(Gravity.CENTER_VERTICAL); if (builder.itemLogo != null && builder.itemLogo.length > i) { Drawable drawableLeft = builder.mContext.getResources().getDrawable(builder.itemLogo[i]); /// ??,??. // drawableLeft.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); // textView.setCompoundDrawables(drawableLeft, null, null, null); // textView.setCompoundDrawablePadding(4); // textView.setBackgroundDrawable(drawableLeft); LinearLayout linearLayout = new LinearLayout(builder.mContext); linearLayout.setMinimumHeight((int) dpToPx(44f)); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); ImageView icon = new ImageView(builder.mContext); icon.setImageDrawable(drawableLeft); linearLayout.addView(icon); linearLayout.addView(textView); vgContent.addView(linearLayout); final int position = i; linearLayout.setClickable(false); linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (builder.mOnItemClickListener != null) { builder.mOnItemClickListener.onClick(position); } mTouchListener.onTouch(v, MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, v.getLeft() + 5, v.getTop() + 5, 0)); } }); } else { vgContent.addView(textView); final int position = i; textView.setClickable(false); textView.setMinimumHeight((int) dpToPx(44f)); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (builder.mOnItemClickListener != null) { builder.mOnItemClickListener.onClick(position); } mTouchListener.onTouch(v, null); } }); } } } mArrowView = new ImageView(builder.mContext); mArrowView.setImageDrawable(builder.mArrowDrawable); LinearLayout.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowHeight, (int) builder.mArrowWidth, 0); } arrowLayoutParams.gravity = Gravity.CENTER; mArrowView.setLayoutParams(arrowLayoutParams); mContentView = new LinearLayout(builder.mContext); mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mContentView.setOrientation(mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); padding = (int) dpToPx(5); switch (mGravity) { case Gravity.START: mContentView.setPadding(0, 0, padding, 0); break; case Gravity.TOP: case Gravity.BOTTOM: mContentView.setPadding(padding, 0, padding, 0); break; case Gravity.END: mContentView.setPadding(padding, 0, 0, 0); break; } if (mGravity == Gravity.TOP || mGravity == Gravity.START) { mContentView.addView(vgContent); mContentView.addView(mArrowView); } else { mContentView.addView(mArrowView); mContentView.addView(vgContent); } if (builder.isCancelable || builder.isDismissOnClick) { mContentView.setOnTouchListener(mTouchListener); } return mContentView; }
From source file:org.apache.cordova.inappbrowser.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from w ww. ja v a 2 s . co m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; showZoomControls = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean zoom = features.get(ZOOM); if (zoom != null) { showZoomControls = zoom.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } Boolean hardwareBack = features.get(HARDWARE_BACK_BUTTON); if (hardwareBack != null) { hadwareBackButton = hardwareBack.booleanValue(); } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { clearSessionCache = cache.booleanValue(); } } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } @SuppressLint("NewApi") public void run() { // Let's create the main dialog dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setInAppBroswer(getInAppBrowser()); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { back.setBackgroundDrawable(backIcon); } else { back.setBackground(backIcon); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { forward.setBackgroundDrawable(fwdIcon); } else { forward.setBackground(fwdIcon); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close/Done button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(closeResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { close.setBackgroundDrawable(closeIcon); } else { close.setBackground(closeIcon); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(getShowZoomControls()); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (clearAllCache) { CookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { CookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.webcomm.plugin.CustomInAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from www . j ava2 s . c o m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { clearSessionCache = cache.booleanValue(); } } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } @SuppressLint("NewApi") public void run() { // Let's create the main dialog dialog = new CustomInAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setInAppBroswer(getInAppBrowser()); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { back.setBackgroundDrawable(backIcon); } else { back.setBackground(backIcon); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { forward.setBackgroundDrawable(fwdIcon); } else { forward.setBackground(fwdIcon); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close/Done button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(closeResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { close.setBackgroundDrawable(closeIcon); } else { close.setBackground(closeIcon); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new CustomInAppChromeClient(thatWebView)); // [Modify] inAppWebView.addJavascriptInterface( new WebAppInterface(cordova.getActivity().getApplicationContext()), "CustomInAppBrowser"); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (clearAllCache) { CookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { CookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.apptentive.android.sdk.module.engagement.interaction.view.TextModalInteractionView.java
@Override public void doOnCreate(final Activity activity, Bundle onSavedInstanceState) { activity.setContentView(R.layout.apptentive_textmodal_interaction_center); TextView title = (TextView) activity.findViewById(R.id.title); if (interaction.getTitle() == null) { title.setVisibility(View.GONE); } else {//w w w .j av a 2 s.co m title.setText(interaction.getTitle()); } TextView body = (TextView) activity.findViewById(R.id.body); if (interaction.getBody() == null) { body.setVisibility(View.GONE); } else { body.setText(interaction.getBody()); } LinearLayout bottomArea = (LinearLayout) activity.findViewById(R.id.bottom_area); List<Action> actions = interaction.getActions().getAsList(); boolean vertical; if (actions != null && !actions.isEmpty()) { int totalChars = 0; for (Action button : actions) { totalChars += button.getLabel().length(); } if (actions.size() == 1) { vertical = false; } else if (actions.size() == 2) { vertical = totalChars > MAX_TEXT_LENGTH_FOR_TWO_BUTTONS; } else if (actions.size() == 3) { vertical = totalChars > MAX_TEXT_LENGTH_FOR_THREE_BUTTONS; } else if (actions.size() == 4) { vertical = totalChars > MAX_TEXT_LENGTH_FOR_FOUR_BUTTONS; } else { vertical = true; } if (vertical) { bottomArea.setOrientation(LinearLayout.VERTICAL); } else { bottomArea.setOrientation(LinearLayout.HORIZONTAL); } for (int i = 0; i < actions.size(); i++) { final Action buttonAction = actions.get(i); final int position = i; ApptentiveDialogButton button = new ApptentiveDialogButton(activity); button.setText(buttonAction.getLabel()); switch (buttonAction.getType()) { case dismiss: button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { JSONObject data = new JSONObject(); try { data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId()); data.put(Action.KEY_LABEL, buttonAction.getLabel()); data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position); } catch (JSONException e) { Log.e("Error creating Event data object.", e); } EngagementModule.engageInternal(activity, interaction, TextModalInteraction.EVENT_NAME_DISMISS, data.toString()); activity.finish(); } }); break; case interaction: button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { LaunchInteractionAction launchInteractionButton = (LaunchInteractionAction) buttonAction; List<Invocation> invocations = launchInteractionButton.getInvocations(); String interactionIdToLaunch = null; for (Invocation invocation : invocations) { if (invocation.isCriteriaMet(activity)) { interactionIdToLaunch = invocation.getInteractionId(); break; } } Interaction invokedInteraction = null; if (interactionIdToLaunch != null) { Interactions interactions = InteractionManager.getInteractions(activity); if (interactions != null) { invokedInteraction = interactions.getInteraction(interactionIdToLaunch); } } JSONObject data = new JSONObject(); try { data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId()); data.put(Action.KEY_LABEL, buttonAction.getLabel()); data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position); data.put(TextModalInteraction.EVENT_KEY_INVOKED_INTERACTION_ID, invokedInteraction == null ? JSONObject.NULL : invokedInteraction.getId()); } catch (JSONException e) { Log.e("Error creating Event data object.", e); } EngagementModule.engageInternal(activity, interaction, TextModalInteraction.EVENT_NAME_INTERACTION, data.toString()); if (invokedInteraction != null) { EngagementModule.launchInteraction(activity, invokedInteraction); } activity.finish(); } }); break; } bottomArea.addView(button); } } else { bottomArea.setVisibility(View.GONE); } }
From source file:org.openremote.android.console.AppSettingsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setTitle(R.string.settings);/* www . j a v a 2 s . c o m*/ this.autoMode = AppSettingsModel.isAutoMode(AppSettingsActivity.this); // The main layout contains all application configuration items. LinearLayout mainLayout = new LinearLayout(this); mainLayout .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mainLayout.setOrientation(LinearLayout.VERTICAL); mainLayout.setBackgroundColor(0); mainLayout.setTag(R.string.settings); loadingPanelProgress = new ProgressDialog(this); // The scroll view contains appSettingsView, and make the appSettingsView can be scrolled. ScrollView scroll = new ScrollView(this); scroll.setVerticalScrollBarEnabled(true); scroll.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1)); appSettingsView = new LinearLayout(this); appSettingsView .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); appSettingsView.setOrientation(LinearLayout.VERTICAL); appSettingsView.addView(createAutoLayout()); appSettingsView.addView(createChooseControllerLabel()); currentServer = ""; if (autoMode) { appSettingsView.addView(constructAutoServersView()); } else { appSettingsView.addView(constructCustomServersView()); } appSettingsView.addView(createChoosePanelLabel()); panelSelectSpinnerView = new PanelSelectSpinnerView(this); appSettingsView.addView(panelSelectSpinnerView); appSettingsView.addView(createCacheText()); appSettingsView.addView(createClearImageCacheButton()); appSettingsView.addView(createSSLLayout()); scroll.addView(appSettingsView); mainLayout.addView(scroll); mainLayout.addView(createDoneAndCancelLayout()); setContentView(mainLayout); initSSLState(); addOnclickListenerOnDoneButton(); addOnclickListenerOnCancelButton(); progressLayout = (LinearLayout) findViewById(R.id.choose_controller_progress); }
From source file:com.sigilance.CardEdit.MainActivity.java
private void promptForChangePin(final int mode) { AlertDialog.Builder builder = new AlertDialog.Builder(this); if (mode == 0x83) builder.setTitle(R.string.action_change_pw3); else/*from ww w . j av a 2s . com*/ builder.setTitle(R.string.action_change_pw1); final String typeString = mode == 0x83 ? "Admin" : "User"; String defaultString = mode == 0x83 ? "12345678" : "123456"; builder.setMessage(String.format("REMINDER: The default %s PIN is %s", typeString, defaultString)); final EditText oldPinInput = new EditText(this); oldPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); oldPinInput.setHint(String.format("Old %s PIN", mode == 0x83 ? "Admin" : "User")); final EditText newPinInput = new EditText(this); newPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); newPinInput.setHint(String.format("New %s PIN", mode == 0x83 ? "Admin" : "User")); final EditText confirmPinInput = new EditText(this); confirmPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); confirmPinInput.setHint("Repeat New PIN"); LinearLayout fields = new LinearLayout(this); fields.setOrientation(LinearLayout.VERTICAL); fields.addView(oldPinInput); fields.addView(newPinInput); fields.addView(confirmPinInput); builder.setView(fields); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Placeholder; we will override this } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldPinInput.getText().toString().length() == 0 || newPinInput.getText().toString().length() == 0) { Toast.makeText(MainActivity.this, "Enter a PIN!", Toast.LENGTH_SHORT).show(); return; } if (!(confirmPinInput.getText().toString().equals(newPinInput.getText().toString()))) { newPinInput.setText(""); confirmPinInput.setText(""); Toast.makeText(MainActivity.this, "PINs did not match.", Toast.LENGTH_SHORT).show(); return; } int minPinLength = (mode == 0x83) ? 8 : 6; if (oldPinInput.getText().toString().length() < minPinLength || newPinInput.getText().toString().length() < minPinLength) { newPinInput.setText(""); confirmPinInput.setText(""); Toast.makeText(MainActivity.this, String.format("%s PIN must be at least %d digits.", typeString, minPinLength), Toast.LENGTH_SHORT).show(); return; } // Once we have valid PINs, add the pending operation. mPendingOperations.add(new PendingChangePinOperation(mode, oldPinInput.getText().toString(), newPinInput.getText().toString())); // And prompt the user to change the PIN. hideUi(); findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_change); dialog.dismiss(); } }); }
From source file:hu.fnf.devel.atlas.Atlas.java
private void setDetailProperties(int page_id) { LinearLayout root = (LinearLayout) findViewById(R.id.detailcatRoot); root.setOrientation(android.widget.LinearLayout.VERTICAL); LinearLayout in = new LinearLayout(getApplicationContext()); in.setId(AtlasData.INCOME);//from www . ja v a 2 s . c o m in.setOnClickListener(onCatClick); LinearLayout out = new LinearLayout(getApplicationContext()); out.setId(AtlasData.OUTCOME); out.setOnClickListener(onCatClick); TextView intext = new TextView(getApplicationContext()); intext.setText(getResources().getString(R.string.income)); intext.setOnClickListener(onCatClick); intext.setId(AtlasData.INCOME); intext.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse); TextView outtext = new TextView(getApplicationContext()); outtext.setText(getResources().getString(R.string.outcome)); outtext.setOnClickListener(onCatClick); outtext.setId(AtlasData.OUTCOME); outtext.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse); in.addView(intext); out.addView(outtext); root.addView(in); addChilds(in, root); root.addView(out); addChilds(out, root); }
From source file:com.aware.Aware.java
/** * Given a plugin's package name, fetch the context card for reuse. * @param context: application context// w w w. j av a 2 s . com * @param package_name: plugin's package name * @return View for reuse (instance of LinearLayout) */ public static View getContextCard(final Context context, final String package_name) { if (!isClassAvailable(context, package_name, "ContextCard")) { return null; } String ui_class = package_name + ".ContextCard"; LinearLayout card = new LinearLayout(context); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); card.setLayoutParams(params); card.setOrientation(LinearLayout.VERTICAL); try { Context packageContext = context.createPackageContext(package_name, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); Class<?> fragment_loader = packageContext.getClassLoader().loadClass(ui_class); Object fragment = fragment_loader.newInstance(); Method[] allMethods = fragment_loader.getDeclaredMethods(); Method m = null; for (Method mItem : allMethods) { String mName = mItem.getName(); if (mName.contains("getContextCard")) { mItem.setAccessible(true); m = mItem; break; } } View ui = (View) m.invoke(fragment, packageContext); if (ui != null) { //Check if plugin has settings. If it does, tapping the card shows the settings if (isClassAvailable(context, package_name, "Settings")) { ui.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); open_settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(open_settings); } }); } //Set card look-n-feel ui.setBackgroundColor(Color.WHITE); ui.setPadding(20, 20, 20, 20); card.addView(ui); LinearLayout shadow = new LinearLayout(context); LayoutParams params_shadow = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params_shadow.setMargins(0, 0, 0, 10); shadow.setBackgroundColor(context.getResources().getColor(R.color.card_shadow)); shadow.setMinimumHeight(5); shadow.setLayoutParams(params_shadow); card.addView(shadow); return card; } else { return null; } } catch (NameNotFoundException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } return null; }
From source file:com.sigilance.CardEdit.MainActivity.java
private void promptForTextDo(final int slot) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final EditText input = new EditText(this); final EditText input2 = new EditText(this); input.setInputType(InputType.TYPE_CLASS_TEXT); input2.setInputType(InputType.TYPE_CLASS_TEXT); LinearLayout fields = new LinearLayout(this); fields.setOrientation(LinearLayout.VERTICAL); fields.addView(input);/*from w w w .j a va 2 s . c o m*/ switch (slot) { case DO_NAME: builder.setTitle(R.string.lbl_cardholder_name); input.setHint(R.string.hint_surname); input2.setHint(R.string.hint_given_name); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); input2.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); String[] names = mCardholderName.split("<<"); if (names.length > 1) { input.setText(names[0].replace('<', ' ')); input2.setText(names[1].replace('<', ' ')); } fields.addView(input2); break; case DO_LANGUAGE: builder.setTitle(R.string.lbl_language_prefs); builder.setMessage("Use a two-letter ISO 639-1 language code: en for English, es for Spanish, etc."); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(2) }); input.setText(mCardholderLanguage); break; case DO_LOGIN_DATA: builder.setTitle(R.string.lbl_login_data); builder.setMessage( "This is arbitrary text; you can use this field to store a username, email address or network logon."); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(254) }); input.setText(new String(mLoginData)); break; case DO_URL: builder.setTitle(R.string.lbl_url); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(254) }); input.setText(mUrl); break; } builder.setView(fields); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { byte[] data; String text = input.getText().toString(); switch (slot) { case DO_NAME: String surname = text.trim().replace(' ', '<'); String givenNames = input2.getText().toString().trim().replace(' ', '<'); data = (surname + "<<" + givenNames).getBytes(Charset.forName("ISO-8859-1")); if (data.length > 39) { Toast.makeText(MainActivity.this, "Name is too long!", Toast.LENGTH_LONG).show(); return; } break; case DO_LANGUAGE: if (text.length() == 2) data = text.toLowerCase().getBytes(); else data = new byte[0]; break; case DO_URL: case DO_LOGIN_DATA: data = text.getBytes(); break; default: data = new byte[0]; } mPendingOperations.add(new PendingPutDataOperation(slot, data)); hideUi(); findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_save); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.create().show(); }
From source file:com.likemag.cordova.inappbrowsercustom.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject/*from w w w . j a v a 2 s . c o m*/ */ public String showWebPage(final String url, HashMap<String, Boolean> features) { // Determine if we should hide the location bar. showLocationBar = true; openWindowHidden = false; if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); if (hidden != null) { openWindowHidden = hidden.booleanValue(); } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { clearSessionCache = cache.booleanValue(); } } } final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } @SuppressLint("NewApi") public void run() { // Let's create the main dialog dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setInAppBroswer(getInAppBrowser()); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! toolbar.setBackgroundColor(android.graphics.Color.WHITE); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button Button back = new Button(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { back.setBackgroundDrawable(backIcon); } else { back.setBackground(backIcon); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button Button forward = new Button(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { forward.setBackgroundDrawable(fwdIcon); } else { forward.setBackground(fwdIcon); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close/Done button Button close = new Button(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setText(getPostName()); close.setTextSize(20.0f); close.setTextColor(android.graphics.Color.GRAY); close.setId(5); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(backResId); closeIcon.setBounds(0, 0, 40, 40); close.setPadding(0, 0, 0, 0); close.setBackgroundDrawable(null); close.setCompoundDrawables(closeIcon, null, null, null); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { //close.setBackgroundDrawable(closeIcon); } else { //close.setBackground(closeIcon); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (clearAllCache) { CookieManager.getInstance().removeAllCookie(); } else if (clearSessionCache) { CookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar //toolbar.addView(actionButtonContainer); //toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(inAppWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (openWindowHidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }