Fix error reason for call and proxy config

This commit is contained in:
Margaux Clerc 2015-08-11 16:32:34 +02:00
parent 6f005e7e0d
commit a0738ca90d
4 changed files with 28 additions and 5 deletions

View file

@ -374,6 +374,9 @@
<string name="error_incompatible_media">Incompatible media parameters</string>
<string name="error_low_bandwidth">Your correspondent has low bandwidth, video can\'t be started</string>
<string name="error_network_unreachable">Network is unreachable</string>
<string name="error_bad_credentials">Bad credentials</string>
<string name="error_unauthorized">Unauthorized</string>
<string name="error_io_error">Network error</string>
<string name="today">Today</string>
<string name="yesterday">Yesterday</string>
<string name="call_state_missed">Missed</string>

View file

@ -499,7 +499,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
LinphoneActivity.instance().isNewProxyConfig();
LinphoneManager.getLc().refreshRegisters();
}
}

View file

@ -43,6 +43,7 @@ import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.Reason;
import org.linphone.mediastream.Log;
import org.linphone.setup.RemoteProvisioningLoginActivity;
import org.linphone.setup.SetupActivity;
@ -104,6 +105,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
private ChatFragment chatFragment;
private SavedState dialerSavedState;
private boolean newProxyConfig;
private boolean isAnimationDisabled = false, preferLinphoneContacts = false;
private OrientationEventListener mOrientationHelper;
private LinphoneCoreListenerBase mListener;
@ -198,6 +200,19 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
lc.removeAuthInfo(authInfo);
}
}
if(state.equals(RegistrationState.RegistrationFailed) && newProxyConfig) {
newProxyConfig = false;
if (proxy.getError() == Reason.BadCredentials) {
displayCustomToast(getString(R.string.error_bad_credentials), Toast.LENGTH_LONG);
}
if (proxy.getError() == Reason.Unauthorized) {
displayCustomToast(getString(R.string.error_unauthorized), Toast.LENGTH_LONG);
}
if (proxy.getError() == Reason.IOError) {
displayCustomToast(getString(R.string.error_io_error), Toast.LENGTH_LONG);
}
}
}
@Override
@ -212,11 +227,11 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
// Convert LinphoneCore message for internalization
if (message != null && message.equals("Call declined.")) {
if (message != null && call.getReason() == Reason.Declined) {
displayCustomToast(getString(R.string.error_call_declined), Toast.LENGTH_LONG);
} else if (message != null && message.equals("Not Found")) {
} else if (message != null && call.getReason() == Reason.NotFound) {
displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_LONG);
} else if (message != null && message.equals("Unsupported media type")) {
} else if (message != null && call.getReason() == Reason.Media) {
displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_LONG);
} else if (message != null && state == State.Error) {
displayCustomToast(getString(R.string.error_unknown) + " - " + message, Toast.LENGTH_LONG);
@ -259,7 +274,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
updateAnimationsState();
}
private void initButtons() {
menu = (LinearLayout) findViewById(R.id.menu);
mark = (LinearLayout) findViewById(R.id.mark);
@ -322,6 +336,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
findViewById(R.id.fragmentContainer).setPadding(0, LinphoneUtils.pixelsToDpi(getResources(), 40), 0, 0);
}
public void isNewProxyConfig(){
newProxyConfig = true;
}
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras) {
changeCurrentFragment(newFragmentType, extras, false);
}

View file

@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.LinphonePreferences.AccountBuilder;
@ -405,6 +406,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
public void success() {
mPrefs.firstLaunchSuccessful();
LinphoneActivity.instance().isNewProxyConfig();
setResult(Activity.RESULT_OK);
finish();
}