Search in sources :

Example 91 with TextWatcher

use of android.text.TextWatcher in project twicalico by moko256.

the class PostActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post);
    model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
    subscription = new CompositeSubscription();
    rootViewGroup = findViewById(R.id.activity_tweet_send_layout_root);
    toolbar = findViewById(R.id.activity_tweet_send_toolbar);
    setSupportActionBar(toolbar);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
    userIcon = findViewById(R.id.activity_tweet_send_user_icon);
    GlideApp.with(this).load(GlobalApplication.userCache.get(GlobalApplication.userId).get400x400ProfileImageURLHttps()).circleCrop().into(userIcon);
    counterTextView = findViewById(R.id.tweet_text_edit_counter);
    editText = findViewById(R.id.tweet_text_edit);
    editText.addTextChangedListener(new TextWatcher() {

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

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            model.setTweetText(s.toString());
            counterTextView.setText(String.valueOf(model.getTweetLength()) + " / " + String.valueOf(model.getMaxTweetLength()));
            counterTextView.setTextColor(model.isValidTweet() ? Color.GRAY : Color.RED);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    editText.setImageAddedListener(imageUri -> {
        if (model.getUriList().size() < model.getUriListSizeLimit()) {
            addedImagesAdapter.getImagesList().add(imageUri);
            model.getUriList().add(imageUri);
            addedImagesAdapter.notifyItemChanged(addedImagesAdapter.getImagesList().size() - 1);
            possiblySensitiveSwitch.setEnabled(true);
            return true;
        } else {
            return false;
        }
    });
    editText.setHint(model.isReply() ? R.string.reply : R.string.post);
    imagesRecyclerView = findViewById(R.id.activity_tweet_send_images_recycler_view);
    addedImagesAdapter = new AddedImagesAdapter(this);
    imagesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
    imagesRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            outRect.right = Math.round(getResources().getDisplayMetrics().density);
        }
    });
    addedImagesAdapter.setLimit(model.getUriListSizeLimit());
    addedImagesAdapter.setOnAddButtonClickListener(v -> startActivityForResult(Intent.createChooser(new Intent(Intent.ACTION_GET_CONTENT).addCategory(Intent.CATEGORY_OPENABLE).putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/*", "video/*" }).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true).setType("*/*"), getString(R.string.add_image)), REQUEST_GET_IMAGE));
    addedImagesAdapter.setOnDeleteButtonListener(position -> {
        addedImagesAdapter.getImagesList().remove(position);
        model.getUriList().remove(position);
        addedImagesAdapter.notifyDataSetChanged();
        boolean enabled = model.getUriList().size() > 0;
        possiblySensitiveSwitch.setEnabled(enabled);
        possiblySensitiveSwitch.setChecked(possiblySensitiveSwitch.isChecked() && enabled);
    });
    addedImagesAdapter.setOnImageClickListener(position -> {
        Intent open = new Intent(Intent.ACTION_VIEW).setData(model.getUriList().get(position)).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(open, getString(R.string.open_image)));
    });
    imagesRecyclerView.setAdapter(addedImagesAdapter);
    possiblySensitiveSwitch = findViewById(R.id.activity_tweet_possibly_sensitive_switch);
    possiblySensitiveSwitch.setEnabled(addedImagesAdapter.getImagesList().size() > 0);
    possiblySensitiveSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> model.setPossiblySensitive(isChecked));
    addLocationSwitch = findViewById(R.id.activity_tweet_location_switch);
    addLocationSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
        if (isChecked) {
            if (PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED) {
                subscription.add(getLocation().subscribe(it -> {
                    model.setLocation(new GeoLocation(it.getLatitude(), it.getLongitude()));
                    locationText.setVisibility(View.VISIBLE);
                    locationText.setText(getString(R.string.lat_and_lon, it.getLatitude(), it.getLongitude()));
                }, Throwable::printStackTrace));
            } else {
                ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 400);
            }
        } else {
            locationText.setVisibility(View.GONE);
        }
    });
    locationText = findViewById(R.id.activity_tweet_location_result);
    locationText.setVisibility(View.GONE);
    if (getIntent() != null) {
        if (!model.isReply()) {
            model.setInReplyToStatusId(getIntent().getLongExtra(INTENT_EXTRA_IN_REPLY_TO_STATUS_ID, -1));
        }
        String text = getIntent().getStringExtra(INTENT_EXTRA_TWEET_TEXT);
        if (text != null) {
            editText.setText(text);
            editText.setSelection(text.length());
        } else {
            editText.setText("");
        }
        ArrayList<Uri> uris = getIntent().getParcelableArrayListExtra(INTENT_EXTRA_IMAGE_URI);
        if (uris != null) {
            addedImagesAdapter.getImagesList().addAll(uris);
            model.getUriList().addAll(uris);
            possiblySensitiveSwitch.setEnabled(true);
        }
    }
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Bundle(android.os.Bundle) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) Criteria(android.location.Criteria) Uri(android.net.Uri) ImageView(android.widget.ImageView) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) LocationListener(android.location.LocationListener) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) Editable(android.text.Editable) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) Manifest(android.Manifest) ImageKeyboardEditText(com.github.moko256.twicalico.widget.ImageKeyboardEditText) Single(rx.Single) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Parcelable(android.os.Parcelable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwitchCompat(android.support.v7.widget.SwitchCompat) ActivityCompat(android.support.v4.app.ActivityCompat) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) Color(android.graphics.Color) CompositeSubscription(rx.subscriptions.CompositeSubscription) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar) GeoLocation(twitter4j.GeoLocation) PermissionChecker(android.support.v4.content.PermissionChecker) Location(android.location.Location) Snackbar(android.support.design.widget.Snackbar) PostTweetModelCreator(com.github.moko256.twicalico.model.impl.PostTweetModelCreator) LocationManager(android.location.LocationManager) TextWatcher(android.text.TextWatcher) Rect(android.graphics.Rect) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Uri(android.net.Uri) CompositeSubscription(rx.subscriptions.CompositeSubscription) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(android.support.v7.widget.RecyclerView) GeoLocation(twitter4j.GeoLocation)

Example 92 with TextWatcher

use of android.text.TextWatcher in project J2ME-Loader by nikita36078.

the class ConfigActivity method onCreate.

@SuppressLint({ "StringFormatMatches", "StringFormatInvalid" })
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_config);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ContextHolder.setCurrentActivity(this);
    pathToMidletDir = getIntent().getDataString();
    String appName = pathToMidletDir.substring(pathToMidletDir.lastIndexOf('/') + 1);
    keylayoutFile = new File(DATA_DIR + appName, "VirtualKeyboardLayout");
    dataDir = new File(DATA_DIR + appName);
    params = new SharedPreferencesContainer(appName, Context.MODE_PRIVATE, this);
    System.setProperty("microedition.sensor.version", "1");
    System.setProperty("microedition.platform", "Nokia 6233");
    System.setProperty("microedition.configuration", "CDLC1.1");
    System.setProperty("microedition.profiles", "MIDP2.0");
    System.setProperty("microedition.m3g.version", "1.1");
    System.setProperty("microedition.media.version", "1.0");
    System.setProperty("supports.mixing", "true");
    System.setProperty("supports.audio.capture", "false");
    System.setProperty("supports.video.capture", "false");
    System.setProperty("supports.recording", "false");
    System.setProperty("microedition.pim.version", "1.0");
    System.setProperty("microedition.io.file.FileConnection.version", "1.0");
    System.setProperty("microedition.locale", Locale.getDefault().getCountry().toLowerCase());
    System.setProperty("microedition.encoding", "ISO-8859-1");
    System.setProperty("user.home", Environment.getExternalStorageDirectory().getPath());
    tfScreenWidth = findViewById(R.id.tfScreenWidth);
    tfScreenHeight = findViewById(R.id.tfScreenHeight);
    tfScreenBack = findViewById(R.id.tfScreenBack);
    cxScaleToFit = findViewById(R.id.cxScaleToFit);
    sbScaleRatio = findViewById(R.id.sbScaleRatio);
    tfScaleRatioValue = findViewById(R.id.tfScaleRatioValue);
    spOrientation = findViewById(R.id.spOrientation);
    cxKeepAspectRatio = findViewById(R.id.cxKeepAspectRatio);
    cxFilter = findViewById(R.id.cxFilter);
    cxImmediate = findViewById(R.id.cxImmediate);
    cxHwAcceleration = findViewById(R.id.cxHwAcceleration);
    tfFontSizeSmall = findViewById(R.id.tfFontSizeSmall);
    tfFontSizeMedium = findViewById(R.id.tfFontSizeMedium);
    tfFontSizeLarge = findViewById(R.id.tfFontSizeLarge);
    cxFontSizeInSP = findViewById(R.id.cxFontSizeInSP);
    tfSystemProperties = findViewById(R.id.tfSystemProperties);
    cxShowKeyboard = findViewById(R.id.cxIsShowKeyboard);
    cxVKFeedback = findViewById(R.id.cxVKFeedback);
    cxTouchInput = findViewById(R.id.cxTouchInput);
    sbVKAlpha = findViewById(R.id.sbVKAlpha);
    tfVKHideDelay = findViewById(R.id.tfVKHideDelay);
    tfVKFore = findViewById(R.id.tfVKFore);
    tfVKBack = findViewById(R.id.tfVKBack);
    tfVKSelFore = findViewById(R.id.tfVKSelFore);
    tfVKSelBack = findViewById(R.id.tfVKSelBack);
    tfVKOutline = findViewById(R.id.tfVKOutline);
    screenWidths = new ArrayList<>();
    screenHeights = new ArrayList<>();
    screenAdapter = new ArrayList<>();
    fillScreenSizePresets(ContextHolder.getDisplayWidth(), ContextHolder.getDisplayHeight());
    fontSmall = new ArrayList<>();
    fontMedium = new ArrayList<>();
    fontLarge = new ArrayList<>();
    fontAdapter = new ArrayList<>();
    addFontSizePreset("128 x 128", 9, 13, 15);
    addFontSizePreset("128 x 160", 13, 15, 20);
    addFontSizePreset("176 x 220", 15, 18, 22);
    addFontSizePreset("240 x 320", 18, 22, 26);
    findViewById(R.id.cmdScreenSizePresets).setOnClickListener(this);
    findViewById(R.id.cmdSwapSizes).setOnClickListener(this);
    findViewById(R.id.cmdFontSizePresets).setOnClickListener(this);
    findViewById(R.id.cmdScreenBack).setOnClickListener(this);
    findViewById(R.id.cmdVKBack).setOnClickListener(this);
    findViewById(R.id.cmdVKFore).setOnClickListener(this);
    findViewById(R.id.cmdVKSelBack).setOnClickListener(this);
    findViewById(R.id.cmdVKSelFore).setOnClickListener(this);
    findViewById(R.id.cmdVKOutline).setOnClickListener(this);
    sbScaleRatio.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
            tfScaleRatioValue.setText(String.valueOf(progress));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    tfScaleRatioValue.addTextChangedListener(new TextWatcher() {

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

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            Integer enteredProgress = Integer.valueOf(s.toString());
            sbScaleRatio.setProgress(enteredProgress);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    loadParams(params);
    applyConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        cxHwAcceleration.setVisibility(View.VISIBLE);
    }
    cxVKFeedback.setEnabled(cxShowKeyboard.isChecked());
    cxShowKeyboard.setOnClickListener(v -> {
        if (!((CheckBox) v).isChecked()) {
            cxVKFeedback.setEnabled(false);
        } else {
            cxVKFeedback.setEnabled(true);
        }
    });
    File appSettings = new File(getFilesDir().getParent() + File.separator + "shared_prefs", appName + ".xml");
    if (appSettings.exists() && !getIntent().getBooleanExtra(SHOW_SETTINGS_KEY, false)) {
        startMIDlet();
    }
}
Also used : SeekBar(android.widget.SeekBar) SharedPreferencesContainer(javax.microedition.util.param.SharedPreferencesContainer) SuppressLint(android.annotation.SuppressLint) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Example 93 with TextWatcher

use of android.text.TextWatcher in project Shuttle by timusus.

the class PlaylistUtils method renamePlaylistDialog.

public static void renamePlaylistDialog(final Context context, final Playlist playlist) {
    @SuppressLint("InflateParams") View customView = LayoutInflater.from(context).inflate(R.layout.dialog_playlist, null);
    final EditText editText = 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();
        }
    }).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 : EditText(android.widget.EditText) R(com.simplecity.amp_library.R) Spannable(android.text.Spannable) Completable(io.reactivex.Completable) Uri(android.net.Uri) PlayCountTable(com.simplecity.amp_library.sql.providers.PlayCountTable) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Song(com.simplecity.amp_library.model.Song) Optional(com.annimon.stream.Optional) CheckBox(android.widget.CheckBox) ContentResolver(android.content.ContentResolver) MediaStore(android.provider.MediaStore) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) Log(android.util.Log) Playlist(com.simplecity.amp_library.model.Playlist) SubMenu(android.view.SubMenu) Query(com.simplecity.amp_library.model.Query) List(java.util.List) TextView(android.widget.TextView) ContentValues(android.content.ContentValues) Nullable(android.support.annotation.Nullable) 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) Single(io.reactivex.Single) Editable(android.text.Editable) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) SpannableStringBuilder(android.text.SpannableStringBuilder) Toast(android.widget.Toast) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Observable(io.reactivex.Observable) UnsafeConsumer(com.simplecity.amp_library.rx.UnsafeConsumer) Cursor(android.database.Cursor) SqlBriteUtils(com.simplecity.amp_library.sql.sqlbrite.SqlBriteUtils) 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) TimeUnit(java.util.concurrent.TimeUnit) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) Pair(android.support.v4.util.Pair) Crashlytics(com.crashlytics.android.Crashlytics) Collections(java.util.Collections) EditText(android.widget.EditText) ContentUris(android.content.ContentUris) ContentValues(android.content.ContentValues) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SuppressLint(android.annotation.SuppressLint) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver)

Example 94 with TextWatcher

use of android.text.TextWatcher in project SmartCampus by Vegen.

the class EaseContactListFragment method setUpView.

@Override
protected void setUpView() {
    EMClient.getInstance().addConnectionListener(connectionListener);
    contactList = new ArrayList<EaseUser>();
    getContactList();
    // init list
    contactListLayout.init(contactList);
    if (listItemClickListener != null) {
        listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EaseUser user = (EaseUser) listView.getItemAtPosition(position);
                listItemClickListener.onListItemClicked(user);
            }
        });
    }
    query.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            contactListLayout.filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);
            }
        }

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

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideSoftKeyboard();
            return false;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) MotionEvent(android.view.MotionEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClickListener(android.view.View.OnClickListener) EaseUser(com.hyphenate.easeui.domain.EaseUser)

Example 95 with TextWatcher

use of android.text.TextWatcher in project iNGAGE by davis123123.

the class ChatActivity method textChangeListener.

private void textChangeListener() {
    textField.addTextChangedListener(new TextWatcher() {

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

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String ss = textField.getText().toString();
            // Toast.makeText(getBaseContext(),"itemclick" + haschar,Toast.LENGTH_SHORT).show();
            if (ss.contains("@") && !haschar) {
                haschar = true;
                // Start Tagging here
                startTagActivity();
            } else if (!(ss.contains("@"))) {
                haschar = false;
                tagged = false;
            // Log.d("STATE", "text: " + ss);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Aggregations

TextWatcher (android.text.TextWatcher)192 Editable (android.text.Editable)158 View (android.view.View)96 TextView (android.widget.TextView)75 Paint (android.graphics.Paint)37 ImageView (android.widget.ImageView)30 TextPaint (android.text.TextPaint)28 EditText (android.widget.EditText)28 Intent (android.content.Intent)25 KeyEvent (android.view.KeyEvent)24 AdapterView (android.widget.AdapterView)21 ListView (android.widget.ListView)17 RecyclerView (android.support.v7.widget.RecyclerView)15 DialogInterface (android.content.DialogInterface)13 SuppressLint (android.annotation.SuppressLint)12 OnClickListener (android.view.View.OnClickListener)12 Button (android.widget.Button)12 InputMethodManager (android.view.inputmethod.InputMethodManager)11 AlertDialog (android.app.AlertDialog)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9