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);
}
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();
}
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");
}
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();
}
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();
}
Aggregations