From 23e66f1c70a8bd403b01d002f26e7c49360b23e2 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Thu, 15 Oct 2015 16:31:39 +0200 Subject: [PATCH] Refresh accounts works and remove about/assistant from settings --- res/layout/search_contact_cell.xml | 51 +- res/values/strings.xml | 704 +++++++++++----------- res/xml/preferences.xml | 8 - src/org/linphone/LinphoneActivity.java | 120 ++-- src/org/linphone/LinphonePreferences.java | 7 +- src/org/linphone/LinphoneUtils.java | 56 ++ src/org/linphone/SettingsFragment.java | 29 - 7 files changed, 490 insertions(+), 485 deletions(-) diff --git a/res/layout/search_contact_cell.xml b/res/layout/search_contact_cell.xml index ee8b6a27c..69de1b610 100644 --- a/res/layout/search_contact_cell.xml +++ b/res/layout/search_contact_cell.xml @@ -2,38 +2,27 @@ - - - - - - - - - \ No newline at end of file + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 13b1764ff..2d5c89b51 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7,12 +7,16 @@ Username Display name Password + Confirm password Domain Provisioning url Email Are you sure you want to delete your selection ? Delete + Retry Cancel + Accept + About free SIP VOIP client @@ -34,7 +38,7 @@ Create account Apply Echo canceller calibration in progress - Confirm password + Enter a number or an address @@ -56,6 +60,7 @@ incoming call outgoing call + Call update requested\nYour correspondent would like to add video to the current call. @@ -110,360 +115,357 @@ Conference - Disable - Tunnel - Hostname - Port - Mode - - - disabled - 3G only - always - auto - + Disable + Tunnel + Hostname + Port + Mode + + + disabled + 3G only + always + auto + - Audio call ongoing - Paused call ongoing - Video capturing call ongoing - Not ready for a new call - Bad contact : %s - Reset verified %s - Verify %s - Encrypted - Starting up… - An error occurred while accepting call - Error adding new call - Transfer initiated - Transfer call to - New call - Resume call - Cannot resume call paused by remote - Show details - Warning: service is not ready - Close - conf - active - paused - paused by remote - - Mute - Speaker - Bluetooth - Cancel - Add call - Transfer call - Enter conference - Momentarily leave conference - Terminate conference - Hang up - Merge - Transfer - video - - Dialpad - Conference - You are part of it - Go out - You are out of it - Go in - Audio hacks - Use specific mode hack - 0=MODE_NORMAL (default), 2=MODE_IN_CALL - Use routing API hack - Use Galaxy S audio hack - Use software volume - Use ipv6 instead of ipv4 - Error while accepting pending call - %s is calling you - Accept - Decline - Unknown - Network - Transport - UDP - TCP - TLS - Use random ports - SIP port to use - At least one item is required - Registration successful - Error - Start - Application not ready - Add account - No phone numbers found for %s - Filter contacts - %s\'s phone numbers - Delete this account - Use as default - Echo canceller calibration - Use front camera - Video - Preferences - Codecs - Preferred video size - Display dialer - Front/Rear Camera - Try High resolution - Low resolution - Change resolution - Mute/Unmute camera - Disable camera - Enable camera - Terminate call - Video settings - Share my camera - Accept incoming video requests - Automatically send my camera - Always accept video requests - Initiate video calls - Always send video requests - Enable Video - Bandwidth limit in kbits/s - Enable Animations - Replace + by 00 - iLBC might be unavailable depending on ARM processor and Android OS version. - Echo cancellation - Start at boot time - Outbound proxy + Audio call ongoing + Paused call ongoing + Video capturing call ongoing + Not ready for a new call + Bad contact : %s + Reset verified %s + Verify %s + Encrypted + Starting up… + An error occurred while accepting call + Error adding new call + Transfer initiated + Transfer call to + New call + Resume call + Cannot resume call paused by remote + Show details + Warning: service is not ready + Close + conf + active + paused + paused by remote + + Mute + Speaker + Bluetooth + Cancel + Add call + Transfer call + Enter conference + Momentarily leave conference + Terminate conference + Hang up + Merge + Transfer + video + + Dialpad + Conference + You are part of it + Go out + You are out of it + Go in + Audio hacks + Use specific mode hack + 0=MODE_NORMAL (default), 2=MODE_IN_CALL + Use routing API hack + Use Galaxy S audio hack + Use software volume + Use ipv6 instead of ipv4 + Error while accepting pending call + %s is calling you + Decline + Unknown + Network + Transport + UDP + TCP + TLS + Use random ports + SIP port to use + At least one item is required + Registration successful + Error + Start + Application not ready + Add account + No phone numbers found for %s + Filter contacts + %s\'s phone numbers + Delete this account + Use as default + Echo canceller calibration + Use front camera + Video + Preferences + Codecs + Preferred video size + Display dialer + Front/Rear Camera + Try High resolution + Low resolution + Change resolution + Mute/Unmute camera + Disable camera + Enable camera + Terminate call + Video settings + Share my camera + Accept incoming video requests + Automatically send my camera + Always accept video requests + Initiate video calls + Always send video requests + Enable Video + Bandwidth limit in kbits/s + Enable Animations + Replace + by 00 + iLBC might be unavailable depending on ARM processor and Android OS version. + Echo cancellation + Start at boot time + Outbound proxy - Codecs - Communication timeout - Incoming call timeout - Video port or port range - Audio port or port range - Video port or port range (minport-maxport) - Audio port or port range (minport-maxport) - Incoming call timeout (in seconds) - Place a call - Adaptive rate control - Adaptive rate algorithm - Codec bitrate limit - - 10 kbits/s - 15 kbits/s - 20 kbits/s - 36 kbits/s - 64 kbits/s - 128 kbits/s - + Codecs + Communication timeout + Incoming call timeout + Video port or port range + Audio port or port range + Video port or port range (minport-maxport) + Audio port or port range (minport-maxport) + Incoming call timeout (in seconds) + Place a call + Adaptive rate control + Adaptive rate algorithm + Codec bitrate limit + + 10 kbits/s + 15 kbits/s + 20 kbits/s + 36 kbits/s + 64 kbits/s + 128 kbits/s + - Debug - Report issue - Describe problem here - Error generating bug report - Logs not found. - Reading logs, may takes time… - Send bug report with… - About - Send log - Reset log - Audio - Prefix - Advanced - Settings - Proxy - Domain* - Password* - Username* - SIP Account - wrong user name - wrong password - Wrong domain - Wrong settings - Dialer - Contact - Cannot call %s - Yes - No - Dismiss - Continue - Never remind me - %s, do you want to go to the settings page ? - Starting echo cancelation audio calibration - Cannot initiate a new call because a call is already engaged - History - Cannot build destination address from [%s] - Clear - Cannot get call parameters - Cannot create default call parameters - Cannot invite destination address [%s] - started - Removes the echo heard by other end - Stun server - Enable ICE - A STUN server must be configured to use ICE - Calibrating… - Calibrated [%s ms] - No echo - failed - Enter your username and password to connect to the service. - Username - Password - Connect - Please enter your login and password - Couldn\'t connect; check your login and password and start again - AMR codec might not be present on your phone - Media encryption - None - Codec disabled, build the app from source code to enable it - Codec disabled, build the app from source code to enable it - SIP Accounts - Use wifi only - Enable push notifications - An error occurred, try again later. - Server unreachable, verify your internet connection. - This username is already in use. - Your username is not valid. - Your email is not valid. - Your password is not valid (6 characters min). - Passwords entered are different. - SIP proxy hostname or ip address (optional) - Route all calls through SIP proxy - Example: john if your account is john@sip.example.org - sip.example.org if your account is john@sip.example.org - You have to re-enter your password if you edit your username and/or the domain + Debug + Report issue + Describe problem here + Error generating bug report + Logs not found. + Reading logs, may takes time… + Send bug report with… + About + Send log + Reset log + Audio + Prefix + Advanced + Settings + Proxy + Domain* + Password* + Username* + SIP Account + wrong user name + wrong password + Wrong domain + Wrong settings + Dialer + Contact + Cannot call %s + Yes + No + Dismiss + Continue + Never remind me + %s, do you want to go to the settings page ? + Starting echo cancelation audio calibration + Cannot initiate a new call because a call is already engaged + History + Cannot build destination address from [%s] + Clear + Cannot get call parameters + Cannot create default call parameters + Cannot invite destination address [%s] + started + Removes the echo heard by other end + Stun server + Enable ICE + A STUN server must be configured to use ICE + Calibrating… + Calibrated [%s ms] + No echo + failed + Enter your username and password to connect to the service. + Username + Password + Connect + Please enter your login and password + Couldn\'t connect; check your login and password and start again + AMR codec might not be present on your phone + Media encryption + None + Codec disabled, build the app from source code to enable it + Codec disabled, build the app from source code to enable it + SIP Accounts + Use wifi only + Enable push notifications + An error occurred, try again later. + Server unreachable, verify your internet connection. + This username is already in use. + Your username is not valid. + Your email is not valid. + Your password is not valid (6 characters min). + Passwords entered are different. + SIP proxy hostname or ip address (optional) + Route all calls through SIP proxy + Example: john if your account is john@sip.example.org + sip.example.org if your account is john@sip.example.org + You have to re-enter your password if you edit your username and/or the domain - Chat - Call - Add to contacts - Registered - Not Registered - Registration in progress - Registration failed - Conference - Draft - Enter a SIP address to chat with… - No call in your history. - No missed call in your history. - No contact in your address book. - No SIP contact in your address book. - No chat history. - Audio - Video - Codec: - Upload bandwidth: - Download bandwidth: - ICE connectivity: - Video size: - + Chat + Call + Add to contacts + Registered + Not Registered + Registration in progress + Registration failed + Conference + Draft + Enter a SIP address to chat with… + No call in your history. + No missed call in your history. + No contact in your address book. + No SIP contact in your address book. + No chat history. + Audio + Video + Codec: + Upload bandwidth: + Download bandwidth: + ICE connectivity: + Video size: + - password - domain - email - Create Account - An email has been sent to the address you gave. In order to activate your account, you need to click on the link inside it. Once it is done, come back here and click on the button above. - Check - Your account has not been validated yet. - Your account has been validated. - History - Contacts - Settings - Chat - About - Cancel - Back - Let\'s go - New conversation - Edit - Cancel - Okay - Back - All - New contact - All - Missed - Delete - Transfer - Add call - Video - Micro - Speaker - Route - Receiver - Bluetooth - Options - Send - Pic - Uploading… - Call update requested - Your correspondent would like to add video to the current call. - Accept - Decline - Small - Medium - Large - Real size - Save picture - Text copied to clipboard - Copy text - Select source - Image saved - Error, image not saved - Friends - New friends - Automatically accept new friend requests - Friend request - wants to share it\'s presence status with you and be aware of yours. + password + domain + email + Create Account + An email has been sent to the address you gave. In order to activate your account, you need to click on the link inside it. Once it is done, come back here and click on the button above. + Check + Your account has not been validated yet. + Your account has been validated. + History + Contacts + Settings + Chat + About + Cancel + Back + Let\'s go + New conversation + Edit + Okay + Back + All + New contact + All + Missed + Delete + Transfer + Add call + Video + Micro + Speaker + Route + Receiver + Bluetooth + Options + Send + Pic + Uploading… + Call update requested + Your correspondent would like to add video to the current call. + Accept + Decline + Small + Medium + Large + Real size + Save picture + Text copied to clipboard + Copy text + Select source + Image saved + Error, image not saved + Friends + New friends + Automatically accept new friend requests + Friend request + wants to share it\'s presence status with you and be aware of yours. - Sharing server - Remote provisioning - Delete - This contact will be deleted. - SIP address - Phone number - First name - Last name - Primary account - Display name - Username - Expire - AVPF - AVPF regular RTCP interval in seconds (between 1 and 5) - Send RFC2833 DTMFs - Send SIP INFO DTMFs - Voice mail uri - unread messages - Unknown error - Call declined - User not found - Incompatible media parameters - Your correspondent has low bandwidth, video can\'t be started - Network is unreachable - Bad credentials - Unauthorized - Network error - Today - Yesterday - Missed - Outgoing - Incoming - Background mode - Show - Download - Download failed. Please check your internet access or try again later. - Auth userid - Enter authentication userid (optionnal) - Display name - Enter display name (optionnal) - Enable UPNP - Manage - Please wait... - Updating messages database - Default account - This assistant will download an existing configuration. - provisioning url - The configuration you downloaded doesn\'t include your account. Please fill it in. - Your username will be %s.\r\n\r\nIt may differ from what you entered to match some requirements.\r\nDo you accept ? + Sharing server + Remote provisioning + Delete + This contact will be deleted. + SIP address + Phone number + First name + Last name + Primary account + Display name + Username + Expire + AVPF + AVPF regular RTCP interval in seconds (between 1 and 5) + Send RFC2833 DTMFs + Send SIP INFO DTMFs + Voice mail uri + unread messages + Unknown error + Call declined + User not found + Incompatible media parameters + Your correspondent has low bandwidth, video can\'t be started + Network is unreachable + Bad credentials + Unauthorized + Network error + Today + Yesterday + Missed + Outgoing + Incoming + Background mode + Show + Download + Download failed. Please check your internet access or try again later. + Auth userid + Enter authentication userid (optionnal) + Display name + Enter display name (optionnal) + Enable UPNP + Manage + Please wait... + Updating messages database + Default account + This assistant will download an existing configuration. + provisioning url + The configuration you downloaded doesn\'t include your account. Please fill it in. + Your username will be %s.\r\n\r\nIt may differ from what you entered to match some requirements.\r\nDo you accept ? - Accept - Deny - You should only accept if you have the same code (see above) as your correspondent - Remote is writing... - %i unread messages - Retry - Failed to download or apply remote provisioning profile... - Remote provisioning - Do you want to change the provisioning URI ? - Processing image, can take up to a few seconds depending on the size of the file + Accept + Deny + You should only accept if you have the same code (see above) as your correspondent + Remote is writing... + %i unread messages + Failed to download or apply remote provisioning profile... + Remote provisioning + Do you want to change the provisioning URI ? + Processing image, can take up to a few seconds depending on the size of the file diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 18039cb16..e796b6d5b 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -1,17 +1,9 @@ - - - - 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 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; diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java index a627312a1..171b34f0f 100644 --- a/src/org/linphone/LinphonePreferences.java +++ b/src/org/linphone/LinphonePreferences.java @@ -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; } diff --git a/src/org/linphone/LinphoneUtils.java b/src/org/linphone/LinphoneUtils.java index d5b83fa98..32c5b27a2 100644 --- a/src/org/linphone/LinphoneUtils.java +++ b/src/org/linphone/LinphoneUtils.java @@ -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)) { diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java index 3deedf6ee..924435860 100644 --- a/src/org/linphone/SettingsFragment.java +++ b/src/org/linphone/SettingsFragment.java @@ -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(); - } } } }