Search in sources :

Example 6 with EditText

use of android.widget.EditText in project playn by threerings.

the class AndroidKeyboard method getText.

@Override
public void getText(final TextType textType, final String label, final String initVal, final Callback<String> callback) {
    platform.activity.runOnUiThread(new Runnable() {

        public void run() {
            final AlertDialog.Builder alert = new AlertDialog.Builder(platform.activity);
            alert.setMessage(label);
            // Set an EditText view to get user input
            final EditText input = new EditText(platform.activity);
            final int inputType;
            switch(textType) {
                case NUMBER:
                    inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
                    break;
                case EMAIL:
                    inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
                    break;
                case URL:
                    inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
                    break;
                case DEFAULT:
                default:
                    inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
                    break;
            }
            input.setInputType(inputType);
            input.setText(initVal);
            alert.setView(input);
            alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    final String value = input.getText().toString();
                    platform.notifySuccess(callback, value);
                }
            });
            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    platform.notifySuccess(callback, null);
                }
            });
            alert.show();
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface)

Example 7 with EditText

use of android.widget.EditText in project jpHolo by teusink.

the class InAppBrowser method showWebPage.

/**
     * Display a new browser with the specified URL.
     *
     * @param url           The url to load.
     * @param jsonObject
     */
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);
            // Will not except input... Makes the text NON-EDITABLE
            edittext.setInputType(InputType.TYPE_NULL);
            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);
            // Show() needs to be called to cause the URL to be loaded
            if (openWindowHidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}
Also used : WindowManager(android.view.WindowManager) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) CordovaWebView(org.apache.cordova.CordovaWebView) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient) EditText(android.widget.EditText) LayoutParams(android.view.WindowManager.LayoutParams) InAppBrowserDialog(org.apache.cordova.inappbrowser.InAppBrowserDialog) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) CordovaWebView(org.apache.cordova.CordovaWebView) View(android.view.View) WebView(android.webkit.WebView) SuppressLint(android.annotation.SuppressLint) WebSettings(android.webkit.WebSettings) RelativeLayout(android.widget.RelativeLayout) LayoutParams(android.view.WindowManager.LayoutParams) CordovaWebView(org.apache.cordova.CordovaWebView) Resources(android.content.res.Resources) LinearLayout(android.widget.LinearLayout)

Example 8 with EditText

use of android.widget.EditText in project Shuttle by timusus.

the class PlaylistUtils method renamePlaylistDialog.

public static void renamePlaylistDialog(final Context context, final Playlist playlist, final MaterialDialog.SingleButtonCallback listener) {
    View customView = LayoutInflater.from(context).inflate(R.layout.dialog_playlist, null);
    final CustomEditText editText = (CustomEditText) customView.findViewById(R.id.editText);
    editText.setText(playlist.name);
    MaterialDialog.Builder builder = DialogUtils.getBuilder(context).title(R.string.create_playlist_create_text_prompt).customView(customView, false).positiveText(R.string.save).onPositive((materialDialog, dialogAction) -> {
        String name = editText.getText().toString();
        if (name.length() > 0) {
            ContentResolver resolver = context.getContentResolver();
            ContentValues values = new ContentValues(1);
            values.put(MediaStore.Audio.Playlists.NAME, name);
            resolver.update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values, MediaStore.Audio.Playlists._ID + "=?", new String[] { Long.valueOf(playlist.id).toString() });
            playlist.name = name;
            Toast.makeText(context, R.string.playlist_renamed_message, Toast.LENGTH_SHORT).show();
        }
        if (listener != null) {
            listener.onClick(materialDialog, dialogAction);
        }
    }).negativeText(R.string.cancel);
    final MaterialDialog dialog = builder.build();
    TextWatcher textWatcher = new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // check if playlist with current name exists already, and warn the user if so.
            setSaveButton(dialog, playlist, editText.getText().toString());
        }

        public void afterTextChanged(Editable s) {
        }
    };
    editText.addTextChangedListener(textWatcher);
    dialog.show();
}
Also used : R(com.simplecity.amp_library.R) Spannable(android.text.Spannable) Uri(android.net.Uri) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) PlayCountTable(com.simplecity.amp_library.sql.providers.PlayCountTable) Song(com.simplecity.amp_library.model.Song) CheckBox(android.widget.CheckBox) ContentResolver(android.content.ContentResolver) MediaStore(android.provider.MediaStore) Schedulers(rx.schedulers.Schedulers) View(android.view.View) Log(android.util.Log) Playlist(com.simplecity.amp_library.model.Playlist) BaseColumns(android.provider.BaseColumns) SubMenu(android.view.SubMenu) Query(com.simplecity.amp_library.model.Query) List(java.util.List) TextView(android.widget.TextView) ContentValues(android.content.ContentValues) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SqlUtils(com.simplecity.amp_library.sql.SqlUtils) TextWatcher(android.text.TextWatcher) FileType(com.simplecity.amp_library.interfaces.FileType) Context(android.content.Context) Stream(com.annimon.stream.Stream) Environment(android.os.Environment) Dialog(android.app.Dialog) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) Editable(android.text.Editable) Observable(rx.Observable) SpannableStringBuilder(android.text.SpannableStringBuilder) Func1(rx.functions.Func1) Toast(android.widget.Toast) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Cursor(android.database.Cursor) SqlBriteUtils(com.simplecity.amp_library.sql.sqlbrite.SqlBriteUtils) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) StyleSpan(android.text.style.StyleSpan) FileWriter(java.io.FileWriter) ProgressDialog(android.app.ProgressDialog) TextUtils(android.text.TextUtils) DialogAction(com.afollestad.materialdialogs.DialogAction) IOException(java.io.IOException) WorkerThread(android.support.annotation.WorkerThread) File(java.io.File) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) MusicService(com.simplecity.amp_library.playback.MusicService) Crashlytics(com.crashlytics.android.Crashlytics) CustomEditText(com.simplecity.amp_library.ui.views.CustomEditText) EditText(android.widget.EditText) ContentUris(android.content.ContentUris) ContentValues(android.content.ContentValues) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CustomEditText(com.simplecity.amp_library.ui.views.CustomEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver)

Example 9 with EditText

use of android.widget.EditText in project Shuttle by timusus.

the class ThemeUtils method themeSearchView.

@SuppressLint("InlinedApi")
public static void themeSearchView(Context context, SearchView searchView) {
    FilterableStateListDrawable stateListDrawable = new FilterableStateListDrawable();
    NinePatchDrawable disabledDrawable = (NinePatchDrawable) CompatUtils.getDrawableCompat(context, R.drawable.abc_textfield_search_default_mtrl_alpha);
    NinePatchDrawable otherDrawable = (NinePatchDrawable) CompatUtils.getDrawableCompat(context, R.drawable.abc_textfield_search_activated_mtrl_alpha);
    int accentColor = ColorUtils.getAccentColor();
    ColorFilter colorFilter = new PorterDuffColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
    stateListDrawable.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_activated }, otherDrawable, colorFilter);
    stateListDrawable.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused }, otherDrawable, colorFilter);
    stateListDrawable.addState(StateSet.WILD_CARD, disabledDrawable);
    View searchPlate = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
    searchPlate.setBackground(stateListDrawable);
    EditText searchTextView = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    try {
        Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        mCursorDrawableRes.setAccessible(true);
        mCursorDrawableRes.set(searchTextView, 0);
    } catch (final Exception | NoClassDefFoundError ignored) {
    }
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) AppCompatEditText(android.support.v7.widget.AppCompatEditText) EditText(android.widget.EditText) Field(java.lang.reflect.Field) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) HmsView(com.doomonafireball.betterpickers.hmspicker.HmsView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) SuppressLint(android.annotation.SuppressLint)

Example 10 with EditText

use of android.widget.EditText in project glitch-hq-android by tinyspeck.

the class ActivityDetailFragment method setActivityDetailView.

void setActivityDetailView(View root) {
    View sectionAct = root.findViewById(R.id.section_activity);
    root.findViewById(R.id.notes_detail_view).setVisibility(m_bNotes ? View.VISIBLE : View.GONE);
    sectionAct.setVisibility(m_bNotes ? View.GONE : View.VISIBLE);
    View sectionV = root.findViewById(R.id.section_in_reply_to);
    setUpdatesSection(sectionV, m_currentActivity.in_reply_to);
    sectionV = root.findViewById(R.id.section_myself);
    setUpdatesSection(m_bNotes ? sectionV : sectionAct, m_currentActivity);
    sectionV = root.findViewById(R.id.section_replies);
    if (m_currentActivity.replies == null || m_currentActivity.replies.size() == 0)
        sectionV.setVisibility(View.GONE);
    else {
        sectionV.setVisibility(View.VISIBLE);
        addRepliesToLayout(root, m_currentActivity.replies);
    }
    if (m_bNotes) {
        root.findViewById(R.id.reply_pane).setVisibility(View.VISIBLE);
        EditText ed = (EditText) root.findViewById(R.id.replyEditor);
        ed.setHint("Reply to " + m_currentActivity.who + "'s update...");
        replyNotes(ed);
    }
}
Also used : EditText(android.widget.EditText) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Aggregations

EditText (android.widget.EditText)655 View (android.view.View)309 TextView (android.widget.TextView)220 DialogInterface (android.content.DialogInterface)143 AlertDialog (android.app.AlertDialog)126 Button (android.widget.Button)126 Intent (android.content.Intent)99 LinearLayout (android.widget.LinearLayout)79 ImageView (android.widget.ImageView)61 AlertDialog (android.support.v7.app.AlertDialog)54 ScrollView (android.widget.ScrollView)52 LayoutInflater (android.view.LayoutInflater)48 AdapterView (android.widget.AdapterView)46 ViewGroup (android.view.ViewGroup)42 Editable (android.text.Editable)41 Context (android.content.Context)40 RecyclerView (android.support.v7.widget.RecyclerView)40 ListView (android.widget.ListView)39 Dialog (android.app.Dialog)36 Bundle (android.os.Bundle)36