Search in sources :

Example 41 with EditText

use of android.widget.EditText in project ShortcutBadger by leolin310148.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final EditText numInput = (EditText) findViewById(R.id.numInput);
    Button button = (Button) findViewById(R.id.btnSetBadge);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int badgeCount = 0;
            try {
                badgeCount = Integer.parseInt(numInput.getText().toString());
            } catch (NumberFormatException e) {
                Toast.makeText(getApplicationContext(), "Error input", Toast.LENGTH_SHORT).show();
            }
            boolean success = ShortcutBadger.applyCount(MainActivity.this, badgeCount);
            Toast.makeText(getApplicationContext(), "Set count=" + badgeCount + ", success=" + success, Toast.LENGTH_SHORT).show();
        }
    });
    Button launchNotification = (Button) findViewById(R.id.btnSetBadgeByNotification);
    launchNotification.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int badgeCount = 0;
            try {
                badgeCount = Integer.parseInt(numInput.getText().toString());
            } catch (NumberFormatException e) {
                Toast.makeText(getApplicationContext(), "Error input", Toast.LENGTH_SHORT).show();
            }
            finish();
            startService(new Intent(MainActivity.this, BadgeIntentService.class).putExtra("badgeCount", badgeCount));
        }
    });
    Button removeBadgeBtn = (Button) findViewById(R.id.btnRemoveBadge);
    removeBadgeBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            boolean success = ShortcutBadger.removeCount(MainActivity.this);
            Toast.makeText(getApplicationContext(), "success=" + success, Toast.LENGTH_SHORT).show();
        }
    });
    //find the home launcher Package
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
    String currentHomePackage = resolveInfo.activityInfo.packageName;
    TextView textViewHomePackage = (TextView) findViewById(R.id.textViewHomePackage);
    textViewHomePackage.setText("launcher:" + currentHomePackage);
}
Also used : EditText(android.widget.EditText) ResolveInfo(android.content.pm.ResolveInfo) Button(android.widget.Button) Intent(android.content.Intent) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 42 with EditText

use of android.widget.EditText in project danci by ling0322.

the class MainActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    Log.d("lia", "main resume");
    EditText et = (EditText) findViewById(R.id.editText1);
    if (et != null)
        et.clearFocus();
}
Also used : EditText(android.widget.EditText)

Example 43 with EditText

use of android.widget.EditText in project danci by ling0322.

the class MainActivity method openIME.

public void openIME(View view) {
    EditText et = (EditText) findViewById(R.id.editText1);
    if (et == null)
        return;
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, 0);
    Log.d("lia", "open input method");
}
Also used : EditText(android.widget.EditText) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 44 with EditText

use of android.widget.EditText in project MusicDNA by harjot-oberai.

the class HomeActivity method renamePlaylistDialog.

public void renamePlaylistDialog(String oldName) {
    final Dialog dialog = new Dialog(ctx);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.save_image_dialog);
    TextView titleText = (TextView) dialog.findViewById(R.id.dialog_title);
    titleText.setText("Rename");
    if (SplashActivity.tf4 != null)
        titleText.setTypeface(SplashActivity.tf4);
    Button btn = (Button) dialog.findViewById(R.id.save_image_btn);
    final EditText newName = (EditText) dialog.findViewById(R.id.save_image_filename_text);
    CheckBox cb = (CheckBox) dialog.findViewById(R.id.text_checkbox);
    cb.setVisibility(GONE);
    newName.setText(oldName);
    btn.setBackgroundColor(themeColor);
    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (newName.getText().toString().trim().equals("")) {
                newName.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (newName.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        newName.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    allPlaylists.getPlaylists().get(renamePlaylistNumber).setPlaylistName(newName.getText().toString());
                    if (pAdapter != null) {
                        pAdapter.notifyItemChanged(renamePlaylistNumber);
                    }
                    AllPlaylistsFragment plFrag = (AllPlaylistsFragment) fragMan.findFragmentByTag("allPlaylists");
                    if (plFrag != null) {
                        plFrag.itemChanged(renamePlaylistNumber);
                    }
                    if (isPlaylistVisible) {
                        ViewPlaylistFragment vplFragment = (ViewPlaylistFragment) fragMan.findFragmentByTag("playlist");
                        vplFragment.updateViewPlaylistFragment();
                    }
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    dialog.dismiss();
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) CheckBox(android.widget.CheckBox) ViewPlaylistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewPlaylistFragment.ViewPlaylistFragment) TextView(android.widget.TextView) AllPlaylistsFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView)

Example 45 with EditText

use of android.widget.EditText in project MusicDNA by harjot-oberai.

the class HomeActivity method showAddToPlaylistDialog.

public void showAddToPlaylistDialog(final UnifiedTrack track) {
    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.add_to_playlist_dialog);
    dialog.setTitle("Add to Playlist");
    ListView lv = (ListView) dialog.findViewById(R.id.playlist_list);
    AddToPlaylistAdapter adapter;
    if (allPlaylists.getPlaylists() != null && allPlaylists.getPlaylists().size() != 0) {
        adapter = new AddToPlaylistAdapter(allPlaylists.getPlaylists(), ctx);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Playlist temp = allPlaylists.getPlaylists().get(position);
                boolean isRepeat = false;
                for (UnifiedTrack ut : temp.getSongList()) {
                    if (track.getType() && ut.getType() && track.getLocalTrack().getTitle().equals(ut.getLocalTrack().getTitle())) {
                        isRepeat = true;
                        break;
                    } else if (!track.getType() && !ut.getType() && track.getStreamTrack().getTitle().equals(ut.getStreamTrack().getTitle())) {
                        isRepeat = true;
                        break;
                    }
                }
                if (!isRepeat) {
                    temp.addSong(track);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    Toast.makeText(ctx, "Added to Playlist : " + temp.getPlaylistName(), Toast.LENGTH_SHORT).show();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    dialog.dismiss();
                } else {
                    Toast.makeText(ctx, "Song already present in Playlist", Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        lv.setVisibility(GONE);
    }
    // set the custom dialog components - text, image and button
    final EditText text = (EditText) dialog.findViewById(R.id.new_playlist_name);
    ImageView image = (ImageView) dialog.findViewById(R.id.confirm_button);
    // if button is clicked, close the custom dialog
    image.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (text.getText().toString().trim().equals("")) {
                text.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (text.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        text.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    List<UnifiedTrack> l = new ArrayList<UnifiedTrack>();
                    l.add(track);
                    Playlist pl = new Playlist(l, text.getText().toString().trim());
                    allPlaylists.addPlaylist(pl);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    dialog.dismiss();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) AddToPlaylistAdapter(com.sdsmdg.harjot.MusicDNA.adapters.playlistdialogadapter.AddToPlaylistAdapter) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView) TextPaint(android.text.TextPaint) Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) ListView(android.widget.ListView) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) AdapterView(android.widget.AdapterView) ColorStateList(android.content.res.ColorStateList) ArrayList(java.util.ArrayList) List(java.util.List) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView)

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