Search in sources :

Example 56 with EditText

use of android.widget.EditText in project FBReaderJ by geometer.

the class FileChooserActivity method doCreateNewDir.

// doSwitchViewType()
/**
     * Confirms user to create new directory.
     */
private void doCreateNewDir() {
    if (mFileProvider instanceof LocalFileProvider && !Utils.hasPermissions(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        Dlg.toast(this, R.string.afc_msg_app_doesnot_have_permission_to_create_files, Dlg._LengthShort);
        return;
    }
    if ((getLocation() instanceof File)) {
        if (!((File) getLocation()).canWrite()) {
            Dlg.toast(this, R.string.afc_msg_app_cant_create_folder, Dlg._LengthShort);
            return;
        }
    }
    final AlertDialog _dlg = Dlg.newDlg(this);
    View view = getLayoutInflater().inflate(R.layout.afc_simple_text_input_view, null);
    final EditText _textFile = (EditText) view.findViewById(R.id.afc_simple_text_input_view_text1);
    _textFile.setHint(mTextResources.get("folderNameHint"));
    _textFile.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                Ui.hideSoftKeyboard(FileChooserActivity.this, _textFile.getWindowToken());
                _dlg.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
                return true;
            }
            return false;
        }
    });
    _dlg.setView(view);
    _dlg.setTitle(mTextResources.get("newFolder"));
    _dlg.setIcon(android.R.drawable.ic_menu_add);
    _dlg.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String name = _textFile.getText().toString().trim();
            if (!FileUtils.isFilenameValid(name)) {
                Dlg.toast(FileChooserActivity.this, getString(R.string.afc_pmsg_filename_is_invalid, name), Dlg._LengthShort);
                return;
            }
            final IFileProvider fileProvider = mFileProvider;
            final IFile location = getLocation();
            if (fileProvider == null || location == null) {
                return;
            }
            IFile dir = fileProvider.fromPath(String.format("%s/%s", location.getAbsolutePath(), name));
            if (dir.mkdir()) {
                Dlg.toast(FileChooserActivity.this, getString(R.string.afc_msg_done), Dlg._LengthShort);
                setLocation(getLocation(), null);
            } else
                Dlg.toast(FileChooserActivity.this, getString(R.string.afc_pmsg_cannot_create_folder, name), Dlg._LengthShort);
        }
    });
    _dlg.show();
    final Button _btnOk = _dlg.getButton(DialogInterface.BUTTON_POSITIVE);
    _btnOk.setEnabled(false);
    _textFile.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        // TODO Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            _btnOk.setEnabled(FileUtils.isFilenameValid(s.toString().trim()));
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) IFileProvider(group.pals.android.lib.ui.filechooser.services.IFileProvider) IFile(group.pals.android.lib.ui.filechooser.io.IFile) DialogInterface(android.content.DialogInterface) LocalFileProvider(group.pals.android.lib.ui.filechooser.services.LocalFileProvider) GridView(android.widget.GridView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) IFile(group.pals.android.lib.ui.filechooser.io.IFile) File(java.io.File)

Example 57 with EditText

use of android.widget.EditText in project AndroidSDK-RecipeBook by gabu.

the class MyActivity method onCreate.

@Override
public void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity);
    // EditText
    EditText editText = (EditText) findViewById(R.id.EditText01);
    // Widget の id を受け取る
    final Uri uri = getIntent().getData();
    // 過去のデータを表示
    if (uri != null) {
        int id = (int) ContentUris.parseId(uri);
        editText.setText(loadText(id));
    }
    // Button
    Button button = (Button) findViewById(R.id.Button01);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Context context = MyActivity.this;
            AppWidgetManager manager = AppWidgetManager.getInstance(context);
            RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
            EditText editText = (EditText) findViewById(R.id.EditText01);
            CharSequence text = editText.getText();
            if (uri != null) {
                int id = (int) ContentUris.parseId(uri);
                Log.d("MyActivity", "id:" + id);
                // 入力された値を保存
                saveText(id, text);
                // Widget 表示を更新
                remoteViews.setTextViewText(R.id.TextView01, text);
                manager.updateAppWidget(id, remoteViews);
            }
            finish();
        }
    });
}
Also used : EditText(android.widget.EditText) Context(android.content.Context) RemoteViews(android.widget.RemoteViews) Button(android.widget.Button) AppWidgetManager(android.appwidget.AppWidgetManager) Uri(android.net.Uri) View(android.view.View)

Example 58 with EditText

use of android.widget.EditText in project stetho by facebook.

the class AccessibilityNodeInfoWrapper method getDescription.

@Nullable
public static CharSequence getDescription(View view) {
    AccessibilityNodeInfoCompat node = createNodeInfoFromView(view);
    try {
        CharSequence contentDescription = node.getContentDescription();
        CharSequence nodeText = node.getText();
        boolean hasNodeText = !TextUtils.isEmpty(nodeText);
        boolean isEditText = view instanceof EditText;
        // EditText's prioritize their own text content over a contentDescription
        if (!TextUtils.isEmpty(contentDescription) && (!isEditText || !hasNodeText)) {
            return contentDescription;
        }
        if (hasNodeText) {
            return nodeText;
        }
        // comma separated, becomes the description.
        if (view instanceof ViewGroup) {
            final StringBuilder concatChildDescription = new StringBuilder();
            final String separator = ", ";
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0, count = viewGroup.getChildCount(); i < count; i++) {
                final View child = viewGroup.getChildAt(i);
                AccessibilityNodeInfoCompat childNodeInfo = AccessibilityNodeInfoCompat.obtain();
                ViewCompat.onInitializeAccessibilityNodeInfo(child, childNodeInfo);
                CharSequence childNodeDescription = null;
                if (AccessibilityUtil.isSpeakingNode(childNodeInfo, child) && !AccessibilityUtil.isAccessibilityFocusable(childNodeInfo, child)) {
                    childNodeDescription = getDescription(child);
                }
                if (!TextUtils.isEmpty(childNodeDescription)) {
                    if (concatChildDescription.length() > 0) {
                        concatChildDescription.append(separator);
                    }
                    concatChildDescription.append(childNodeDescription);
                }
                childNodeInfo.recycle();
            }
            return concatChildDescription.length() > 0 ? concatChildDescription.toString() : null;
        }
        return null;
    } finally {
        node.recycle();
    }
}
Also used : EditText(android.widget.EditText) ViewGroup(android.view.ViewGroup) AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 59 with EditText

use of android.widget.EditText in project android-sqrl by geir54.

the class newuserActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_newuser);
    final EditText userEdit = (EditText) findViewById(R.id.editText1);
    final EditText passEdit = (EditText) findViewById(R.id.editText2);
    final EditText repassEdit = (EditText) findViewById(R.id.editText3);
    final Button button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            String user = userEdit.getText().toString();
            String pass = passEdit.getText().toString();
            String repass = repassEdit.getText().toString();
            if (pass.compareTo(repass) == 0) {
                // Check that password and retype are the same
                identity id = new identity();
                id.createKeys();
                id.makeVerificationKey(pass);
                id.save(getApplicationContext());
                finish();
            }
        }
    });
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) View(android.view.View)

Example 60 with EditText

use of android.widget.EditText in project WordPress-Android by wordpress-mobile.

the class LegacyEditorFragment method loadWPImageSpanThumbnail.

private void loadWPImageSpanThumbnail(MediaFile mediaFile, String imageURL, ImageLoader imageLoader) {
    if (mediaFile == null || imageURL == null) {
        return;
    }
    final String mediaId = mediaFile.getMediaId();
    if (mediaId == null) {
        return;
    }
    final int maxThumbWidth = ImageUtils.getMaximumThumbnailWidthForEditor(getActivity());
    imageLoader.get(imageURL, new ImageLoader.ImageListener() {

        @Override
        public void onErrorResponse(VolleyError arg0) {
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer container, boolean arg1) {
            Bitmap downloadedBitmap = container.getBitmap();
            if (downloadedBitmap == null) {
                // no bitmap downloaded from the server.
                return;
            }
            if (downloadedBitmap.getWidth() < MIN_THUMBNAIL_WIDTH) {
                // Picture is too small. Show the placeholder in this case.
                return;
            }
            Bitmap resizedBitmap;
            // resize the downloaded bitmap
            resizedBitmap = ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap, maxThumbWidth);
            if (resizedBitmap == null) {
                return;
            }
            final EditText editText = mContentEditText;
            Editable s = editText.getText();
            if (s == null) {
                return;
            }
            WPImageSpan[] spans = s.getSpans(0, s.length(), WPImageSpan.class);
            if (spans.length != 0 && getActivity() != null) {
                for (WPImageSpan is : spans) {
                    MediaFile mediaFile = is.getMediaFile();
                    if (mediaFile == null) {
                        continue;
                    }
                    if (mediaId.equals(mediaFile.getMediaId()) && !is.isNetworkImageLoaded()) {
                        // replace the existing span with a new one with the correct image, re-add
                        // it to the same position.
                        int spanStart = is.getStartPosition();
                        int spanEnd = is.getEndPosition();
                        WPEditImageSpan imageSpan = new WPEditImageSpan(getActivity(), resizedBitmap, is.getImageSource());
                        imageSpan.setMediaFile(is.getMediaFile());
                        imageSpan.setNetworkImageLoaded(true);
                        imageSpan.setPosition(spanStart, spanEnd);
                        s.removeSpan(is);
                        s.setSpan(imageSpan, spanStart, spanEnd + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                        break;
                    }
                }
            }
        }
    }, 0, 0);
}
Also used : VolleyError(com.android.volley.VolleyError) WPEditText(org.wordpress.android.util.widgets.WPEditText) EditText(android.widget.EditText) MediaFile(org.wordpress.android.util.helpers.MediaFile) WPEditImageSpan(org.wordpress.android.editor.legacy.WPEditImageSpan) WPImageSpan(org.wordpress.android.util.helpers.WPImageSpan) Bitmap(android.graphics.Bitmap) Editable(android.text.Editable) ImageLoader(com.android.volley.toolbox.ImageLoader)

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