Add phone number in account creation

This commit is contained in:
Margaux Clerc 2016-07-27 16:00:21 +02:00
parent 250c719279
commit 22eed4eb6f
18 changed files with 1346 additions and 162 deletions

View file

@ -26,13 +26,96 @@
android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/phone_number_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginTop="30dp"
android:orientation="vertical">
<Button
android:id="@+id/select_country"
style="@style/font8"
android:text="@string/select_your_country"
android:background="@drawable/resizable_assistant_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/phone_number_label"
android:text="@string/phone_number"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/dial_code"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="phone"
android:layout_marginRight="10dp"
android:layout_width="50dp"
android:layout_height="40dp"
android:singleLine="true"/>
<EditText
android:id="@+id/phone_number"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:contentDescription="@string/content_description_phone_number_field"
android:inputType="phone"
android:layout_width="match_parent"
android:layout_height="40dp"
android:singleLine="true"/>
</LinearLayout>
<TextView
android:id="@+id/phone_number_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
<TextView
android:id="@+id/sip_uri"
style="@style/font9"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<CheckBox
android:id="@+id/use_username"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Don't use phone number as username"/>
<CheckBox
android:id="@+id/use_email"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Don't use phone number for account activation"/>
<LinearLayout
android:id="@+id/username_layout"
android:visibility="gone"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -66,115 +149,124 @@
</LinearLayout>
<LinearLayout
android:id="@+id/email_layout"
android:visibility="gone"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/password_label"
style="@style/font13"
android:text="@string/password"
android:textAllCaps="true"
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:textCursorDrawable="@null"
<TextView
android:id="@+id/password_label"
style="@style/font13"
android:text="@string/password"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/password_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
android:layout_height="wrap_content">
<TextView
android:id="@+id/password_error"
android:text="@string/error"
style="@style/font20"
<TextView
android:id="@+id/confirm_password_label"
android:text="@string/confirm_password"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/confirm_password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:contentDescription="@string/content_description_confirm_password_field"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/confirm_password_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
android:layout_height="wrap_content">
</LinearLayout>
<TextView
android:id="@+id/email_label"
android:text="@string/email"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textEmailAddress"
android:contentDescription="@string/content_description_email_field"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/confirm_password_label"
android:text="@string/confirm_password"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/email_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
<EditText
android:id="@+id/confirm_password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:contentDescription="@string/content_description_confirm_password_field"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/confirm_password_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/email_label"
android:text="@string/email"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/email"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textEmailAddress"
android:contentDescription="@string/content_description_email_field"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/email_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/assistant_create"
android:text="@string/assistant_create_account"
android:text="@string/assistant_continue"
android:background="@drawable/assistant_button"
android:textColor="@drawable/assistant_button_text_color"
style="@style/font8"

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:text="@string/assistant_create_account"
style="@style/font6"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="@string/assistant_create_account_part_2"
style="@style/font11"
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="@string/assistant_validate_code"
style="@style/font11"
android:paddingTop="10dp"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/assistant_code"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:contentDescription="@string/content_description_activation_code_field"
android:inputType="text|textNoSuggestions"
android:gravity="center_vertical|center_horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:singleLine="true"/>
<Button
android:id="@+id/assistant_check"
android:text="@string/assistant_activate"
android:background="@drawable/assistant_button"
android:textColor="@drawable/assistant_button_text_color"
style="@style/font8"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_marginTop="20dp"/>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/assistant_choose_country"
style="@style/font6"
android:singleLine="true"
android:gravity="center_vertical|center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="@+id/search_country"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:textColor="@android:color/black"
android:background="@drawable/resizable_textfield"
android:gravity="center"
android:inputType="textPersonName"/>
<ImageView
android:id="@+id/clearSearchField"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/clean_field_default"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:paddingLeft="5dp"
android:paddingRight="5dp"/>
</RelativeLayout>
<ListView
android:id="@+id/countryList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/colorE"
android:cacheColorHint="@color/transparent"
android:dividerHeight="1dp" />
</LinearLayout>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="40dp"
android:padding="5dp">
<TextView
android:id="@+id/country_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="@style/font6"/>
<TextView
android:id="@+id/country_prefix"
style="@style/font6"
android:paddingLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>

246
res/raw/countries.json Executable file
View file

@ -0,0 +1,246 @@
[
{"name":"Afghanistan","dial_code":"+93","code":"AF","maxNum":"9"},
{"name":"Albania","dial_code":"+355","code":"AL","maxNum":"9"},
{"name":"Algeria","dial_code":"+213","code":"DZ","maxNum":"9"},
{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS","maxNum":"10"},
{"name":"Andorra","dial_code":"+376","code":"AD","maxNum":"6"},
{"name":"Angola","dial_code":"+244","code":"AO","maxNum":"9"},
{"name":"Anguilla","dial_code":"+1 264","code":"AI","maxNum":"10"},
{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG","maxNum":"10"},
{"name":"Argentina","dial_code":"+54","code":"AR","maxNum":"10"},
{"name":"Armenia","dial_code":"+374","code":"AM","maxNum":"8"},
{"name":"Aruba","dial_code":"+297","code":"AW","maxNum":"7"},
{"name":"Australia","dial_code":"+61","code":"AU","maxNum":"9"},
{"name":"Austria","dial_code":"+43","code":"AT","maxNum":"10"},
{"name":"Azerbaijan","dial_code":"+994","code":"AZ","maxNum":"9"},
{"name":"Bahamas","dial_code":"+1 242","code":"BS","maxNum":"10"},
{"name":"Bahrain","dial_code":"+973","code":"BH","maxNum":"8"},
{"name":"Bangladesh","dial_code":"+880","code":"BD","maxNum":"10"},
{"name":"Barbados","dial_code":"+1 246","code":"BB","maxNum":"10"},
{"name":"Belarus","dial_code":"+375","code":"BY","maxNum":"9"},
{"name":"Belgium","dial_code":"+32","code":"BE","maxNum":"9"},
{"name":"Belize","dial_code":"+501","code":"BZ","maxNum":"7"},
{"name":"Benin","dial_code":"+229","code":"BJ","maxNum":"8"},
{"name":"Bermuda","dial_code":"+1 441","code":"BM","maxNum":"10"},
{"name":"Bhutan","dial_code":"+975","code":"BT","maxNum":"8"},
{"name":"Bolivia","dial_code":"+591","code":"BO","maxNum":"8"},
{"name":"Bosnia and Herzegovina","dial_code":"+387","code":"BA","maxNum":"8"},
{"name":"Botswana","dial_code":"+267","code":"BW","maxNum":"8"},
{"name":"Brazil","dial_code":"+55","code":"BR","maxNum":"10"},
{"name":"Brunei Darussalam","dial_code":"+673","code":"BN","maxNum":"7"},
{"name":"British Indian Ocean Territory","dial_code":"+246","code":"IO","maxNum":"0"},
{"name":"Bulgaria","dial_code":"+359","code":"BG","maxNum":"9"},
{"name":"Burkina Faso","dial_code":"+226","code":"BF","maxNum":"8"},
{"name":"Burundi","dial_code":"+257","code":"BI","maxNum":"8"},
{"name":"Cambodia","dial_code":"+855","code":"KH","maxNum":"9"},
{"name":"Cameroon","dial_code":"+237","code":"CM","maxNum":"8"},
{"name":"Canada","dial_code":"+1","code":"CA","maxNum":"10"},
{"name":"Cape Verde","dial_code":"+238","code":"CV","maxNum":"7"},
{"name":"Cayman Islands","dial_code":"+ 345","code":"KY","maxNum":"10"},
{"name":"Central African Republic","dial_code":"+236","code":"CF","maxNum":"8"},
{"name":"Chad","dial_code":"+235","code":"TD","maxNum":"8"},
{"name":"Chile","dial_code":"+56","code":"CL","maxNum":"9"},
{"name":"China","dial_code":"+86","code":"CN","maxNum":"11"},
{"name":"Christmas Island","dial_code":"+61","code":"CX","maxNum":"0"},
{"name":"Colombia","dial_code":"+57","code":"CO","maxNum":"10"},
{"name":"Comoros","dial_code":"+269","code":"KM","maxNum":"7"},
{"name":"Congo","dial_code":"+242","code":"CG","maxNum":"9"},
{"name":"Congo,Democratic Republic","dial_code":"+243","code":"CD","maxNum":"9"},
{"name":"Cook Islands","dial_code":"+682","code":"CK","maxNum":"5"},
{"name":"Costa Rica","dial_code":"+506","code":"CR","maxNum":"8"},
{"name":"Cote d'Ivoire","dial_code":"+225","code":"CI","maxNum":"8"},
{"name":"Croatia","dial_code":"+385","code":"HR","maxNum":"9"},
{"name":"Cuba","dial_code":"+53","code":"CU","maxNum":"8"},
{"name":"Cyprus","dial_code":"+537","code":"CY","maxNum":"8"},
{"name":"Czech Republic","dial_code":"+420","code":"CZ","maxNum":"9"},
{"name":"Denmark","dial_code":"+45","code":"DK","maxNum":"8"},
{"name":"Djibouti","dial_code":"+253","code":"DJ","maxNum":"8"},
{"name":"Dominica","dial_code":"+1 767","code":"DM","maxNum":"10"},
{"name":"Dominican Republic","dial_code":"+1 849","code":"DO","maxNum":"10"},
{"name":"Ecuador","dial_code":"+593","code":"EC","maxNum":"9"},
{"name":"Egypt","dial_code":"+20","code":"EG","maxNum":"10"},
{"name":"El Salvador","dial_code":"+503","code":"SV","maxNum":"8"},
{"name":"Equatorial Guinea","dial_code":"+240","code":"GQ","maxNum":"9"},
{"name":"Eritrea","dial_code":"+291","code":"ER","maxNum":"7"},
{"name":"Estonia","dial_code":"+372","code":"EE","maxNum":"8"},
{"name":"Ethiopia","dial_code":"+251","code":"ET","maxNum":"9"},
{"name":"Falkland Islands","dial_code":"+500","code":"FK","maxNum":"5"},
{"name":"Faroe Islands","dial_code":"+298","code":"FO","maxNum":"6"},
{"name":"Fiji","dial_code":"+679","code":"FJ","maxNum":"7"},
{"name":"Finland","dial_code":"+358","code":"FI","maxNum":"9"},
{"name":"France","dial_code":"+33","code":"FR","maxNum":"9"},
{"name":"French Guiana","dial_code":"+594","code":"GF","maxNum":"9"},
{"name":"French Polynesia","dial_code":"+689","code":"PF","maxNum":"6"},
{"name":"Gabon","dial_code":"+241","code":"GA","maxNum":"8"},
{"name":"Gambia","dial_code":"+220","code":"GM","maxNum":"7"},
{"name":"Georgia","dial_code":"+995","code":"GE","maxNum":"9"},
{"name":"Germany","dial_code":"+49","code":"DE","maxNum":"11"},
{"name":"Ghana","dial_code":"+233","code":"GH","maxNum":"9"},
{"name":"Gibraltar","dial_code":"+350","code":"GI","maxNum":"8"},
{"name":"Greece","dial_code":"+30","code":"GR","maxNum":"10"},
{"name":"Greenland","dial_code":"+299","code":"GL","maxNum":"6"},
{"name":"Grenada","dial_code":"+1 473","code":"GD","maxNum":"10"},
{"name":"Guadeloupe","dial_code":"+590","code":"GP","maxNum":"9"},
{"name":"Guam","dial_code":"+1 671","code":"GU","maxNum":"10"},
{"name":"Guatemala","dial_code":"+502","code":"GT","maxNum":"8"},
{"name":"Guinea","dial_code":"+224","code":"GN","maxNum":"8"},
{"name":"Guinea-Bissau","dial_code":"+245","code":"GW","maxNum":"7"},
{"name":"Guyana","dial_code":"+595","code":"GY","maxNum":"7"},
{"name":"Haiti","dial_code":"+509","code":"HT","maxNum":"8"},
{"name":"Honduras","dial_code":"+504","code":"HN","maxNum":"8"},
{"name":"Hong Kong","dial_code":"+852","code":"HK","maxNum":"8"},
{"name":"Hungary","dial_code":"+36","code":"HU","maxNum":"9"},
{"name":"Iceland","dial_code":"+354","code":"IS","maxNum":"9"},
{"name":"India","dial_code":"+91","code":"IN","maxNum":"10"},
{"name":"Indonesia","dial_code":"+62","code":"ID","maxNum":"10"},
{"name":"Iran, Islamic Republic of","dial_code":"+98","code":"IR","maxNum":"10"},
{"name":"Iraq","dial_code":"+964","code":"IQ","maxNum":"10"},
{"name":"Ireland","dial_code":"+353","code":"IE","maxNum":"9"},
{"name":"Israel","dial_code":"+972","code":"IL","maxNum":"9"},
{"name":"Italy","dial_code":"+39","code":"IT","maxNum":"10"},
{"name":"Jamaica","dial_code":"+1 876","code":"JM","maxNum":"10"},
{"name":"Japan","dial_code":"+81","code":"JP","maxNum":"10"},
{"name":"Jordan","dial_code":"+962","code":"JO","maxNum":"9"},
{"name":"Kazakhstan","dial_code":"+7 7","code":"KZ","maxNum":"10"},
{"name":"Kenya","dial_code":"+254","code":"KE","maxNum":"9"},
{"name":"Kiribati","dial_code":"+686","code":"KI","maxNum":"5"},
{"name":"Korea, People's Rep.","dial_code":"+850","code":"KP","maxNum":"12"},
{"name":"Korea, Republic of","dial_code":"+82","code":"KR","maxNum":"12"},
{"name":"Kuwait","dial_code":"+965","code":"KW","maxNum":"8"},
{"name":"Kyrgyzstan","dial_code":"+996","code":"KG","maxNum":"9"},
{"name":"Lao People's Democratic Rep.","dial_code":"+856","code":"LA","maxNum":"10"},
{"name":"Latvia","dial_code":"+371","code":"LV","maxNum":"8"},
{"name":"Lebanon","dial_code":"+961","code":"LB","maxNum":"7"},
{"name":"Lesotho","dial_code":"+266","code":"LS","maxNum":"8"},
{"name":"Libyan Arab Jamahiriya","dial_code":"+218","code":"LY","maxNum":"8"},
{"name":"Liberia","dial_code":"+231","code":"LR","maxNum":"8"},
{"name":"Liechtenstein","dial_code":"+423","code":"LI","maxNum":"7"},
{"name":"Lithuania","dial_code":"+370","code":"LT","maxNum":"8"},
{"name":"Luxembourg","dial_code":"+352","code":"LU","maxNum":"9"},
{"name":"Macao","dial_code":"+853","code":"MO","maxNum":"8"},
{"name":"Macedonia","dial_code":"+389","code":"MK","maxNum":"8"},
{"name":"Micronesia","dial_code":"+691","code":"FM","maxNum":"7"},
{"name":"Madagascar","dial_code":"+261","code":"MG","maxNum":"9"},
{"name":"Malawi","dial_code":"+265","code":"MW","maxNum":"9"},
{"name":"Malaysia","dial_code":"+60","code":"MY","maxNum":"9"},
{"name":"Maldives","dial_code":"+960","code":"MV","maxNum":"7"},
{"name":"Mali","dial_code":"+223","code":"ML","maxNum":"8"},
{"name":"Malta","dial_code":"+356","code":"MT","maxNum":"8"},
{"name":"Marshall Islands","dial_code":"+692","code":"MH","maxNum":"7"},
{"name":"Martinique","dial_code":"+596","code":"MQ","maxNum":"9"},
{"name":"Mauritania","dial_code":"+222","code":"MR","maxNum":"8"},
{"name":"Mauritius","dial_code":"+230","code":"MU","maxNum":"7"},
{"name":"Mayotte","dial_code":"+262","code":"YT","maxNum":"9"},
{"name":"Mexico","dial_code":"+52","code":"MX","maxNum":"10"},
{"name":"Moldova, Republic of","dial_code":"+373","code":"MD","maxNum":"8"},
{"name":"Monaco","dial_code":"+377","code":"MC","maxNum":"8"},
{"name":"Mongolia","dial_code":"+976","code":"MN","maxNum":"8"},
{"name":"Montenegro","dial_code":"+382","code":"ME","maxNum":"8"},
{"name":"Montserrat","dial_code":"+1664","code":"MS","maxNum":"10"},
{"name":"Morocco","dial_code":"+212","code":"MA","maxNum":"9"},
{"name":"Mozambique","dial_code":"+258","code":"MZ","maxNum":"9"},
{"name":"Myanmar","dial_code":"+95","code":"MM","maxNum":"8"},
{"name":"Namibia","dial_code":"+264","code":"NA","maxNum":"9"},
{"name":"Nauru","dial_code":"+674","code":"NR","maxNum":"7"},
{"name":"Nepal","dial_code":"+977","code":"NP","maxNum":"10"},
{"name":"Netherlands","dial_code":"+31","code":"NL","maxNum":"9"},
{"name":"Netherlands Antilles","dial_code":"+599","code":"AN","maxNum":"0"},
{"name":"New Caledonia","dial_code":"+687","code":"NC","maxNum":"6"},
{"name":"New Zealand","dial_code":"+64","code":"NZ","maxNum":"10"},
{"name":"Nicaragua","dial_code":"+505","code":"NI","maxNum":"8"},
{"name":"Niger","dial_code":"+227","code":"NE","maxNum":"8"},
{"name":"Nigeria","dial_code":"+234","code":"NG","maxNum":"10"},
{"name":"Niue","dial_code":"+683","code":"NU","maxNum":"4"},
{"name":"Norfolk Island","dial_code":"+672","code":"NF","maxNum":"5"},
{"name":"Northern Mariana Islands","dial_code":"+1 670","code":"MP","maxNum":"10"},
{"name":"Norway","dial_code":"+47","code":"NO","maxNum":"8"},
{"name":"Oman","dial_code":"+968","code":"OM","maxNum":"8"},
{"name":"Pakistan","dial_code":"+92","code":"PK","maxNum":"10"},
{"name":"Palau","dial_code":"+680","code":"PW","maxNum":"7"},
{"name":"Palestine","dial_code":"+970","code":"PS","maxNum":"9"},
{"name":"Panama","dial_code":"+507","code":"PA","maxNum":"8"},
{"name":"Papua New Guinea","dial_code":"+675","code":"PG","maxNum":"8"},
{"name":"Paraguay","dial_code":"+595","code":"PY","maxNum":"9"},
{"name":"Peru","dial_code":"+51","code":"PE","maxNum":"9"},
{"name":"Philippines","dial_code":"+63","code":"PH","maxNum":"10"},
{"name":"Poland","dial_code":"+48","code":"PL","maxNum":"9"},
{"name":"Portugal","dial_code":"+351","code":"PT","maxNum":"9"},
{"name":"Puerto Rico","dial_code":"+1 939","code":"PR","maxNum":"10"},
{"name":"Qatar","dial_code":"+974","code":"QA","maxNum":"8"},
{"name":"Romania","dial_code":"+40","code":"RO","maxNum":"9"},
{"name":"Russian Federation","dial_code":"+7","code":"RU","maxNum":"10"},
{"name":"Rwanda","dial_code":"+250","code":"RW","maxNum":"9"},
{"name":"Réunion Island","dial_code":"+262","code":"RE","maxNum":"9"},
{"name":"Saint Barthélemy","dial_code":"+590","code":"BL","maxNum":"0"},
{"name":"Saint Helena","dial_code":"+290","code":"SH","maxNum":"4"},
{"name":"Saint Kitts and Nevis","dial_code":"+1 869","code":"KN","maxNum":"10"},
{"name":"Saint Lucia","dial_code":"+1 758","code":"LC","maxNum":"10"},
{"name":"Saint Martin","dial_code":"+590","code":"MF","maxNum":"0"},
{"name":"Saint Pierre and Miquelon","dial_code":"+508","code":"PM","maxNum":"6"},
{"name":"Saint Vincent","dial_code":"+1 784","code":"VC","maxNum":"10"},
{"name":"Sao Tome and Principe","dial_code":"+239","code":"ST","maxNum":"7"},
{"name":"Somalia","dial_code":"+252","code":"SO","maxNum":"8"},
{"name":"Svalbard and Jan Mayen","dial_code":"+47","code":"SJ","maxNum":"0"},
{"name":"Syrian Arab Republic","dial_code":"+963","code":"SY","maxNum":"9"},
{"name":"Samoa","dial_code":"+685","code":"WS","maxNum":"7"},
{"name":"San Marino","dial_code":"+378","code":"SM","maxNum":"10"},
{"name":"Saudi Arabia","dial_code":"+966","code":"SA","maxNum":"9"},
{"name":"Senegal","dial_code":"+221","code":"SN","maxNum":"9"},
{"name":"Serbia","dial_code":"+381","code":"RS","maxNum":"9"},
{"name":"Seychelles","dial_code":"+248","code":"SC","maxNum":"7"},
{"name":"Sierra Leone","dial_code":"+232","code":"SL","maxNum":"8"},
{"name":"Singapore","dial_code":"+65","code":"SG","maxNum":"8"},
{"name":"Slovakia","dial_code":"+421","code":"SK","maxNum":"9"},
{"name":"Slovenia","dial_code":"+386","code":"SI","maxNum":"8"},
{"name":"Solomon Islands","dial_code":"+677","code":"SB","maxNum":"7"},
{"name":"South Africa","dial_code":"+27","code":"ZA","maxNum":"9"},
{"name":"South Georgia Islands","dial_code":"+500","code":"GS","maxNum":"0"},
{"name":"Spain","dial_code":"+34","code":"ES","maxNum":"9"},
{"name":"Sri Lanka","dial_code":"+94","code":"LK","maxNum":"9"},
{"name":"Sudan","dial_code":"+249","code":"SD","maxNum":"9"},
{"name":"Suriname","dial_code":"+597","code":"SR","maxNum":"7"},
{"name":"Swaziland","dial_code":"+268","code":"SZ","maxNum":"8"},
{"name":"Sweden","dial_code":"+46","code":"SE","maxNum":"9"},
{"name":"Switzerland","dial_code":"+41","code":"CH","maxNum":"9"},
{"name":"Taiwan","dial_code":"+886","code":"TW","maxNum":"9"},
{"name":"Tajikistan","dial_code":"+992","code":"TJ","maxNum":"9"},
{"name":"Tanzania, United Republic of","dial_code":"+255","code":"TZ","maxNum":"9"},
{"name":"Thailand","dial_code":"+66","code":"TH","maxNum":"9"},
{"name":"Togo","dial_code":"+228","code":"TG","maxNum":"8"},
{"name":"Tokelau","dial_code":"+690","code":"TK","maxNum":"4"},
{"name":"Tonga","dial_code":"+676","code":"TO","maxNum":"5"},
{"name":"Trinidad and Tobago","dial_code":"+1 868","code":"TT","maxNum":"10"},
{"name":"Tunisia","dial_code":"+216","code":"TN","maxNum":"8"},
{"name":"Turkey","dial_code":"+90","code":"TR","maxNum":"10"},
{"name":"Turkmenistan","dial_code":"+993","code":"TM","maxNum":"8"},
{"name":"Turks and Caicos Islands","dial_code":"+1 649","code":"TC","maxNum":"7"},
{"name":"Tuvalu","dial_code":"+688","code":"TV","maxNum":"5"},
{"name":"Uganda","dial_code":"+256","code":"UG","maxNum":"9"},
{"name":"Ukraine","dial_code":"+380","code":"UA","maxNum":"9"},
{"name":"United Arab Emirates","dial_code":"+971","code":"AE","maxNum":"9"},
{"name":"United Kingdom","dial_code":"+44","code":"GB","maxNum":"10"},
{"name":"United States","dial_code":"+1","code":"US","maxNum":"10"},
{"name":"Uruguay","dial_code":"+598","code":"UY","maxNum":"8"},
{"name":"Uzbekistan","dial_code":"+998","code":"UZ","maxNum":"9"},
{"name":"Vanuatu","dial_code":"+678","code":"VU","maxNum":"7"},
{"name":"Venezuela","dial_code":"+58","code":"VE","maxNum":"10"},
{"name":"VietNam","dial_code":"+84","code":"VN","maxNum":"9"},
{"name":"Wallis and Futuna","dial_code":"+681","code":"WF","maxNum":"5"},
{"name":"Yemen","dial_code":"+967","code":"YE","maxNum":"9"},
{"name":"Zambia","dial_code":"+260","code":"ZM","maxNum":"9"},
{"name":"Zimbabwe","dial_code":"+263","code":"ZW","maxNum":"9"},
{"name":"Cocos (Keeling) Islands","dial_code":"+61","code":"CC","maxNum":"0"},
{"name":"Guernsey","dial_code":"+44","code":"GG","maxNum":"0"},
{"name":"Holy See (Vatican City State)","dial_code":"+379","code":"VA","maxNum":"0"},
{"name":"Isle of Man","dial_code":"+44","code":"IM","maxNum":"0"},
{"name":"Jersey","dial_code":"+44","code":"JE","maxNum":"0"},
{"name":"Pitcairn","dial_code":"+872","code":"PN","maxNum":"0"},
{"name":"Timor-Leste","dial_code":"+670","code":"TL","maxNum":"0"},
{"name":"Virgin Islands, British","dial_code":"+1 284","code":"VG","maxNum":"0"},
{"name":"Virgin Islands, U.S.","dial_code":"+1 340","code":"VI","maxNum":"0"}]

View file

@ -33,6 +33,9 @@ ec_calibrator_cool_tones=1
[misc]
max_calls=10
[app]
activation_code_length=4
[in-app-purchase]
server_url=https://www.linphone.org/xmlrpc.php
purchasable_items_ids=test_account_subscription

View file

@ -9,6 +9,7 @@
<string name="sync_mimetype">vnd.android.cursor.item/org.linphone.profile</string> <!-- Change package, leave .profile at the end. Also change res/xml/contacts.xml ! -->
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool>
<bool name="assistant_allow_username">true</bool> <!-- Allow to use an username instead of the phone number for account creation -->
<bool name="hide_in_call_stats">false</bool>
<bool name="orientation_portrait_only">false</bool>
<bool name="show_statusbar_only_on_dialer">false</bool>

View file

@ -23,6 +23,7 @@
<!-- Common -->
<string name="username">Username</string>
<string name="phone_number">Phone number</string>
<string name="display_name">Display name</string>
<string name="password">Password</string>
<string name="confirm_password">Password confirmation</string>
@ -54,8 +55,11 @@
<string name="welcome">Welcome</string>
<string name="assistant">Assistant</string>
<string name="assistant_create_account">Create account</string>
<string name="assistant_continue">Continue</string>
<string name="assistant_activate">Activate account</string>
<string name="assistant_finish">Finish configuration</string>
<string name="assistant_validate_account">Your account is created. Please check your mails to validate your account. Once it is done, come back here and click on the button.</string>
<string name="assistant_validate_code">Enter your activation code</string>
<string name="assistant_welcome_desc">This assistant will help you to use a SIP account for your calls.</string>
<string name="assistant_linphone_login_desc">Enter your username and password of Linphone account</string>
<string name="assistant_login_desc">Enter your username and password with your SIP domain</string>
@ -83,13 +87,18 @@
<string name="wizard_failed">An error occurred, try again later.</string>
<string name="wizard_server_unavailable">Server unreachable, verify your network connection.</string>
<string name="wizard_username_unavailable">This username is already in use.</string>
<string name="assistant_phone_number_unavailable">This phone number is already in use.</string>
<string name="wizard_username_incorrect">Your username is invalid.</string>
<string name="assistant_phone_number_incorrect">Your phone number is invalid.</string>
<string name="wizard_email_incorrect">Your email is invalid.</string>
<string name="wizard_password_incorrect">Your password is invalid</string>
<string name="wizard_passwords_unmatched">Passwords do not match.</string>
<string name="setup_confirm_username">Your username will be %s.\r\n\r\nIt may differ from your input to match requirements.\r\nDo you accept?</string>
<string name="first_launch_no_login_password">Please enter your login and password</string>
<string name="forgot_password">Forgot password ?</string>
<string name="assistant_choose_country">Choose a country</string>
<string name="select_your_country">Select your Country</string>
<string name="country_code">(%s)</string>
<!-- Dailer -->
<string name="address_bar_hint">Enter a number or an address</string>
@ -107,7 +116,6 @@
<string name="delete_contacts">Do you want to delete selected contacts?</string>
<string name="delete_contact">Do you want to delete selected contact?</string>
<string name="sip_address">SIP address</string>
<string name="phone_number">Phone number</string>
<string name="contact_first_name">First name</string>
<string name="contact_last_name">Last name</string>
<string name="contact_organization">Organization</string>
@ -350,6 +358,7 @@
<string name="content_description_new_discussion">New discussion</string>
<string name="content_description_search">Search</string>
<string name="content_description_search_contact">Search contact</string>
<string name="content_description_search_country">Search country</string>
<string name="content_description_all_contacts">All contacts</string>
<string name="content_description_linphone_contacts">Linphone contacts</string>
<string name="content_description_call_direction">Call direction</string>
@ -369,6 +378,8 @@
<string name="content_description_message_status">Message status</string>
<string name="content_description_conference">Conference</string>
<string name="content_description_username_field">Username field</string>
<string name="content_description_activation_code_field">Username field</string>
<string name="content_description_phone_number_field">Phone number field</string>
<string name="content_description_display_field">Display name field</string>
<string name="content_description_domain_field">Domain field</string>
<string name="content_description_url_field">Remote provisioning field</string>

View file

@ -968,6 +968,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
private int mAlwaysChangingPhoneAngle = -1;
private class LocalOrientationEventListener extends OrientationEventListener {
public LocalOrientationEventListener(Context context) {
super(context);

View file

@ -198,6 +198,7 @@ public class LinphonePreferences {
private String tempDisplayName;
private String tempUserId;
private String tempPassword;
private String tempHa1;
private String tempDomain;
private String tempProxy;
private String tempRealm;
@ -238,6 +239,11 @@ public class LinphonePreferences {
return this;
}
public AccountBuilder setHa1(String ha1) {
tempHa1 = ha1;
return this;
}
public AccountBuilder setDomain(String domain) {
tempDomain = domain;
return this;
@ -363,7 +369,7 @@ public class LinphonePreferences {
if(tempRealm != null)
prxCfg.setRealm(tempRealm);
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain);
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, tempHa1, tempRealm, tempDomain);
lc.addProxyConfig(prxCfg);
lc.addAuthInfo(authInfo);
@ -520,6 +526,13 @@ public class LinphonePreferences {
}
}
public void setAccountHa1(int n, String ha1) {
if(getAccountDomain(n) != null && getAccountUsername(n) != null) {
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(getAccountUsername(n), null, null, ha1, null, getAccountDomain(n));
LinphoneManager.getLc().addAuthInfo(authInfo);
}
}
public String getAccountPassword(int n) {
LinphoneAuthInfo authInfo = getAuthInfo(n);
return authInfo == null ? null : authInfo.getPassword();
@ -1357,4 +1370,8 @@ public class LinphonePreferences {
public void enableAutoAnswer(boolean enable) {
getConfig().setBool("app", "auto_answer", enable);
}
public int getCodeLength(){
return getConfig().getInt("app", "activation_code_length", 0);
}
}

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;
@ -79,6 +80,12 @@ private static AssistantActivity instance;
private boolean remoteProvisioningInProgress;
private boolean echoCancellerAlreadyDone;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
private static final int PERMISSIONS_READ_PHONE_STATE = 202;
public CountryListFragment.Country country;
public String phone_number;
public String email;
public String activation_code;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -104,9 +111,9 @@ private static AssistantActivity instance;
echoCancellerAlreadyDone = false;
}
mPrefs = LinphonePreferences.instance();
//if(mPrefs.isFirstLaunch()) {
status.enableSideMenu(false);
//}
status.enableSideMenu(false);
checkAndRequestReadPhoneState();
mListener = new LinphoneCoreListenerBase() {
@Override
@ -234,6 +241,8 @@ private static AssistantActivity instance;
back.setVisibility(View.INVISIBLE);
} else if (currentFragment == AssistantFragmentsEnum.WELCOME) {
finish();
} else if (currentFragment == AssistantFragmentsEnum.COUNTRY_CHOOSER){
displayCreateAccount();
}
}
@ -245,14 +254,22 @@ private static AssistantActivity instance;
}
}
public void checkAndRequestReadPhoneState() {
checkAndRequestPermission(Manifest.permission.READ_PHONE_STATE, 0);
}
public void checkAndRequestAudioPermission() {
int recordAudio = getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName());
Log.i("[Permission] Record audio permission is " + (recordAudio == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
if (recordAudio != PackageManager.PERMISSION_GRANTED) {
if (LinphonePreferences.instance().firstTimeAskingForPermission(Manifest.permission.RECORD_AUDIO) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.RECORD_AUDIO)) {
Log.i("[Permission] Asking for record audio");
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST_RECORD_AUDIO);
checkAndRequestPermission(Manifest.permission.RECORD_AUDIO, 0);
}
public void checkAndRequestPermission(String permission, int result) {
int permissionGranted = getPackageManager().checkPermission(permission, getPackageName());
Log.i("[Permission] " + permission + " is " + (permissionGranted == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
if (permissionGranted != PackageManager.PERMISSION_GRANTED) {
if (LinphonePreferences.instance().firstTimeAskingForPermission(permission) || ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) {
Log.i("[Permission] Asking for " + permission);
ActivityCompat.requestPermissions(this, new String[] { permission }, result);
}
}
}
@ -262,15 +279,13 @@ private static AssistantActivity instance;
for (int i = 0; i < permissions.length; i++) {
Log.i("[Permission] " + permissions[i] + " is " + (grantResults[i] == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
}
if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
launchEchoCancellerCalibration(true);
} else {
isEchoCalibrationFinished();
}
} else {
isEchoCalibrationFinished();
}
}
@ -291,11 +306,11 @@ private static AssistantActivity instance;
}
private void logIn(String username, String password, String displayName, String domain, TransportType transport, boolean sendEcCalibrationResult) {
saveCreatedAccount(username, password, displayName, domain, transport);
saveCreatedAccount(username, password, displayName, null, domain, transport);
}
public void checkAccount(String username, String password, String displayName, String domain) {
saveCreatedAccount(username, password, displayName, domain, null);
saveCreatedAccount(username, password, displayName, null, domain, null);
}
public void linphoneLogIn(String username, String password, String displayName, boolean validate) {
@ -311,7 +326,7 @@ private static AssistantActivity instance;
}
public void genericLogIn(String username, String password, String displayName, String domain, TransportType transport) {
if(accountCreated) {
if (accountCreated) {
retryLogin(username, password, displayName, domain, transport);
} else {
logIn(username, password, displayName, domain, transport, false);
@ -366,9 +381,16 @@ private static AssistantActivity instance;
back.setVisibility(View.VISIBLE);
}
public void displayCountryChooser() {
fragment = new CountryListFragment();
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.COUNTRY_CHOOSER;
back.setVisibility(View.VISIBLE);
}
public void retryLogin(String username, String password, String displayName, String domain, TransportType transport) {
accountCreated = false;
saveCreatedAccount(username, password, displayName, domain, transport);
saveCreatedAccount(username, password, displayName, null, domain, transport);
}
public void loadLinphoneConfig(){
@ -392,7 +414,13 @@ private static AssistantActivity instance;
goToLinphoneActivity();
}
public void saveCreatedAccount(String username, String password, String displayName, String domain, TransportType transport) {
public String getPhoneWithCountry() {
if(country == null || phone_number == null) return "";
String phoneNumberWithCountry = country.dial_code + phone_number.replace("\\D", "");
return phoneNumberWithCountry;
}
public void saveCreatedAccount(String username, String password, String displayName, String ha1, String domain, TransportType transport) {
if (accountCreated)
return;
@ -415,6 +443,7 @@ private static AssistantActivity instance;
.setUsername(username)
.setDomain(domain)
.setDisplayName(displayName)
.setHa1(ha1)
.setPassword(password);
if (isMainAccountLinphoneDotOrg) {
@ -461,6 +490,8 @@ private static AssistantActivity instance;
}
}
try {
builder.saveNewAccount();
if(!newAccount) {
@ -508,6 +539,19 @@ private static AssistantActivity instance;
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_ACTIVATION;
back.setVisibility(View.INVISIBLE);
}
public void displayAssistantCodeConfirm(String username, String phone) {
CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment();
newAccount = true;
Bundle extras = new Bundle();
extras.putString("Username", username);
extras.putString("Phone", phone);
fragment.setArguments(extras);
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_CODE_ACTIVATION;
back.setVisibility(View.INVISIBLE);
}
public void isAccountVerified(String username) {
Toast.makeText(this, getString(R.string.assistant_account_validated), Toast.LENGTH_LONG).show();

View file

@ -24,7 +24,9 @@ public enum AssistantFragmentsEnum {
WELCOME,
CREATE_ACCOUNT,
CREATE_ACCOUNT_ACTIVATION,
CREATE_ACCOUNT_CODE_ACTIVATION,
LINPHONE_LOGIN,
COUNTRY_CHOOSER,
LOGIN,
REMOTE_PROVISIONING,
ECHO_CANCELLER_CALIBRATION,

View file

@ -0,0 +1,213 @@
package org.linphone.assistant;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.linphone.R;
import org.linphone.mediastream.Log;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class CountryListFragment extends Fragment implements AdapterView.OnItemClickListener, View.OnClickListener {
private LayoutInflater mInflater;
private ListView list;
private EditText search;
private ImageView clearSearchField;
private CountryListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mInflater = inflater;
View view = inflater.inflate(R.layout.assistant_country_list, container, false);
adapter = new CountryListAdapter(R.raw.countries, getActivity().getApplicationContext());
search = (EditText)view.findViewById(R.id.search_country);
clearSearchField = (ImageView) view.findViewById(R.id.clearSearchField);
clearSearchField.setOnClickListener(this);
list = (ListView)view.findViewById(R.id.countryList);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
search.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s);
}
@Override
public void afterTextChanged(Editable s) {
}
});
return view;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Country c = (Country)view.getTag();
AssistantActivity.instance().country = c;
AssistantActivity.instance().displayCreateAccount();
}
@Override
public void onClick(View v) {
if(v.getId() == R.id.clearSearchField) {
search.setText("");
}
}
/**
* This class represents a Country. There's a name, dial_code, code and max number of digits.
* It is constructed from a JSON object containing all these parameters.
*/
public class Country {
public String name;
public String dial_code;
public String code;
public int maxNum;
public Country(JSONObject obj ){
try {
name = obj.getString("name");
dial_code = obj.getString("dial_code");
code = obj.getString("code");
maxNum = obj.getInt("maxNum");
} catch (JSONException e){
e.printStackTrace();
}
}
}
/**
* This class reads a JSON file containing Country-specific phone number description,
* and allows to present them into a ListView
*/
private class CountryListAdapter extends BaseAdapter implements Filterable {
private List<Country> allCountries;
private List<Country> filteredCountries;
private Context context;
public CountryListAdapter(int jsonId, Context ctx) {
context = ctx;
allCountries = new ArrayList<Country>();
String jsonString = loadJSONFromAsset(R.raw.countries);
try {
JSONArray c = new JSONArray(jsonString);
for( int i = 0; i < c.length(); i++) {
allCountries.add(new Country(c.getJSONObject(i)));
}
filteredCountries = allCountries;
} catch (JSONException e){
e.printStackTrace();
}
}
public String loadJSONFromAsset(int id) {
String json = null;
try {
InputStream is = getResources().openRawResource(id);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return json;
}
@Override
public int getCount() {
return filteredCountries.size();
}
@Override
public Country getItem(int position) {
return filteredCountries.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
View view = null;
if (convertView != null) {
view = convertView;
} else {
view = mInflater.inflate(R.layout.country_cell, parent, false);
}
Country c = filteredCountries.get(position);
TextView name = (TextView) view.findViewById(R.id.country_name);
name.setText(c.name);
TextView dial_code = (TextView) view.findViewById(R.id.country_prefix);
dial_code.setText(String.format(getString(R.string.country_code),c.dial_code));
view.setTag(c);
return view;
}
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
ArrayList<Country> filteredCountries = new ArrayList<Country>();
for (Country c : allCountries) {
if (c.name.toLowerCase().contains(constraint) || c.dial_code.contains(constraint)){
filteredCountries.add(c);
}
}
FilterResults filterResults = new FilterResults();
filterResults.values = filteredCountries;
return filterResults;
}
@Override
@SuppressWarnings("unchecked")
protected void publishResults(CharSequence constraint, FilterResults results) {
filteredCountries = (List<Country>) results.values;
CountryListAdapter.this.notifyDataSetChanged();
}
};
}
}
}

View file

@ -48,7 +48,7 @@ public class CreateAccountActivationFragment extends Fragment implements Linphon
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation_activation, container, false);
View view = inflater.inflate(R.layout.assistant_account_creation_email_activation, container, false);
username = getArguments().getString("Username");
password = getArguments().getString("Password");
@ -71,7 +71,7 @@ public class CreateAccountActivationFragment extends Fragment implements Linphon
runOk = new Runnable() {
public void run() {
checkAccount.setEnabled(true);
AssistantActivity.instance().saveCreatedAccount(username,password,null, getString(R.string.default_domain),null);
AssistantActivity.instance().saveCreatedAccount(username, password, null, null, getString(R.string.default_domain),null);
AssistantActivity.instance().isAccountVerified(username);
}
};

View file

@ -0,0 +1,145 @@
package org.linphone.assistant;
/*
CreateAccountActivationFragment.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
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 2
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.R;
import org.linphone.core.LinphoneXmlRpcRequest;
import org.linphone.core.LinphoneXmlRpcRequest.LinphoneXmlRpcRequestListener;
import org.linphone.core.LinphoneXmlRpcRequestImpl;
import org.linphone.core.LinphoneXmlRpcSession;
import org.linphone.core.LinphoneXmlRpcSession;
import org.linphone.core.LinphoneXmlRpcSessionImpl;
import org.linphone.mediastream.Log;
/**
* @author Sylvain Berfini
*/
public class CreateAccountCodeActivationFragment extends Fragment {
private String username, phone, ha1;
private EditText code;
private int code_length;
private Handler mHandler = new Handler();
private Button checkAccount;
private LinphoneXmlRpcSession xmlRpcSession;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation_code_activation, container, false);
username = getArguments().getString("Username");
phone = getArguments().getString("Phone");
code_length = LinphonePreferences.instance().getCodeLength();
if(username == null || username.length() == 0){
username = phone;
}
code = (EditText) view.findViewById(R.id.assistant_code);
code.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void afterTextChanged(Editable s) {
if(s.length() == code_length){
checkAccount.setEnabled(true);
} else {
checkAccount.setEnabled(false);
}
}
});
checkAccount = (Button) view.findViewById(R.id.assistant_check);
checkAccount.setEnabled(false);
checkAccount.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
checkAccount.setEnabled(false);
activateAccount(phone, username, code.getText().toString(), false);
}
});
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url));
return view;
}
private void activateAccount(final String phone, final String username, final String code, boolean suscribe) {
final Runnable runNotOk = new Runnable() {
public void run() {
Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show();
}
};
final Runnable runOk = new Runnable() {
public void run() {
checkAccount.setEnabled(true);
AssistantActivity.instance().saveCreatedAccount(username, null, null, ha1, getString(R.string.default_domain), null);
AssistantActivity.instance().isAccountVerified(username);
}
};
final Runnable runNotReachable = new Runnable() {
public void run() {
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
}
};
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("activate_phone_account", LinphoneXmlRpcRequest.ArgType.String);
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
@Override
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) {
String response = request.getStringResponse();
if (response.contains("ERROR")) {
mHandler.post(runNotOk);
} else {
ha1 = response;
mHandler.post(runOk);
}
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
mHandler.post(runNotReachable);
}
}
});
xmlRpcRequest.addStringArg(phone);
xmlRpcRequest.addStringArg(username);
xmlRpcRequest.addStringArg(code);
xmlRpcRequest.addStringArg(getString(R.string.default_domain));
xmlRpcSession.sendRequest(xmlRpcRequest);
}
}

View file

@ -29,14 +29,18 @@ import org.linphone.core.LinphoneXmlRpcRequest.LinphoneXmlRpcRequestListener;
import org.linphone.core.LinphoneXmlRpcRequestImpl;
import org.linphone.core.LinphoneXmlRpcSession;
import org.linphone.core.LinphoneXmlRpcSessionImpl;
import org.linphone.xmlrpc.XmlRpcHelper;
import android.Manifest;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Fragment;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.LayoutInflater;
@ -44,86 +48,226 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* @author Sylvain Berfini
*/
public class CreateAccountFragment extends Fragment {
public class CreateAccountFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener {
private Handler mHandler = new Handler();
private EditText usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit;
private TextView usernameError, passwordError, passwordConfirmError, emailError;
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, sipUri;
private boolean phoneNumberOk = false;
private boolean usernameOk = false;
private boolean passwordOk = false;
private boolean emailOk = false;
private boolean confirmPasswordOk = false;
private Button createAccount;
private Button createAccount, selectCountry;
private CheckBox useUsername, useEmail;
private LinearLayout phoneNumberLayout, usernameLayout, emailLayout;
private final Pattern UPPER_CASE_REGEX = Pattern.compile("[A-Z]");
private LinphoneXmlRpcSession xmlRpcSession;
private CountryListFragment.Country country;
private String getUsername() {
String username = usernameEdit.getText().toString();
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_wizard)) {
LinphoneProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
username = lpc.normalizePhoneNumber(username);
}
return username.toLowerCase(Locale.getDefault());
}
private String getPhoneNumber(){
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
String countryCode = dialCode.getText().toString();
if(countryCode != null && countryCode.startsWith("+")) {
countryCode = countryCode.substring(1);
}
proxyConfig.setDialPrefix(countryCode);
return proxyConfig.normalizePhoneNumber(phoneNumberEdit.getText().toString());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
usernameError = (TextView) view.findViewById(R.id.username_error);
usernameEdit = (EditText) view.findViewById(R.id.username);
phoneNumberError = (TextView) view.findViewById(R.id.phone_number_error);
phoneNumberEdit = (EditText) view.findViewById(R.id.phone_number);
phoneNumberEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
passwordError = (TextView) view.findViewById(R.id.password_error);
passwordEdit = (EditText) view.findViewById(R.id.password);
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
passwordConfirmError = (TextView) view.findViewById(R.id.confirm_password_error);
passwordConfirmEdit = (EditText) view.findViewById(R.id.confirm_password);
@Override
public void afterTextChanged(Editable s) {}
});
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
addXMLRPCPhoneNumberHandler(phoneNumberEdit, null);
emailError = (TextView) view.findViewById(R.id.email_error);
emailEdit = (EditText) view.findViewById(R.id.email);
selectCountry = (Button) view.findViewById(R.id.select_country);
selectCountry.setOnClickListener(this);
addXMLRPCUsernameHandler(usernameEdit, null);
dialCode = (EditText) view.findViewById(R.id.dial_code);
sipUri = (TextView) view.findViewById(R.id.sip_uri);
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_wizard)) {
usernameEdit.setInputType(InputType.TYPE_CLASS_NUMBER);
}
addXMLRPCPasswordHandler(passwordEdit, null);
addXMLRPCConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
addXMLRPCEmailHandler(emailEdit, null);
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
useUsername = (CheckBox) view.findViewById(R.id.use_username);
useUsername.setVisibility(View.VISIBLE);
useUsername.setOnCheckedChangeListener(this);
usernameError = (TextView) view.findViewById(R.id.username_error);
usernameEdit = (EditText) view.findViewById(R.id.username);
usernameEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
/*if(useUsername.isChecked() && usernameEdit.getText().length() > 0) {
sipUri.setText("Sip uri is sip:" + s.toString() + "@sip.linphone.org");
} else {
if(phoneNumberEdit.getText().length() > 0){
sipUri.setText("Sip uri is sip:" + phoneNumberEdit.getText().toString()+ "@sip.linphone.org");
} else {
sipUri.setText("");
}
}*/
}
@Override
public void afterTextChanged(Editable s) {}
});
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
addXMLRPCUsernameHandler(usernameEdit, null);
}
if(getResources().getBoolean(R.bool.isTablet)){
useEmail.setVisibility(View.VISIBLE);
useEmail = (CheckBox) view.findViewById(R.id.use_email);
useEmail.setOnCheckedChangeListener(this);
passwordError = (TextView) view.findViewById(R.id.password_error);
passwordEdit = (EditText) view.findViewById(R.id.password);
passwordConfirmError = (TextView) view.findViewById(R.id.confirm_password_error);
passwordConfirmEdit = (EditText) view.findViewById(R.id.confirm_password);
emailError = (TextView) view.findViewById(R.id.email_error);
emailEdit = (EditText) view.findViewById(R.id.email);
emailLayout = (LinearLayout) view.findViewById(R.id.email_layout);
addXMLRPCPasswordHandler(passwordEdit, null);
addXMLRPCConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
addXMLRPCEmailHandler(emailEdit, null);
if (getResources().getBoolean(R.bool.pre_fill_email_in_wizard)) {
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
for (Account account: accounts) {
if (isEmailCorrect(account.name)) {
String possibleEmail = account.name;
emailEdit.setText(possibleEmail);
emailOk = true;
break;
}
}
}
}
String previousPhone = AssistantActivity.instance().phone_number;
if(previousPhone != null ){
phoneNumberEdit.setText(previousPhone);
}
setCountry(AssistantActivity.instance().country);
updateApplyButton();
createAccount = (Button) view.findViewById(R.id.assistant_create);
createAccount.setEnabled(false);
createAccount.setEnabled(true);
createAccount.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
createAccount(getUsername(), passwordEdit.getText().toString(), emailEdit.getText().toString(), false);
if(getResources().getBoolean(R.bool.isTablet)) {
if (useEmail.isChecked()) {
createAccountWithEmail(getUsername(), passwordEdit.getText().toString(), emailEdit.getText().toString(), false);
}
} else {
createAccountWithPhoneNumber(getUsername(), "", getPhoneNumber(), false);
}
}
});
});
if (getResources().getBoolean(R.bool.pre_fill_email_in_wizard)) {
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
for (Account account: accounts) {
if (isEmailCorrect(account.name)) {
String possibleEmail = account.name;
emailEdit.setText(possibleEmail);
emailOk = true;
break;
}
}
}
int phoneStatePermission = getActivity().getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getActivity().getPackageName());
if (phoneStatePermission == PackageManager.PERMISSION_GRANTED) {
TelephonyManager mTelephonyManager;
mTelephonyManager = (TelephonyManager) getActivity().getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String yourNumber = mTelephonyManager.getLine1Number();
String iso = mTelephonyManager.getNetworkCountryIso();
}
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url));
return view;
}
private void updateApplyButton() {
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(buttonView.getId() == R.id.use_username) {
if(isChecked) {
usernameLayout.setVisibility(View.VISIBLE);
if(usernameEdit.getText().length() > 0){
sipUri.setText("Sip uri is sip:" + usernameEdit.getText().toString() + "@sip.linphone.org");
}
} else {
usernameLayout.setVisibility(View.GONE);
if(phoneNumberEdit.getText().length() > 0){
sipUri.setText("Sip uri is sip:" + phoneNumberEdit.getText().toString() + "@sip.linphone.org");
}
}
} else if(buttonView.getId() == R.id.use_email){
if(isChecked) {
emailLayout.setVisibility(View.VISIBLE);
usernameLayout.setVisibility(View.VISIBLE);
useUsername.setEnabled(false);
} else {
if(!useUsername.isChecked()) {
usernameLayout.setVisibility(View.GONE);
}
emailLayout.setVisibility(View.GONE);
usernameLayout.setVisibility(View.GONE);
useUsername.setEnabled(true);
}
}
}
public void setCountry(CountryListFragment.Country c) {
country = c;
if( c!= null) {
dialCode.setText(c.dial_code);
selectCountry.setText(c.name);
}
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.select_country: {
AssistantActivity.instance().displayCountryChooser();
}
}
}
private void displayError(Boolean isOk, TextView error, EditText editText, String errorText){
if(isOk || editText.getText().toString().equals("")){
error.setVisibility(View.INVISIBLE);
@ -168,16 +312,70 @@ public class CreateAccountFragment extends Fragment {
}
};
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("check_account", LinphoneXmlRpcRequest.ArgType.Int);
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("is_account_used", LinphoneXmlRpcRequest.ArgType.String);
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
@Override
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) {
int response = request.getIntResponse();
if (response != 0) {
mHandler.post(runNotOk);
} else {
String response = request.getStringResponse();
if(response.equals(XmlRpcHelper.SERVER_ERROR_ACCOUNT_DOESNT_EXIST)) {
mHandler.post(runOk);
} else {
mHandler.post(runNotOk);
}
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
mHandler.post(runNotReachable);
}
}
});
xmlRpcRequest.addStringArg(username);
xmlRpcSession.sendRequest(xmlRpcRequest);
}
private void isPhoneNumberRegistred(final String username, final ImageView icon) {
final Runnable runOk = new Runnable() {
public void run() {
phoneNumberOk = false;
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, LinphoneManager.getInstance().getContext().getString(R.string.assistant_phone_number_unavailable));
//createAccount.setEnabled(phoneNumberOk);
}
};
final Runnable runNotOk = new Runnable() {
public void run() {
phoneNumberOk = true;
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, "");
createAccount.setEnabled(phoneNumberOk);
}
};
final Runnable runNotReachable = new Runnable() {
public void run() {
phoneNumberOk = false;
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, LinphoneManager.getInstance().getContext().getString(R.string.wizard_server_unavailable));
createAccount.setEnabled(phoneNumberOk);
}
};
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("is_phone_number_used", LinphoneXmlRpcRequest.ArgType.String);
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
@Override
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) {
final String response = request.getStringResponse();
if (response.equals(XmlRpcHelper.SERVER_RESPONSE_OK)) {
mHandler.post(runOk);
} else {
if(response.startsWith("ERROR")){
mHandler.post(new Runnable() {
@Override
public void run() {
phoneNumberOk = false;
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, response);
//createAccount.setEnabled(phoneNumberOk);
}
});
} else {
mHandler.post(runNotOk);
}
}
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
mHandler.post(runNotReachable);
@ -197,7 +395,49 @@ public class CreateAccountFragment extends Fragment {
return password.length() >= 1;
}
private void createAccount(final String username, final String password, String email, boolean suscribe) {
private void createAccountWithPhoneNumber(final String username, final String password, final String phone, boolean suscribe) {
AssistantActivity.instance().displayAssistantCodeConfirm(username, phone);
final Runnable runNotOk = new Runnable() {
public void run() {
//TODO errorMessage.setText(R.string.wizard_failed);
}
};
final Runnable runOk = new Runnable() {
public void run() {
AssistantActivity.instance().displayAssistantCodeConfirm(username, phone);
}
};
final Runnable runNotReachable = new Runnable() {
public void run() {
//TODO errorMessage.setText(R.string.wizard_not_reachable);
}
};
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("create_phone_account", LinphoneXmlRpcRequest.ArgType.String);
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
@Override
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) {
String response = request.getStringResponse();
if (response.contains("ERROR")) {
mHandler.post(runNotOk);
} else {
mHandler.post(runOk);
}
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
mHandler.post(runNotReachable);
}
}
});
xmlRpcRequest.addStringArg(phone);
xmlRpcRequest.addStringArg("");
xmlRpcRequest.addStringArg("");
xmlRpcRequest.addStringArg(LinphoneManager.getInstance().getUserAgent());
xmlRpcRequest.addStringArg("");
xmlRpcSession.sendRequest(xmlRpcRequest);
}
private void createAccountWithEmail(final String username, final String password, String email, boolean suscribe) {
final Runnable runNotOk = new Runnable() {
public void run() {
//TODO errorMessage.setText(R.string.wizard_failed);
@ -213,7 +453,7 @@ public class CreateAccountFragment extends Fragment {
//TODO errorMessage.setText(R.string.wizard_not_reachable);
}
};
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("create_account_with_useragent", LinphoneXmlRpcRequest.ArgType.Int);
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
@Override
@ -236,6 +476,28 @@ public class CreateAccountFragment extends Fragment {
xmlRpcRequest.addStringArg(LinphoneManager.getInstance().getUserAgent());
xmlRpcSession.sendRequest(xmlRpcRequest);
}
private void addXMLRPCPhoneNumberHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
if (s.length() > 0) {
phoneNumberOk = false;
String phoneNumber = getPhoneNumber();
if (LinphoneManager.getLc().createProxyConfig().isPhoneNumber(phoneNumber)) {
isPhoneNumberRegistred(phoneNumber, icon);
} else {
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, getResources().getString(R.string.wizard_username_incorrect));
}
} else {
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, "");
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int count, int after) {}
});
}
private void addXMLRPCUsernameHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener(new TextWatcher() {
@ -255,7 +517,7 @@ public class CreateAccountFragment extends Fragment {
field.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus){
if (!hasFocus) {
usernameOk = false;
String username = field.getText().toString();
if (isUsernameCorrect(username)) {

View file

@ -11,6 +11,9 @@ import org.linphone.mediastream.Log;
public class XmlRpcHelper {
public static final String SERVER_ERROR_INVALID_ACCOUNT = "ERROR_INVALID_ACCOUNT";
public static final String SERVER_RESPONSE_OK = "OK";
public static final String SERVER_ERROR_INCORRECT_PHONE_NUMBER = "ERROR_PHONE_ISNT_E164";
public static final String SERVER_ERROR_ACCOUNT_DOESNT_EXIST = "ERROR_ACCOUNT_DOESNT_EXIST";
public static final String SERVER_ERROR_PURCHASE_CANCELLED = "ERROR_PURCHASE_CANCELLED";
public static final String SERVER_ERROR_RECEIPT_PARSING_FAILED = "ERROR_RECEIPT_PARSING_FAILED";
public static final String SERVER_ERROR_UID_ALREADY_IN_USE = "ERROR_UID_ALREADY_IN_USE";
@ -152,7 +155,7 @@ public class XmlRpcHelper {
}
public void isTrialAccountAsync(final XmlRpcListener listener, String username, String password) {
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("check_account_trial", LinphoneXmlRpcRequest.ArgType.String);
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("is_account_trial", LinphoneXmlRpcRequest.ArgType.String);
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
@Override
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {