Removed KEY_RINGTONE_IS_SILENT and KEY_NOTIFICATION_IS_SILENT From
Database closes #98 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -86,13 +86,15 @@ public class RingerDatabase {
|
|||||||
public final static String KEY_RINGTONE = "home_ringtone";
|
public final static String KEY_RINGTONE = "home_ringtone";
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public final static String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
|
public final static String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
|
||||||
|
@Deprecated
|
||||||
|
public final static String KEY_RINGTONE_IS_SILENT = "ringtone_is_silent";
|
||||||
|
@Deprecated
|
||||||
|
public final static String KEY_NOTIFICATION_IS_SILENT = "notification_is_silent";
|
||||||
|
|
||||||
|
public final static String KEY_IS_ENABLED = "is_enabled";
|
||||||
public final static String KEY_RADIUS = "radius";
|
public final static String KEY_RADIUS = "radius";
|
||||||
public final static String KEY_RINGER_NAME = "ringer_name";
|
public final static String KEY_RINGER_NAME = "ringer_name";
|
||||||
public final static String KEY_LOCATION = "location";
|
public final static String KEY_LOCATION = "location";
|
||||||
public final static String KEY_RINGTONE_IS_SILENT = "ringtone_is_silent";
|
|
||||||
public final static String KEY_NOTIFICATION_IS_SILENT = "notification_is_silent";
|
|
||||||
public final static String KEY_IS_ENABLED = "is_enabled";
|
|
||||||
public final static String KEY_RINGTONE_URI = "ringtone_uri";
|
public final static String KEY_RINGTONE_URI = "ringtone_uri";
|
||||||
public final static String KEY_NOTIFICATION_RINGTONE_URI = "away_notification_uri";
|
public final static String KEY_NOTIFICATION_RINGTONE_URI = "away_notification_uri";
|
||||||
public final static String KEY_RINGTONE_VOLUME = "ringtone_volume";
|
public final static String KEY_RINGTONE_VOLUME = "ringtone_volume";
|
||||||
|
|||||||
@@ -71,35 +71,21 @@ public class RingerProcessingService extends Service {
|
|||||||
if(this.getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE).getBoolean(SettingsActivity.TOASTY, false))
|
if(this.getSharedPreferences(SettingsActivity.SETTINGS, Debug.SHARED_PREFS_MODE).getBoolean(SettingsActivity.TOASTY, false))
|
||||||
Toast.makeText(this.getApplicationContext(), "Applying "+ name, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this.getApplicationContext(), "Applying "+ name, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
/*
|
|
||||||
* We need to null check all the value except ring/notification tone uri's and boolean values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ringtone & volume
|
* ringtone & volume
|
||||||
* if the ringtone is set to silent we want to set the volume to 0
|
|
||||||
*/
|
*/
|
||||||
if(values.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT)){
|
if(values.containsKey(RingerDatabase.KEY_RINGTONE_URI))
|
||||||
Log.d(TAG, "Ringtone: "+ applyRingtone(RingtoneManager.TYPE_RINGTONE, RingerDatabase.parseBoolean(values.getAsString(RingerDatabase.KEY_RINGTONE_IS_SILENT)), values.getAsString(RingerDatabase.KEY_RINGTONE_URI)));
|
Log.d(TAG, "Ringtone: "+ applyRingtone(RingtoneManager.TYPE_RINGTONE, values.getAsString(RingerDatabase.KEY_RINGTONE_URI)));
|
||||||
if(RingerDatabase.parseBoolean(values.getAsString(RingerDatabase.KEY_RINGTONE_IS_SILENT)))
|
if(values.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME))
|
||||||
setStreamVolume(0, AudioManager.STREAM_RING);
|
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_RINGTONE_VOLUME), AudioManager.STREAM_RING);
|
||||||
else
|
|
||||||
if(values.get(RingerDatabase.KEY_RINGTONE_VOLUME) != null)
|
|
||||||
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_RINGTONE_VOLUME), AudioManager.STREAM_RING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* notification ringtone & volume
|
* notification ringtone & volume
|
||||||
* if the notification ringtone is silent, we want to set the volume to 0
|
|
||||||
*/
|
*/
|
||||||
if(values.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT)){
|
if(values.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI))
|
||||||
Log.d(TAG, "Notification Ringtone: "+ applyRingtone(RingtoneManager.TYPE_NOTIFICATION, RingerDatabase.parseBoolean(values.getAsString(RingerDatabase.KEY_NOTIFICATION_IS_SILENT)), values.getAsString(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI)));
|
Log.d(TAG, "Notification Ringtone: "+ applyRingtone(RingtoneManager.TYPE_NOTIFICATION, values.getAsString(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI)));
|
||||||
if(RingerDatabase.parseBoolean(values.getAsString(RingerDatabase.KEY_NOTIFICATION_IS_SILENT)))
|
if(values.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME))
|
||||||
setStreamVolume(0, AudioManager.STREAM_NOTIFICATION);
|
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME), AudioManager.STREAM_NOTIFICATION);
|
||||||
else
|
|
||||||
if(values.get(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME) != null)
|
|
||||||
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME), AudioManager.STREAM_NOTIFICATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Debug.DEBUG){
|
if(Debug.DEBUG){
|
||||||
Log.d(TAG, "Music "+ (mAudioManager.isMusicActive() ? "is playing " : "is not playing"));
|
Log.d(TAG, "Music "+ (mAudioManager.isMusicActive() ? "is playing " : "is not playing"));
|
||||||
@@ -118,13 +104,10 @@ public class RingerProcessingService extends Service {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* alarm volume
|
* alarm volume
|
||||||
* we will set the alarm volume only if music is not playing, and there is no wired head set
|
|
||||||
*/
|
*/
|
||||||
if(values.containsKey(RingerDatabase.KEY_ALARM_VOLUME))
|
if(values.containsKey(RingerDatabase.KEY_ALARM_VOLUME))
|
||||||
if(values.get(RingerDatabase.KEY_ALARM_VOLUME) != null)
|
if(values.get(RingerDatabase.KEY_ALARM_VOLUME) != null)
|
||||||
if(! mAudioManager.isMusicActive())
|
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_ALARM_VOLUME), AudioManager.STREAM_ALARM);
|
||||||
if(! mAudioManager.isWiredHeadsetOn())
|
|
||||||
setStreamVolume(values.getAsInteger(RingerDatabase.KEY_ALARM_VOLUME), AudioManager.STREAM_ALARM);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wifi & bluetooth
|
* wifi & bluetooth
|
||||||
@@ -172,55 +155,35 @@ public class RingerProcessingService extends Service {
|
|||||||
* @return string uri of applied ringtone, null if silent was applied
|
* @return string uri of applied ringtone, null if silent was applied
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private String applyRingtone(int type, boolean isSilent, String uri) {
|
private String applyRingtone(int type, String uri) {
|
||||||
String ringtoneURI = null;
|
RingtoneManager.setActualDefaultRingtoneUri(this, type, uri == null ? null : Uri.parse(uri));
|
||||||
if(isSilent){
|
|
||||||
if(Debug.DEBUG)
|
|
||||||
Log.d(TAG, "Ringtone was set to silent ");
|
|
||||||
} else
|
|
||||||
ringtoneURI = uri;
|
|
||||||
RingtoneManager.setActualDefaultRingtoneUri(this, type, ringtoneURI == null ? null : Uri.parse(ringtoneURI));
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Backs up the current settings into the database to be re applied as default
|
* appends the new ringer's information in content values
|
||||||
// * @author ricky barrette
|
* @param id
|
||||||
// */
|
* @return
|
||||||
// private void backup() {
|
*/
|
||||||
//
|
private ContentValues getRinger(ContentValues values, long id) {
|
||||||
// if(Debug.DEBUG)
|
String name = this.mDb.getRingerName(id);
|
||||||
// Log.d(TAG, "backup()");
|
values.put(RingerDatabase.KEY_RINGER_NAME, name);
|
||||||
//
|
|
||||||
// ContentValues ringer = new ContentValues();
|
/*
|
||||||
// ContentValues info = new ContentValues();
|
* get the ringer's info, and parse it into content values
|
||||||
//
|
*/
|
||||||
// /*
|
values.putAll(this.mDb.getRingerInfo(name));
|
||||||
// * package the ringer table information
|
return values;
|
||||||
// */
|
}
|
||||||
// ringer.put(RingerDatabase.KEY_RINGER_NAME, DEFAULT_RINGER);
|
|
||||||
//
|
/**
|
||||||
// /*
|
* returns all the ringers information as content values
|
||||||
// * package the ringer_info table information
|
* @param id
|
||||||
// */
|
* @return
|
||||||
// info.put(RingerDatabase.KEY_RINGTONE_IS_SILENT, mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT ? true : false);
|
*/
|
||||||
// info.put(RingerDatabase.KEY_RINGTONE_URI, RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE).toString());
|
private ContentValues getRinger(long id) {
|
||||||
// info.put(RingerDatabase.KEY_NOTIFICATION_IS_SILENT, mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT ? true : false);
|
return getRinger(new ContentValues(), id);
|
||||||
// info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION).toString());
|
}
|
||||||
// info.put(RingerDatabase.KEY_RINGTONE_VOLUME, mAudioManager.getStreamVolume(AudioManager.STREAM_RING));
|
|
||||||
// info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME, mAudioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION));
|
|
||||||
// info.put(RingerDatabase.KEY_MUSIC_VOLUME, mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
|
|
||||||
// info.put(RingerDatabase.KEY_ALARM_VOLUME, mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM));
|
|
||||||
// info.put(RingerDatabase.KEY_UPDATE_INTERVAL, this.mSettings.getString(SettingsActivity.SETTINGS, "10"));
|
|
||||||
//
|
|
||||||
// if(this.mBluetoothAdapter != null)
|
|
||||||
// info.put(RingerDatabase.KEY_BT, this.mBluetoothAdapter.isEnabled());
|
|
||||||
//
|
|
||||||
// if(this.mWifiManager != null)
|
|
||||||
// info.put(RingerDatabase.KEY_WIFI, this.mWifiManager.isWifiEnabled());
|
|
||||||
//
|
|
||||||
// this.mDb.updateRinger(1, ringer, info);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see android.app.Service#onBind(android.content.Intent)
|
* @see android.app.Service#onBind(android.content.Intent)
|
||||||
@@ -283,17 +246,6 @@ public class RingerProcessingService extends Service {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// //if this is the first time the service ever starts, then back up the current settings to create a back up
|
|
||||||
// if(this.mSettings.getBoolean(SettingsActivity.IS_FIRST_RINGER_PROCESSING, true)){
|
|
||||||
// backup();
|
|
||||||
// this.mSettings.edit().putBoolean(SettingsActivity.IS_FIRST_RINGER_PROCESSING, false).commit();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //if the default ringer is the currently applied ringer back up the current settings
|
|
||||||
// if(this.mSettings.getBoolean(SettingsActivity.IS_DEFAULT, false)){
|
|
||||||
// backup();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(intent.getParcelableExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED) != null){
|
if(intent.getParcelableExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED) != null){
|
||||||
this.mLocation = intent.getParcelableExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED);
|
this.mLocation = intent.getParcelableExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED);
|
||||||
processRingers();
|
processRingers();
|
||||||
@@ -362,31 +314,6 @@ public class RingerProcessingService extends Service {
|
|||||||
this.stopSelf(mStartId);
|
this.stopSelf(mStartId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* appends the new ringer's information in content values
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ContentValues getRinger(ContentValues values, long id) {
|
|
||||||
String name = this.mDb.getRingerName(id);
|
|
||||||
values.put(RingerDatabase.KEY_RINGER_NAME, name);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get the ringer's info, and parse it into content values
|
|
||||||
*/
|
|
||||||
values.putAll(this.mDb.getRingerInfo(name));
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns all the ringers information as content values
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ContentValues getRinger(long id) {
|
|
||||||
return getRinger(new ContentValues(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the volume of a particular stream
|
* set the volume of a particular stream
|
||||||
* @param volume
|
* @param volume
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
private ArrayList<Fragment> initList() {
|
private ArrayList<Fragment> initList() {
|
||||||
ArrayList<Fragment> what = new ArrayList<Fragment>();
|
ArrayList<Fragment> what = new ArrayList<Fragment>();
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){
|
if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){
|
||||||
what.add(initFeatureFragment(KEY_ADDED_RINGTONE));
|
what.add(initFeatureFragment(KEY_ADDED_RINGTONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){
|
if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){
|
||||||
what.add(initFeatureFragment(KEY_ADDED_NOTIFICATIONTONE));
|
what.add(initFeatureFragment(KEY_ADDED_NOTIFICATIONTONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,10 +256,10 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
*/
|
*/
|
||||||
switch(id){
|
switch(id){
|
||||||
case KEY_ADDED_RINGTONE:
|
case KEY_ADDED_RINGTONE:
|
||||||
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_RINGTONE_VOLUME);
|
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_VOLUME);
|
||||||
break;
|
break;
|
||||||
case KEY_ADDED_NOTIFICATIONTONE:
|
case KEY_ADDED_NOTIFICATIONTONE:
|
||||||
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerDatabase.KEY_NOTIFICATION_IS_SILENT, RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME);
|
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME);
|
||||||
break;
|
break;
|
||||||
case KEY_ADDED_ALARM_VOLUME:
|
case KEY_ADDED_ALARM_VOLUME:
|
||||||
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_ALARM_VOLUME);
|
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_ALARM_VOLUME);
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
|||||||
private final int mStream;
|
private final int mStream;
|
||||||
private final int mType;
|
private final int mType;
|
||||||
private final OnContentChangedListener mChangedListener;
|
private final OnContentChangedListener mChangedListener;
|
||||||
private final String mKeyEnabled;
|
|
||||||
private final String mKeyUri;
|
private final String mKeyUri;
|
||||||
private final String mKeyVolume;
|
private final String mKeyVolume;
|
||||||
private final ContentValues mInfo;
|
private final ContentValues mInfo;
|
||||||
@@ -68,7 +67,6 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
|||||||
|
|
||||||
switch(stream){
|
switch(stream){
|
||||||
case AudioManager.STREAM_NOTIFICATION:
|
case AudioManager.STREAM_NOTIFICATION:
|
||||||
mKeyEnabled = RingerDatabase.KEY_NOTIFICATION_IS_SILENT;
|
|
||||||
mKeyUri = RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI;
|
mKeyUri = RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI;
|
||||||
mKeyVolume = RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME;
|
mKeyVolume = RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME;
|
||||||
mLabel = R.string.notification_ringtone;
|
mLabel = R.string.notification_ringtone;
|
||||||
@@ -77,7 +75,6 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
|||||||
|
|
||||||
case AudioManager.STREAM_RING:
|
case AudioManager.STREAM_RING:
|
||||||
default:
|
default:
|
||||||
mKeyEnabled = RingerDatabase.KEY_RINGTONE_IS_SILENT;
|
|
||||||
mKeyUri = RingerDatabase.KEY_RINGTONE_URI;
|
mKeyUri = RingerDatabase.KEY_RINGTONE_URI;
|
||||||
mKeyVolume = RingerDatabase.KEY_RINGTONE_VOLUME;
|
mKeyVolume = RingerDatabase.KEY_RINGTONE_VOLUME;
|
||||||
mLabel = R.string.ringtone;
|
mLabel = R.string.ringtone;
|
||||||
@@ -111,7 +108,6 @@ public class RingtoneFragment extends BaseFeatureFragment implements OnClickList
|
|||||||
if(this.mChangedListener != null){
|
if(this.mChangedListener != null){
|
||||||
ContentValues info = new ContentValues();
|
ContentValues info = new ContentValues();
|
||||||
info.put(this.mKeyUri, tone != null ? tone.toString() : null);
|
info.put(this.mKeyUri, tone != null ? tone.toString() : null);
|
||||||
info.put(mKeyEnabled, tone == null);
|
|
||||||
this.mChangedListener.onInfoContentChanged(info);
|
this.mChangedListener.onInfoContentChanged(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user