I have got basic funtionaltiy for adding fragments.
The next step is to remove items from the list, if they already exist in the UI Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="features">
|
||||
<item>@string/ringtone</item>
|
||||
<item>@string/notification_ringtone</item>
|
||||
@@ -7,7 +8,6 @@
|
||||
<item>@string/music_volume</item>
|
||||
<item>@string/bluetooth</item>
|
||||
<item>@string/wifi</item>
|
||||
<item>@string/update_interval</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
||||
</resources>
|
||||
@@ -121,17 +121,17 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
*/
|
||||
ArrayList<Fragment> what = new ArrayList<Fragment>();
|
||||
|
||||
// if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE_VOLUME))
|
||||
if(this.mInfo.containsKey(RingerDatabase.KEY_RINGTONE) || 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));
|
||||
// if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_IS_SILENT) || this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME))
|
||||
if(this.mInfo.containsKey(RingerDatabase.KEY_NOTIFICATION_RINGTONE) || 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));
|
||||
// if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME))
|
||||
if(this.mInfo.containsKey(RingerDatabase.KEY_ALARM_VOLUME))
|
||||
what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_ALARM));
|
||||
// if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME))
|
||||
if(this.mInfo.containsKey(RingerDatabase.KEY_MUSIC_VOLUME))
|
||||
what.add(new VolumeFragment(this.mInfo, this, this, AudioManager.STREAM_MUSIC));
|
||||
// if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI))
|
||||
if(this.mInfo.containsKey(RingerDatabase.KEY_WIFI))
|
||||
what.add(new ToggleButtonFragment(this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this));
|
||||
// if(this.mInfo.containsKey(RingerDatabase.KEY_BT))
|
||||
if(this.mInfo.containsKey(RingerDatabase.KEY_BT))
|
||||
what.add(new ToggleButtonFragment(this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this));
|
||||
|
||||
fragments.add(new FeatureListFragment(this.mInfo, this, what));
|
||||
|
||||
@@ -9,18 +9,23 @@ package com.TwentyCodes.android.LocationRinger.ui.fragments;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ContentValues;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -30,10 +35,12 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
*
|
||||
* @author ricky
|
||||
*/
|
||||
public class FeatureListFragment extends Fragment {
|
||||
public class FeatureListFragment extends Fragment implements OnClickListener, android.content.DialogInterface.OnClickListener {
|
||||
|
||||
private static final String TAG = "FeatureListFragment";
|
||||
private final ArrayList<Fragment> mFragments;
|
||||
private final ContentValues mInfo;
|
||||
private final OnContentChangedListener mListener;
|
||||
|
||||
/**
|
||||
* Creates a new FeatureListFragment
|
||||
@@ -45,6 +52,8 @@ public class FeatureListFragment extends Fragment {
|
||||
public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList<Fragment> fragments) {
|
||||
super();
|
||||
mFragments = fragments;
|
||||
mInfo = info;
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +97,9 @@ public class FeatureListFragment extends Fragment {
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle bundle) {
|
||||
return inflator.inflate(R.layout.fragment_list_contianer, null);
|
||||
final View v = inflator.inflate(R.layout.fragment_list_contianer, null);
|
||||
v.findViewById(R.id.add_feature_button).setOnClickListener(this);
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,4 +154,54 @@ public class FeatureListFragment extends Fragment {
|
||||
}
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the add feature button is clicked
|
||||
* (non-Javadoc)
|
||||
* @see android.view.View.OnClickListener#onClick(android.view.View)
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new AlertDialog.Builder(this.getActivity())
|
||||
.setTitle(R.string.add_a_feature)
|
||||
.setItems(R.array.features, this)
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is picked from the add featue list
|
||||
* (non-Javadoc)
|
||||
* @see android.content.DialogInterface.OnClickListener#onClick(android.content.DialogInterface, int)
|
||||
*/
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Fragment f = null;
|
||||
switch(which){
|
||||
case 0:
|
||||
f= new RingtoneFragment(this.mInfo, this.mListener, AudioManager.STREAM_RING);
|
||||
break;
|
||||
case 1:
|
||||
f = new RingtoneFragment(this.mInfo, this.mListener, AudioManager.STREAM_NOTIFICATION);
|
||||
break;
|
||||
case 2:
|
||||
f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, AudioManager.STREAM_ALARM);
|
||||
break;
|
||||
case 3:
|
||||
f = new VolumeFragment(this.mInfo, this.getActivity(), this.mListener, AudioManager.STREAM_MUSIC);
|
||||
break;
|
||||
case 4:
|
||||
f = new ToggleButtonFragment(this.getString(R.string.bluetooth), RingerDatabase.KEY_BT, this.mInfo, this.mListener);
|
||||
break;
|
||||
case 5:
|
||||
f = new ToggleButtonFragment(this.getString(R.string.wifi), RingerDatabase.KEY_WIFI, this.mInfo, this.mListener);
|
||||
break;
|
||||
// case 6:
|
||||
// f =
|
||||
// break;
|
||||
}
|
||||
|
||||
if(f != null)
|
||||
add(f);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user