Cleaned up some of the code, and updated comments
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import android.app.ProgressDialog;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.v4.app.Fragment;
|
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.AboutRingerFragment;
|
||||||
import com.TwentyCodes.android.LocationRinger.ui.fragments.FeatureListFragment;
|
import com.TwentyCodes.android.LocationRinger.ui.fragments.FeatureListFragment;
|
||||||
import com.TwentyCodes.android.LocationRinger.ui.fragments.LocationInfomationFragment;
|
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.TitlePageIndicator;
|
||||||
import com.jakewharton.android.viewpagerindicator.TitledFragmentAdapter;
|
import com.jakewharton.android.viewpagerindicator.TitledFragmentAdapter;
|
||||||
|
|
||||||
@@ -63,12 +59,16 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
|||||||
Log.d(TAG, item.getKey() +" = "+ item.getValue());
|
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
|
@Override
|
||||||
protected void onCreate(Bundle arg0) {
|
protected void onCreate(Bundle arg0) {
|
||||||
super.onCreate(arg0);
|
super.onCreate(arg0);
|
||||||
setContentView(R.layout.ringer_information_activity);
|
setContentView(R.layout.ringer_information_activity);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up the action bar if required
|
* Set up the action bar if required
|
||||||
*/
|
*/
|
||||||
@@ -112,47 +112,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
|||||||
if(!isDefault)
|
if(!isDefault)
|
||||||
fragments.add(new LocationInfomationFragment(this.mInfo, this, this));
|
fragments.add(new LocationInfomationFragment(this.mInfo, this, this));
|
||||||
|
|
||||||
/*
|
fragments.add(new FeatureListFragment(this.mInfo, this));
|
||||||
* What page
|
|
||||||
* ONLY Dynamically add the required fragments that have already been added.
|
|
||||||
*
|
|
||||||
* TODO
|
|
||||||
* update interval
|
|
||||||
*/
|
|
||||||
ArrayList<Integer> added = new ArrayList<Integer>();
|
|
||||||
ArrayList<Fragment> what = new ArrayList<Fragment>();
|
|
||||||
//
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
//Populate the pager
|
//Populate the pager
|
||||||
this.mPager = (ViewPager)findViewById(R.id.pager);
|
this.mPager = (ViewPager)findViewById(R.id.pager);
|
||||||
@@ -165,11 +125,6 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
|||||||
indicator.setViewPager(this.mPager);
|
indicator.setViewPager(this.mPager);
|
||||||
|
|
||||||
indicator.setOnPageChangeListener(this);
|
indicator.setOnPageChangeListener(this);
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO
|
|
||||||
* button bar
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,8 +184,6 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int arg0) {
|
public void onPageSelected(int arg0) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -261,7 +214,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
|||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setScrollEnabled(boolean enabled) {
|
public void setScrollEnabled(boolean enabled) {
|
||||||
this.mPager.setScrollEnabled(enabled);
|
this.mPager.setScrollEnabled(enabled);
|
||||||
|
|||||||
@@ -29,9 +29,6 @@ import com.TwentyCodes.android.LocationRinger.db.RingerDatabase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This fragment will be used to display a list of features
|
* 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
|
* @author ricky
|
||||||
*/
|
*/
|
||||||
public class FeatureListFragment extends BaseFragmentListFragment implements OnClickListener, android.content.DialogInterface.OnClickListener, FeatureRemovedListener {
|
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_MUSIC_VOLUME = 3;
|
||||||
private static final int KEY_ADDED_BT = 4;
|
private static final int KEY_ADDED_BT = 4;
|
||||||
private static final int KEY_ADDED_WIFI = 5;
|
private static final int KEY_ADDED_WIFI = 5;
|
||||||
private static final String TAG = "FeatureListFragment";
|
|
||||||
private final ContentValues mInfo;
|
private final ContentValues mInfo;
|
||||||
private final OnContentChangedListener mListener;
|
private final OnContentChangedListener mListener;
|
||||||
private final ArrayList<Integer> mAdded;
|
private final ArrayList<Integer> mAdded;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new FeatureListFragment
|
* Creates a new populated FeatureListFragment
|
||||||
* @param info
|
* @param info
|
||||||
* @param listener
|
* @param listener
|
||||||
* @param fragments
|
* @param fragments
|
||||||
@@ -56,11 +52,37 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
*/
|
*/
|
||||||
public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList<Fragment> fragments, ArrayList<Integer> added) {
|
public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList<Fragment> fragments, ArrayList<Integer> added) {
|
||||||
super(R.layout.fragment_list_contianer, R.id.fragment_list_contianer);
|
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;
|
mInfo = info;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mAdded = added;
|
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<Fragment>(), new ArrayList<Integer>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a feature fragment
|
||||||
|
* @param fragmentCode
|
||||||
|
* @return
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
public Fragment initFeatureFragment(int fragmentCode){
|
public Fragment initFeatureFragment(int fragmentCode){
|
||||||
Fragment f = null;
|
Fragment f = null;
|
||||||
switch(fragmentCode){
|
switch(fragmentCode){
|
||||||
@@ -94,7 +116,7 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initali
|
* Initializes feature fragments based upon current records
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private ArrayList<Fragment> initList() {
|
private ArrayList<Fragment> initList() {
|
||||||
@@ -192,17 +214,18 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Called when the activity is first created
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see android.support.v4.app.Fragment#onCreate(android.os.Bundle)
|
* @see android.support.v4.app.Fragment#onCreate(android.os.Bundle)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle arg0) {
|
public void onCreate(Bundle arg0) {
|
||||||
addAllInit(initList());
|
addAllInit(initList());
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onCreate(arg0);
|
super.onCreate(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Called when the view needs to be created
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.TwentyCodes.android.LocationRinger.ui.fragments.BaseFragmentListFragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
|
* @see com.TwentyCodes.android.LocationRinger.ui.fragments.BaseFragmentListFragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import android.media.Ringtone;
|
|||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
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){
|
public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
||||||
super(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.mChangedListener = changedListener;
|
||||||
this.mStream = stream;
|
this.mStream = stream;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
|
|||||||
@@ -6,14 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.TwentyCodes.android.LocationRinger.ui.fragments;
|
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.content.ContentValues;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -24,6 +18,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.ToggleButton;
|
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
|
* A simple fragment that displays a toggle button and a title label
|
||||||
* @author ricky
|
* @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) {
|
public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int id) {
|
||||||
super(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.mTitle = title;
|
||||||
this.mKey = key;
|
this.mKey = key;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
@@ -51,6 +62,11 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL
|
|||||||
this.mRemovedListener = removedListener;
|
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
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) {
|
||||||
final View view = inflater.inflate(R.layout.toggle_button_fragment, container, false);
|
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the toggle button is clicked
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see android.widget.CompoundButton.OnCheckedChangeListener#onCheckedChanged(android.widget.CompoundButton, boolean)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if(this.mChangedListener != null){
|
if(this.mChangedListener != null){
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import android.content.ContentValues;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
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){
|
public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
||||||
super(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.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
this.mStream = stream;
|
this.mStream = stream;
|
||||||
this.mChangedListener = changedListener;
|
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
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
@@ -149,12 +163,10 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user