From d048903501cb3506b2edeef4354b5b17bcca5563 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 10:46:04 -0400 Subject: [PATCH 01/11] Created a new feature title bar, it will be used in place of the current feature title bar Signed-off-by: Ricky Barrette --- .../res/layout/feature_title_bar.xml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 LocationRinger/res/layout/feature_title_bar.xml diff --git a/LocationRinger/res/layout/feature_title_bar.xml b/LocationRinger/res/layout/feature_title_bar.xml new file mode 100644 index 0000000..ca7ab44 --- /dev/null +++ b/LocationRinger/res/layout/feature_title_bar.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file From 5ead10d129c7348314fb490b660eb6f9da84a023 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 10:53:28 -0400 Subject: [PATCH 02/11] Updated XML of ringtone fragment, toggle button fragment, and volume fragment to use the new feature title bar. I also deleted list.xml because it is no longer used. Signed-off-by: Ricky Barrette --- LocationRinger/res/layout/list.xml | 5 ----- LocationRinger/res/layout/ringtone_fragment.xml | 8 +++----- LocationRinger/res/layout/toggle_button_fragment.xml | 8 +++----- LocationRinger/res/layout/volume_fragment.xml | 8 +++----- 4 files changed, 9 insertions(+), 20 deletions(-) delete mode 100644 LocationRinger/res/layout/list.xml diff --git a/LocationRinger/res/layout/list.xml b/LocationRinger/res/layout/list.xml deleted file mode 100644 index d169124..0000000 --- a/LocationRinger/res/layout/list.xml +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/LocationRinger/res/layout/ringtone_fragment.xml b/LocationRinger/res/layout/ringtone_fragment.xml index bde96f1..aaa1c72 100644 --- a/LocationRinger/res/layout/ringtone_fragment.xml +++ b/LocationRinger/res/layout/ringtone_fragment.xml @@ -4,14 +4,12 @@ android:layout_height="wrap_content" android:orientation="vertical" > - + layout="@layout/feature_title_bar" /> - + layout="@layout/feature_title_bar" /> - + layout="@layout/feature_title_bar" /> Date: Sat, 26 May 2012 12:09:20 -0400 Subject: [PATCH 03/11] Started intergrating the new fragment title bar into the following fragments: ringtone fragment, toggle button fragment, volume fragment Signed-off-by: Ricky Barrette --- .../ui/fragments/RingtoneFragment.java | 31 ++++++++++++------- .../ui/fragments/ToggleButtonFragment.java | 6 +++- .../ui/fragments/VolumeFragment.java | 19 ++++++++---- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java index f519fba..3795d5c 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java @@ -24,6 +24,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.EditText; +import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; @@ -51,6 +52,7 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee private EditText mRingtone; private Uri mRingtoneURI; private SeekBar mVolume; + private ImageView mIcon; public RingtoneFragment(ContentValues info, OnContentChangedListener listener, int stream){ super(); @@ -114,6 +116,7 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee * @author ricky barrette */ private void notifyVolumeChanged(int progress) { + mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off)); if(this.mListener != null){ final ContentValues info = new ContentValues(); info.put(this.mKeyVolume, progress); @@ -133,6 +136,7 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee this.mRingtone.setText(R.string.silent); mVolume.setEnabled(false); mVolume.setProgress(0); + notifyVolumeChanged(0); } else { mVolume.setEnabled(true); Ringtone ringtone = RingtoneManager.getRingtone(this.getActivity(), Uri.parse(tone.toString())); @@ -164,15 +168,28 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee /* * initialize the views */ - final TextView label = (TextView) view.findViewById(R.id.label); + final TextView label = (TextView) view.findViewById(R.id.title); label.setText(mLabel); + mIcon = (ImageView) view.findViewById(R.id.icon); + mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(android.R.drawable.ic_lock_silent_mode_off)); + this.mRingtone = (EditText) view.findViewById(R.id.ringtone); mVolume = (SeekBar) view.findViewById(R.id.ringtone_volume); this.mRingtone.setOnClickListener(this); mVolume.setMax(audioManager.getStreamMaxVolume(mStream)); + /* + * volume + */ + if(this.mInfo.containsKey(this.mKeyVolume)) + mVolume.setProgress(Integer.parseInt(this.mInfo.getAsString(this.mKeyVolume))); + else { + mVolume.setProgress(audioManager.getStreamVolume(mStream)); + notifyVolumeChanged(audioManager.getStreamVolume(mStream)); + } + /* * ringtone & uri */ @@ -195,16 +212,8 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee mRingtone.setText(R.string.silent); mVolume.setProgress(0); } - - /* - * volume - */ - if(this.mInfo.containsKey(this.mKeyVolume)) - mVolume.setProgress(Integer.parseInt(this.mInfo.getAsString(this.mKeyVolume))); - else { - mVolume.setProgress(audioManager.getStreamVolume(mStream)); - notifyVolumeChanged(audioManager.getStreamVolume(mStream)); - } + + mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(mVolume.getProgress() == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off)); mVolume.setOnSeekBarChangeListener(this); return view; diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java index 2b1f449..e082b3b 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java @@ -18,6 +18,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.ImageView; import android.widget.TextView; import android.widget.ToggleButton; @@ -47,9 +48,12 @@ public class ToggleButtonFragment extends Fragment implements OnCheckedChangeLis @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) { View view = inflater.inflate(R.layout.toggle_button_fragment, container, false); - TextView t = (TextView) view.findViewById(R.id.label); + TextView t = (TextView) view.findViewById(R.id.title); t.setText(this.mTitle); + final ImageView icon = (ImageView) view.findViewById(R.id.icon); + icon.setImageDrawable(this.getActivity().getResources().getDrawable(android.R.drawable.ic_lock_silent_mode_off)); + ToggleButton b = (ToggleButton) view.findViewById(R.id.toggle); if(this.mInfo.containsKey(this.mKey)) b.setChecked(RingerDatabase.parseBoolean(this.mInfo.getAsString(this.mKey))); diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java index 252a4d3..99ee79f 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java @@ -17,12 +17,13 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; -import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; +import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; import com.TwentyCodes.android.LocationRinger.debug.Debug; @@ -39,6 +40,7 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener private final String mKey; private final ContentValues mInfo; private final int mLabel; + private ImageView mIcon; /** * Creates a new Volume Fragment @@ -98,27 +100,32 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener for(Entry item : this.mInfo.valueSet()) Log.d(TAG, item.getKey() +" = "+ item.getValue()); - View view = inflater.inflate(R.layout.volume_fragment, container, false); - TextView label = (TextView) view.findViewById(R.id.volume_label); - SeekBar volume = (SeekBar) view.findViewById(R.id.volume); + final View view = inflater.inflate(R.layout.volume_fragment, container, false); + final TextView label = (TextView) view.findViewById(R.id.title); + final SeekBar volume = (SeekBar) view.findViewById(R.id.volume); volume.setMax(this.mAudioManager.getStreamMaxVolume(mStream)); volume.setProgress(this.mAudioManager.getStreamVolume(mStream)); volume.setOnSeekBarChangeListener(this); label.setText(mLabel); + mIcon = (ImageView) view.findViewById(R.id.icon); + if(this.mInfo.containsKey(this.mKey)) volume.setProgress(Integer.parseInt(this.mInfo.getAsString(this.mKey))); else notifyListener(this.mAudioManager.getStreamVolume(mStream)); - + + mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(volume.getProgress() == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off)); return view; } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - if(fromUser) + if(fromUser){ notifyListener(progress); + mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off)); + } } /** From 36ecfc3507869ce550385a449633be047fe36f32 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 12:58:38 -0400 Subject: [PATCH 04/11] I got the initial funtionality of removing fragmens from the List. the next step is to better handle the added array Signed-off-by: Ricky Barrette --- .../ui/RingerInformationActivity.java | 62 ++++++++--------- .../fragments/BaseFragmentListFragment.java | 39 ++++++++++- .../ui/fragments/FeatureListFragment.java | 68 ++++++++++++++++--- .../ui/fragments/RingtoneFragment.java | 30 +++++--- .../ui/fragments/ToggleButtonFragment.java | 44 ++++++++---- .../ui/fragments/VolumeFragment.java | 32 ++++++--- 6 files changed, 206 insertions(+), 69 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java index c3402b6..a98e0ae 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java @@ -119,38 +119,38 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon * TODO * update interval */ - ArrayList what = new ArrayList(); ArrayList added = new ArrayList(); - - if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){ - what.add(new RingtoneFragment(this.mInfo, this, AudioManager.STREAM_RING)); - added.add(0); - } - - if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){ - what.add(new RingtoneFragment(this.mInfo, this, AudioManager.STREAM_NOTIFICATION)); - added.add(1); - } - - if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){ - what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_ALARM)); - added.add(2); - } - - if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){ - what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_MUSIC)); - added.add(3); - } - - if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){ - what.add(new ToggleButtonFragment(this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this)); - added.add(4); - } - - if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){ - what.add(new ToggleButtonFragment(this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this)); - added.add(5); - } + ArrayList what = new ArrayList(); +// +// if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){ +// what.add(new RingtoneFragment(this.mInfo, this, AudioManager.STREAM_RING)); +// added.add(0); +// } +// +// if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){ +// what.add(new RingtoneFragment(this.mInfo, this, AudioManager.STREAM_NOTIFICATION)); +// added.add(1); +// } +// +// if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){ +// what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_ALARM)); +// added.add(2); +// } +// +// if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){ +// what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_MUSIC)); +// added.add(3); +// } +// +// if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){ +// what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this)); +// added.add(4); +// } +// +// if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){ +// what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this)); +// added.add(5); +// } fragments.add(new FeatureListFragment(this.mInfo, this, what, added)); diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/BaseFragmentListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/BaseFragmentListFragment.java index 9639c8f..5a018d0 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/BaseFragmentListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/BaseFragmentListFragment.java @@ -32,7 +32,7 @@ public abstract class BaseFragmentListFragment extends Fragment { private final int mLayout; /** - * Creates a new BaseFragmentListFragment + * Creates a new Populated BaseFragmentListFragment * @author ricky barrette */ public BaseFragmentListFragment(ArrayList fragments, int layout, int container) { @@ -42,6 +42,18 @@ public abstract class BaseFragmentListFragment extends Fragment { mContainer = container; } + /** + * Creates a new Empty Base Fragment List + * @param layout + * @param container + * @author ricky barrette + */ + public BaseFragmentListFragment(int layout, int container) { + mLayout = layout; + mContainer = container; + mFragments = new ArrayList(); + } + /** * Adds the fragment to the list * @param fragment @@ -54,6 +66,31 @@ public abstract class BaseFragmentListFragment extends Fragment { transaction.commit(); } + /** + * Adds a collection ofs fragments to the list + * @param fragments + * @author ricky barrette + */ + public void addAll(final ArrayList fragments){ + final FragmentTransaction transaction = this.getFragmentManager().beginTransaction(); + for(Fragment f : fragments){ + this.mFragments.add(f); + transaction.add(mContainer, f, f.getTag()); + } + transaction.commit(); + } + + /** + * Adds a collection ofs fragments to the list, but doesn't preform any transactions + * @param fragment + * @author ricky barrette + */ + protected void addAllInit(final ArrayList fragments){ + for(Fragment f : fragments){ + this.mFragments.add(f); + } + } + /** * Loads all the fragments * @author ricky barrette diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index dd4c046..4a5487e 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -22,6 +22,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; +import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; @@ -33,7 +34,7 @@ import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; * * @author ricky */ -public class FeatureListFragment extends BaseFragmentListFragment implements OnClickListener, android.content.DialogInterface.OnClickListener { +public class FeatureListFragment extends BaseFragmentListFragment implements OnClickListener, android.content.DialogInterface.OnClickListener, FeatureRemovedListener { private static final String TAG = "FeatureListFragment"; private final ContentValues mInfo; @@ -48,10 +49,50 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC * @author ricky barrette */ public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList fragments, ArrayList added) { - super(fragments, R.layout.fragment_list_contianer, R.id.fragment_list_contianer); + super(R.layout.fragment_list_contianer, R.id.fragment_list_contianer); mInfo = info; mListener = listener; mAdded = added; + addAllInit(initList()); + } + + /** + * Initali + * @author ricky barrette + */ + private ArrayList initList() { + ArrayList what = new ArrayList(); + + if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){ + what.add(new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING)); + mAdded.add(0); + } + + if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){ + what.add(new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION)); + mAdded.add(1); + } + + if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){ + what.add(new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_ALARM)); + mAdded.add(2); + } + + if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){ + what.add(new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_MUSIC)); + mAdded.add(3); + } + + if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){ + what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener, this)); + mAdded.add(4); + } + + if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){ + what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener, this)); + mAdded.add(5); + } + return what; } /** @@ -64,27 +105,27 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC Fragment f = null; switch(which){ case 0: - f= new RingtoneFragment(this.mInfo, this.mListener, AudioManager.STREAM_RING); + f= new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING); mAdded.add(0); break; case 1: - f = new RingtoneFragment(this.mInfo, this.mListener, AudioManager.STREAM_NOTIFICATION); + f = new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION); mAdded.add(1); break; case 2: - f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, AudioManager.STREAM_ALARM); + f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_ALARM); mAdded.add(2); break; case 3: - f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, AudioManager.STREAM_MUSIC); + f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_MUSIC); mAdded.add(3); break; case 4: - f = new ToggleButtonFragment(this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener); + f = new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener, this); mAdded.add(4); break; case 5: - f = new ToggleButtonFragment(this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener); + f = new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener, this); mAdded.add(5); break; // case 6: @@ -159,4 +200,15 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC v.findViewById(R.id.add_feature_button).setOnClickListener(this); return v; } + + /** + * Called when a fragment needs to be removed + * (non-Javadoc) + * @see com.TwentyCodes.android.LocationRinger.FeatureRemovedListener#onFeatureRemoved(android.support.v4.app.Fragment) + */ + @Override + public void onFeatureRemoved(Fragment f) { + this.remove(f); + //TODO remove database entries + } } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java index 3795d5c..4a5ddc8 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java @@ -29,6 +29,7 @@ import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; +import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; @@ -43,22 +44,24 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee private static final String TAG = "RingtoneFragment"; private final int mStream; private final int mType; - private final OnContentChangedListener mListener; + private final OnContentChangedListener mChangedListener; private final String mKeyEnabled; private final String mKeyUri; private final String mKeyVolume; private final ContentValues mInfo; + private final FeatureRemovedListener mRemovedListener; private final int mLabel; private EditText mRingtone; private Uri mRingtoneURI; private SeekBar mVolume; private ImageView mIcon; - public RingtoneFragment(ContentValues info, OnContentChangedListener listener, int stream){ + public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream){ super(); - this.mListener = listener; + this.mChangedListener = changedListener; this.mStream = stream; this.mInfo = info; + this.mRemovedListener = removedListener; switch(stream){ case AudioManager.STREAM_NOTIFICATION: @@ -102,11 +105,11 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee * @author ricky barrette */ private void notifyRingtoneChanged(Uri tone) { - if(this.mListener != null){ + if(this.mChangedListener != null){ ContentValues info = new ContentValues(); info.put(this.mKeyUri, tone != null ? tone.toString() : null); info.put(mKeyEnabled, tone == null); - this.mListener.onInfoContentChanged(info); + this.mChangedListener.onInfoContentChanged(info); } } @@ -117,10 +120,10 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee */ private void notifyVolumeChanged(int progress) { mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off)); - if(this.mListener != null){ + if(this.mChangedListener != null){ final ContentValues info = new ContentValues(); info.put(this.mKeyVolume, progress); - this.mListener.onInfoContentChanged(info); + this.mChangedListener.onInfoContentChanged(info); } } @@ -153,7 +156,16 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee */ @Override public void onClick(View v) { - getRingtoneURI(this.mType, mRingtoneURI); + switch(v.getId()){ + case R.id.ringtone: + getRingtoneURI(this.mType, mRingtoneURI); + break; + case R.id.close: + if(this.mRemovedListener != null) + this.mRemovedListener.onFeatureRemoved(this); + break; + + } } @Override @@ -180,6 +192,8 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee this.mRingtone.setOnClickListener(this); mVolume.setMax(audioManager.getStreamMaxVolume(mStream)); + view.findViewById(R.id.close).setOnClickListener(this); + /* * volume */ diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java index e082b3b..b0bae2f 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java @@ -6,6 +6,7 @@ */ package com.TwentyCodes.android.LocationRinger.ui.fragments; +import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener; import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; @@ -15,6 +16,7 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; @@ -26,35 +28,41 @@ import android.widget.ToggleButton; * A simple fragment that displays a toggle button and a title label * @author ricky */ -public class ToggleButtonFragment extends Fragment implements OnCheckedChangeListener { +public class ToggleButtonFragment extends Fragment implements OnCheckedChangeListener, OnClickListener { - private String mTitle; - private String mKey; - private ContentValues mInfo; - private OnContentChangedListener mListener; + private final String mTitle; + private final String mKey; + private final ContentValues mInfo; + private final OnContentChangedListener mChangedListener; + private final int mIcon; + private final FeatureRemovedListener mRemovedListener; /** * Creates a new ToggleButtonFtagment * @author ricky barrette */ - public ToggleButtonFragment(String title, String key, ContentValues info, OnContentChangedListener listener) { + public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener) { super(); this.mTitle = title; this.mKey = key; this.mInfo = info; - this.mListener = listener; + this.mChangedListener = changedListener; + this.mIcon = icon; + this.mRemovedListener = removedListener; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) { - View view = inflater.inflate(R.layout.toggle_button_fragment, container, false); - TextView t = (TextView) view.findViewById(R.id.title); + final View view = inflater.inflate(R.layout.toggle_button_fragment, container, false); + final TextView t = (TextView) view.findViewById(R.id.title); t.setText(this.mTitle); final ImageView icon = (ImageView) view.findViewById(R.id.icon); - icon.setImageDrawable(this.getActivity().getResources().getDrawable(android.R.drawable.ic_lock_silent_mode_off)); + icon.setImageDrawable(this.getActivity().getResources().getDrawable(mIcon)); - ToggleButton b = (ToggleButton) view.findViewById(R.id.toggle); + view.findViewById(R.id.close).setOnClickListener(this); + + final ToggleButton b = (ToggleButton) view.findViewById(R.id.toggle); if(this.mInfo.containsKey(this.mKey)) b.setChecked(RingerDatabase.parseBoolean(this.mInfo.getAsString(this.mKey))); b.setOnCheckedChangeListener(this); @@ -63,11 +71,21 @@ public class ToggleButtonFragment extends Fragment implements OnCheckedChangeLis @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if(this.mListener != null){ + if(this.mChangedListener != null){ ContentValues info = new ContentValues(); info.put(this.mKey, isChecked); - this.mListener.onInfoContentChanged(info); + this.mChangedListener.onInfoContentChanged(info); } } + /** + * Called when the user clicks the remove button + * @param v + * @author ricky barrette + */ + @Override + public void onClick(View v) { + if(this.mRemovedListener != null) + this.mRemovedListener.onFeatureRemoved(this); + } } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java index 99ee79f..001bf3a 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java @@ -16,12 +16,14 @@ import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; +import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; @@ -31,31 +33,33 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; * This fragment will represent the volume fragments * @author ricky */ -public class VolumeFragment extends Fragment implements OnSeekBarChangeListener { +public class VolumeFragment extends Fragment implements OnSeekBarChangeListener, OnClickListener { private static final String TAG = "VolumeFragment"; private final AudioManager mAudioManager; private final int mStream; - private final OnContentChangedListener mListener; + private final OnContentChangedListener mChangedListener; private final String mKey; private final ContentValues mInfo; private final int mLabel; + private final FeatureRemovedListener mRemovedListener; private ImageView mIcon; /** * Creates a new Volume Fragment * @param info * @param context - * @param listener + * @param changedListener * @param stream * @author ricky barrette */ - public VolumeFragment(ContentValues info, Context context, OnContentChangedListener listener, int stream){ + public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream){ super(); this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); this.mStream = stream; - this.mListener = listener; + this.mChangedListener = changedListener; this.mInfo = info; + this.mRemovedListener = removedListener; switch(this.mStream){ case AudioManager.STREAM_ALARM: @@ -111,6 +115,8 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener mIcon = (ImageView) view.findViewById(R.id.icon); + view.findViewById(R.id.close).setOnClickListener(this); + if(this.mInfo.containsKey(this.mKey)) volume.setProgress(Integer.parseInt(this.mInfo.getAsString(this.mKey))); else @@ -134,10 +140,10 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener * @author ricky barrette */ private void notifyListener(final int progress) { - if(this.mListener != null){ + if(this.mChangedListener != null){ final ContentValues info = new ContentValues(); info.put(this.mKey, progress); - this.mListener.onInfoContentChanged(info); + this.mChangedListener.onInfoContentChanged(info); } } @@ -151,4 +157,14 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener // TODO Auto-generated method stub } -} + /** + * Called when the user clicks on the remove button + * (non-Javadoc) + * @see android.view.View.OnClickListener#onClick(android.view.View) + */ + @Override + public void onClick(View v) { + if(this.mRemovedListener != null) + this.mRemovedListener.onFeatureRemoved(this); + } +} \ No newline at end of file From 7aebd3b60d8b95837ac7d8eaa739373709a39184 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 13:22:27 -0400 Subject: [PATCH 05/11] I finished fixing the add feature list filtering Signed-off-by: Ricky Barrette --- .../FeatureRemovedListener.java | 22 +++++ .../ui/fragments/FeatureListFragment.java | 94 ++++++++++--------- .../ui/fragments/IdFragment.java | 30 ++++++ .../ui/fragments/RingtoneFragment.java | 6 +- .../ui/fragments/ToggleButtonFragment.java | 6 +- .../ui/fragments/VolumeFragment.java | 6 +- 6 files changed, 110 insertions(+), 54 deletions(-) create mode 100644 LocationRinger/src/com/TwentyCodes/android/LocationRinger/FeatureRemovedListener.java create mode 100644 LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/IdFragment.java diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/FeatureRemovedListener.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/FeatureRemovedListener.java new file mode 100644 index 0000000..48e9b0a --- /dev/null +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/FeatureRemovedListener.java @@ -0,0 +1,22 @@ +/** + * FeatureRemovedListener.java + * @date May 26, 2012 + * @author ricky barrette + * @author Twenty Codes, LLC + */ +package com.TwentyCodes.android.LocationRinger; + +import android.support.v4.app.Fragment; + +/** + * This interface will be used to notify + * @author ricky barrette + */ +public interface FeatureRemovedListener { + + /** + * Called when a feature is removed from the list + * @author ricky barrette + */ + public void onFeatureRemoved(Fragment fragment); +} \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index 4a5487e..220bea6 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -35,7 +35,13 @@ import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; * @author ricky */ public class FeatureListFragment extends BaseFragmentListFragment implements OnClickListener, android.content.DialogInterface.OnClickListener, FeatureRemovedListener { - + + private static final int KEY_ADDED_RINGTONE = 0; + private static final int KEY_ADDED_NOTIFICATIONTONE = 1; + private static final int KEY_ADDED_ALARM_VOLUME = 2; + private static final int KEY_ADDED_MUSIC_VOLUME = 3; + private static final int KEY_ADDED_BT = 4; + private static final int KEY_ADDED_WIFI = 5; private static final String TAG = "FeatureListFragment"; private final ContentValues mInfo; private final OnContentChangedListener mListener; @@ -64,33 +70,27 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC ArrayList what = new ArrayList(); if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){ - what.add(new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING)); - mAdded.add(0); + initFeatureFragment(KEY_ADDED_RINGTONE); } if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){ - what.add(new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION)); - mAdded.add(1); + initFeatureFragment(KEY_ADDED_NOTIFICATIONTONE); } if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){ - what.add(new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_ALARM)); - mAdded.add(2); + initFeatureFragment(KEY_ADDED_ALARM_VOLUME); } if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){ - what.add(new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_MUSIC)); - mAdded.add(3); + initFeatureFragment(KEY_ADDED_MUSIC_VOLUME); } if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){ - what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener, this)); - mAdded.add(4); + initFeatureFragment(KEY_ADDED_BT); } if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){ - what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener, this)); - mAdded.add(5); + initFeatureFragment(KEY_ADDED_WIFI); } return what; } @@ -102,40 +102,42 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC */ @Override public void onClick(DialogInterface dialog, int which) { - Fragment f = null; - switch(which){ - case 0: - f= new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING); - mAdded.add(0); - break; - case 1: - f = new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION); - mAdded.add(1); - break; - case 2: - f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_ALARM); - mAdded.add(2); - break; - case 3: - f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_MUSIC); - mAdded.add(3); - break; - case 4: - f = new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener, this); - mAdded.add(4); - break; - case 5: - f = new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener, this); - mAdded.add(5); - break; -// case 6: -// f = -// break; - } - + final Fragment f = initFeatureFragment(which); if(f != null) add(f); } + + public Fragment initFeatureFragment(int fragmentCode){ + Fragment f = null; + switch(fragmentCode){ + case 0: + f= new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING, KEY_ADDED_RINGTONE); + mAdded.add(KEY_ADDED_RINGTONE); + break; + case 1: + f = new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION, KEY_ADDED_NOTIFICATIONTONE); + mAdded.add(KEY_ADDED_NOTIFICATIONTONE); + break; + case 2: + 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: + 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: + 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: + 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; + + } + return f; + } /** * Called when the add feature button is clicked @@ -209,6 +211,8 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC @Override public void onFeatureRemoved(Fragment f) { this.remove(f); - //TODO remove database entries + + if(f instanceof IdFragment) + mAdded.remove(new Integer(((IdFragment) f).getFragmentId())); } } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/IdFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/IdFragment.java new file mode 100644 index 0000000..c959ed7 --- /dev/null +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/IdFragment.java @@ -0,0 +1,30 @@ +/** + * IdFragment.java + * @date May 26, 2012 + * @author ricky barrette + * @author Twenty Codes, LLC + */ +package com.TwentyCodes.android.LocationRinger.ui.fragments; + +import android.support.v4.app.Fragment; + +/** + * This is a simple extention of a fragment that will allow for storage of an id + * @author ricky barrette + */ +public class IdFragment extends Fragment { + + private final int mId; + + public IdFragment(int id){ + super(); + mId = id; + } + + /** + * @return the id of this fragment + */ + public int getFragmentId() { + return mId; + } +} \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java index 4a5ddc8..eee6c4a 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java @@ -39,7 +39,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; * This fragment will be for ringtone settings * @author ricky */ -public class RingtoneFragment extends Fragment implements OnClickListener, OnSeekBarChangeListener { +public class RingtoneFragment extends IdFragment implements OnClickListener, OnSeekBarChangeListener { private static final String TAG = "RingtoneFragment"; private final int mStream; @@ -56,8 +56,8 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee private SeekBar mVolume; private ImageView mIcon; - public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream){ - super(); + public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){ + super(id); this.mChangedListener = changedListener; this.mStream = stream; this.mInfo = info; diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java index b0bae2f..213bb9b 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java @@ -28,7 +28,7 @@ import android.widget.ToggleButton; * A simple fragment that displays a toggle button and a title label * @author ricky */ -public class ToggleButtonFragment extends Fragment implements OnCheckedChangeListener, OnClickListener { +public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeListener, OnClickListener { private final String mTitle; private final String mKey; @@ -41,8 +41,8 @@ public class ToggleButtonFragment extends Fragment implements OnCheckedChangeLis * Creates a new ToggleButtonFtagment * @author ricky barrette */ - public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener) { - super(); + public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int id) { + super(id); this.mTitle = title; this.mKey = key; this.mInfo = info; diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java index 001bf3a..f24978c 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java @@ -33,7 +33,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; * This fragment will represent the volume fragments * @author ricky */ -public class VolumeFragment extends Fragment implements OnSeekBarChangeListener, OnClickListener { +public class VolumeFragment extends IdFragment implements OnSeekBarChangeListener, OnClickListener { private static final String TAG = "VolumeFragment"; private final AudioManager mAudioManager; @@ -53,8 +53,8 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener, * @param stream * @author ricky barrette */ - public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream){ - super(); + public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){ + super(id); this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); this.mStream = stream; this.mChangedListener = changedListener; From fa7cbb812220a71bcdfd15967f0f3abe383d151d Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 13:27:31 -0400 Subject: [PATCH 06/11] Fixed the null pointer caused by calling getActivity() before the fragment had one. Also I fixed the loading of the feaure list of saved ringers Signed-off-by: Ricky Barrette --- .../ui/fragments/FeatureListFragment.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index 220bea6..ff32a68 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -59,7 +59,6 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC mInfo = info; mListener = listener; mAdded = added; - addAllInit(initList()); } /** @@ -70,27 +69,27 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC ArrayList what = new ArrayList(); if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){ - 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)){ - initFeatureFragment(KEY_ADDED_NOTIFICATIONTONE); + what.add(initFeatureFragment(KEY_ADDED_NOTIFICATIONTONE)); } if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){ - initFeatureFragment(KEY_ADDED_ALARM_VOLUME); + what.add(initFeatureFragment(KEY_ADDED_ALARM_VOLUME)); } if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){ - initFeatureFragment(KEY_ADDED_MUSIC_VOLUME); + what.add(initFeatureFragment(KEY_ADDED_MUSIC_VOLUME)); } if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){ - initFeatureFragment(KEY_ADDED_BT); + what.add(initFeatureFragment(KEY_ADDED_BT)); } if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){ - initFeatureFragment(KEY_ADDED_WIFI); + what.add(initFeatureFragment(KEY_ADDED_WIFI)); } return what; } @@ -198,6 +197,7 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC */ @Override public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle bundle) { + addAllInit(initList()); final View v = super.onCreateView(inflator, container, bundle); v.findViewById(R.id.add_feature_button).setOnClickListener(this); return v; From 0f119a8d3b28cbf65e6cc0887279c47c6dcdf498 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 14:42:30 -0400 Subject: [PATCH 07/11] Fixed the feature item duplication bug Signed-off-by: Ricky Barrette --- .../ui/fragments/FeatureListFragment.java | 78 +++++++++++-------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index ff32a68..28ff68a 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -61,6 +61,38 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC mAdded = added; } + public Fragment initFeatureFragment(int fragmentCode){ + Fragment f = null; + switch(fragmentCode){ + case 0: + f= new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING, KEY_ADDED_RINGTONE); + mAdded.add(KEY_ADDED_RINGTONE); + break; + case 1: + f = new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION, KEY_ADDED_NOTIFICATIONTONE); + mAdded.add(KEY_ADDED_NOTIFICATIONTONE); + break; + case 2: + 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: + 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: + 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: + 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; + + } + return f; + } + /** * Initali * @author ricky barrette @@ -93,7 +125,7 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC } return what; } - + /** * Called when an item is picked from the add featue list * (non-Javadoc) @@ -105,38 +137,6 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC if(f != null) add(f); } - - public Fragment initFeatureFragment(int fragmentCode){ - Fragment f = null; - switch(fragmentCode){ - case 0: - f= new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING, KEY_ADDED_RINGTONE); - mAdded.add(KEY_ADDED_RINGTONE); - break; - case 1: - f = new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_NOTIFICATION, KEY_ADDED_NOTIFICATIONTONE); - mAdded.add(KEY_ADDED_NOTIFICATIONTONE); - break; - case 2: - 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: - 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: - 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: - 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; - - } - return f; - } /** * Called when the add feature button is clicked @@ -191,13 +191,23 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC .show(); } + /** + * (non-Javadoc) + * @see android.support.v4.app.Fragment#onCreate(android.os.Bundle) + */ + @Override + public void onCreate(Bundle arg0) { + addAllInit(initList()); + // TODO Auto-generated method stub + super.onCreate(arg0); + } + /** * (non-Javadoc) * @see com.TwentyCodes.android.LocationRinger.ui.fragments.BaseFragmentListFragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) */ @Override public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle bundle) { - addAllInit(initList()); final View v = super.onCreateView(inflator, container, bundle); v.findViewById(R.id.add_feature_button).setOnClickListener(this); return v; From 15d7b5a25ab4704649088bac990927a8aa269930 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 15:00:10 -0400 Subject: [PATCH 08/11] Cleaned up some of the code, and updated comments Signed-off-by: Ricky Barrette --- .../ui/RingerInformationActivity.java | 61 +++---------------- .../ui/fragments/FeatureListFragment.java | 37 ++++++++--- .../ui/fragments/RingtoneFragment.java | 9 ++- .../ui/fragments/ToggleButtonFragment.java | 33 ++++++++-- .../ui/fragments/VolumeFragment.java | 18 +++++- 5 files changed, 87 insertions(+), 71 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java index a98e0ae..9c28a7b 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java @@ -14,7 +14,6 @@ import android.app.ProgressDialog; import android.content.ContentValues; import android.content.Context; import android.content.Intent; -import android.media.AudioManager; import android.os.Bundle; import android.os.Looper; import android.support.v4.app.Fragment; @@ -35,9 +34,6 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; import com.TwentyCodes.android.LocationRinger.ui.fragments.AboutRingerFragment; import com.TwentyCodes.android.LocationRinger.ui.fragments.FeatureListFragment; import com.TwentyCodes.android.LocationRinger.ui.fragments.LocationInfomationFragment; -import com.TwentyCodes.android.LocationRinger.ui.fragments.RingtoneFragment; -import com.TwentyCodes.android.LocationRinger.ui.fragments.ToggleButtonFragment; -import com.TwentyCodes.android.LocationRinger.ui.fragments.VolumeFragment; import com.jakewharton.android.viewpagerindicator.TitlePageIndicator; import com.jakewharton.android.viewpagerindicator.TitledFragmentAdapter; @@ -63,12 +59,16 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon Log.d(TAG, item.getKey() +" = "+ item.getValue()); } + /** + * Called when the activity is first created + * (non-Javadoc) + * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle) + */ @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.ringer_information_activity); - /* * Set up the action bar if required */ @@ -112,47 +112,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon if(!isDefault) fragments.add(new LocationInfomationFragment(this.mInfo, this, this)); - /* - * What page - * ONLY Dynamically add the required fragments that have already been added. - * - * TODO - * update interval - */ - ArrayList added = new ArrayList(); - ArrayList what = new ArrayList(); -// -// if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){ -// what.add(new RingtoneFragment(this.mInfo, this, AudioManager.STREAM_RING)); -// added.add(0); -// } -// -// if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){ -// what.add(new RingtoneFragment(this.mInfo, this, AudioManager.STREAM_NOTIFICATION)); -// added.add(1); -// } -// -// if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){ -// what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_ALARM)); -// added.add(2); -// } -// -// if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){ -// what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_MUSIC)); -// added.add(3); -// } -// -// if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){ -// what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this)); -// added.add(4); -// } -// -// if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){ -// what.add(new ToggleButtonFragment(android.R.drawable.stat_sys_data_bluetooth, this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this)); -// added.add(5); -// } - - fragments.add(new FeatureListFragment(this.mInfo, this, what, added)); + fragments.add(new FeatureListFragment(this.mInfo, this)); //Populate the pager this.mPager = (ViewPager)findViewById(R.id.pager); @@ -165,11 +125,6 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon indicator.setViewPager(this.mPager); indicator.setOnPageChangeListener(this); - - /* - * TODO - * button bar - */ } /** @@ -229,8 +184,6 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon @Override public void onPageSelected(int arg0) { - // TODO Auto-generated method stub - } @Override @@ -261,7 +214,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon } }).start(); } - + @Override public void setScrollEnabled(boolean enabled) { this.mPager.setScrollEnabled(enabled); diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index 28ff68a..195a9c2 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -29,9 +29,6 @@ import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; /** * This fragment will be used to display a list of features - * TODO - * + create button bar that had a plus button and a hint + add/remove features - * * @author ricky */ public class FeatureListFragment extends BaseFragmentListFragment implements OnClickListener, android.content.DialogInterface.OnClickListener, FeatureRemovedListener { @@ -42,13 +39,12 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC private static final int KEY_ADDED_MUSIC_VOLUME = 3; private static final int KEY_ADDED_BT = 4; private static final int KEY_ADDED_WIFI = 5; - private static final String TAG = "FeatureListFragment"; private final ContentValues mInfo; private final OnContentChangedListener mListener; private final ArrayList mAdded; /** - * Creates a new FeatureListFragment + * Creates a new populated FeatureListFragment * @param info * @param listener * @param fragments @@ -56,11 +52,37 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC */ public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList fragments, ArrayList added) { super(R.layout.fragment_list_contianer, R.id.fragment_list_contianer); + + if ( info == null ) + throw new NullPointerException(); + if ( listener == null ) + throw new NullPointerException(); + if ( fragments == null ) + throw new NullPointerException(); + if ( added == null ) + throw new NullPointerException(); + mInfo = info; mListener = listener; mAdded = added; } + + /** + * Creates a new empty feature list fragment + * @param info + * @param listener + * @author ricky barrette + */ + public FeatureListFragment(ContentValues info, OnContentChangedListener listener){ + this(info, listener, new ArrayList(), new ArrayList()); + } + /** + * Initializes a feature fragment + * @param fragmentCode + * @return + * @author ricky barrette + */ public Fragment initFeatureFragment(int fragmentCode){ Fragment f = null; switch(fragmentCode){ @@ -94,7 +116,7 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC } /** - * Initali + * Initializes feature fragments based upon current records * @author ricky barrette */ private ArrayList initList() { @@ -192,17 +214,18 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC } /** + * Called when the activity is first created * (non-Javadoc) * @see android.support.v4.app.Fragment#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle arg0) { addAllInit(initList()); - // TODO Auto-generated method stub super.onCreate(arg0); } /** + * Called when the view needs to be created * (non-Javadoc) * @see com.TwentyCodes.android.LocationRinger.ui.fragments.BaseFragmentListFragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) */ diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java index eee6c4a..a133ce9 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/RingtoneFragment.java @@ -17,7 +17,6 @@ import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -58,6 +57,14 @@ public class RingtoneFragment extends IdFragment implements OnClickListener, OnS public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){ super(id); + + if ( info == null ) + throw new NullPointerException(); + if ( changedListener == null ) + throw new NullPointerException(); + if ( removedListener == null ) + throw new NullPointerException(); + this.mChangedListener = changedListener; this.mStream = stream; this.mInfo = info; diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java index 213bb9b..127fedb 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/ToggleButtonFragment.java @@ -6,14 +6,8 @@ */ package com.TwentyCodes.android.LocationRinger.ui.fragments; -import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener; -import com.TwentyCodes.android.LocationRinger.R; -import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; -import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; - import android.content.ContentValues; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -24,6 +18,11 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.ToggleButton; +import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener; +import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; +import com.TwentyCodes.android.LocationRinger.R; +import com.TwentyCodes.android.LocationRinger.db.RingerDatabase; + /** * A simple fragment that displays a toggle button and a title label * @author ricky @@ -43,6 +42,18 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL */ public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int id) { super(id); + + if ( info == null ) + throw new NullPointerException(); + if (title == null ) + throw new NullPointerException(); + if ( key == null ) + throw new NullPointerException(); + if ( changedListener == null ) + throw new NullPointerException(); + if ( removedListener == null ) + throw new NullPointerException(); + this.mTitle = title; this.mKey = key; this.mInfo = info; @@ -51,6 +62,11 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL this.mRemovedListener = removedListener; } + /** + * Called when the fragment's view needs to be created + * (non-Javadoc) + * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) + */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) { final View view = inflater.inflate(R.layout.toggle_button_fragment, container, false); @@ -69,6 +85,11 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL return view; } + /** + * Called when the toggle button is clicked + * (non-Javadoc) + * @see android.widget.CompoundButton.OnCheckedChangeListener#onCheckedChanged(android.widget.CompoundButton, boolean) + */ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(this.mChangedListener != null){ diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java index f24978c..0674964 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/VolumeFragment.java @@ -12,7 +12,6 @@ import android.content.ContentValues; import android.content.Context; import android.media.AudioManager; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -55,6 +54,16 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene */ public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){ super(id); + + if ( info == null ) + throw new NullPointerException(); + if ( context == null ) + throw new NullPointerException(); + if ( changedListener == null ) + throw new NullPointerException(); + if ( removedListener == null ) + throw new NullPointerException(); + this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); this.mStream = stream; this.mChangedListener = changedListener; @@ -97,6 +106,11 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene } } + /** + * Called when the fragment's view needs to be created + * (non-Javadoc) + * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) + */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -149,12 +163,10 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene @Override public void onStartTrackingTouch(SeekBar seekBar) { - // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { - // TODO Auto-generated method stub } /** From f64d6a3d3bd5eddeffe9ef161cd3e14f4def57c5 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 17:17:02 -0400 Subject: [PATCH 09/11] Started working on deleteing features from the database, after they are removed and saved. Signed-off-by: Ricky Barrette --- .../OnContentChangedListener.java | 1 + .../ui/RingerInformationActivity.java | 7 +++++ .../ui/fragments/FeatureListFragment.java | 27 +++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java index dfe9d4c..1fc4b26 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java @@ -19,4 +19,5 @@ public interface OnContentChangedListener { void onInfoContentChanged(ContentValues info); + void onInfoContentRemoved(String... keys); } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java index 9c28a7b..b9d0215 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java @@ -220,4 +220,11 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon this.mPager.setScrollEnabled(enabled); } + @Override + public void onInfoContentRemoved(String... keys) { + for(String key : keys) + if(this.mInfo.containsKey(key)) + this.mInfo.remove(key); + } + } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index 195a9c2..1a52e4e 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -245,7 +245,30 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC public void onFeatureRemoved(Fragment f) { this.remove(f); - if(f instanceof IdFragment) - mAdded.remove(new Integer(((IdFragment) f).getFragmentId())); + if(f instanceof IdFragment){ + final int id = ((IdFragment) f).getFragmentId(); + mAdded.remove(new Integer(id)); + + switch(id){ + case KEY_ADDED_RINGTONE: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_RINGTONE_VOLUME); + break; + case KEY_ADDED_NOTIFICATIONTONE: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME); + break; + case KEY_ADDED_ALARM_VOLUME: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_ALARM_VOLUME); + break; + case KEY_ADDED_MUSIC_VOLUME: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_MUSIC_VOLUME); + break; + case KEY_ADDED_BT: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_BT); + break; + case KEY_ADDED_WIFI: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_WIFI); + break; + } + } } } \ No newline at end of file From 10a0ee47b8b2b90f65577cfbaefc4535f4847bbc Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 18:52:39 -0400 Subject: [PATCH 10/11] Finished Deleteing features from the database Signed-off-by: Ricky Barrette --- .../LocationRinger/db/RingerDatabase.java | 16 ++++++++++++++- .../ui/RingerInformationActivity.java | 20 +++++++++++++++++++ .../ui/fragments/FeatureListFragment.java | 15 ++++++++------ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java index c24fa36..8103052 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java @@ -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 item : info.valueSet()){ + if(old.containsKey(item.getKey())) + old.remove(item.getKey()); + } + for(final Entry 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))); diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java index b9d0215..f93ab8b 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java @@ -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) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index 1a52e4e..f0ed135 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -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); From b0e17459b242f52046354971fd0815e1222f9837 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 19:13:25 -0400 Subject: [PATCH 11/11] Cleaned up some code, updated comments and fix the bug with deleting notification feature Signed-off-by: Ricky Barrette --- .../LocationRinger/db/RingerDatabase.java | 98 +++++++++++-------- .../ui/fragments/FeatureListFragment.java | 2 +- 2 files changed, 57 insertions(+), 43 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java index 8103052..f0a6584 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/db/RingerDatabase.java @@ -38,10 +38,10 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; public class RingerDatabase { private static final String TAG = "RingerDatabase"; - private Context mContext; + private final Context mContext; private SQLiteDatabase mDb; + private final DatabaseListener mListener; public boolean isUpgrading = false; - private DatabaseListener mListener; /* * database information values @@ -109,7 +109,7 @@ public class RingerDatabase { */ private void convert2to3(SQLiteDatabase db){ //get all the ringer information from the old table - Cursor cursor = db.query("two", new String[] { KEY_RINGER_NAME, KEY_RINGTONE, + final Cursor cursor = db.query("two", new String[] { KEY_RINGER_NAME, KEY_RINGTONE, KEY_NOTIFICATION_RINGTONE, KEY_RINGTONE_IS_SILENT, KEY_NOTIFICATION_IS_SILENT, KEY_IS_ENABLED, KEY_RADIUS, KEY_LOCATION_LAT, KEY_LOCATION_LON, @@ -124,7 +124,7 @@ public class RingerDatabase { int count = cursor.getColumnCount(); if (cursor.moveToFirst()) { do { - ContentValues ringer = new ContentValues(); + final ContentValues ringer = new ContentValues(); if(Debug.DEBUG) Log.v(TAG, "Converting: " + cursor.getString(0)); for(int i = 0; i < count; i++){ @@ -278,10 +278,15 @@ public class RingerDatabase { * @author ricky barrette */ public RingerDatabase(Context context){ - this.mContext = context; - this.mDb = new OpenHelper(this.mContext).getWritableDatabase(); + this(context, null); } + /** + * Creates a new RingerDatabase + * @param context + * @param listener + * @author ricky barrette + */ public RingerDatabase(Context context, DatabaseListener listener){ this.mListener = listener; this.mContext = context; @@ -308,13 +313,14 @@ public class RingerDatabase { * @author ricky barrette */ public boolean backup(){ - File dbFile = new File(Environment.getDataDirectory() + "/data/"+mContext.getPackageName()+"/databases/"+DATABASE_NAME); + final File dbFile = new File(Environment.getDataDirectory() + "/data/"+mContext.getPackageName()+"/databases/"+DATABASE_NAME); - File exportDir = new File(Environment.getExternalStorageDirectory(), "/"+this.mContext.getString(R.string.app_name)); + final File exportDir = new File(Environment.getExternalStorageDirectory(), "/"+this.mContext.getString(R.string.app_name)); if (!exportDir.exists()) { exportDir.mkdirs(); } - File file = new File(exportDir, dbFile.getName()); + + final File file = new File(exportDir, dbFile.getName()); try { file.createNewFile(); @@ -331,9 +337,9 @@ public class RingerDatabase { * @param name * @return */ - private String checkRingerName(String name){ + private String checkRingerName(final String name){ - List names = this.getAllRingerTitles(); + final List names = this.getAllRingerTitles(); String ringerName = name; int count = 1; @@ -344,8 +350,6 @@ public class RingerDatabase { } } return ringerName; - -// return checkRingerName(name, 0); } /** @@ -355,9 +359,9 @@ public class RingerDatabase { * @throws IOException * @author ricky barrette */ - private void copyFile(File src, File dst) throws IOException { - FileChannel inChannel = new FileInputStream(src).getChannel(); - FileChannel outChannel = new FileOutputStream(dst).getChannel(); + private void copyFile(final File src, final File dst) throws IOException { + final FileChannel inChannel = new FileInputStream(src).getChannel(); + final FileChannel outChannel = new FileOutputStream(dst).getChannel(); try { inChannel.transferTo(0, inChannel.size(), outChannel); } finally { @@ -421,8 +425,8 @@ public class RingerDatabase { * @author ricky barrette */ public List getAllRingerTitles() { - List list = new ArrayList(); - Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { KEY_RINGER_NAME }, null, null, null, null, null); + final List list = new ArrayList(); + final Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { KEY_RINGER_NAME }, null, null, null, null, null); if (cursor.moveToFirst()) { do { list.add(cursor.getString(0)); @@ -440,8 +444,8 @@ public class RingerDatabase { * @author ricky barrette */ public List getAllRingerDescriptions() { - List list = new ArrayList(); - List ringers = getAllRingerTitles(); + final List list = new ArrayList(); + final List ringers = getAllRingerTitles(); for(String ringer: ringers){ list.add(getRingerInfo(ringer).getAsString(KEY_RINGER_DESCRIPTION)); } @@ -464,9 +468,9 @@ public class RingerDatabase { * @return * @author ricky barrette */ - public ContentValues getRingerInfo(String ringerName){ - ContentValues values = new ContentValues(); - Cursor info = this.mDb.query(RINGER_INFO_TABLE, new String[]{ KEY, KEY_VALUE }, KEY_RINGER_NAME +" = "+ DatabaseUtils.sqlEscapeString(ringerName), null, null, null, null); + public ContentValues getRingerInfo(final String ringerName){ + final ContentValues values = new ContentValues(); + final Cursor info = this.mDb.query(RINGER_INFO_TABLE, new String[]{ KEY, KEY_VALUE }, KEY_RINGER_NAME +" = "+ DatabaseUtils.sqlEscapeString(ringerName), null, null, null, null); if (info.moveToFirst()) { do { values.put(info.getString(0), info.getString(1)); @@ -484,9 +488,9 @@ public class RingerDatabase { * @return ringer's name * @author ricky barrette */ - public String getRingerName(long id) { + public String getRingerName(final long id) { String name = null; - Cursor cursor = this.mDb.query(RINGER_TABLE, new String[]{ KEY_RINGER_NAME }, "id = "+id, null, null, null, null);; + final Cursor cursor = this.mDb.query(RINGER_TABLE, new String[]{ KEY_RINGER_NAME }, "id = "+id, null, null, null, null);; if (cursor.moveToFirst()) { name = cursor.getString(0); } @@ -502,14 +506,14 @@ public class RingerDatabase { * @param ringerInfo values * @author ricky barrette */ - public void insertRinger(ContentValues ringer, ContentValues ringerInfo){ + public void insertRinger(final ContentValues ringer, final ContentValues ringerInfo){ ringer.put(RingerDatabase.KEY_RINGER_NAME, checkRingerName(ringer.getAsString(RingerDatabase.KEY_RINGER_NAME))); mDb.insert(RINGER_TABLE, null, ringer); - String ringerName = ringer.getAsString(RingerDatabase.KEY_RINGER_NAME); + final String ringerName = ringer.getAsString(RingerDatabase.KEY_RINGER_NAME); //insert the information values - for(Entry item : ringerInfo.valueSet()){ - ContentValues values = new ContentValues(); + for(final Entry item : ringerInfo.valueSet()){ + final ContentValues values = new ContentValues(); values.put(KEY_RINGER_NAME, ringerName); values.put(KEY, item.getKey()); /* @@ -540,8 +544,8 @@ public class RingerDatabase { * @return true if the ringer is enabled * @author ricky barrette */ - public boolean isRingerEnabled(long id) { - Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { KEY_IS_ENABLED }, "id = "+id, null, null, null, null); + public boolean isRingerEnabled(final long id) { + final Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { KEY_IS_ENABLED }, "id = "+id, null, null, null, null); if (cursor.moveToFirst()) { if(Debug.DEBUG) Log.d(TAG, "isRingerEnabled("+id+") = "+ cursor.getString(0)); @@ -556,13 +560,14 @@ public class RingerDatabase { * @author ricky barrette */ public void restore(){ - File dbFile = new File(Environment.getDataDirectory() + "/data/"+mContext.getPackageName()+"/databases/"+DATABASE_NAME); + final File dbFile = new File(Environment.getDataDirectory() + "/data/"+mContext.getPackageName()+"/databases/"+DATABASE_NAME); - File exportDir = new File(Environment.getExternalStorageDirectory(), "/"+this.mContext.getString(R.string.app_name)); + final File exportDir = new File(Environment.getExternalStorageDirectory(), "/"+this.mContext.getString(R.string.app_name)); if (!exportDir.exists()) { exportDir.mkdirs(); } - File file = new File(exportDir, dbFile.getName()); + + final File file = new File(exportDir, dbFile.getName()); try { file.createNewFile(); @@ -580,10 +585,10 @@ public class RingerDatabase { this.mListener.onRestoreComplete(); } - public int setRingerEnabled(long id, boolean enabled) { + public int setRingerEnabled(final long id, final boolean enabled) { if(Debug.DEBUG) Log.d(TAG, "setRingerEnabled("+id+") = "+ enabled); - ContentValues values = new ContentValues(); + final ContentValues values = new ContentValues(); values.put(KEY_IS_ENABLED, enabled); return mDb.update(RINGER_TABLE, values, "id" + "= "+ id, null); } @@ -595,7 +600,7 @@ public class RingerDatabase { * @param info values * @author ricky barrette */ - public void updateRinger(long id, ContentValues ringer, ContentValues info) throws NullPointerException{ + public void updateRinger(final long id, final ContentValues ringer, final ContentValues info) throws NullPointerException{ if(ringer == null || info == null) throw new NullPointerException("ringer content was null"); @@ -616,12 +621,17 @@ public class RingerDatabase { RingerDatabase.this.mDb.delete(RINGER_INFO_TABLE, KEY +" = "+ DatabaseUtils.sqlEscapeString(item.getKey()) +" and "+ KEY_RINGER_NAME +" = "+DatabaseUtils.sqlEscapeString(ringer_name), null); } + /* + * here we want to update the ringer name if needed + */ if(!ringer_name.equals(ringer.getAsString(RingerDatabase.KEY_RINGER_NAME))) ringer.put(RingerDatabase.KEY_RINGER_NAME, checkRingerName(ringer.getAsString(RingerDatabase.KEY_RINGER_NAME))); - //update the information values in the info table - for(Entry item : info.valueSet()){ - ContentValues values = new ContentValues(); + /* + * here we wanr to update the information values in the info table + */ + for(final Entry item : info.valueSet()){ + final ContentValues values = new ContentValues(); values.put(KEY_RINGER_NAME, ringer.getAsString(KEY_RINGER_NAME)); values.put(KEY, item.getKey()); try { @@ -633,7 +643,11 @@ public class RingerDatabase { values.put(KEY_VALUE, (Integer) item.getValue()); } } - //try to update, if update fails insert + + /* + * here we are going to try to update a row, + * if that fails we will insert a row insead + */ if(!(mDb.update(RINGER_INFO_TABLE, values, KEY_RINGER_NAME + "="+ DatabaseUtils.sqlEscapeString(ringer_name) +" AND " + KEY +"='"+ item.getKey()+"'", null) > 0)) mDb.insert(RINGER_INFO_TABLE, null, values); } @@ -650,7 +664,7 @@ public class RingerDatabase { private void updateRowIds(long id) { long currentRow; ContentValues values = new ContentValues(); - Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { "id" },null, null, null, null, null); + final Cursor cursor = this.mDb.query(RINGER_TABLE, new String[] { "id" },null, null, null, null, null); if (cursor.moveToFirst()) { do { currentRow = cursor.getLong(0); diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index f0ed135..73d3df9 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -257,7 +257,7 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC this.mListener.onInfoContentRemoved(RingerDatabase.KEY_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_RINGTONE_VOLUME); break; case KEY_ADDED_NOTIFICATIONTONE: - this.mListener.onInfoContentRemoved(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME); + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerDatabase.KEY_NOTIFICATION_IS_SILENT, RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME); break; case KEY_ADDED_ALARM_VOLUME: this.mListener.onInfoContentRemoved(RingerDatabase.KEY_ALARM_VOLUME);