* #31728: dynamic codec status
diff --git a/res/layout/frag_account_creation.xml b/res/layout/frag_account_creation.xml
index 7bb9f98..acb0623 100644
--- a/res/layout/frag_account_creation.xml
+++ b/res/layout/frag_account_creation.xml
@@ -45,9 +45,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
- android:imeActionId="@+id/login"
+ android:imeActionId="@+id/register"
android:imeActionLabel="@string/action_create_short"
- android:imeOptions="actionUnspecified"
+ android:imeOptions="actionGo"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
diff --git a/res/layout/frag_contact_list.xml b/res/layout/frag_contact_list.xml
index 9cd89c9..f14bf10 100644
--- a/res/layout/frag_contact_list.xml
+++ b/res/layout/frag_contact_list.xml
@@ -50,7 +50,7 @@
android:focusableInTouchMode="true" />
<TextView
- android:id="@+id/empty_list_contact"
+ android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
diff --git a/res/layout/item_codec.xml b/res/layout/item_codec.xml
index 7b9679e..078b9ae 100644
--- a/res/layout/item_codec.xml
+++ b/res/layout/item_codec.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/codec_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" >
@@ -22,23 +23,23 @@
android:layout_below="@+id/codec_name"
android:layout_marginLeft="4dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <TextView
+
+ <TextView
android:id="@+id/codec_bitrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_toRightOf="@+id/codec_samplerate"
android:layout_below="@+id/codec_name"
android:layout_marginLeft="4dp"
+ android:layout_toRightOf="@+id/codec_samplerate"
android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <TextView
+
+ <TextView
android:id="@+id/codec_channels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_toRightOf="@+id/codec_bitrate"
android:layout_below="@+id/codec_name"
android:layout_marginLeft="4dp"
+ android:layout_toRightOf="@+id/codec_bitrate"
android:textAppearance="?android:attr/textAppearanceSmall" />
<CheckBox
diff --git a/src/org/sflphone/fragments/AudioManagementFragment.java b/src/org/sflphone/fragments/AudioManagementFragment.java
index b58ec29..2b24775 100644
--- a/src/org/sflphone/fragments/AudioManagementFragment.java
+++ b/src/org/sflphone/fragments/AudioManagementFragment.java
@@ -40,21 +40,17 @@
import org.sflphone.views.AudioCodecListPreference;
import android.app.Activity;
-import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.res.TypedArray;
-import android.database.DataSetObserver;
import android.os.Bundle;
import android.os.RemoteException;
-import android.preference.ListPreference;
import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
-import android.widget.ListAdapter;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
@@ -112,8 +108,20 @@
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.audio_prefs);
-
- ((AudioCodecListPreference)getPreferenceManager().findPreference("Audio.codec")).setList(codecs);
+ final AudioCodecListPreference codecPref = ((AudioCodecListPreference)getPreferenceManager().findPreference("Audio.codec"));
+ codecPref.setList(codecs);
+ codecPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ try {
+ mCallbacks.getService().setActiveCodecList(codecPref.getActiveCodecList(), mCallbacks.getAccountID());
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+ });
}
diff --git a/src/org/sflphone/fragments/ContactListFragment.java b/src/org/sflphone/fragments/ContactListFragment.java
index b010460..939b325 100644
--- a/src/org/sflphone/fragments/ContactListFragment.java
+++ b/src/org/sflphone/fragments/ContactListFragment.java
@@ -191,7 +191,7 @@
}, true, false));
list.setOnItemLongClickListener(mItemLongClickListener);
- list.setEmptyView(inflatedView.findViewById(R.id.empty_list_contact));
+ list.setEmptyView(inflatedView.findViewById(android.R.id.empty));
View header = inflater.inflate(R.layout.frag_contact_list_header, null);
list.addHeaderView(header, null, false);
TACGridView grid = (TACGridView) header.findViewById(R.id.favorites_grid);
diff --git a/src/org/sflphone/model/Codec.java b/src/org/sflphone/model/Codec.java
index a2b38ab..972b91d 100644
--- a/src/org/sflphone/model/Codec.java
+++ b/src/org/sflphone/model/Codec.java
@@ -1,7 +1,5 @@
package org.sflphone.model;
-import java.util.ArrayList;
-
import org.sflphone.service.StringVect;
import android.os.Parcel;
@@ -13,13 +11,15 @@
String sampleRate;
String bitRate;
String channels;
+ boolean enabled;
- public Codec(int i, StringVect audioCodecDetails) {
+ public Codec(int i, StringVect audioCodecDetails, boolean b) {
payload = i;
name = audioCodecDetails.get(0);
sampleRate = audioCodecDetails.get(1);
bitRate = audioCodecDetails.get(2);
channels = audioCodecDetails.get(3);
+ enabled = b;
}
@Override
@@ -34,6 +34,7 @@
out.writeString(sampleRate);
out.writeString(bitRate);
out.writeString(channels);
+ out.writeByte((byte) (enabled ? 1 : 0));
}
public static final Parcelable.Creator<Codec> CREATOR = new Parcelable.Creator<Codec>() {
@@ -52,6 +53,7 @@
sampleRate = in.readString();
bitRate = in.readString();
channels = in.readString();
+ enabled = in.readByte() == 1 ? true : false;
}
@Override
@@ -81,4 +83,12 @@
return channels;
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean b) {
+ enabled = b;
+ }
+
}
diff --git a/src/org/sflphone/views/AudioCodecListPreference.java b/src/org/sflphone/views/AudioCodecListPreference.java
index 8f28058..6d974ab 100644
--- a/src/org/sflphone/views/AudioCodecListPreference.java
+++ b/src/org/sflphone/views/AudioCodecListPreference.java
@@ -9,11 +9,14 @@
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
+import android.widget.RelativeLayout;
import android.widget.TextView;
public class AudioCodecListPreference extends DialogPreference {
@@ -39,7 +42,7 @@
private Context mContext;
public CodecAdapter(Context context) {
-
+
mContext = context;
}
@@ -78,6 +81,8 @@
entryView.samplerate = (TextView) rowView.findViewById(R.id.codec_samplerate);
entryView.channels = (TextView) rowView.findViewById(R.id.codec_channels);
entryView.enabled = (CheckBox) rowView.findViewById(R.id.codec_checked);
+ entryView.layout = (RelativeLayout) rowView.findViewById(R.id.codec_background);
+ entryView.layout.setOnClickListener(new mClickListener(items.get(pos), entryView.enabled));
rowView.setTag(entryView);
} else {
entryView = (CodecView) rowView.getTag();
@@ -87,23 +92,7 @@
entryView.samplerate.setText(items.get(pos).getSampleRate());
entryView.bitrate.setText(items.get(pos).getBitRate());
entryView.channels.setText(items.get(pos).getChannels());
-
-// entryView.enabled.setChecked(items.get(pos).isEnabled());
-
-// entryView.enabled.setOnCheckedChangeListener(new OnCheckedChangeListener() {
-//
-// @Override
-// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-// items.get(pos).setEnabled(isChecked);
-//
-// try {
-// mCallbacks.getService().setAccountDetails(accounts.get(pos).getAccountID(), accounts.get(pos).getDetails());
-// } catch (RemoteException e) {
-// e.printStackTrace();
-// }
-// }
-// });
-
+ entryView.enabled.setChecked(items.get(pos).isEnabled());;
return rowView;
}
@@ -136,11 +125,12 @@
public void setDataset(ArrayList<Codec> codecs) {
items = new ArrayList<Codec>(codecs);
}
-
+
/*********************
* ViewHolder Pattern
*********************/
public class CodecView {
+ public RelativeLayout layout;
public TextView name;
public TextView samplerate;
public TextView bitrate;
@@ -148,6 +138,22 @@
public CheckBox enabled;
}
+ public class mClickListener implements OnClickListener {
+ CheckBox checked;
+ Codec item;
+
+ public mClickListener(Codec codec, CheckBox enabled) {
+ checked = enabled;
+ item = codec;
+ }
+
+ @Override
+ public void onClick(View v) {
+ item.setEnabled(checked.isChecked());
+ }
+
+ }
+
}
public void setList(ArrayList<Codec> codecs) {
@@ -155,4 +161,15 @@
listAdapter.notifyDataSetChanged();
}
+ public ArrayList<String> getActiveCodecList() {
+ ArrayList<String> results = new ArrayList<String>();
+ for(int i = 0 ; i < listAdapter.getCount(); ++i){
+ if(listAdapter.getItem(i).isEnabled()){
+ results.add(listAdapter.getItem(i).getPayload().toString());
+ Log.i("Prefs", listAdapter.getItem(i).getName()+" is enabled");
+ }
+ }
+ return results;
+ }
+
}