I finished fixing the add feature list filtering
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
@@ -36,6 +36,12 @@ import com.TwentyCodes.android.LocationRinger.db.RingerDatabase;
|
|||||||
*/
|
*/
|
||||||
public class FeatureListFragment extends BaseFragmentListFragment implements OnClickListener, android.content.DialogInterface.OnClickListener, FeatureRemovedListener {
|
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 static final String TAG = "FeatureListFragment";
|
||||||
private final ContentValues mInfo;
|
private final ContentValues mInfo;
|
||||||
private final OnContentChangedListener mListener;
|
private final OnContentChangedListener mListener;
|
||||||
@@ -64,33 +70,27 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
ArrayList<Fragment> what = new ArrayList<Fragment>();
|
ArrayList<Fragment> what = new ArrayList<Fragment>();
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){
|
if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME)){
|
||||||
what.add(new RingtoneFragment(this.mInfo, this.mListener, this, AudioManager.STREAM_RING));
|
initFeatureFragment(KEY_ADDED_RINGTONE);
|
||||||
mAdded.add(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME)){
|
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));
|
initFeatureFragment(KEY_ADDED_NOTIFICATIONTONE);
|
||||||
mAdded.add(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){
|
if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME)){
|
||||||
what.add(new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_ALARM));
|
initFeatureFragment(KEY_ADDED_ALARM_VOLUME);
|
||||||
mAdded.add(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){
|
if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME)){
|
||||||
what.add(new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, this, AudioManager.STREAM_MUSIC));
|
initFeatureFragment(KEY_ADDED_MUSIC_VOLUME);
|
||||||
mAdded.add(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_BT)){
|
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));
|
initFeatureFragment(KEY_ADDED_BT);
|
||||||
mAdded.add(4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI)){
|
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));
|
initFeatureFragment(KEY_ADDED_WIFI);
|
||||||
mAdded.add(5);
|
|
||||||
}
|
}
|
||||||
return what;
|
return what;
|
||||||
}
|
}
|
||||||
@@ -102,41 +102,43 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Fragment f = null;
|
final Fragment f = initFeatureFragment(which);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(f != null)
|
if(f != null)
|
||||||
add(f);
|
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
|
* Called when the add feature button is clicked
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -209,6 +211,8 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
@Override
|
@Override
|
||||||
public void onFeatureRemoved(Fragment f) {
|
public void onFeatureRemoved(Fragment f) {
|
||||||
this.remove(f);
|
this.remove(f);
|
||||||
//TODO remove database entries
|
|
||||||
|
if(f instanceof IdFragment)
|
||||||
|
mAdded.remove(new Integer(((IdFragment) f).getFragmentId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
|||||||
* This fragment will be for ringtone settings
|
* This fragment will be for ringtone settings
|
||||||
* @author ricky
|
* @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 static final String TAG = "RingtoneFragment";
|
||||||
private final int mStream;
|
private final int mStream;
|
||||||
@@ -56,8 +56,8 @@ public class RingtoneFragment extends Fragment implements OnClickListener, OnSee
|
|||||||
private SeekBar mVolume;
|
private SeekBar mVolume;
|
||||||
private ImageView mIcon;
|
private ImageView mIcon;
|
||||||
|
|
||||||
public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream){
|
public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
||||||
super();
|
super(id);
|
||||||
this.mChangedListener = changedListener;
|
this.mChangedListener = changedListener;
|
||||||
this.mStream = stream;
|
this.mStream = stream;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import android.widget.ToggleButton;
|
|||||||
* A simple fragment that displays a toggle button and a title label
|
* A simple fragment that displays a toggle button and a title label
|
||||||
* @author ricky
|
* @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 mTitle;
|
||||||
private final String mKey;
|
private final String mKey;
|
||||||
@@ -41,8 +41,8 @@ public class ToggleButtonFragment extends Fragment implements OnCheckedChangeLis
|
|||||||
* Creates a new ToggleButtonFtagment
|
* Creates a new ToggleButtonFtagment
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener) {
|
public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int id) {
|
||||||
super();
|
super(id);
|
||||||
this.mTitle = title;
|
this.mTitle = title;
|
||||||
this.mKey = key;
|
this.mKey = key;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
|||||||
* This fragment will represent the volume fragments
|
* This fragment will represent the volume fragments
|
||||||
* @author ricky
|
* @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 static final String TAG = "VolumeFragment";
|
||||||
private final AudioManager mAudioManager;
|
private final AudioManager mAudioManager;
|
||||||
@@ -53,8 +53,8 @@ public class VolumeFragment extends Fragment implements OnSeekBarChangeListener,
|
|||||||
* @param stream
|
* @param stream
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream){
|
public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
||||||
super();
|
super(id);
|
||||||
this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
this.mStream = stream;
|
this.mStream = stream;
|
||||||
this.mChangedListener = changedListener;
|
this.mChangedListener = changedListener;
|
||||||
|
|||||||
Reference in New Issue
Block a user