Example usage for android.media RingtoneManager EXTRA_RINGTONE_TITLE

List of usage examples for android.media RingtoneManager EXTRA_RINGTONE_TITLE

Introduction

In this page you can find the example usage for android.media RingtoneManager EXTRA_RINGTONE_TITLE.

Prototype

String EXTRA_RINGTONE_TITLE

To view the source code for android.media RingtoneManager EXTRA_RINGTONE_TITLE.

Click Source Link

Document

Given to the ringtone picker as a CharSequence .

Usage

From source file:Main.java

public static void pickRing(Activity activity) {
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");

    if (mRingUri != null) {
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, mRingUri);
    } else {/*ww w. j  av a 2  s. c om*/
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
    }
    activity.startActivityForResult(intent, RESULT_PICK_RING);
}

From source file:org.apache.cordova.ringtonepicker.RingtonePicker.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    this.callbackContext = callbackContext;
    if (action.equals("getRingtone")) {
        Log.d("customPlugin", " getRingtone ");

        Runnable getRingtone = new Runnable() {

            @Override//w  w w. ja  v a  2  s  .  c o  m
            public void run() {
                Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
                notification_uri = Settings.System.getString(cordova.getActivity().getContentResolver(),
                        Settings.System.NOTIFICATION_SOUND);
                if (notification_uri == null) {
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
                } else {
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(notification_uri));
                }
                cordova.setActivityResultCallback(RingtonePicker.this);
                cordova.getActivity().startActivityForResult(intent, 5);
            }
        };
        this.cordova.getActivity().runOnUiThread(getRingtone);
        return true;
    } else {
        return false;
    }
}

From source file:org.apache.cordova.stringtoimagefile.StringToImageFile.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    this.callbackContext = callbackContext;
    if (action.equals("stringToImage")) {
        Log.d("customPlugin", "stringToImage ");

        Runnable getRingtone = new Runnable() {

            @Override//w w w  .  j  av  a 2 s  . co  m
            public void run() {
                Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
                notification_uri = Settings.System.getString(cordova.getActivity().getContentResolver(),
                        Settings.System.NOTIFICATION_SOUND);
                if (notification_uri == null) {
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
                } else {
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(notification_uri));
                }
                cordova.setActivityResultCallback(StringToImageFile.this);
                cordova.getActivity().startActivityForResult(intent, 5);
            }
        };
        this.cordova.getActivity().runOnUiThread(getRingtone);
        return true;
    } else {
        return false;
    }
}

From source file:org.kontalk.ui.prefs.NotificationFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences_notification);

    // set ringtone
    final Preference setRingtone = findPreference("pref_ringtone");
    setRingtone.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//  w ww . j a  v a  2 s.c  om
        public boolean onPreferenceClick(Preference preference) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(preference.getContext());

            String _currentRingtone = prefs.getString(preference.getKey(),
                    getString(R.string.pref_default_ringtone));
            Uri currentRingtone = !TextUtils.isEmpty(_currentRingtone) ? Uri.parse(_currentRingtone) : null;

            final Intent i = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentRingtone);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                    RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

            i.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, preference.getTitle());

            startActivityForResult(i, REQUEST_PICK_RINGTONE);
            return true;
        }
    });

    // notification LED color
    final Preference notificationLed = findPreference("pref_notification_led_color");
    notificationLed.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Context context = getContext();
            int[] ledColors = new int[] { ContextCompat.getColor(context, android.R.color.white),
                    ContextCompat.getColor(context, R.color.blue_light),
                    ContextCompat.getColor(context, R.color.purple_light),
                    ContextCompat.getColor(context, R.color.green_light),
                    ContextCompat.getColor(context, R.color.yellow_light),
                    ContextCompat.getColor(context, R.color.red_light), };

            try {
                new ColorChooserDialog.Builder((BasePreferencesActivity) getActivity(),
                        R.string.pref_notification_led_color).customColors(ledColors, null)
                                .preselect(Preferences.getNotificationLEDColor(getContext()))
                                .allowUserColorInput(false).dynamicButtonColor(false).show();
            } catch (IllegalStateException e) {
                // fragment is being destroyed - ignore
            }
            return true;
        }
    });
}

From source file:id.satusatudua.sigap.ui.fragment.SettingFragment.java

@OnClick(R.id.ringtone)
public void chooseRingtone() {
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Pilih Nada Dering");
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
            CacheManager.pluck().getRingtone() == null ? null : Uri.parse(CacheManager.pluck().getRingtone()));
    startActivityForResult(intent, 5);/*w ww .j  a v a 2  s.c o m*/
}

From source file:com.microsoft.mimickeralarm.settings.RingtonePreference.java

private void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, getRingtone());
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
            GeneralUtilities.defaultRingtone());
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getTitle());
}

From source file:rikka.materialpreference.RingtonePreference.java

/**
 * Prepares the intent to launch the ringtone picker. This can be modified
 * to adjust the parameters of the ringtone picker.
 *
 * @param ringtonePickerIntent The ringtone picker intent that can be
 *            modified by putting extras.
 *//* w  w  w .  j av a2s . com*/
protected void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {

    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, onRestoreRingtone());

    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, mShowDefault);
    if (mShowDefault) {
        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                RingtoneManager.getDefaultUri(getRingtoneType()));
    }

    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, mRingtoneType);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getTitle());
}

From source file:org.schabi.terminightor.AlarmItemDetailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    lastSavedInstaneState = savedInstanceState;
    Activity a = getActivity();/* www.j  ava 2s  .  c  o m*/
    setAlarmTimeView = (TextView) a.findViewById(R.id.setAlarmTimeView);
    setAlarmAMPMView = (TextView) a.findViewById(R.id.setAlarmAmPmSuffix);
    repeatCheckBox = (CheckBox) a.findViewById(R.id.setRepeatCheckBox);
    chooseDateView = (ChooseDaysView) a.findViewById(R.id.chooseDateView);
    alarmLabelBox = (EditText) a.findViewById(R.id.setAlarmLabelBox);
    setAlarmToneButton = (Button) a.findViewById(R.id.setAlarmToneButton);
    vibrateCheckBox = (CheckBox) a.findViewById(R.id.vibrateCheckBox);
    nfcTagLabelView = (ImageView) a.findViewById(R.id.nfcTagLabelView);
    nfcTagIdView = (TextView) a.findViewById(R.id.nfcTagIdView);
    addNfcTabButton = (FloatingActionButton) a.findViewById(R.id.addNfcTagButton);

    repeatCheckBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (repeatCheckBox.isChecked()) {
                chooseDateView.setVisibility(View.VISIBLE);
            } else {
                chooseDateView.setVisibility(View.GONE);
            }
            chooseDateView.setRepeatEnabled(repeatCheckBox.isChecked());
        }
    });

    setAlarmTimeView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            timePickerDialog.show();
        }
    });

    setAlarmToneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,
                    getResources().getString(R.string.selectAlarmToneTitle));
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
            if (!alarm.getAlarmTone().isEmpty()) {
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(alarm.getAlarmTone()));
            }
            startActivityForResult(intent, SET_ALARM_TONE);
        }
    });

    addNfcTabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), SetTagActivity.class);
            startActivityForResult(intent, READ_NFC_ID);
        }
    });
}

From source file:support.plus.reportit.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Default config

    if (savedInstanceState != null) {
        // Restore value of members from saved state
        userName = savedInstanceState.getString(userName);
        userBossName = savedInstanceState.getString(userBossName);
    } else {/*from   www . j  a v a  2s.c  o m*/
        // Probably initialize members with default values for a new instance
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(R.string.app_name);
    toolbar.setNavigationIcon(R.drawable.ic_back);

    final TextView TextuserName = (TextView) findViewById(R.id.userName);
    final TextView TextuserBossName = (TextView) findViewById(R.id.userBossName);
    final EditText inuserName = (EditText) findViewById(R.id.inuserName);
    final EditText inuserBossName = (EditText) findViewById(R.id.inuserBossName);
    final Switch sNoti = (Switch) findViewById(R.id.sNoti);
    final Button btimePick = (Button) findViewById(R.id.btimePick);
    final Button bSave = (Button) findViewById(R.id.bSave);
    final Switch sfingerprint_activ = (Switch) findViewById(R.id.sfingerprint_activ);
    final Button bsetpassword = (Button) findViewById(R.id.bsetpassword);
    final Switch sdarkTheme = (Switch) findViewById(R.id.sdarkTheme);
    final Button bchooseRingtone = (Button) findViewById(R.id.bringtonePick);

    final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE);
    Boolean themeDark = pref3.getBoolean("darkTheme", false);
    if (themeDark == true) {
        sdarkTheme.setChecked(true);
    } else {
        sdarkTheme.setChecked(false);
    }
    sdarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = pref3.edit();
                editor.putBoolean("darkTheme", true);
                editor.commit();
                getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
                // Now recreate for it to take effect
                // startActivity(getIntent());
                recreate();
            } else {
                SharedPreferences.Editor editor = pref3.edit();
                editor.putBoolean("darkTheme", false);
                editor.commit();
                getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
                // Now recreate for it to take effect
                // startActivity(getIntent());
                recreate();
            }
        }
    });

    /*
    SECURITY SETTINGS
     */

    final SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE);
    Boolean fingerprintSet = pref1.getBoolean("fingerprintSet", false);
    if (fingerprintSet == true) {
        sfingerprint_activ.setChecked(true);
        bsetpassword.setVisibility(View.VISIBLE);
    } else {
        sfingerprint_activ.setChecked(false);
        bsetpassword.setVisibility(View.GONE);
    }
    sfingerprint_activ.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                SharedPreferences.Editor editor = pref1.edit();
                editor.putBoolean("fingerprintSet", true);
                editor.commit();
                bsetpassword.setVisibility(View.VISIBLE);
            } else {
                SharedPreferences.Editor editor = pref1.edit();
                editor.putBoolean("fingerprintSet", false);
                editor.commit();
                bsetpassword.setVisibility(View.GONE);
            }
        }
    });

    bsetpassword.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new MaterialDialog.Builder(SettingsActivity.this).title(R.string.set_password)
                    .content(R.string.set_password_desc)
                    .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .inputRange(1, 10)
                    .input(getString(R.string.password), "", new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            String name = String.valueOf(input);
                            SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE);
                            SharedPreferences.Editor editor = pref1.edit();
                            editor.putString("passwordSet", name);
                            editor.commit();
                            return;
                        }
                    }).positiveText(R.string.set_password).negativeText(R.string.cancel).cancelable(false)
                    .show();
        }

    });

    /*
    END SECURITY SETTINGS
     */

    /*
    NOTIFICATION SETTINGS
     */
    btimePick.setVisibility(View.GONE);
    sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                btimePick.setVisibility(View.VISIBLE);
                bchooseRingtone.setVisibility(View.VISIBLE);
            } else {
                btimePick.setVisibility(View.GONE);
                bchooseRingtone.setVisibility(View.GONE);
            }
        }
    });

    final SharedPreferences pref4 = getApplicationContext().getSharedPreferences("userNotification",
            MODE_PRIVATE);
    Boolean notificationSet = pref4.getBoolean("alarmSet", false);
    if (notificationSet == true) {
        sNoti.setChecked(true);
        btimePick.setVisibility(View.VISIBLE);
        bchooseRingtone.setVisibility(View.VISIBLE);
    } else {
        sNoti.setChecked(false);
        btimePick.setVisibility(View.GONE);
        bchooseRingtone.setVisibility(View.GONE);
    }
    sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                SharedPreferences.Editor editor = pref4.edit();
                editor.putBoolean("alarmSet", true);
                editor.commit();
                btimePick.setVisibility(View.VISIBLE);
                bchooseRingtone.setVisibility(View.VISIBLE);

            } else {
                SharedPreferences.Editor editor = pref4.edit();
                editor.putBoolean("alarmSet", false);
                editor.commit();
                btimePick.setVisibility(View.GONE);
                bchooseRingtone.setVisibility(View.GONE);

            }
        }
    });
    bchooseRingtone.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, R.string.choose_ringtone);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
            startActivityForResult(intent, 5);
        }
    });

    btimePick.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogFragment newFragment = new TimePickerFragment();
            newFragment.show(getSupportFragmentManager(), "timePicker");
        }
    });

    /*
    END NOTIFICATION SETTINGS
     */

    /*
    SAVE SETTINGS
     */
    bSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String saveworkplace = "Student";
            String saveuserBossName = "Boss";
            saveworkplace = inuserName.getText().toString();
            saveuserBossName = inuserBossName.getText().toString();
            TextuserName.setText(getString(R.string.firm_name) + String.valueOf(saveworkplace));
            TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(saveuserBossName));
            final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData",
                    MODE_APPEND);
            SharedPreferences.Editor editor = pref2.edit();
            editor.putString("userName", saveworkplace);
            editor.putString("userBoss", saveuserBossName);
            editor.putBoolean("data_saved", true);
            editor.commit();
            Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content),
                    "Data saved. Restart the app to see changes.", Snackbar.LENGTH_LONG);
            snackbar.show();
            // finish();
            startActivity(getIntent());
        }
    });
    final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND);
    if (pref2.getBoolean("data_saved", true)) {
        String TextuserNameString = pref2.getString("userName", "");
        String TextuserBossNameString = pref2.getString("userBoss", "");
        TextuserName.setText(getString(R.string.firm_name) + String.valueOf(TextuserNameString));
        TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(TextuserBossNameString));
        inuserName.setVisibility(View.GONE);
        inuserBossName.setVisibility(View.GONE);
        bSave.setVisibility(View.GONE);

    } else {
        Toast toast = Toast.makeText(this, "No data saved", Toast.LENGTH_SHORT);
        toast.show();
    }
    /*
    END SAVE SETTINGS
     */

}

From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java

protected void ringtonepicker() {
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
    if (uri != null) {
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
    } else {//from www.ja  v a2  s  .c  om
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
    }
    startActivityForResult(intent, Set_Ringtone);
    SlidingFragmentActivity sfa = (SlidingFragmentActivity) getActivity();
    sfa.showContent();
}