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 } /**