Finished Deleteing features from the database

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-05-26 18:52:39 -04:00
parent f64d6a3d3b
commit 10a0ee47b8
3 changed files with 44 additions and 7 deletions

View File

@@ -600,7 +600,21 @@ public class RingerDatabase {
if(ringer == null || info == null)
throw new NullPointerException("ringer content was null");
String ringer_name = getRingerName(id);
final String ringer_name = getRingerName(id);
/*
* here we retrive the old values.
* we will compare the old value against the new values.
* we will delete all values that are NOT included in the new values.
*/
final ContentValues old = getRingerInfo(ringer_name);
for(final Entry<String, Object> item : info.valueSet()){
if(old.containsKey(item.getKey()))
old.remove(item.getKey());
}
for(final Entry<String, Object> item : old.valueSet()){
RingerDatabase.this.mDb.delete(RINGER_INFO_TABLE, KEY +" = "+ DatabaseUtils.sqlEscapeString(item.getKey()) +" and "+ KEY_RINGER_NAME +" = "+DatabaseUtils.sqlEscapeString(ringer_name), null);
}
if(!ringer_name.equals(ringer.getAsString(RingerDatabase.KEY_RINGER_NAME)))
ringer.put(RingerDatabase.KEY_RINGER_NAME, checkRingerName(ringer.getAsString(RingerDatabase.KEY_RINGER_NAME)));

View File

@@ -137,6 +137,11 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
return super.onCreateOptionsMenu(menu);
}
/**
* Called when the ringer info has changed
* (non-Javadoc)
* @see com.TwentyCodes.android.LocationRinger.OnContentChangedListener#onInfoContentChanged(android.content.ContentValues)
*/
@Override
public void onInfoContentChanged(ContentValues values) {
if(Debug.DEBUG){
@@ -186,6 +191,11 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
public void onPageSelected(int arg0) {
}
/**
* Called when the ringer content has been changed
* (non-Javadoc)
* @see com.TwentyCodes.android.LocationRinger.OnContentChangedListener#onRingerContentChanged(android.content.ContentValues)
*/
@Override
public void onRingerContentChanged(ContentValues values) {
if(Debug.DEBUG){
@@ -215,11 +225,21 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
}).start();
}
/**
* Called when the scrolling state of the view pager is changed
* (non-Javadoc)
* @see com.TwentyCodes.android.LocationRinger.EnableScrollingListener#setScrollEnabled(boolean)
*/
@Override
public void setScrollEnabled(boolean enabled) {
this.mPager.setScrollEnabled(enabled);
}
/**
* Called when a feature is removed
* (non-Javadoc)
* @see com.TwentyCodes.android.LocationRinger.OnContentChangedListener#onInfoContentRemoved(java.lang.String[])
*/
@Override
public void onInfoContentRemoved(String... keys) {
for(String key : keys)

View File

@@ -86,27 +86,27 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
public Fragment initFeatureFragment(int fragmentCode){
Fragment f = null;
switch(fragmentCode){
case 0:
case KEY_ADDED_RINGTONE:
f= new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING, KEY_ADDED_RINGTONE);
mAdded.add(KEY_ADDED_RINGTONE);
break;
case 1:
case KEY_ADDED_NOTIFICATIONTONE:
f = new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION, KEY_ADDED_NOTIFICATIONTONE);
mAdded.add(KEY_ADDED_NOTIFICATIONTONE);
break;
case 2:
case KEY_ADDED_ALARM_VOLUME:
f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_ALARM, KEY_ADDED_ALARM_VOLUME);
mAdded.add(KEY_ADDED_ALARM_VOLUME);
break;
case 3:
case KEY_ADDED_MUSIC_VOLUME:
f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_MUSIC, KEY_ADDED_MUSIC_VOLUME);
mAdded.add(KEY_ADDED_MUSIC_VOLUME);
break;
case 4:
case KEY_ADDED_BT:
f = new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener, this, KEY_ADDED_BT);
mAdded.add(KEY_ADDED_BT);
break;
case 5:
case KEY_ADDED_WIFI:
f = new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener, this, KEY_ADDED_WIFI);
mAdded.add(KEY_ADDED_WIFI);
break;
@@ -249,6 +249,9 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
final int id = ((IdFragment) f).getFragmentId();
mAdded.remove(new Integer(id));
/*
* we need to notify our parent activity that the feature have been removed.
*/
switch(id){
case KEY_ADDED_RINGTONE:
this.mListener.onInfoContentRemoved(RingerDatabase.KEY_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_RINGTONE_VOLUME);