Search in sources :

Example 46 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project JamsMusicPlayer by psaravan.

the class EditDeleteMusicLibraryDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mApp = (Common) getActivity().getApplicationContext();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    //Get the operation that needs to be performed (edit vs. delete).
    operation = getArguments().getString("OPERATION");
    if (operation.equals("EDIT")) {
        builder.setTitle(R.string.edit_music_library);
    } else {
        builder.setTitle(R.string.delete_music_library);
    }
    //Get a cursor with a list of all the music libraries on the device.
    cursor = mApp.getDBAccessHelper().getAllUniqueUserLibraries(getActivity().getApplicationContext());
    if (cursor.getCount() == 0) {
        getActivity().finish();
        Toast.makeText(getActivity(), R.string.no_music_libraries_found, Toast.LENGTH_SHORT).show();
    }
    builder.setAdapter(new EditDeleteMusicLibraryAdapter(getActivity(), cursor), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Get the name of the library that has just been clicked. Also get its lable color code.
            cursor.moveToPosition(which);
            String libraryName = cursor.getString(cursor.getColumnIndex(DBAccessHelper.LIBRARY_NAME));
            String libraryColorCode = cursor.getString(cursor.getColumnIndex(DBAccessHelper.LIBRARY_TAG));
            if (operation.equals("DELETE")) {
                //Loop through the DB and look for entries that have the specified name and color code. Delete those entries.
                mApp.getDBAccessHelper().deleteLibrary(libraryName, libraryColorCode);
                //Display a toast message.
                String toastMessage = getActivity().getResources().getString(R.string.deleted) + " " + libraryName;
                Toast.makeText(getActivity(), toastMessage, Toast.LENGTH_LONG).show();
            } else {
                AsyncGetLibrarySongIdsTask task = new AsyncGetLibrarySongIdsTask(getActivity().getApplicationContext(), libraryName, libraryColorCode);
                task.execute();
            }
            dialog.dismiss();
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) EditDeleteMusicLibraryAdapter(com.jams.music.player.MusicLibraryEditorActivity.EditDeleteMusicLibraryAdapter)

Example 47 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project JamsMusicPlayer by psaravan.

the class EditGooglePlayMusicTagsDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final DialogFragment dialog = this;
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    //Set the dialog title.
    builder.setTitle(R.string.google_play_music_no_asterisk);
    builder.setMessage(getResources().getString(R.string.edit_google_play_music_tags_unsupported));
    builder.setNegativeButton(R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialog.dismiss();
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) DialogFragment(android.support.v4.app.DialogFragment) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 48 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project JamsMusicPlayer by psaravan.

the class NowPlayingColorSchemesDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();
    dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("colorSchemesDialog");
    final SharedPreferences sharedPreferences = parentActivity.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    //Check which theme is currently selected and set the appropriate flag.
    if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(WHITE)) {
        selectedThemeIndex = 0;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(GRAY)) {
        selectedThemeIndex = 1;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(BLUE)) {
        selectedThemeIndex = 2;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(RED)) {
        selectedThemeIndex = 3;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(GREEN)) {
        selectedThemeIndex = 4;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(ORANGE)) {
        selectedThemeIndex = 5;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(PURPLE)) {
        selectedThemeIndex = 6;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(MAGENTA)) {
        selectedThemeIndex = 7;
    } else if (sharedPreferences.getString(NOW_PLAYING_COLOR, BLUE).equals(BLACK)) {
        selectedThemeIndex = 8;
    } else {
        selectedThemeIndex = 0;
    }
    //Set the dialog title.
    builder.setTitle(R.string.now_playing_color_scheme);
    builder.setSingleChoiceItems(R.array.now_playing_color_schemes, selectedThemeIndex, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == 0) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, WHITE).commit();
                dialog.dismiss();
            } else if (which == 1) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, GRAY).commit();
                dialog.dismiss();
            } else if (which == 2) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, BLUE).commit();
                dialog.dismiss();
            } else if (which == 3) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, RED).commit();
                dialog.dismiss();
            } else if (which == 4) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, GREEN).commit();
                dialog.dismiss();
            } else if (which == 5) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, ORANGE).commit();
                dialog.dismiss();
            } else if (which == 6) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, PURPLE).commit();
                dialog.dismiss();
            } else if (which == 7) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, MAGENTA).commit();
                dialog.dismiss();
            } else if (which == 8) {
                sharedPreferences.edit().putString(NOW_PLAYING_COLOR, BLACK).commit();
                dialog.dismiss();
            }
            getActivity().getActionBar().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(getActivity()));
            getActivity().getWindow().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(getActivity()));
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 49 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project JamsMusicPlayer by psaravan.

the class RenamePlaylistDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();
    dialog = this;
    //Retrieve the arguments.
    final String PLAYLIST_NAME = getArguments().getString("PLAYLIST_NAME");
    final String PLAYLIST_FILE_PATH = getArguments().getString("PLAYLIST_FILE_PATH");
    final String PLAYLIST_FOLDER_PATH = getArguments().getString("PLAYLIST_FOLDER_PATH");
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    dialogView = parentActivity.getLayoutInflater().inflate(R.layout.rename_playlist_dialog_layout, null);
    playlistInfo = (TextView) dialogView.findViewById(R.id.rename_playlist_info);
    playlistInfo.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistInfo.setPaintFlags(playlistInfo.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    playlistNameField = (EditText) dialogView.findViewById(R.id.rename_playlist_text_field);
    playlistNameField.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameField.setPaintFlags(playlistNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    playlistNameField.setText(PLAYLIST_NAME);
    //Set the dialog title.
    builder.setTitle(R.string.rename_playlist);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialog.dismiss();
        }
    });
    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Create a File that points to the playlist on the filesystem.
            File file = new File(PLAYLIST_FILE_PATH);
            //Retrieve the name and file path for the playlist.
            String playlistName = playlistNameField.getText().toString();
            //Replace illegal characters in the playlistName.
            if (playlistName.contains("/")) {
                playlistName = playlistName.replace("/", "_");
            }
            if (playlistName.contains("\\")) {
                playlistName = playlistName.replace("\\", "_");
            }
            //Create another File that points to the renamed playlist file.
            File newFile = new File(PLAYLIST_FOLDER_PATH + "/" + playlistName + ".m3u");
            file.renameTo(newFile);
            /*//Update the database with the new file path and playlist name.
				DBAccessHelper playlistsDBHelper = new DBAccessHelper(parentActivity);
				playlistsDBHelper.renamePlaylist(PLAYLIST_FILE_PATH, playlistName, newFile.getAbsolutePath());
				
				//Delete any instances of the old DB entries.
				playlistsDBHelper.deleteSpecificPlaylist(PLAYLIST_NAME, PLAYLIST_FILE_PATH);*/
            Toast.makeText(parentActivity, R.string.playlist_renamed, Toast.LENGTH_SHORT).show();
            //Refresh the playlists list view.
            //PlaylistsFragment playlistsFragment = new PlaylistsFragment();
            //playlistsFragment.refreshPlaylists();
            //playlistsDBHelper.close();
            dialog.dismiss();
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) File(java.io.File) Paint(android.graphics.Paint)

Example 50 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project JamsMusicPlayer by psaravan.

the class TrialExpiryDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();
    dialogFragment = this;
    View rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null);
    sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    //Check if the BETA version has expired.
    File file = new File(Environment.getExternalStorageDirectory() + "/.beta2");
    if (file.exists()) {
        //The app has expired.
        EXPIRED_FLAG = true;
    } else {
        EXPIRED_FLAG = false;
    }
    /*        //Change the dialog message based on the expiry status of the app.
        if (EXPIRED_FLAG==true) {
    		trialExpiryText = (TextView) rootView.findViewById(R.id.beta_version_will_expire);
    		trialExpiryText.setText(R.string.beta_has_expired);
    		trialExpiryText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    		trialExpiryText.setPaintFlags(trialExpiryText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    		
    		numberOfDaysLeftTextView = (TextView) rootView.findViewById(R.id.beta_expire_day_count);
    		numberOfDaysLeftTextView.setVisibility(View.GONE);
    		
    		daysTextView = (TextView) rootView.findViewById(R.id.beta_days_text);
    		daysTextView.setVisibility(View.GONE);
    		
    		trialCounterDummyInfoTextView = (TextView) rootView.findViewById(R.id.beta_trial_dummy_info_text);
    		trialCounterDummyInfoTextView.setVisibility(View.GONE);
    		
        } else {
    		trialExpiryText = (TextView) rootView.findViewById(R.id.beta_version_will_expire);
    		trialExpiryText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    		trialExpiryText.setPaintFlags(trialExpiryText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    		
    		numberOfDaysLeftTextView = (TextView) rootView.findViewById(R.id.beta_expire_day_count);
    		numberOfDaysLeftTextView.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    		numberOfDaysLeftTextView.setPaintFlags(numberOfDaysLeftTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    		
    		trialCounterDummyInfoTextView = (TextView) rootView.findViewById(R.id.beta_trial_dummy_info_text);
    		trialCounterDummyInfoTextView.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    		trialCounterDummyInfoTextView.setPaintFlags(trialCounterDummyInfoTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    		
    		//Calculate the number of days left.
    		Date date = new Date();
    		//1296000000 ms = 15 days.
    		long expiryDate = sharedPreferences.getLong("EXPIRY_DATE", date.getTime() + 1296000000);
    		long currentDate = date.getTime();
    		long millisLeft = expiryDate - currentDate;
    		long daysLeft = TimeUnit.MILLISECONDS.toDays(millisLeft);
    		numberOfDaysLeftTextView.setText("" + daysLeft);
    		
    		daysTextView = (TextView) rootView.findViewById(R.id.beta_days_text);
    		daysTextView.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    		daysTextView.setPaintFlags(daysTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        }*/
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    //Set the dialog title.
    builder.setTitle(R.string.app_name);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            if (EXPIRED_FLAG == true) {
                getActivity().finish();
            }
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) View(android.view.View) File(java.io.File)

Aggregations

OnClickListener (android.content.DialogInterface.OnClickListener)264 DialogInterface (android.content.DialogInterface)259 AlertDialog (android.app.AlertDialog)161 View (android.view.View)75 TextView (android.widget.TextView)52 Intent (android.content.Intent)44 SuppressLint (android.annotation.SuppressLint)41 Context (android.content.Context)35 AlertDialog (android.support.v7.app.AlertDialog)32 LayoutInflater (android.view.LayoutInflater)30 EditText (android.widget.EditText)30 Activity (android.app.Activity)27 Bundle (android.os.Bundle)25 OnCancelListener (android.content.DialogInterface.OnCancelListener)21 ImageView (android.widget.ImageView)17 Builder (android.app.AlertDialog.Builder)16 Dialog (android.app.Dialog)16 ProgressDialog (android.app.ProgressDialog)15 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)15