Skip to content
Snippets Groups Projects
Commit 68ee0ace authored by Alexandre Lision's avatar Alexandre Lision
Browse files

* #36392: ringtone activable in settings

This commit also activates the DTMF route type (SIP or RTP)
parent b342649a
No related branches found
No related tags found
No related merge requests found
File added
This diff is collapsed.
File added
File added
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/lv_holder_prefs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="1" > android:weightSum="1" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
</ListView>
</LinearLayout>
<TextView <TextView
android:id="@+id/list_header_title" android:id="@+id/list_header_title"
style="?android:attr/listSeparatorTextViewStyle" style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingLeft="5dp"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:paddingBottom="2dip"
android:paddingLeft="5dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:text="Codecs" /> android:text="Codecs" />
...@@ -44,11 +64,6 @@ ...@@ -44,11 +64,6 @@
dslv:remove_enabled="false" dslv:remove_enabled="false"
dslv:slide_shuffle_speed="0.3" /> dslv:slide_shuffle_speed="0.3" />
</LinearLayout> </LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout> </LinearLayout>
</ScrollView>
\ No newline at end of file
...@@ -69,4 +69,19 @@ as that of the covered work. ...@@ -69,4 +69,19 @@ as that of the covered work.
<item>SDES</item> <item>SDES</item>
</string-array> </string-array>
<string-array name="dtmf_types_values">
<item>overrtp</item>
<item>sipinfo</item>
</string-array>
<string-array name="dtmf_types_entries">
<item>RTP</item>
<item>SIP</item>
</string-array>
</resources> </resources>
\ No newline at end of file
...@@ -33,24 +33,29 @@ as that of the covered work. ...@@ -33,24 +33,29 @@ as that of the covered work.
<PreferenceCategory <PreferenceCategory
android:id="@+id/audio_dtmf_category" android:id="@+id/audio_dtmf_category"
android:title="Ringtones" > android:title="DTMF" >
<EditTextPreference <ListPreference
android:id="@+id/account_dtmf_type" android:id="@+id/account_dtmf_type"
android:defaultValue="SIP" android:entries="@array/dtmf_types_entries"
android:entryValues="@array/dtmf_types_values"
android:key="Account.dtmfType" android:key="Account.dtmfType"
android:persistent="false" android:persistent="false"
android:summary="SIP"
android:title="DTMF Type" /> android:title="DTMF Type" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:id="@+id/audio_ringtone_category" android:id="@+id/audio_ringtone_category"
android:title="Ringtones" > android:title="Ringtones" >
<CheckBoxPreference
android:id="@+id/audio_ringtone"
android:key="Account.ringtoneEnabled"
android:persistent="false"
android:title="Activate ringtones " />
<EditTextPreference <EditTextPreference
android:id="@+id/audio_ringtone" android:id="@+id/audio_ringtone"
android:defaultValue="" android:key="Account.ringtonePath"
android:key="Audio.ringtone" android:enabled="false"
android:persistent="false" android:persistent="false"
android:summary=""
android:title="Ringtone" /> android:title="Ringtone" />
</PreferenceCategory> </PreferenceCategory>
......
...@@ -313,11 +313,6 @@ public class AccountEditionActivity extends Activity implements GeneralAccountFr ...@@ -313,11 +313,6 @@ public class AccountEditionActivity extends Activity implements GeneralAccountFr
return service; return service;
} }
@Override
public String getAccountID() {
return acc_selected.getAccountID();
}
@Override @Override
public Account getAccount() { public Account getAccount() {
return acc_selected; return acc_selected;
......
...@@ -23,8 +23,6 @@ public class AdvancedAccountFragment extends PreferenceFragment { ...@@ -23,8 +23,6 @@ public class AdvancedAccountFragment extends PreferenceFragment {
private static final String TAG = AdvancedAccountFragment.class.getSimpleName(); private static final String TAG = AdvancedAccountFragment.class.getSimpleName();
private boolean isDifferent = false;
private Callbacks mCallbacks = sDummyCallbacks; private Callbacks mCallbacks = sDummyCallbacks;
private static Callbacks sDummyCallbacks = new Callbacks() { private static Callbacks sDummyCallbacks = new Callbacks() {
...@@ -141,13 +139,13 @@ public class AdvancedAccountFragment extends PreferenceFragment { ...@@ -141,13 +139,13 @@ public class AdvancedAccountFragment extends PreferenceFragment {
findPreference("Account.publishedPort").setEnabled(!(Boolean) newValue); findPreference("Account.publishedPort").setEnabled(!(Boolean) newValue);
findPreference("Account.publishedAddress").setEnabled(!(Boolean) newValue); findPreference("Account.publishedAddress").setEnabled(!(Boolean) newValue);
} }
mCallbacks.getAccount().notifyObservers();
} else { } else {
preference.setSummary((CharSequence) newValue); preference.setSummary((CharSequence) newValue);
Log.i(TAG, "Changing" + preference.getKey() + " value:" + newValue); Log.i(TAG, "Changing" + preference.getKey() + " value:" + newValue);
mCallbacks.getAccount().getAdvancedDetails().setDetailString(preference.getKey(), ((CharSequence) newValue).toString()); mCallbacks.getAccount().getAdvancedDetails().setDetailString(preference.getKey(), ((CharSequence) newValue).toString());
mCallbacks.getAccount().notifyObservers();
} }
mCallbacks.getAccount().notifyObservers();
return true; return true;
} }
}; };
......
...@@ -35,6 +35,8 @@ package org.sflphone.fragments; ...@@ -35,6 +35,8 @@ package org.sflphone.fragments;
import java.util.ArrayList; import java.util.ArrayList;
import org.sflphone.R; import org.sflphone.R;
import org.sflphone.account.AccountDetail;
import org.sflphone.model.Account;
import org.sflphone.model.Codec; import org.sflphone.model.Codec;
import org.sflphone.service.ISipService; import org.sflphone.service.ISipService;
import org.sflphone.views.dragsortlv.DragSortListView; import org.sflphone.views.dragsortlv.DragSortListView;
...@@ -43,12 +45,15 @@ import android.app.Activity; ...@@ -43,12 +45,15 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
...@@ -73,7 +78,7 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -73,7 +78,7 @@ public class AudioManagementFragment extends PreferenceFragment {
} }
@Override @Override
public String getAccountID() { public Account getAccount() {
return null; return null;
} }
...@@ -83,7 +88,7 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -83,7 +88,7 @@ public class AudioManagementFragment extends PreferenceFragment {
public ISipService getService(); public ISipService getService();
public String getAccountID(); public Account getAccount();
} }
...@@ -96,7 +101,7 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -96,7 +101,7 @@ public class AudioManagementFragment extends PreferenceFragment {
mCallbacks = (Callbacks) activity; mCallbacks = (Callbacks) activity;
try { try {
codecs = (ArrayList<Codec>) mCallbacks.getService().getAudioCodecList(mCallbacks.getAccountID()); codecs = (ArrayList<Codec>) mCallbacks.getService().getAudioCodecList(mCallbacks.getAccount().getAccountID());
mCallbacks.getService().getRingtoneList(); mCallbacks.getService().getRingtoneList();
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -117,7 +122,7 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -117,7 +122,7 @@ public class AudioManagementFragment extends PreferenceFragment {
listAdapter.remove(item); listAdapter.remove(item);
listAdapter.insert(item, to); listAdapter.insert(item, to);
try { try {
mCallbacks.getService().setActiveCodecList(getActiveCodecList(), mCallbacks.getAccountID()); mCallbacks.getService().setActiveCodecList(getActiveCodecList(), mCallbacks.getAccount().getAccountID());
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -125,6 +130,8 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -125,6 +130,8 @@ public class AudioManagementFragment extends PreferenceFragment {
} }
}; };
private ListView mPrefsList;
public ArrayList<String> getActiveCodecList() { public ArrayList<String> getActiveCodecList() {
ArrayList<String> results = new ArrayList<String>(); ArrayList<String> results = new ArrayList<String>();
for (int i = 0; i < listAdapter.getCount(); ++i) { for (int i = 0; i < listAdapter.getCount(); ++i) {
...@@ -139,6 +146,8 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -139,6 +146,8 @@ public class AudioManagementFragment extends PreferenceFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState); super.onCreateView(inflater, container, savedInstanceState);
View rootView = LayoutInflater.from(getActivity()).inflate(R.layout.frag_audio_mgmt, null); View rootView = LayoutInflater.from(getActivity()).inflate(R.layout.frag_audio_mgmt, null);
mPrefsList = (ListView) rootView.findViewById(android.R.id.list);
mCodecList = (DragSortListView) rootView.findViewById(R.id.dndlistview); mCodecList = (DragSortListView) rootView.findViewById(R.id.dndlistview);
mCodecList.setAdapter(listAdapter); mCodecList.setAdapter(listAdapter);
mCodecList.setDropListener(onDrop); mCodecList.setDropListener(onDrop);
...@@ -149,7 +158,7 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -149,7 +158,7 @@ public class AudioManagementFragment extends PreferenceFragment {
listAdapter.getItem(pos).toggleState(); listAdapter.getItem(pos).toggleState();
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
try { try {
mCallbacks.getService().setActiveCodecList(getActiveCodecList(), mCallbacks.getAccountID()); mCallbacks.getService().setActiveCodecList(getActiveCodecList(), mCallbacks.getAccount().getAccountID());
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -163,11 +172,13 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -163,11 +172,13 @@ public class AudioManagementFragment extends PreferenceFragment {
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
final LinearLayout holder = (LinearLayout) getView().findViewById(R.id.lv_holder); final LinearLayout holder = (LinearLayout) getView().findViewById(R.id.lv_holder);
final LinearLayout holder_prefs = (LinearLayout) getView().findViewById(R.id.lv_holder_prefs);
holder.post(new Runnable() { holder.post(new Runnable() {
@Override @Override
public void run() { public void run() {
setListViewHeight(mCodecList, holder); setListViewHeight(mCodecList, holder);
setListViewHeight(mPrefsList, holder_prefs);
} }
}); });
...@@ -185,20 +196,18 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -185,20 +196,18 @@ public class AudioManagementFragment extends PreferenceFragment {
int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST);
for (int i = 0; i < listAdapter.getCount(); i++) { for (int i = 0; i < listAdapter.getCount(); i++) {
if (i == 0) {
View listItem = listAdapter.getView(i, null, listView); View listItem = listAdapter.getView(i, null, listView);
listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED); listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
firstHeight = listItem.getMeasuredHeight(); firstHeight = listItem.getMeasuredHeight();
}
totalHeight += firstHeight; totalHeight += firstHeight;
} }
// totalHeight -= iv.getMeasuredHeight(); totalHeight += getView().findViewById(R.id.list_header_title).getMeasuredHeight();
Log.w(TAG, "totalHeight:" + totalHeight);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llMain.getLayoutParams(); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llMain.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount()));
llMain.setLayoutParams(params); llMain.setLayoutParams(params);
getView().requestLayout(); getView().requestLayout();
} }
...@@ -210,15 +219,81 @@ public class AudioManagementFragment extends PreferenceFragment { ...@@ -210,15 +219,81 @@ public class AudioManagementFragment extends PreferenceFragment {
addPreferencesFromResource(R.xml.account_audio_prefs); addPreferencesFromResource(R.xml.account_audio_prefs);
listAdapter = new CodecAdapter(getActivity()); listAdapter = new CodecAdapter(getActivity());
listAdapter.setDataset(codecs); listAdapter.setDataset(codecs);
setPreferenceDetails(mCallbacks.getAccount().getAdvancedDetails());
addPreferenceListener(mCallbacks.getAccount().getAdvancedDetails(), changeAudioPreferenceListener);
}
Preference.OnPreferenceChangeListener changeAudioPreferenceListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference instanceof CheckBoxPreference) {
mCallbacks.getAccount().getAdvancedDetails().setDetailString(preference.getKey(), ((Boolean) newValue).toString());
} else {
preference.setSummary((CharSequence) newValue);
Log.i(TAG, "Changing" + preference.getKey() + " value:" + newValue);
mCallbacks.getAccount().getAdvancedDetails().setDetailString(preference.getKey(), ((CharSequence) newValue).toString());
}
mCallbacks.getAccount().notifyObservers();
return true;
} }
};
Preference.OnPreferenceChangeListener changePreferenceListener = new Preference.OnPreferenceChangeListener() { Preference.OnPreferenceChangeListener changePreferenceListener = new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference instanceof CheckBoxPreference) {
mCallbacks.getAccount().getAdvancedDetails().setDetailString(preference.getKey(), ((Boolean) newValue).toString());
} else {
preference.setSummary((CharSequence) newValue); preference.setSummary((CharSequence) newValue);
Log.i(TAG, "Changing" + preference.getKey() + " value:" + newValue);
mCallbacks.getAccount().getAdvancedDetails().setDetailString(preference.getKey(), ((CharSequence) newValue).toString());
}
mCallbacks.getAccount().notifyObservers();
return true; return true;
} }
}; };
private void setPreferenceDetails(AccountDetail details) {
for (AccountDetail.PreferenceEntry p : details.getDetailValues()) {
Log.i(TAG, "setPreferenceDetails: pref " + p.mKey + " value " + p.mValue);
Preference pref = findPreference(p.mKey);
if (pref != null) {
if (!p.isTwoState) {
if (p.mKey.contentEquals("Account.dtmfType")){
pref.setDefaultValue(p.mValue.contentEquals("overrtp") ? "RTP" : "SIP");
pref.setSummary(p.mValue);
} else {
pref.setSummary(p.mValue);
}
} else {
((CheckBoxPreference) pref).setChecked(p.mValue.contentEquals("true"));
}
} else {
Log.w(TAG, "pref not found");
}
}
}
private void addPreferenceListener(AccountDetail details, OnPreferenceChangeListener listener) {
for (AccountDetail.PreferenceEntry p : details.getDetailValues()) {
Log.i(TAG, "addPreferenceListener: pref " + p.mKey + p.mValue);
Preference pref = findPreference(p.mKey);
if (pref != null) {
pref.setOnPreferenceChangeListener(listener);
} else {
Log.w(TAG, "addPreferenceListener: pref not found");
}
}
}
public static class CodecAdapter extends BaseAdapter { public static class CodecAdapter extends BaseAdapter {
ArrayList<Codec> items; ArrayList<Codec> items;
......
...@@ -13,6 +13,8 @@ import org.sflphone.service.ServiceConstants; ...@@ -13,6 +13,8 @@ import org.sflphone.service.ServiceConstants;
import org.sflphone.service.StringMap; import org.sflphone.service.StringMap;
import org.sflphone.service.VectMap; import org.sflphone.service.VectMap;
import android.util.Log;
public class SwigNativeConverter { public class SwigNativeConverter {
/** /**
...@@ -24,6 +26,9 @@ public class SwigNativeConverter { ...@@ -24,6 +26,9 @@ public class SwigNativeConverter {
Set<String> keys = nativemap.keySet(); Set<String> keys = nativemap.keySet();
for (String key : keys) { for (String key : keys) {
if (nativemap.get(key) == null) {
swigmap.set(key, "");
} else
swigmap.set(key, nativemap.get(key)); swigmap.set(key, nativemap.get(key));
} }
return swigmap; return swigmap;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment