Refresh accounts works and remove about/assistant from settings
This commit is contained in:
parent
237487cb58
commit
23e66f1c70
7 changed files with 490 additions and 485 deletions
|
@ -2,16 +2,11 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@drawable/list_selector"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Contact_name"
|
||||
android:lines="1"
|
||||
|
@ -20,20 +15,14 @@
|
|||
android:layout_toRightOf="@id/icon"
|
||||
android:layout_centerVertical="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/text_contrast"
|
||||
android:layout_marginLeft="10dp" />
|
||||
android:textColor="@color/colorB" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_address"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginRight="20dp"
|
||||
android:scaleType="centerInside" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -7,12 +7,16 @@
|
|||
<string name="username">Username</string>
|
||||
<string name="display_name">Display name</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="confirm_password">Confirm password</string>
|
||||
<string name="domain">Domain</string>
|
||||
<string name="remote_provisioning_url">Provisioning url</string>
|
||||
<string name="email">Email</string>
|
||||
<string name="delete_text">Are you sure you want to delete your selection ?</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="retry">Retry</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="accept">Accept</string>
|
||||
<string name="about">About</string>
|
||||
|
||||
<!-- splashscreen -->
|
||||
<string name="app_description">free SIP VOIP client</string>
|
||||
|
@ -34,7 +38,7 @@
|
|||
<string name="assistant_create">Create account</string>
|
||||
<string name="assistant_apply">Apply</string>
|
||||
<string name="assistant_ec_calibration">Echo canceller calibration in progress</string>
|
||||
<string name="assistant_password_confirm">Confirm password</string>
|
||||
|
||||
|
||||
<!-- 1. Dailer -->
|
||||
<string name="address_bar_hint">Enter a number or an address</string>
|
||||
|
@ -56,6 +60,7 @@
|
|||
<!-- Call -->
|
||||
<string name="incoming_call">incoming call</string>
|
||||
<string name="outgoing_call">outgoing call</string>
|
||||
<string name="call_update_video">Call update requested\nYour correspondent would like to add video to the current call.</string>
|
||||
|
||||
|
||||
<!-- Content description -->
|
||||
|
@ -176,7 +181,6 @@
|
|||
<string name="pref_ipv6_title">Use ipv6 instead of ipv4</string>
|
||||
<string name="error_while_accepting_pending_call">Error while accepting pending call</string>
|
||||
<string name="incoming_call_dialog_title">%s is calling you</string>
|
||||
<string name="accept">Accept</string>
|
||||
<string name="decline">Decline</string>
|
||||
<string name="unknown_incoming_call_name">Unknown</string>
|
||||
<string name="pref_network_title">Network</string>
|
||||
|
@ -367,7 +371,6 @@
|
|||
<string name="button_setup_next">Let\'s go</string>
|
||||
<string name="button_new_chat">New conversation</string>
|
||||
<string name="button_edit">Edit</string>
|
||||
<string name="button_cancel">Cancel</string>
|
||||
<string name="button_ok">Okay</string>
|
||||
<string name="button_back">Back</string>
|
||||
<string name="button_all_contacts">All</string>
|
||||
|
@ -462,7 +465,6 @@
|
|||
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>
|
||||
<string name="remote_composing">Remote is writing...</string>
|
||||
<string name="unread_messages">%i unread messages</string>
|
||||
<string name="retry">Retry</string>
|
||||
<string name="remote_provisioning_failure">Failed to download or apply remote provisioning profile...</string>
|
||||
<string name="remote_provisioning_again_title">Remote provisioning</string>
|
||||
<string name="remote_provisioning_again_message">Do you want to change the provisioning URI ?</string>
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:title="@string/menu_about"
|
||||
android:key="@string/menu_about_key"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_sipaccounts"
|
||||
android:key="@string/pref_sipaccounts_key"/>
|
||||
|
||||
<Preference
|
||||
android:title="@string/assistant_title"
|
||||
android:key="@string/setup_key"/>
|
||||
|
||||
<Preference
|
||||
android:title="@string/pref_add_account"
|
||||
android:key="@string/pref_add_account_key"/>
|
||||
|
|
|
@ -207,6 +207,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
}
|
||||
|
||||
if(proxy == lc.getDefaultProxyConfig()){
|
||||
displayMainAccount();
|
||||
} else {
|
||||
refreshAccounts();
|
||||
}
|
||||
|
||||
if(state.equals(RegistrationState.RegistrationFailed) && newProxyConfig) {
|
||||
newProxyConfig = false;
|
||||
if (proxy.getError() == Reason.BadCredentials) {
|
||||
|
@ -219,7 +225,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
displayCustomToast(getString(R.string.error_io_error), Toast.LENGTH_LONG);
|
||||
}
|
||||
}
|
||||
initAccounts();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1306,60 +1311,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
});
|
||||
}
|
||||
|
||||
private void initAccounts() {
|
||||
accountsList = (ListView) findViewById(R.id.accounts_list);
|
||||
defaultAccount = (RelativeLayout) findViewById(R.id.default_account);
|
||||
|
||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||
defaultAccount.setVisibility(View.VISIBLE);
|
||||
ImageView status = (ImageView)findViewById(R.id.status_led);
|
||||
TextView address = (TextView) findViewById(R.id.address);
|
||||
TextView displayName = (TextView) findViewById(R.id.display_name);
|
||||
|
||||
try {
|
||||
LinphoneAddress identity = LinphoneCoreFactory.instance().createLinphoneAddress((LinphoneManager.getLc().getDefaultProxyConfig().getIdentity()));
|
||||
address.setText(identity.asStringUriOnly());
|
||||
if (identity.getDisplayName() != null) {
|
||||
displayName.setText(identity.getDisplayName());
|
||||
} else if (identity.getUserName() != null) {
|
||||
displayName.setText(identity.getUserName());
|
||||
} else {
|
||||
displayName.setText("");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
status.setImageResource(getStatusIconResource(LinphoneManager.getLc().getDefaultProxyConfig().getState()));
|
||||
|
||||
defaultAccount.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LinphoneActivity.instance().displayAccountSettings(LinphonePreferences.instance().getDefaultAccountIndex());
|
||||
openOrCloseSideMenu(false);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
defaultAccount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
||||
accountsList.setVisibility(View.VISIBLE);
|
||||
accountsList.setAdapter(new AccountsListAdapter());
|
||||
accountsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
int position = Integer.parseInt(view.getTag().toString());
|
||||
LinphoneActivity.instance().displayAccountSettings(position);
|
||||
openOrCloseSideMenu(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
accountsList.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private int getStatusIconResource(LinphoneCore.RegistrationState state) {
|
||||
try {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
@ -1379,6 +1330,58 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
return R.drawable.led_disconnected;
|
||||
}
|
||||
|
||||
private void displayMainAccount(){
|
||||
defaultAccount.setVisibility(View.VISIBLE);
|
||||
defaultAccount = (RelativeLayout) findViewById(R.id.default_account);
|
||||
ImageView status = (ImageView) defaultAccount.findViewById(R.id.status_led);
|
||||
TextView address = (TextView) defaultAccount.findViewById(R.id.address);
|
||||
TextView displayName = (TextView) defaultAccount.findViewById(R.id.display_name);
|
||||
|
||||
LinphoneProxyConfig proxy = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||
|
||||
address.setText(proxy.getAddress().asStringUriOnly());
|
||||
displayName.setText(LinphoneUtils.getAddressDisplayName(proxy.getAddress()));
|
||||
status.setImageResource(getStatusIconResource(proxy.getState()));
|
||||
|
||||
defaultAccount.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LinphoneActivity.instance().displayAccountSettings(LinphonePreferences.instance().getDefaultAccountIndex());
|
||||
openOrCloseSideMenu(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshAccounts(){
|
||||
if(LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
||||
accountsList.setVisibility(View.VISIBLE);
|
||||
accountsList.setAdapter(new AccountsListAdapter());
|
||||
accountsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
int position = Integer.parseInt(view.getTag().toString());
|
||||
LinphoneActivity.instance().displayAccountSettings(position);
|
||||
openOrCloseSideMenu(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
accountsList.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initAccounts() {
|
||||
accountsList = (ListView) findViewById(R.id.accounts_list);
|
||||
defaultAccount = (RelativeLayout) findViewById(R.id.default_account);
|
||||
|
||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||
displayMainAccount();
|
||||
} else {
|
||||
defaultAccount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
refreshAccounts();
|
||||
}
|
||||
|
||||
class AccountsListAdapter extends BaseAdapter {
|
||||
List<LinphoneProxyConfig> proxy_list;
|
||||
|
||||
|
@ -1425,12 +1428,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
TextView address = (TextView) view.findViewById(R.id.address);
|
||||
String sipAddress = lpc.getAddress().asStringUriOnly();
|
||||
|
||||
try {
|
||||
LinphoneAddress identity = LinphoneCoreFactory.instance().createLinphoneAddress(lpc.getIdentity());
|
||||
address.setText(identity.asStringUriOnly());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
address.setText(sipAddress);
|
||||
|
||||
int nbAccounts = LinphonePreferences.instance().getAccountCount();
|
||||
int accountIndex = 0;
|
||||
|
|
|
@ -458,13 +458,10 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public String getAccountDisplayName(int n) {
|
||||
try {
|
||||
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(getProxyConfig(n).getIdentity());
|
||||
LinphoneAddress addr = getProxyConfig(n).getAddress();
|
||||
if(addr != null) {
|
||||
return addr.getDisplayName();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,10 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
@ -99,6 +101,28 @@ public final class LinphoneUtils {
|
|||
return isSipAddress(numberOrAddress) && numberOrAddress.startsWith("sip:");
|
||||
}
|
||||
|
||||
public static String getAddressDisplayName(String uri){
|
||||
LinphoneAddress lAddress;
|
||||
try {
|
||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(uri);
|
||||
return getAddressDisplayName(lAddress);
|
||||
} catch (LinphoneCoreException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAddressDisplayName(LinphoneAddress address){
|
||||
if(address.getDisplayName() != null) {
|
||||
return address.getDisplayName();
|
||||
} else {
|
||||
if(address.getUserName() != null){
|
||||
return address.getUserName();
|
||||
} else {
|
||||
return address.asStringUriOnly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUsernameFromAddress(String address) {
|
||||
if (address.contains("sip:"))
|
||||
address = address.replace("sip:", "");
|
||||
|
@ -120,6 +144,38 @@ public final class LinphoneUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static String timestampToHumanDate(Context context, long timestamp, String format) {
|
||||
try {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(timestamp);
|
||||
|
||||
SimpleDateFormat dateFormat;
|
||||
if (isToday(cal)) {
|
||||
dateFormat = new SimpleDateFormat(context.getResources().getString(R.string.today_date_format));
|
||||
} else {
|
||||
dateFormat = new SimpleDateFormat(format);
|
||||
}
|
||||
|
||||
return dateFormat.format(cal.getTime());
|
||||
} catch (NumberFormatException nfe) {
|
||||
return String.valueOf(timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isToday(Calendar cal) {
|
||||
return isSameDay(cal, Calendar.getInstance());
|
||||
}
|
||||
|
||||
static boolean isSameDay(Calendar cal1, Calendar cal2) {
|
||||
if (cal1 == null || cal2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
|
||||
cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
|
||||
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
|
||||
}
|
||||
|
||||
public static boolean onKeyVolumeAdjust(int keyCode) {
|
||||
if (!((keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
||||
&& (Hacks.needSoftvolume())|| Build.VERSION.SDK_INT >= 15)) {
|
||||
|
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.assistant.AssistantActivity;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.AdaptiveRateAlgorithm;
|
||||
|
@ -39,7 +38,6 @@ import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
|||
import org.linphone.ui.LedPreference;
|
||||
import org.linphone.ui.PreferencesListFragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.CheckBoxPreference;
|
||||
|
@ -55,7 +53,6 @@ import android.preference.PreferenceScreen;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class SettingsFragment extends PreferencesListFragment {
|
||||
private static final int WIZARD_INTENT = 1;
|
||||
private LinphonePreferences mPrefs;
|
||||
private Handler mHandler = new Handler();
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
|
@ -110,25 +107,6 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
initNetworkSettings();
|
||||
initAdvancedSettings();
|
||||
|
||||
// Add action on About button
|
||||
findPreference(getString(R.string.menu_about_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().displayAbout();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
findPreference(getString(R.string.setup_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(LinphoneService.instance(), AssistantActivity.class);
|
||||
startActivityForResult(intent, WIZARD_INTENT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
findPreference(getString(R.string.pref_add_account_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
|
@ -155,10 +133,6 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
emptyAndHidePreference(R.string.pref_sipaccounts_key);
|
||||
}
|
||||
|
||||
if (getResources().getBoolean(R.bool.hide_wizard)){
|
||||
hidePreference(R.string.setup_key);
|
||||
}
|
||||
|
||||
if(!getResources().getBoolean(R.bool.replace_wizard_with_old_interface)){
|
||||
hidePreference(R.string.pref_add_account_key);
|
||||
}
|
||||
|
@ -1054,9 +1028,6 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.SETTINGS);
|
||||
|
||||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
||||
LinphoneActivity.instance().hideStatusBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue