diff --git a/ring-android/app/src/main/java/cx/ring/fragments/AccountCreationFragment.java b/ring-android/app/src/main/java/cx/ring/fragments/AccountCreationFragment.java index 331527b3a77569975f11993fb4742e92945c6524..161d2b7a6087097c1360e70f903a0a7aedc7c367 100644 --- a/ring-android/app/src/main/java/cx/ring/fragments/AccountCreationFragment.java +++ b/ring-android/app/src/main/java/cx/ring/fragments/AccountCreationFragment.java @@ -17,11 +17,14 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; +import android.widget.ViewFlipper; + import cx.ring.views.PasswordEditText; public class AccountCreationFragment extends Fragment { @@ -39,6 +42,9 @@ public class AccountCreationFragment extends Fragment { private EditText mUsernameView; private PasswordEditText mPasswordView; private Spinner mAccountTypeView; + private ViewGroup mFieldFlipper; + private ViewGroup mFieldsSip; + private ViewGroup mFieldsRing; private Callbacks mCallbacks = sDummyCallbacks; private static Callbacks sDummyCallbacks = new Callbacks() { @@ -64,23 +70,45 @@ public class AccountCreationFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View inflatedView = inflater.inflate(R.layout.frag_account_creation, parent, false); + mFieldFlipper = (ViewGroup) inflatedView.findViewById(R.id.field_flipper); + mFieldsSip = (ViewGroup) inflatedView.findViewById(R.id.sip_fields); + mFieldsRing = (ViewGroup) inflatedView.findViewById(R.id.ring_fields); + mAliasView = (EditText) inflatedView.findViewById(R.id.alias); mHostnameView = (EditText) inflatedView.findViewById(R.id.hostname); mUsernameView = (EditText) inflatedView.findViewById(R.id.username); mPasswordView = (PasswordEditText) inflatedView.findViewById(R.id.password); mAccountTypeView = (Spinner) inflatedView.findViewById(R.id.account_type); + mAccountTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { + if (parent.getSelectedItem().toString().equals("RING")) { + mFieldsSip.setVisibility(View.GONE); + mFieldsRing.setVisibility(View.VISIBLE); + } else { + mFieldsSip.setVisibility(View.VISIBLE); + mFieldsRing.setVisibility(View.GONE); + } + } + public void onNothingSelected(AdapterView<?> parent) { + } + }); mPasswordView.getEdit_text().setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + mAccountType = mAccountTypeView.getSelectedItem().toString(); // if(actionId == EditorInfo.IME_ACTION_GO || event.getAction() == KeyEvent.KEYCODE_ENTER){ - mAlias = mAliasView.getText().toString(); - mHostname = mHostnameView.getText().toString(); - mUsername = mUsernameView.getText().toString(); - mPassword = mPasswordView.getText().toString(); - mAccountType = mAccountTypeView.getSelectedItem().toString(); - attemptCreation(); + if (mAccountType.equals("RING")) { + initCreation(); + } else { + mAlias = mAliasView.getText().toString(); + mHostname = mHostnameView.getText().toString(); + mUsername = mUsernameView.getText().toString(); + mPassword = mPasswordView.getText().toString(); + attemptCreation(); + } // } return true; @@ -89,12 +117,16 @@ public class AccountCreationFragment extends Fragment { inflatedView.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - mAlias = mAliasView.getText().toString(); - mHostname = mHostnameView.getText().toString(); - mUsername = mUsernameView.getText().toString(); - mPassword = mPasswordView.getText().toString(); - mAccountType = mAccountTypeView.getSelectedItem().toString(); - attemptCreation(); + mAccountType = mAccountTypeView.getSelectedItem().toString(); + if (mAccountType.equals("RING")) { + initCreation(); + } else { + mAlias = mAliasView.getText().toString(); + mHostname = mHostnameView.getText().toString(); + mUsername = mUsernameView.getText().toString(); + mPassword = mPasswordView.getText().toString(); + attemptCreation(); + } } }); @@ -179,12 +211,18 @@ public class AccountCreationFragment extends Fragment { private void initCreation() { try { - HashMap<String, String> accountDetails = (HashMap<String, String>) mCallbacks.getService().getAccountTemplate("SIP"); - 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_TYPE, mAccountType); + + HashMap<String, String> accountDetails = (HashMap<String, String>) mCallbacks.getService().getAccountTemplate(mAccountType); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_TYPE, mAccountType); + if (mAccountType.equals("RING")) { + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, "Ring"); + accountDetails.put(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME, "bootstrap.ring.cx"); + } else { + 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); + } createNewAccount(accountDetails); diff --git a/ring-android/app/src/main/java/cx/ring/model/account/Account.java b/ring-android/app/src/main/java/cx/ring/model/account/Account.java index b6eaee3c9ceca9a2ecc4efd91cdc638fdbca76f6..ceb65e717313db9a52c3b0b99333bee811412677 100644 --- a/ring-android/app/src/main/java/cx/ring/model/account/Account.java +++ b/ring-android/app/src/main/java/cx/ring/model/account/Account.java @@ -92,6 +92,10 @@ public class Account extends java.util.Observable implements Parcelable { return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_TYPE).equals("SIP"); } + public Boolean isRing() { + return basicDetails.getDetailString(AccountDetailBasic.CONFIG_ACCOUNT_TYPE).equals("RING"); + } + public void setAlias(String alias) { basicDetails.setDetailString(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS, alias); } diff --git a/ring-android/app/src/main/res/layout/frag_account_creation.xml b/ring-android/app/src/main/res/layout/frag_account_creation.xml index 05829b978ab6cc9de23f1f941b35a3fcd8ec8b67..b8af89dcb434dde83cd7dd789708671d28a641e5 100644 --- a/ring-android/app/src/main/res/layout/frag_account_creation.xml +++ b/ring-android/app/src/main/res/layout/frag_account_creation.xml @@ -2,58 +2,104 @@ <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" > + android:layout_height="match_parent"> <LinearLayout style="@style/AccountFormContainer" - android:orientation="vertical" > + android:orientation="vertical" + android:descendantFocusability="beforeDescendants" + android:focusableInTouchMode="true" > - <Spinner - android:id="@+id/account_type" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:entries="@array/accountType" - android:typeface="monospace" /> - - <EditText - android:id="@+id/alias" + <LinearLayout + android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/prompt_alias" - android:singleLine="true" - android:typeface="monospace" > + android:gravity="center_vertical"> - <requestFocus /> - </EditText> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/account_type" + android:id="@+id/textView3" + android:layout_marginRight="16dp" /> - <EditText - android:id="@+id/hostname" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/prompt_hostname" - android:singleLine="true" - android:typeface="monospace" > - </EditText> + <Spinner + android:id="@+id/account_type" + android:layout_width="match_parent" + android:layout_height="52dp" +android:minHeight="52dp" + android:entries="@array/accountType" + android:typeface="monospace" /> - <EditText - android:id="@+id/username" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/prompt_username" - android:singleLine="true" - android:typeface="monospace" /> + </LinearLayout> - <cx.ring.views.PasswordEditText - android:id="@+id/password" + <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/prompt_password" - android:imeActionLabel="@string/action_create_short" - android:imeOptions="actionGo" - android:inputType="textPassword" - android:singleLine="true" - android:typeface="sans" /> + android:id="@+id/field_flipper" + > + + <LinearLayout + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/sip_fields" + android:visibility="gone"> + + <EditText + android:id="@+id/alias" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_alias" + android:singleLine="true" + android:typeface="monospace" > + </EditText> + + <EditText + android:id="@+id/hostname" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_hostname" + android:singleLine="true" + android:typeface="monospace" > + </EditText> + + <EditText + android:id="@+id/username" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_username" + android:singleLine="true" + android:typeface="monospace" /> + + <cx.ring.views.PasswordEditText + android:id="@+id/password" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:hint="@string/prompt_password" + android:imeActionLabel="@string/action_create_short" + android:imeOptions="actionGo" + android:inputType="textPassword" + android:singleLine="true" + android:typeface="sans" /> + </LinearLayout> + + <LinearLayout + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/ring_fields"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/help_ring" + android:id="@+id/textView" + android:singleLine="false" /> + </LinearLayout> + </FrameLayout> <Button android:id="@+id/create_button" diff --git a/ring-android/app/src/main/res/layout/item_account_pref.xml b/ring-android/app/src/main/res/layout/item_account_pref.xml index 24bd7a4bea2e31b319a5ffc9124d6459c9c48a02..8785b1073fea1a36aa22c4fb47659128ecb55a45 100644 --- a/ring-android/app/src/main/res/layout/item_account_pref.xml +++ b/ring-android/app/src/main/res/layout/item_account_pref.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@id/container" + android:id="@+id/account_container" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:padding="4dp" > + android:layout_height="72dp" + android:minHeight="72dp"> <ImageView android:id="@+id/drag_handle" @@ -11,34 +11,36 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_alignParentLeft="true" - android:layout_marginLeft="10dp" + android:layout_marginLeft="16dp" android:src="@drawable/handle"/> <TextView android:id="@+id/account_alias" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toRightOf="@+id/drag_handle" android:layout_alignParentTop="true" - android:layout_marginBottom="4dp" - android:layout_marginLeft="4dp" - android:textAppearance="?android:attr/textAppearanceLarge" /> + android:layout_marginLeft="72dp" + android:text="Acount name" + android:textAppearance="@style/ListPrimary" + android:layout_alignParentLeft="true" + android:layout_marginTop="16dp" /> <TextView android:id="@+id/account_host" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toRightOf="@+id/drag_handle" android:layout_below="@+id/account_alias" - android:layout_marginLeft="4dp" - android:textAppearance="?android:attr/textAppearanceSmall" /> + android:layout_marginLeft="72dp" + android:textAppearance="@style/ListSecondary" + android:text="hostname" + android:layout_alignParentLeft="true" /> <CheckBox android:id="@+id/account_checked" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" - android:layout_marginRight="10dp" + android:layout_marginRight="16dp" android:focusable="false" android:layout_centerVertical="true" /> diff --git a/ring-android/app/src/main/res/values-fr/strings.xml b/ring-android/app/src/main/res/values-fr/strings.xml index fe70eea3aa0021135f82627218876bfe5729e692..5d4f89fb691518c7abebd73e1bd593afa2d653ea 100644 --- a/ring-android/app/src/main/res/values-fr/strings.xml +++ b/ring-android/app/src/main/res/values-fr/strings.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2004-2014 Savoir-Faire Linux Inc. Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> @@ -78,7 +77,7 @@ as that of the covered work. <!-- Home Fragment --> <plurals name="home_conferences_title"> <item quantity="zero">No Conversation</item> - <item quantity="one">%d Conversation</item> + <item quantity="one">%d Conversation</item> <item quantity="other">%d Conversations</item> </plurals> <string name="home_transfering">Transfert de %1$s à %1$s</string> @@ -113,10 +112,14 @@ as that of the covered work. <string name="web_site">Site web</string> <string name="help_gestures"> This view will help users with different interactions during calls. Different actions will be described; Long press, fling, swype etc.</string> - <!-- combobox protocole --> - <string-array name="accountType"> - <item>SIP</item> - <item>IAX</item> - </string-array> + <!-- combobox protocole --> + <string-array name="accountType"> + <item>RING</item> + <item>SIP</item> + <item>IAX</item> + </string-array> + <string name="help_ring">Les comptes Ring vous permettent de discuter de manière sécurisée en connexion directe de pair à pair à l\'aide d\'un réseau distribué.\n\n +En créant un compte Ring, une nouvelle clef RSA de 4096 bits sera générée. L\'identifiant de la clef publique devient alors votre ID Ring.</string> + <string name="account_type">Type de compte</string> </resources> diff --git a/ring-android/app/src/main/res/values/strings.xml b/ring-android/app/src/main/res/values/strings.xml index 9a1c9ccc5825118c0ec3464cb5ae873f92b88118..93ca32103acb6db951e68933cc9dcef4d38b86ff 100644 --- a/ring-android/app/src/main/res/values/strings.xml +++ b/ring-android/app/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- +<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2004-2014 Savoir-Faire Linux Inc. Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> @@ -34,7 +33,7 @@ as that of the covered work. <string name="app_name">Ring</string> - <!-- SFLPhoneActivity --> + <!-- RingActivity --> <string name="close_msg">Press back again to leave</string> <string name="title_section0">Dial</string> <string name="title_section1">Call</string> @@ -71,7 +70,7 @@ as that of the covered work. <string name="hist_no_history">No history</string> <string name="hist_in_calls">In:%1$d</string> <string name="hist_out_calls">Out:%1$d</string> - + <!-- DetailsHistory Fragment --> <string name="detail_hist_call_number">Call %1$s</string> @@ -114,10 +113,15 @@ as that of the covered work. <string name="web_site">Website</string> <string name="help_gestures"> This view will help users with different interactions during calls. Different actions will be described; Long press, fling, swype etc.</string> - <!-- combobox protocol --> - <string-array name="accountType"> - <item>SIP</item> - <item>IAX</item> - </string-array> + <!-- combobox protocol --> + <string-array name="accountType"> + <item>RING</item> + <item>SIP</item> + <item>IAX</item> + </string-array> + <string name="help_ring">Ring accounts allow you to reach people securely in peer to peer through a fully distributed network.\n\n +When creating a Ring account, a new 4096 bits RSA key pair is generated. The hash of the public key then becomes your Ring ID. + </string> + <string name="account_type">Account type</string> </resources>