Example usage for android.widget LinearLayout VERTICAL

List of usage examples for android.widget LinearLayout VERTICAL

Introduction

In this page you can find the example usage for android.widget LinearLayout VERTICAL.

Prototype

int VERTICAL

To view the source code for android.widget LinearLayout VERTICAL.

Click Source Link

Usage

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private int getInvertedEnd(View v) {
    if (this.orientation == LinearLayout.VERTICAL) {
        return v.getRight();
    }/*  w w  w .j  av  a  2  s.c o m*/

    return v.getBottom();
}

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private void ensureTitle() {
    if (!TextUtils.isEmpty(titleText) || !TextUtils.isEmpty(messageText)) {
        LinearLayout titleContainer = new LinearLayout(getActivity());
        titleContainer.setOrientation(LinearLayout.VERTICAL);
        titleContainer.setGravity(Gravity.CENTER);
        titleContainer.setBackgroundColor(Color.WHITE);
        titleContainer/*from w w w. j  a  v  a  2 s .  c o  m*/
                .setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(56)));

        if (!TextUtils.isEmpty(titleText)) {
            TextView title = new TextView(getActivity());
            title.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            title.setText(titleText);
            title.setGravity(Gravity.CENTER_HORIZONTAL);
            title.setTextColor(COLOR_TITLE);
            title.getPaint().setFakeBoldText(true);
            titleContainer.addView(title);
        }

        if (!TextUtils.isEmpty(messageText)) {
            TextView message = new TextView(getActivity());
            message.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
            message.setGravity(Gravity.CENTER_HORIZONTAL);
            message.setText(messageText);
            message.setTextColor(COLOR_TITLE);
            titleContainer.addView(message);
        }

        titleContainer.setClickable(true);
        titleContainer.setFocusableInTouchMode(true);

        sheetContainer.addView(titleContainer);
        sheetContainer.addView(createLine());
    }
}

From source file:jp.watnow.plugins.dialog.Notification.java

/**
 * // w  w w.  j  a va  2 s. c  om
 * @param message
 * @param title
 * @param buttonLabels
 * @param defaultTexts
 * @param callbackContext
 */
public synchronized void login(final String title, final String message, final JSONArray buttonLabels,
        final JSONArray defaultTexts, final CallbackContext callbackContext) {

    final CordovaInterface cordova = this.cordova;

    Runnable runnable = new Runnable() {
        public void run() {
            LinearLayout layout = new LinearLayout(cordova.getActivity());
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setPadding(10, 0, 10, 0);
            final EditText usernameInput = new EditText(cordova.getActivity());
            usernameInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
            final EditText passwordInput = new EditText(cordova.getActivity());
            passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            try {
                usernameInput.setHint("ID");
                usernameInput.setText(defaultTexts.getString(0));
                passwordInput.setHint("PASSWORD");
                passwordInput.setText(defaultTexts.getString(1));
            } catch (JSONException e1) {
            }

            layout.addView(usernameInput, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            layout.addView(passwordInput, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));

            AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            dlg.setView(layout);

            final JSONObject result = new JSONObject();

            try {
                dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        try {
                            result.put("buttonIndex", 1);
                            result.put("input1", usernameInput.getText());
                            result.put("input2", passwordInput.getText());
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                    }
                });
            } catch (JSONException e) {
            }

            try {
                dlg.setPositiveButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        try {
                            result.put("buttonIndex", 3);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                    }
                });
            } catch (JSONException e) {
            }

            dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    try {
                        result.put("buttonIndex", 0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                }
            });

            changeTextDirection(dlg);
        };
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:net.opendasharchive.openarchive.ReviewMediaActivity.java

private void deleteMedia() {
    final Switch swDeleteLocal = new Switch(this);
    final Switch swDeleteRemote = new Switch(this);

    LinearLayout linearLayoutGroup = new LinearLayout(this);
    linearLayoutGroup.setOrientation(LinearLayout.VERTICAL);
    linearLayoutGroup.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    swDeleteLocal.setTextOn(getString(R.string.answer_yes));
    swDeleteLocal.setTextOff(getString(R.string.answer_no));

    TextView tvLocal = new TextView(this);
    tvLocal.setText(R.string.delete_local);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);

    linearLayout.addView(tvLocal);//from w w  w. j a v a 2s.c  o m
    linearLayout.addView(swDeleteLocal);

    linearLayoutGroup.addView(linearLayout);

    if (mMedia.getServerUrl() != null) {
        swDeleteRemote.setTextOn(getString(R.string.answer_yes));
        swDeleteRemote.setTextOff(getString(R.string.answer_no));

        TextView tvRemote = new TextView(this);
        tvRemote.setText(R.string.delete_remote);

        LinearLayout linearLayoutRemote = new LinearLayout(this);
        linearLayoutRemote.setOrientation(LinearLayout.HORIZONTAL);
        linearLayoutRemote.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        linearLayoutRemote.setGravity(Gravity.CENTER_HORIZONTAL);

        linearLayoutRemote.addView(tvRemote);
        linearLayoutRemote.addView(swDeleteRemote);
        linearLayoutGroup.addView(linearLayoutRemote);

    }

    AlertDialog.Builder build = new AlertDialog.Builder(ReviewMediaActivity.this).setTitle(R.string.menu_delete)
            .setMessage(R.string.alert_delete_media).setView(linearLayoutGroup).setCancelable(true)
            .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    //do nothing
                }
            })

            .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    deleteMedia(swDeleteLocal.isChecked(), swDeleteRemote.isChecked());
                    finish();

                }
            });

    build.create().show();
}

From source file:com.nttec.everychan.ui.NewTabFragment.java

private void openChansList() {
    final ArrayAdapter<ChanModule> chansAdapter = new ArrayAdapter<ChanModule>(activity, 0) {
        private LayoutInflater inflater = LayoutInflater.from(activity);
        private int drawablePadding = (int) (resources.getDisplayMetrics().density * 5 + 0.5f);

        {// w  w w .  ja va2s. c o m
            for (ChanModule chan : MainApplication.getInstance().chanModulesList)
                add(chan);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ChanModule chan = getItem(position);
            TextView view = (TextView) (convertView == null
                    ? inflater.inflate(android.R.layout.simple_list_item_1, parent, false)
                    : convertView);
            view.setText(chan.getDisplayingName());
            view.setCompoundDrawablesWithIntrinsicBounds(chan.getChanFavicon(), null, null, null);
            view.setCompoundDrawablePadding(drawablePadding);
            return view;
        }
    };

    DialogInterface.OnClickListener onChanSelected = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ChanModule chan = chansAdapter.getItem(which);
            UrlPageModel model = new UrlPageModel();
            model.chanName = chan.getChanName();
            model.type = UrlPageModel.TYPE_INDEXPAGE;
            openNewTab(chan.buildUrl(model));
        }
    };

    final AlertDialog chansListDialog = new AlertDialog.Builder(activity)
            .setTitle(R.string.newtab_quickaccess_all_boards).setAdapter(chansAdapter, onChanSelected)
            .setNegativeButton(android.R.string.cancel, null).create();

    chansListDialog.getListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            MenuItem.OnMenuItemClickListener contextMenuHandler = new MenuItem.OnMenuItemClickListener() {
                @SuppressLint("InlinedApi")
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    final ChanModule chan = chansAdapter
                            .getItem(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position);
                    switch (item.getItemId()) {
                    case R.id.context_menu_favorites_from_fragment:
                        if (MainApplication.getInstance().database.isFavorite(chan.getChanName(), null, null,
                                null)) {
                            MainApplication.getInstance().database.removeFavorite(chan.getChanName(), null,
                                    null, null);
                        } else {
                            try {
                                UrlPageModel indexPage = new UrlPageModel();
                                indexPage.chanName = chan.getChanName();
                                indexPage.type = UrlPageModel.TYPE_INDEXPAGE;
                                MainApplication.getInstance().database.addFavorite(chan.getChanName(), null,
                                        null, null, chan.getChanName(), chan.buildUrl(indexPage));
                            } catch (Exception e) {
                                Logger.e(TAG, e);
                            }
                        }
                        return true;
                    case R.id.context_menu_quickaccess_add:
                        QuickAccess.Entry newEntry = new QuickAccess.Entry();
                        newEntry.chan = chan;
                        list.add(0, newEntry);
                        adapter.notifyDataSetChanged();
                        saveQuickAccessToPreferences();
                        chansListDialog.dismiss();
                        return true;
                    case R.id.context_menu_quickaccess_custom_board:
                        LinearLayout dialogLayout = new LinearLayout(activity);
                        dialogLayout.setOrientation(LinearLayout.VERTICAL);
                        final EditText boardField = new EditText(activity);
                        final EditText descriptionField = new EditText(activity);
                        boardField.setHint(R.string.newtab_quickaccess_addcustom_boardcode);
                        descriptionField.setHint(R.string.newtab_quickaccess_addcustom_boarddesc);
                        LinearLayout.LayoutParams fieldsParams = new LinearLayout.LayoutParams(
                                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        dialogLayout.addView(boardField, fieldsParams);
                        dialogLayout.addView(descriptionField, fieldsParams);
                        DialogInterface.OnClickListener onOkClicked = new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String boardName = boardField.getText().toString();
                                for (QuickAccess.Entry entry : list)
                                    if (entry.boardName != null && entry.chan != null)
                                        if (entry.chan.getChanName().equals(chan.getChanName())
                                                && entry.boardName.equals(boardName)) {
                                            Toast.makeText(activity,
                                                    R.string.newtab_quickaccess_addcustom_already_exists,
                                                    Toast.LENGTH_LONG).show();
                                            return;
                                        }

                                try {
                                    if (boardName.trim().length() == 0)
                                        throw new Exception();
                                    UrlPageModel boardPageModel = new UrlPageModel();
                                    boardPageModel.type = UrlPageModel.TYPE_BOARDPAGE;
                                    boardPageModel.chanName = chan.getChanName();
                                    boardPageModel.boardName = boardName;
                                    boardPageModel.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE;
                                    chan.buildUrl(boardPageModel); //,  ??  ?    
                                } catch (Exception e) {
                                    Toast.makeText(activity,
                                            R.string.newtab_quickaccess_addcustom_incorrect_code,
                                            Toast.LENGTH_LONG).show();
                                    return;
                                }

                                QuickAccess.Entry newEntry = new QuickAccess.Entry();
                                newEntry.chan = chan;
                                newEntry.boardName = boardName;
                                newEntry.boardDescription = descriptionField.getText().toString();
                                list.add(0, newEntry);
                                adapter.notifyDataSetChanged();
                                saveQuickAccessToPreferences();
                                chansListDialog.dismiss();
                            }
                        };
                        new AlertDialog.Builder(activity)
                                .setTitle(resources.getString(R.string.newtab_quickaccess_addcustom_title,
                                        chan.getChanName()))
                                .setView(dialogLayout).setPositiveButton(android.R.string.ok, onOkClicked)
                                .setNegativeButton(android.R.string.cancel, null).show();
                        return true;
                    }
                    return false;
                }
            };
            String thisChanName = chansAdapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position)
                    .getChanName();
            boolean canAddToQuickAccess = true;
            for (QuickAccess.Entry entry : list)
                if (entry.boardName == null && entry.chan != null
                        && entry.chan.getChanName().equals(thisChanName)) {
                    canAddToQuickAccess = false;
                    break;
                }
            menu.add(Menu.NONE, R.id.context_menu_favorites_from_fragment, 1,
                    MainApplication.getInstance().database.isFavorite(thisChanName, null, null, null)
                            ? R.string.context_menu_remove_favorites
                            : R.string.context_menu_add_favorites)
                    .setOnMenuItemClickListener(contextMenuHandler);
            menu.add(Menu.NONE, R.id.context_menu_quickaccess_add, 2, R.string.context_menu_quickaccess_add)
                    .setOnMenuItemClickListener(contextMenuHandler).setVisible(canAddToQuickAccess);
            menu.add(Menu.NONE, R.id.context_menu_quickaccess_custom_board, 3,
                    R.string.context_menu_quickaccess_custom_board)
                    .setOnMenuItemClickListener(contextMenuHandler);
            if (isSingleboardChan(
                    chansAdapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position)))
                menu.findItem(R.id.context_menu_quickaccess_custom_board).setVisible(false);
        }
    });
    chansListDialog.show();
}

From source file:com.neka.cordova.inappbrowser.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject//  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;
        }

        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);
            /*
            back.setText("<");
            */
            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);
            //forward.setText(">");
            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 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);
            //close.setText(buttonLabel);
            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(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.bhb27.isu.Props.java

private void EditProps(String[] props) {
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.setPadding(30, 20, 30, 20);

    TextView descriptionText = new TextView(getActivity());
    descriptionText.setText(getString(R.string.props_any_edit_dialog_summary));
    linearLayout.addView(descriptionText);

    ScrollView scrollView = new ScrollView(getActivity());
    scrollView.setPadding(0, 0, 0, 10);//  www .ja va2 s .  co  m
    linearLayout.addView(scrollView);

    LinearLayout editLayout = new LinearLayout(getActivity());
    editLayout.setOrientation(LinearLayout.VERTICAL);
    scrollView.addView(editLayout);

    final AppCompatEditText[] EditProps = new AppCompatEditText[props.length];
    final AppCompatCheckBox[] ForceBP = new AppCompatCheckBox[props.length];
    final TextView[] descriptionAboveText = new TextView[props.length];
    final TextView[] descriptionBelowText = new TextView[props.length];

    for (int i = 0; i < props.length; i++) {
        descriptionAboveText[i] = new TextView(getActivity());
        descriptionAboveText[i].setText(String.format(getString(R.string.empty), props[i]));
        editLayout.addView(descriptionAboveText[i]);

        EditProps[i] = new AppCompatEditText(getActivity());
        EditProps[i].setText(Tools.getprop(props[i]));
        editLayout.addView(EditProps[i]);

        descriptionBelowText[i] = new TextView(getActivity());
        descriptionBelowText[i].setText(getString(R.string.props_any_edit_dialog_already_bp));
        ForceBP[i] = new AppCompatCheckBox(getActivity());
        ForceBP[i].setText(getString(R.string.props_any_edit_dialog_force_bp));

        if (Tools.PropIsinbp(props[i], getActivity()))
            editLayout.addView(descriptionBelowText[i]);
        else
            editLayout.addView(ForceBP[i]);
    }

    new AlertDialog.Builder(getActivity(), R.style.AlertDialogStyle)
            .setTitle(getString(R.string.props_any_edit_dialog_title)).setView(linearLayout)
            .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    return;
                }
            }).setPositiveButton(getString(R.string.apply), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int id) {
                    String finalmenssage = "\n", edited;
                    for (int i = 0; i < props.length; i++) {
                        edited = EditProps[i].getText().toString();
                        if (edited.isEmpty()) {
                            finalmenssage = finalmenssage
                                    + String.format(getString(R.string.edited_text_ro), props[i]);
                        } else if (edited.equals(Tools.getprop(props[i])))
                            finalmenssage = finalmenssage
                                    + String.format(getString(R.string.edited_text_equals), props[i]);
                        else {
                            if (((AppCompatCheckBox) ForceBP[i]).isChecked())
                                Tools.resetprop(executableFilePath, props[i], edited, getActivity(), true);
                            else
                                Tools.resetprop(executableFilePath, props[i], edited, getActivity(), false);
                            finalmenssage = finalmenssage
                                    + String.format(getString(R.string.edited_text_ok), props[i]);
                            save_prop(props[i], edited);
                        }
                        finalmenssage = finalmenssage + "\n";
                    }
                    finaldialogro(finalmenssage);
                    return;
                }
            }).show();
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

private int getInvertedScrollerOffset() {
    if (this.orientation == LinearLayout.VERTICAL) {
        return mScroller.getCurrX();
    }//from  w w w .  ja  v a2 s .com

    return mScroller.getCurrY();
}

From source file:com.grarak.kerneladiutor.fragments.other.SettingsFragment.java

private void colorDialog(int selection) {
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    int padding = (int) getResources().getDimension(R.dimen.dialog_padding);
    linearLayout.setPadding(padding, padding, padding, padding);

    final List<BorderCircleView> circles = new ArrayList<>();

    LinearLayout subView = null;/* w ww  .j a v  a 2 s  .c  om*/
    for (int i = 0; i < BorderCircleView.sAccentColors.size(); i++) {
        if (subView == null || i % 5 == 0) {
            subView = new LinearLayout(getActivity());
            subView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            linearLayout.addView(subView);
        }

        BorderCircleView circle = new BorderCircleView(getActivity());
        circle.setChecked(i == selection);
        circle.setBackgroundColor(
                ContextCompat.getColor(getActivity(), BorderCircleView.sAccentColors.keyAt(i)));
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        int margin = (int) getResources().getDimension(R.dimen.color_dialog_margin);
        params.setMargins(margin, margin, margin, margin);
        circle.setLayoutParams(params);
        circle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (BorderCircleView borderCircleView : circles) {
                    if (v == borderCircleView) {
                        borderCircleView.setChecked(true);
                        mColorSelection = circles.indexOf(borderCircleView);
                    } else {
                        borderCircleView.setChecked(false);
                    }
                }
            }
        });

        circles.add(circle);
        subView.addView(circle);
    }

    new Dialog(getActivity()).setView(linearLayout)
            .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (mColorSelection >= 0) {
                        Prefs.saveString(KEY_ACCENT_COLOR,
                                BorderCircleView.sAccentColors.valueAt(mColorSelection), getActivity());
                    }
                    getActivity().finish();
                    Intent intent = new Intent(getActivity(), MainActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                }
            }).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    mColorSelection = -1;
                }
            }).show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showSendMoneyPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    final String message = "Send Money to Friend In A Flash";
    String positiveButtonText = "Send";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelAmount = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editMobileNo = new EditText(getActivity());
    final TextView labelMessage = new TextView(getActivity());
    final EditText editMessage = new EditText(getActivity());
    editAmount.setSingleLine(true);/*from   w  w  w.  ja  v a  2  s .  c  o m*/
    editMobileNo.setSingleLine(true);
    editMessage.setSingleLine(true);

    labelAmount.setText("Amount");
    labelMobileNo.setText("Enter Mobile No of Friend");
    labelMessage.setText("Enter Message (Optional)");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    labelMessage.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    editMobileNo.setLayoutParams(layoutParams);
    editMessage.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editMobileNo);
    linearLayout.addView(labelMessage);
    linearLayout.addView(editMessage);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editMobileNo.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Send Money In A Flash");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editAmount.getText().toString();
            String mobileNo = editMobileNo.getText().toString();
            String message = editMessage.getText().toString();

            mCitrusClient.sendMoneyToMoblieNo(new Amount(amount), mobileNo, message,
                    new Callback<PaymentResponse>() {
                        @Override
                        public void success(PaymentResponse paymentResponse) {
                            //                        Utils.showToast(getActivity(), paymentResponse.getStatus() == CitrusResponse.Status.SUCCESSFUL ? "Sent Money Successfully." : "Failed To Send the Money");
                            ((UIActivity) getActivity()).showSnackBar(
                                    paymentResponse.getStatus() == CitrusResponse.Status.SUCCESSFUL
                                            ? "Sent Money Successfully."
                                            : "Failed To Send the Money");
                        }

                        @Override
                        public void error(CitrusError error) {
                            //                        Utils.showToast(getActivity(), error.getMessage());
                            ((UIActivity) getActivity()).showSnackBar(error.getMessage());
                        }
                    });
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editAmount.requestFocus();
    alert.show();
}