fix Switch with R.id.object problem
This commit is contained in:
parent
c7dd9a30ce
commit
064ffd23e5
3 changed files with 80 additions and 100 deletions
|
@ -17,14 +17,6 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
import org.linphone.LinphoneManager;
|
|
||||||
import org.linphone.LinphonePreferences;
|
|
||||||
import org.linphone.R;
|
|
||||||
import org.linphone.core.LinphoneAccountCreator;
|
|
||||||
import org.linphone.core.LinphoneAccountCreator.LinphoneAccountCreatorListener;
|
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
|
||||||
import org.linphone.mediastream.Log;
|
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -34,6 +26,13 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
|
import org.linphone.R;
|
||||||
|
import org.linphone.core.LinphoneAccountCreator;
|
||||||
|
import org.linphone.core.LinphoneAccountCreator.LinphoneAccountCreatorListener;
|
||||||
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +44,7 @@ public class CreateAccountActivationFragment extends Fragment implements OnClick
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.assistant_account_creation_email_activation, container, false);
|
View view = inflater.inflate(R.layout.assistant_account_creation_email_activation, container, false);
|
||||||
|
|
||||||
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc()
|
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc()
|
||||||
|
@ -69,12 +68,10 @@ public class CreateAccountActivationFragment extends Fragment implements OnClick
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
int id = v.getId();
|
||||||
case R.id.assistant_check: {
|
if(id == R.id.assistant_check) {
|
||||||
checkAccount.setEnabled(false);
|
checkAccount.setEnabled(false);
|
||||||
accountCreator.isAccountActivated();
|
accountCreator.isAccountActivated();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,13 +225,13 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
assisstantTitle.setText(getResources().getString(R.string.link_account));
|
assisstantTitle.setText(getResources().getString(R.string.link_account));
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
accountCreator.setLanguage(Locale.getDefault().toLanguageTag());
|
accountCreator.setLanguage(Locale.getDefault().toLanguageTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
addUsernameHandler(usernameEdit, null);
|
addUsernameHandler(usernameEdit, null);
|
||||||
|
|
||||||
createAccount.setEnabled(true);
|
createAccount.setEnabled(true);
|
||||||
createAccount.setOnClickListener(this);
|
createAccount.setOnClickListener(this);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -296,59 +296,51 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
int id = v.getId();
|
||||||
case R.id.select_country: {
|
if(id == R.id.select_country){
|
||||||
AssistantActivity.instance().displayCountryChooser();
|
AssistantActivity.instance().displayCountryChooser();
|
||||||
break;
|
}
|
||||||
|
else if (id == R.id.assistant_skip){
|
||||||
|
if (getArguments().getBoolean("LinkFromPref")) {
|
||||||
|
startActivity(new Intent().setClass(AssistantActivity.instance(), LinphoneActivity.class));
|
||||||
|
AssistantActivity.instance().finish();
|
||||||
|
} else {
|
||||||
|
AssistantActivity.instance().success();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case R.id.assistant_skip: {
|
else if(id == R.id.info_phone_number){
|
||||||
if (getArguments().getBoolean("LinkFromPref")) {
|
if (linkAccount) {
|
||||||
startActivity(new Intent().setClass(AssistantActivity.instance(), LinphoneActivity.class));
|
new AlertDialog.Builder(getActivity())
|
||||||
AssistantActivity.instance().finish();
|
.setTitle(getString(R.string.phone_number_info_title))
|
||||||
} else {
|
.setMessage(getString(R.string.phone_number_link_info_content) + "\n"
|
||||||
AssistantActivity.instance().success();
|
+ getString(R.string.phone_number_link_info_content_already_account))
|
||||||
}
|
.show();
|
||||||
break;
|
} else {
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle(getString(R.string.phone_number_info_title))
|
||||||
|
.setMessage(getString(R.string.phone_number_info_content))
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case R.id.info_phone_number: {
|
else if(id == R.id.assistant_create){
|
||||||
if (linkAccount) {
|
createAccount.setEnabled(false);
|
||||||
new AlertDialog.Builder(getActivity())
|
if (linkAccount) {
|
||||||
.setTitle(getString(R.string.phone_number_info_title))
|
addAlias();
|
||||||
.setMessage(getString(R.string.phone_number_link_info_content) + "\n"
|
} else {
|
||||||
+ getString(R.string.phone_number_link_info_content_already_account))
|
if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) {
|
||||||
.show();
|
accountCreator.isAccountUsed();
|
||||||
} else {
|
} else {
|
||||||
new AlertDialog.Builder(getActivity())
|
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(Status.UsernameTooShort)
|
||||||
.setTitle(getString(R.string.phone_number_info_title))
|
, AssistantActivity.instance());
|
||||||
.setMessage(getString(R.string.phone_number_info_content))
|
createAccount.setEnabled(true);
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case R.id.assistant_create: {
|
|
||||||
createAccount.setEnabled(false);
|
|
||||||
if (linkAccount) {
|
|
||||||
addAlias();
|
|
||||||
} else {
|
|
||||||
if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) {
|
|
||||||
accountCreator.isAccountUsed();
|
|
||||||
} else {
|
|
||||||
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(Status.UsernameTooShort)
|
|
||||||
, AssistantActivity.instance());
|
|
||||||
createAccount.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEmailCorrect(String email) {
|
private boolean isEmailCorrect(String email) {
|
||||||
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
|
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
|
||||||
return emailPattern.matcher(email).matches();
|
return emailPattern.matcher(email).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPasswordCorrect(String password) {
|
private boolean isPasswordCorrect(String password) {
|
||||||
|
|
|
@ -17,19 +17,6 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
|
||||||
import org.linphone.LinphonePreferences;
|
|
||||||
import org.linphone.LinphoneUtils;
|
|
||||||
import org.linphone.R;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
|
||||||
import org.linphone.core.DialPlan;
|
|
||||||
import org.linphone.core.LinphoneAccountCreator;
|
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
|
||||||
import org.linphone.mediastream.Log;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -42,7 +29,6 @@ import android.text.method.LinkMovementMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewDebug;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
@ -52,6 +38,18 @@ import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
|
import org.linphone.LinphoneUtils;
|
||||||
|
import org.linphone.R;
|
||||||
|
import org.linphone.compatibility.Compatibility;
|
||||||
|
import org.linphone.core.DialPlan;
|
||||||
|
import org.linphone.core.LinphoneAccountCreator;
|
||||||
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +67,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.assistant_linphone_login, container, false);
|
View view = inflater.inflate(R.layout.assistant_linphone_login, container, false);
|
||||||
|
|
||||||
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
|
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
|
||||||
|
@ -231,31 +229,24 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
if(id == R.id.assistant_apply){
|
||||||
switch(id) {
|
apply.setEnabled(false);
|
||||||
case R.id.assistant_apply: {
|
if (recoverAccount) {
|
||||||
apply.setEnabled(false);
|
recoverAccount();
|
||||||
if (recoverAccount) {
|
} else {
|
||||||
recoverAccount();
|
linphoneLogIn();
|
||||||
} else {
|
|
||||||
linphoneLogIn();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case R.id.info_phone_number: {
|
|
||||||
new AlertDialog.Builder(getActivity())
|
|
||||||
.setTitle(getString(R.string.phone_number_info_title))
|
|
||||||
.setMessage(getString(R.string.phone_number_link_info_content))
|
|
||||||
.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case R.id.select_country: {
|
|
||||||
AssistantActivity.instance().displayCountryChooser();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if(id == R.id.info_phone_number){
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle(getString(R.string.phone_number_info_title))
|
||||||
|
.setMessage(getString(R.string.phone_number_link_info_content))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
else if(id == R.id.select_country){
|
||||||
|
AssistantActivity.instance().displayCountryChooser();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recoverAccount() {
|
private void recoverAccount() {
|
||||||
|
|
Loading…
Reference in a new issue