Skip to content
Snippets Groups Projects
Commit 5cfc35d6 authored by alision's avatar alision
Browse files

* #27064 New creation process (faster), lightened parameters

Refactoring on accounts
parent 5de91788
No related branches found
No related tags found
No related merge requests found
Showing
with 764 additions and 317 deletions
......@@ -76,6 +76,15 @@ as that of the covered work.
android:name="android.support.PARENT_ACTIVITY"
android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" />
</activity>
<activity
android:name="com.savoirfairelinux.sflphone.client.AccountWizard"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" />
</activity>
<activity
android:name="com.savoirfairelinux.sflphone.client.AccountPreferenceActivity"
android:label="@string/app_name"
......
......@@ -76,6 +76,15 @@ as that of the covered work.
android:name="android.support.PARENT_ACTIVITY"
android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" />
</activity>
<activity
android:name="com.savoirfairelinux.sflphone.client.AccountWizard"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.savoirfairelinux.sflphone.client.SFLPhoneHome" />
</activity>
<activity
android:name="com.savoirfairelinux.sflphone.client.AccountPreferenceActivity"
android:label="@string/app_name"
......
......@@ -68,7 +68,7 @@ as that of the covered work.
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:background="#000000"
android:background="#FFFFFF"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light" >
<LinearLayout
style="@style/LoginFormContainer"
android:orientation="vertical" >
<EditText
android:id="@+id/alias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_alias"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/hostname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_hostname"
android:maxLines="1"
android:singleLine="true" >
</EditText>
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_username"
android:maxLines="1"
android:singleLine="true" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_create_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
<Button
android:id="@+id/create_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="16dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:text="@string/action_create" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
<resources>
<!-- Strings related to login -->
<string name="prompt_alias">Alias</string>
<string name="prompt_hostname">Hostname</string>
<string name="prompt_username">Username</string>
<string name="prompt_password">Password</string>
<string name="action_create"><b>Create Account</b></string>
<string name="action_create_short">Create</string>
<string name="action_forgot_password">Recover lost password</string>
<string name="login_progress_signing_in">Signing in&#8230;</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
</resources>
......@@ -39,4 +39,10 @@ as that of the covered work.
<item name="android:dividerHeight">5dp</item>
</style>
<style name="LoginFormContainer">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">16dp</item>
</style>
</resources>
\ No newline at end of file
......@@ -33,14 +33,14 @@ as that of the covered work.
<PreferenceCategory
android:id="@+id/account_basic_category"
android:title="Basic settings">
<CheckBoxPreference
android:id="@+id/account_creation_enable"
android:key="Account.enable"
android:persistent="false"
android:defaultValue="true"
android:title="Account enabled"
android:summaryOn="enabled"
android:summaryOff="disabled"/>
<!-- <CheckBoxPreference -->
<!-- android:id="@+id/account_creation_enable" -->
<!-- android:key="Account.enable" -->
<!-- android:persistent="false" -->
<!-- android:defaultValue="true" -->
<!-- android:title="Account enabled" -->
<!-- android:summaryOn="enabled" -->
<!-- android:summaryOff="disabled"/> -->
<!-- <EditTextPreference -->
<!-- android:id="@+id/account_creation_type" -->
<!-- android:key="Account.type" -->
......
......@@ -54,10 +54,14 @@ public class AccountDetailAdvanced implements AccountDetail {
public static final String CONFIG_LOCAL_PORT = "Account.localPort";
public static final String CONFIG_PUBLISHED_PORT = "Account.publishedPort";
public static final String CONFIG_PUBLISHED_ADDRESS = "Account.publishedAddress";
public static final String CONFIG_DEFAULT_LOCAL_PORT = "5060";
public static final String CONFIG_DEFAULT_PUBLISHED_PORT = "5060";
public static final String CONFIG_DEFAULT_LOCAL_PORT = "5070";
public static final String CONFIG_DEFAULT_PUBLISHED_PORT = "5070";
public static final String CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL = "true";
public static final String CONFIG_DEFAULT_INTERFACE = "default";
public static final String CONFIG_DEFAULT_INTERFACE = "wlan0";
public static final String CONFIG_DEFAULT_REGISTRATION_EXPIRE = "60";
public static final String CONFIG_DISPLAY_NAME = "Account.displayName";
public static final String CONFIG_DEFAULT_ADDRESS = "0.0.0.0";
......
......@@ -23,6 +23,7 @@ package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.account.AccountDetail;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
import android.util.Log;
......@@ -36,15 +37,22 @@ public class AccountDetailBasic implements AccountDetail {
private static final String TAG = "AccountDetailBasic";
public static final String BUNDLE_TAG = "BasicPreferenceArrayList";
public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable";
public static final String CONFIG_ACCOUNT_TYPE = "Account.type";
public static final String CONFIG_ACCOUNT_ALIAS = "Account.alias";
public static final String CONFIG_ACCOUNT_HOSTNAME = "Account.hostname";
public static final String CONFIG_ACCOUNT_USERNAME = "Account.username";
public static final String CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
public static final String CONFIG_ACCOUNT_PASSWORD = "Account.password";
public static final String CONFIG_ACCOUNT_REALM = "Account.realm";
public static final String CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
public static final String CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
public static final String CONFIG_ACCOUNT_TYPE = "Account.type";
public static final String CONFIG_ACCOUNT_ALIAS = "Account.alias";
public static final String CONFIG_ACCOUNT_ENABLE = "Account.enable";
public static final String CONFIG_ACCOUNT_DEFAULT_TYPE = "SIP";
public static final String CONFIG_ACCOUNT_DEFAULT_ENABLE = "true";
public static final String CONFIG_ACCOUNT_DEFAULT_REALM = "*";
public static final String CONFIG_ACCOUNT_DEFAULT_USERAGENT = "SFLphone";
private ArrayList<AccountDetail.PreferenceEntry> privateArray;
......
......@@ -24,6 +24,7 @@ package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.account.AccountDetail;
import com.savoirfairelinux.sflphone.account.AccountDetail.PreferenceEntry;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
import android.util.Log;
......@@ -36,7 +37,7 @@ public class AccountDetailSrtp implements AccountDetail{
private static final String TAG = "AccountDetailSrtp";
public static final String BUNDLE_TAG = "SrtpPreferenceArrayList";
public static final String CONFIG_SRTP_ENABLE = "SRTP.enable";
public static final String CONFIG_SRTP_KEY_EXCHANGE = "SRTP.keyExchange";
public static final String CONFIG_SRTP_ENCRYPTION_ALGO = "SRTP.encryptionAlgorithm"; // Provided by ccRTP,0=NULL,1=AESCM,2=AESF8
......
......@@ -21,22 +21,19 @@
*/
package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.account.AccountDetail;
import com.savoirfairelinux.sflphone.account.AccountDetail.PreferenceEntry;
import java.util.ArrayList;
import java.util.HashMap;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
import java.util.HashMap;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
public class AccountDetailTls implements AccountDetail {
private static final String TAG = "AccountDetailTls";
public static final String BUNDLE_TAG = "TlsPreferenceArrayList";
public static final String CONFIG_TLS_LISTENER_PORT = "TLS.listenerPort";
public static final String CONFIG_TLS_ENABLE = "TLS.enable";
public static final String CONFIG_TLS_CA_LIST_FILE = "TLS.certificateListFile";
......@@ -51,7 +48,7 @@ public class AccountDetailTls implements AccountDetail {
public static final String CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE = "TLS.requireClientCertificate";
public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec";
public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC = "TLS.negotiationTimemoutMsec";
private ArrayList<AccountDetail.PreferenceEntry> privateArray;
public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries()
......
......@@ -36,28 +36,6 @@ public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
return fragments.get(i);
}
// public Fragment getFragment(int i) {
// Fragment fragment;
//
// switch (i) {
// case 0:
// fragment = new DialingFragment();
// break;
// case 1:
// fragment = new CallElementListFragment();
// break;
// case 2:
// fragment = new HistoryFragment();
// break;
// default:
// Log.e(TAG, "getClassName: unknown fragment position " + i);
// fragment = null;
// }
// Log.w(TAG, "getFragment: fragment=" + fragment);
// return fragment;
// }
public String getClassName(int i) {
String name;
......
......@@ -62,19 +62,14 @@ import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced;
import com.savoirfairelinux.sflphone.account.AccountDetailBasic;
import com.savoirfairelinux.sflphone.account.AccountDetailSrtp;
import com.savoirfairelinux.sflphone.account.AccountDetailTls;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
public class AccountPreferenceActivity extends PreferenceActivity {
private static final String TAG = "AccoutPreferenceActivity";
public static final String KEY_MODE = "mode";
public interface mode {
static final int CREATION_MODE = 0;
static final int EDITION_MODE = 1;
}
public interface result {
static final int ACCOUNT_CREATED = Activity.RESULT_FIRST_USER + 0;
static final int ACCOUNT_MODIFIED = Activity.RESULT_FIRST_USER + 1;
static final int ACCOUNT_DELETED = Activity.RESULT_FIRST_USER + 2;
}
......@@ -93,18 +88,7 @@ public class AccountPreferenceActivity extends PreferenceActivity {
addPreferencesFromResource(R.xml.account_creation_preferences);
mPreferenceManager = getPreferenceManager();
Bundle b = getIntent().getExtras();
switch (b.getInt(KEY_MODE)) {
case mode.CREATION_MODE:
Log.i(TAG, "CREATION");
initCreation();
break;
case mode.EDITION_MODE:
Log.i(TAG, "EDITION");
initEdition();
break;
}
initEdition();
getActionBar().setDisplayHomeAsUpEnabled(true);
......@@ -116,19 +100,6 @@ public class AccountPreferenceActivity extends PreferenceActivity {
}
private void initCreation() {
basicDetails = new AccountDetailBasic();
advancedDetails = new AccountDetailAdvanced();
srtpDetails = new AccountDetailSrtp();
tlsDetails = new AccountDetailTls();
addPreferenceListener(basicDetails, changeBasicPreferenceListener);
// addPreferenceListener(advancedDetails, changeAdvancedPreferenceListener);
// addPreferenceListener(srtpDetails, changeSrtpPreferenceListener);
// addPreferenceListener(tlsDetails, changeTlsPreferenceListener);
}
private void initEdition() {
Bundle b = getIntent().getExtras();
......@@ -158,38 +129,18 @@ public class AccountPreferenceActivity extends PreferenceActivity {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
Bundle b = getIntent().getExtras();
switch (b.getInt(KEY_MODE)) {
case mode.CREATION_MODE:
Log.i(TAG, "CREATION");
inflater.inflate(R.menu.account_creation, menu);
break;
case mode.EDITION_MODE:
Log.i(TAG, "onCreateOptionsMenu: " + mAccountID);
if (mAccountID.equals("IP2IP"))
return true;
Log.i(TAG, "onCreateOptionsMenu: " + mAccountID);
inflater.inflate(R.menu.account_edition, menu);
break;
}
inflater.inflate(R.menu.account_edition, menu);
return true;
}
@Override
public void onBackPressed() {
Bundle b = getIntent().getExtras();
switch (b.getInt(KEY_MODE)) {
case mode.CREATION_MODE:
Log.i(TAG, "CREATION");
AlertDialog dialog = createCancelDialog();
dialog.show();
break;
case mode.EDITION_MODE:
finish();
}
AlertDialog dialog = createCancelDialog();
dialog.show();
}
......@@ -204,10 +155,6 @@ public class AccountPreferenceActivity extends PreferenceActivity {
AlertDialog dialog = createDeleteDialog();
dialog.show();
break;
case R.id.menuitem_create:
Toast.makeText(this, "ACCOUNT_CREATED", Toast.LENGTH_LONG).show();
processAccount(result.ACCOUNT_CREATED);
break;
case R.id.menuitem_edit:
processAccount(result.ACCOUNT_MODIFIED);
break;
......@@ -230,9 +177,8 @@ public class AccountPreferenceActivity extends PreferenceActivity {
updateAccountDetails(accountDetails, advancedDetails);
updateAccountDetails(accountDetails, srtpDetails);
updateAccountDetails(accountDetails, tlsDetails);
accountDetails.put("Account.type", "SIP");
Toast.makeText(this, "updateAccountDetails", Toast.LENGTH_LONG).show();
bundle.putSerializable(AccountDetail.TAG, accountDetails);
Intent resultIntent = new Intent();
resultIntent.putExtras(bundle);
......@@ -269,11 +215,11 @@ public class AccountPreferenceActivity extends PreferenceActivity {
if (p.isTwoState) {
accountDetails.put(p.mKey, det.getDetailString(p.mKey));
} else {
// if (p.mKey == AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE) {
// accountDetails.put(p.mKey, det.getDetailString(p.mKey));
// } else {
accountDetails.put(p.mKey, det.getDetailString(p.mKey));
// }
// if (p.mKey == AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE) {
// accountDetails.put(p.mKey, det.getDetailString(p.mKey));
// } else {
accountDetails.put(p.mKey, det.getDetailString(p.mKey));
// }
}
// Preference pref = mPreferenceManager.findPreference(p.mKey);
......
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
package com.savoirfairelinux.sflphone.client;
import java.util.ArrayList;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.MenuItem;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.fragments.AccountCreationFragment;
import com.savoirfairelinux.sflphone.interfaces.AccountsInterface;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService;
public class AccountWizard extends Activity implements AccountsInterface {
static final String TAG = "AccountWizard";
public static final int ACCOUNT_CREATED = Activity.RESULT_OK;
ViewPager mViewPager;
private ISipService service;
private SectionsPagerAdapter mSectionsPagerAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wizard);
mViewPager = (ViewPager) findViewById(R.id.pager);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
Intent intent = new Intent(this, SipService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
/* activity finishes itself or is being killed by the system */
@Override
protected void onDestroy() {
/* stop the service, if no other bound user, no need to check if it is running */
unbindService(mConnection);
super.onDestroy();
}
/** Defines callbacks for service binding, passed to bindService() */
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder binder) {
service = ISipService.Stub.asInterface(binder);
mSectionsPagerAdapter = new SectionsPagerAdapter(AccountWizard.this, getFragmentManager());
mViewPager.setAdapter(mSectionsPagerAdapter);
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
}
};
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return true;
}
}
@Override
public void accountsChanged() {
// TODO Auto-generated method stub
}
@Override
public void accountStateChanged(Intent accountState) {
// TODO Auto-generated method stub
}
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
Context mContext;
final private int[] icon_res_id = { R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history };
ArrayList<Fragment> fragments;
public SectionsPagerAdapter(Context c, FragmentManager fm) {
super(fm);
mContext = c;
fragments = new ArrayList<Fragment>();
fragments.add(new AccountCreationFragment());
}
@Override
public Fragment getItem(int i) {
return fragments.get(i);
}
public String getClassName(int i) {
String name;
switch (i) {
case 0:
name = AccountCreationFragment.class.getName();
break;
default:
Log.e(TAG, "getClassName: unknown fragment position " + i);
return null;
}
// Log.w(TAG, "getClassName: name=" + name);
return name;
}
@Override
public int getCount() {
return 1;
}
public int getIconOf(int pos) {
return icon_res_id[pos];
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return mContext.getString(R.string.title_section0).toUpperCase();
default:
Log.e(TAG, "getPageTitle: unknown tab position " + position);
break;
}
return null;
}
}
}
......@@ -100,9 +100,6 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
private CharSequence mDrawerTitle;
private CharSequence mTitle;
// AccountSelectionAdapter mAdapter;
// private Spinner spinnerAccounts;
public static final int REQUEST_CODE_PREFERENCES = 1;
private static final int REQUEST_CODE_CALL = 2;
......
package com.savoirfairelinux.sflphone.fragments;
import java.util.HashMap;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.account.AccountDetail;
import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced;
import com.savoirfairelinux.sflphone.account.AccountDetailBasic;
import com.savoirfairelinux.sflphone.account.AccountDetailSrtp;
import com.savoirfairelinux.sflphone.account.AccountDetailTls;
public class AccountCreationFragment extends Fragment {
// Values for email and password at the time of the login attempt.
private String mAlias;
private String mHostname;
private String mUsername;
private String mPassword;
// UI references.
private EditText mAliasView;
private EditText mHostnameView;
private EditText mUsernameView;
private EditText mPasswordView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// mAdapter = new HistoryAdapter(getActivity(),new ArrayList<HashMap<String, String>>());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.frag_account_creation, parent, false);
mAliasView = (EditText) inflatedView.findViewById(R.id.alias);
mHostnameView = (EditText) inflatedView.findViewById(R.id.hostname);
mUsernameView = (EditText) inflatedView.findViewById(R.id.username);
mPasswordView = (EditText) inflatedView.findViewById(R.id.password);
inflatedView.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
attemptCreation();
}
});
return inflatedView;
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onStart() {
super.onStart();
}
/**
* Attempts to sign in or register the account specified by the login form. If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
public void attemptCreation() {
// Reset errors.
mAliasView.setError(null);
mPasswordView.setError(null);
// Store values at the time of the login attempt.
mAlias = mAliasView.getText().toString();
mHostname = mHostnameView.getText().toString();
mUsername = mUsernameView.getText().toString();
mPassword = mPasswordView.getText().toString();
boolean cancel = false;
View focusView = null;
// Check for a valid password.
if (TextUtils.isEmpty(mPassword)) {
mPasswordView.setError(getString(R.string.error_field_required));
focusView = mPasswordView;
cancel = true;
}
if (TextUtils.isEmpty(mUsername)) {
mUsernameView.setError(getString(R.string.error_field_required));
focusView = mUsernameView;
cancel = true;
}
if (TextUtils.isEmpty(mHostname)) {
mHostnameView.setError(getString(R.string.error_field_required));
focusView = mHostnameView;
cancel = true;
}
// Check for a valid email address.
if (TextUtils.isEmpty(mAlias)) {
mAliasView.setError(getString(R.string.error_field_required));
focusView = mAliasView;
cancel = true;
}
if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus();
} else {
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
initCreation();
}
}
private void initCreation() {
HashMap<String, String> accountDetails = new HashMap<String, String>();
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_TYPE, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_TYPE);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, mAlias);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, mHostname);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_USERNAME, mUsername);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, mPassword);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ROUTESET, "");
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_REALM, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_REALM);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ENABLE, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_ENABLE);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_PASSWORD, mPassword);
accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_USERAGENT, AccountDetailBasic.CONFIG_ACCOUNT_DEFAULT_USERAGENT);
accountDetails.put(AccountDetailAdvanced.CONFIG_LOCAL_PORT, AccountDetailAdvanced.CONFIG_DEFAULT_LOCAL_PORT);
accountDetails.put(AccountDetailAdvanced.CONFIG_LOCAL_INTERFACE, AccountDetailAdvanced.CONFIG_DEFAULT_INTERFACE);
accountDetails.put(AccountDetailAdvanced.CONFIG_PUBLISHED_PORT, AccountDetailAdvanced.CONFIG_DEFAULT_PUBLISHED_PORT);
accountDetails.put(AccountDetailAdvanced.CONFIG_PUBLISHED_ADDRESS, AccountDetailAdvanced.CONFIG_DEFAULT_ADDRESS);
accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_EXPIRE, AccountDetailAdvanced.CONFIG_DEFAULT_REGISTRATION_EXPIRE);
accountDetails.put(AccountDetailAdvanced.CONFIG_STUN_SERVER, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATUS, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_AUTOANSWER, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_ACCOUNT_DTMF_TYPE, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_KEEP_ALIVE_ENABLED, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_STUN_SERVER, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_PUBLISHED_SAMEAS_LOCAL, AccountDetailAdvanced.CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL);
accountDetails.put(AccountDetailAdvanced.CONFIG_RINGTONE_ENABLED, "false");
accountDetails.put(AccountDetailAdvanced.CONFIG_RINGTONE_PATH, "");
accountDetails.put(AccountDetailAdvanced.CONFIG_STUN_ENABLE, "false");
accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, "");
accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_RTP_FALLBACK, "");
accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_ENABLE, "");
accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, "");
accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS, "");
accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE, "");
accountDetails.put(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE, "");
accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_HELLO_HASH, "");
accountDetails.put(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_CIPHERS, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_METHOD, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_ENABLE, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_PASSWORD, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_PRIVATE_KEY_FILE, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_SERVER_NAME, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, "false");
accountDetails.put(AccountDetailTls.CONFIG_TLS_LISTENER_PORT, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_VERIFY_CLIENT, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_CERTIFICATE_FILE, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_CA_LIST_FILE, "");
accountDetails.put(AccountDetailTls.CONFIG_TLS_VERIFY_SERVER, "");
Bundle bundle = new Bundle();
bundle.putSerializable(AccountDetail.TAG, accountDetails);
Intent resultIntent = new Intent();
resultIntent.putExtras(bundle);
getActivity().setResult(Activity.RESULT_OK, resultIntent);
getActivity().finish();
}
private AlertDialog createCancelDialog() {
Activity ownerActivity = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity);
builder.setMessage("All parameters will be lost").setTitle("Account Creation").setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Activity activity = ((Dialog) dialog).getOwnerActivity();
activity.finish();
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* Terminate with no action */
}
});
AlertDialog alertDialog = builder.create();
alertDialog.setOwnerActivity(ownerActivity);
return alertDialog;
}
}
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
*
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -41,7 +42,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Environment;
import android.os.RemoteException;
import android.preference.Preference;
import android.preference.PreferenceCategory;
......@@ -49,6 +49,7 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.account.AccountDetail;
......@@ -57,8 +58,10 @@ import com.savoirfairelinux.sflphone.account.AccountDetailBasic;
import com.savoirfairelinux.sflphone.account.AccountDetailSrtp;
import com.savoirfairelinux.sflphone.account.AccountDetailTls;
import com.savoirfairelinux.sflphone.client.AccountPreferenceActivity;
import com.savoirfairelinux.sflphone.client.AccountWizard;
import com.savoirfairelinux.sflphone.client.SFLPhonePreferenceActivity;
import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
import com.savoirfairelinux.sflphone.model.Account;
import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
......@@ -71,10 +74,10 @@ public class AccountManagementFragment extends PreferenceFragment {
private SFLPhonePreferenceActivity sflphonePreferenceActivity;
private ISipService service = null;
ArrayList<AccountDetail.PreferenceEntry> basicDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> advancedDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> srtpDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> tlsDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> basicDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> advancedDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> srtpDetailKeys = null;
// ArrayList<AccountDetail.PreferenceEntry> tlsDetailKeys = null;
HashMap<String, Preference> accountPreferenceHashMap = null;
PreferenceScreen mRoot = null;
......@@ -87,10 +90,10 @@ public class AccountManagementFragment extends PreferenceFragment {
}
public AccountManagementFragment() {
basicDetailKeys = AccountDetailBasic.getPreferenceEntries();
// advancedDetailKeys = AccountDetailAdvanced.getPreferenceEntries();
// srtpDetailKeys = AccountDetailSrtp.getPreferenceEntries();
// tlsDetailKeys = AccountDetailTls.getPreferenceEntries();
// basicDetailKeys = AccountDetailBasic.getPreferenceEntries();
// advancedDetailKeys = AccountDetailAdvanced.getPreferenceEntries();
// srtpDetailKeys = AccountDetailSrtp.getPreferenceEntries();
// tlsDetailKeys = AccountDetailTls.getPreferenceEntries();
accountPreferenceHashMap = new HashMap<String, Preference>();
}
......@@ -111,7 +114,6 @@ public class AccountManagementFragment extends PreferenceFragment {
Log.e(TAG, "onCreate() service=" + service);
}
}
Log.w(TAG, "onCreate() service=" + service);
setPreferenceScreen(getAccountListPreferenceScreen());
......@@ -136,11 +138,15 @@ public class AccountManagementFragment extends PreferenceFragment {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case ACCOUNT_CREATE_REQUEST:
if (resultCode == AccountPreferenceActivity.result.ACCOUNT_CREATED) {
if (resultCode == AccountWizard.ACCOUNT_CREATED) {
Bundle bundle = data.getExtras();
Log.i(TAG, "Create account settings");
HashMap<String, String> accountDetails = new HashMap<String, String>();
accountDetails = (HashMap<String, String>) bundle.getSerializable(AccountDetail.TAG);
// if(accountDetails == null){
// Toast.makeText(getActivity(), "NUUUUL", Toast.LENGTH_SHORT).show();
// } else
// Toast.makeText(getActivity(), "OKKKK", Toast.LENGTH_SHORT).show();
createNewAccount(accountDetails);
}
break;
......@@ -152,7 +158,7 @@ public class AccountManagementFragment extends PreferenceFragment {
HashMap<String, String> accountDetails = new HashMap<String, String>();
accountDetails = (HashMap<String, String>) bundle.getSerializable(AccountDetail.TAG);
Preference accountScreen = accountPreferenceHashMap.get(accountID);
mRoot.removePreference(accountScreen);
accountPreferenceHashMap.remove(accountID);
......@@ -247,28 +253,23 @@ public class AccountManagementFragment extends PreferenceFragment {
private void launchAccountCreationActivity(Preference preference) {
Log.i(TAG, "Launch account creation activity");
Intent intent = preference.getIntent();
intent.putExtra(AccountPreferenceActivity.KEY_MODE, AccountPreferenceActivity.mode.CREATION_MODE);
startActivityForResult(intent, ACCOUNT_CREATE_REQUEST);
}
private void launchAccountEditActivity(Preference preference) {
Log.i(TAG, "Launch account edit activity");
Intent intent = preference.getIntent();
intent.putExtra(AccountPreferenceActivity.KEY_MODE, AccountPreferenceActivity.mode.EDITION_MODE);
Bundle bundle = intent.getExtras();
String accountID = bundle.getString("AccountID");
HashMap<String, String> preferenceMap = getAccountDetails(accountID);
AccountDetailBasic basicDetails = new AccountDetailBasic(preferenceMap);
AccountDetailAdvanced advancedDetails = new AccountDetailAdvanced(preferenceMap);
AccountDetailSrtp srtpDetails = new AccountDetailSrtp(preferenceMap);
AccountDetailTls tlsDetails = new AccountDetailTls(preferenceMap);
Account d = new Account(accountID, preferenceMap);
bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, basicDetails.getValuesOnly());
bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, advancedDetails.getValuesOnly());
bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, srtpDetails.getValuesOnly());
bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, tlsDetails.getValuesOnly());
bundle.putStringArrayList(AccountDetailBasic.BUNDLE_TAG, d.getBasicDetails().getValuesOnly());
bundle.putStringArrayList(AccountDetailAdvanced.BUNDLE_TAG, d.getAdvancedDetails().getValuesOnly());
bundle.putStringArrayList(AccountDetailSrtp.BUNDLE_TAG, d.getSrtpDetails().getValuesOnly());
bundle.putStringArrayList(AccountDetailTls.BUNDLE_TAG, d.getTlsDetails().getValuesOnly());
intent.putExtras(bundle);
......@@ -293,13 +294,6 @@ public class AccountManagementFragment extends PreferenceFragment {
HashMap<String, String> accountDetails = null;
try {
accountDetails = (HashMap<String, String>) service.getAccountDetails(accountID);
// ArrayList<Integer> tmp = (ArrayList<Integer>) service.getAudioCodecList(accountID);
// for(Integer i : tmp){
// Log.w(TAG,"Codec : "+i);
// }
// if (accountDetails.containsKey("TLS.negotiationTimeoutSec"))
// Log.i(TAG, "localinterface existe");
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
......@@ -313,11 +307,11 @@ public class AccountManagementFragment extends PreferenceFragment {
mRoot = getPreferenceManager().createPreferenceScreen(currentContext);
// Default account category
PreferenceCategory defaultAccountCat = new PreferenceCategory(currentContext);
defaultAccountCat.setTitle(R.string.default_account_category);
mRoot.addPreference(defaultAccountCat);
mRoot.addPreference(createAccountPreferenceScreen(DEFAULT_ACCOUNT_ID));
// PreferenceCategory defaultAccountCat = new PreferenceCategory(currentContext);
// defaultAccountCat.setTitle(R.string.default_account_category);
// mRoot.addPreference(defaultAccountCat);
//
// mRoot.addPreference(createAccountPreferenceScreen(DEFAULT_ACCOUNT_ID));
// Account list category
PreferenceCategory accountListCat = new PreferenceCategory(currentContext);
......@@ -327,7 +321,7 @@ public class AccountManagementFragment extends PreferenceFragment {
Preference createNewAccount = new Preference(currentContext);
createNewAccount.setTitle("Create New Account");
createNewAccount.setOnPreferenceClickListener(launchAccountCreationOnClick);
createNewAccount.setIntent(new Intent().setClass(getActivity(), AccountPreferenceActivity.class));
createNewAccount.setIntent(new Intent().setClass(getActivity(), AccountWizard.class));
mRoot.addPreference(createNewAccount);
ArrayList<String> accountList = getAccountList();
......
......@@ -31,9 +31,12 @@
package com.savoirfairelinux.sflphone.fragments;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
......@@ -54,15 +57,12 @@ public class DialingFragment extends Fragment {
private static final String TAG = DialingFragment.class.getSimpleName();
public static final String ARG_SECTION_NUMBER = "section_number";
ClearableEditText textField;
// private AccountSelectionSpinner mAccountSelectionSpinner;
// AccountSelectionAdapter mAdapter;
// AccountSelectionAdapter mAdapter;
private Callbacks mCallbacks = sDummyCallbacks;
// private Spinner spinnerAccounts;
// private Spinner spinnerAccounts;
/**
* A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
......@@ -118,8 +118,6 @@ public class DialingFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.frag_dialing, parent, false);
textField = (ClearableEditText) inflatedView.findViewById(R.id.textField);
((ImageButton) inflatedView.findViewById(R.id.buttonCall)).setOnClickListener(new OnClickListener() {
@Override
......@@ -157,6 +155,7 @@ public class DialingFragment extends Fragment {
return inflatedView;
}
@Override
public void onResume() {
super.onResume();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment