Added bool to ensure account is valid in setup assistant + dynamic disable of options items while in call
This commit is contained in:
parent
84cd341efc
commit
11cffbda2b
5 changed files with 66 additions and 10 deletions
|
@ -22,6 +22,7 @@
|
||||||
<string name="setup_forced_proxy"></string>
|
<string name="setup_forced_proxy"></string>
|
||||||
<bool name="setup_cancel_move_to_back">false</bool>
|
<bool name="setup_cancel_move_to_back">false</bool>
|
||||||
<bool name="setup_use_linphone_as_first_fragment">false</bool>
|
<bool name="setup_use_linphone_as_first_fragment">false</bool>
|
||||||
|
<bool name="setup_account_validation_mandatory">false</bool>
|
||||||
<bool name="hide_linphone_accounts_wizard">false</bool>
|
<bool name="hide_linphone_accounts_wizard">false</bool>
|
||||||
<bool name="hide_generic_accounts_wizard">false</bool>
|
<bool name="hide_generic_accounts_wizard">false</bool>
|
||||||
<bool name="hide_accounts">false</bool>
|
<bool name="hide_accounts">false</bool>
|
||||||
|
|
|
@ -333,16 +333,13 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (getResources().getBoolean(R.bool.disable_options_in_call)) {
|
addCall.setEnabled(LinphoneManager.getLc().getCallsNb() < LinphoneManager.getLc().getMaxCalls());
|
||||||
options.setEnabled(false);
|
transfer.setEnabled(getResources().getBoolean(R.bool.allow_transfers));
|
||||||
} else {
|
options.setEnabled(!getResources().getBoolean(R.bool.disable_options_in_call) && (addCall.isEnabled() || transfer.isEnabled()));
|
||||||
options.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
video.setEnabled(true);
|
video.setEnabled(true);
|
||||||
micro.setEnabled(true);
|
micro.setEnabled(true);
|
||||||
speaker.setEnabled(true);
|
speaker.setEnabled(true);
|
||||||
addCall.setEnabled(true);
|
|
||||||
transfer.setEnabled(true);
|
transfer.setEnabled(true);
|
||||||
pause.setEnabled(true);
|
pause.setEnabled(true);
|
||||||
dialer.setEnabled(true);
|
dialer.setEnabled(true);
|
||||||
|
|
|
@ -1637,7 +1637,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
public void onRegistrationStateChanged(RegistrationState state,
|
public void onRegistrationStateChanged(RegistrationState state,
|
||||||
String message) {
|
String message) {
|
||||||
if (serviceListener != null) serviceListener.onRegistrationStateChanged(state, message);
|
if (serviceListener != null) serviceListener.onRegistrationStateChanged(state, message);
|
||||||
for (LinphoneOnRegistrationStateChangedListener listener : getSimpleListeners(LinphoneActivity.class)) {
|
for (LinphoneOnRegistrationStateChangedListener listener : getSimpleListeners(LinphoneOnRegistrationStateChangedListener.class)) {
|
||||||
listener.onRegistrationStateChanged(state);
|
listener.onRegistrationStateChanged(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString());
|
SetupActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), getResources().getBoolean(R.bool.setup_account_validation_mandatory));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,9 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -26,6 +28,7 @@ import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
@ -47,6 +50,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
private SetupFragmentsEnum firstFragment;
|
private SetupFragmentsEnum firstFragment;
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
private boolean accountCreated = false;
|
private boolean accountCreated = false;
|
||||||
|
private Handler mHandler = new Handler();
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -192,8 +196,54 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void linphoneLogIn(String username, String password) {
|
|
||||||
logIn(username, password, getString(R.string.default_domain), true);
|
private LinphoneOnRegistrationStateChangedListener registrationListener = new LinphoneOnRegistrationStateChangedListener() {
|
||||||
|
public void onRegistrationStateChanged(RegistrationState state) {
|
||||||
|
if (state == RegistrationState.RegistrationOk) {
|
||||||
|
LinphoneManager.removeListener(registrationListener);
|
||||||
|
|
||||||
|
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
|
mHandler .post(new Runnable () {
|
||||||
|
public void run() {
|
||||||
|
launchEchoCancellerCalibration(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (state == RegistrationState.RegistrationFailed) {
|
||||||
|
LinphoneManager.removeListener(registrationListener);
|
||||||
|
deleteCreatedAccount();
|
||||||
|
mHandler.post(new Runnable () {
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public void checkAccount(String username, String password, String domain) {
|
||||||
|
LinphoneManager.removeListener(registrationListener);
|
||||||
|
LinphoneManager.addListener(registrationListener);
|
||||||
|
|
||||||
|
saveCreatedAccount(username, password, domain);
|
||||||
|
LinphoneManager.getInstance().initializePayloads();
|
||||||
|
|
||||||
|
try {
|
||||||
|
LinphoneManager.getInstance().initFromConf();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
LinphoneManager.removeListener(registrationListener);
|
||||||
|
deleteCreatedAccount();
|
||||||
|
|
||||||
|
Log.e(e, "Error while initializing from config in first login activity");
|
||||||
|
Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void linphoneLogIn(String username, String password, boolean validate) {
|
||||||
|
if (validate) {
|
||||||
|
checkAccount(username, password, getString(R.string.default_domain));
|
||||||
|
} else {
|
||||||
|
logIn(username, password, getString(R.string.default_domain), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void genericLogIn(String username, String password, String domain) {
|
public void genericLogIn(String username, String password, String domain) {
|
||||||
|
@ -253,6 +303,14 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
currentFragment = SetupFragmentsEnum.WIZARD;
|
currentFragment = SetupFragmentsEnum.WIZARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteCreatedAccount() {
|
||||||
|
if (!accountCreated)
|
||||||
|
return;
|
||||||
|
|
||||||
|
writePreference(R.string.pref_extra_accounts, 0);
|
||||||
|
accountCreated = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void saveCreatedAccount(String username, String password, String domain) {
|
public void saveCreatedAccount(String username, String password, String domain) {
|
||||||
if (accountCreated)
|
if (accountCreated)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue