Integration of account creator
This commit is contained in:
parent
1edbb7bf7e
commit
ec3542fca9
18 changed files with 988 additions and 572 deletions
BIN
res/drawable-xhdpi/info.png
Normal file
BIN
res/drawable-xhdpi/info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -25,11 +25,12 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="30dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -38,44 +39,153 @@
|
||||||
android:layout_marginRight="10dp">
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/phone_number_layout"
|
||||||
|
android:visibility="visible"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/username_label"
|
android:id="@+id/phone_number_label"
|
||||||
android:text="@string/username"
|
android:text="@string/phone_number"
|
||||||
style="@style/font13"
|
style="@style/font13"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/info_phone_number"
|
||||||
|
android:src="@drawable/info"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:visibility="visible"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/select_country"
|
||||||
|
style="@style/font8"
|
||||||
|
android:text="@string/select_your_country"
|
||||||
|
android:background="@drawable/resizable_assistant_button"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="40dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/username"
|
android:id="@+id/dial_code"
|
||||||
android:background="@drawable/resizable_textfield"
|
android:background="@drawable/resizable_textfield"
|
||||||
android:textColor="@color/colorB"
|
android:textColor="@color/colorB"
|
||||||
android:inputType="text|textNoSuggestions"
|
android:inputType="phone"
|
||||||
android:contentDescription="@string/content_description_username_field"
|
android:text="+"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="65dp"
|
||||||
|
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_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:singleLine="true"/>
|
android:singleLine="true"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/username_error"
|
android:id="@+id/phone_number_error"
|
||||||
android:text="@string/error"
|
android:text="@string/error"
|
||||||
style="@style/font20"
|
style="@style/font20"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sip_uri"
|
||||||
|
style="@style/font9"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/use_username"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/use_username_instead_or_phone_number"
|
||||||
|
android:checked="false" android:layout_column="1"/>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/use_email"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/use_email_for_validation" android:layout_column="1"
|
||||||
|
android:checked="false"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/password_layout"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:visibility="visible"
|
||||||
android:paddingLeft="30dp"
|
android:paddingLeft="30dp"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content" android:layout_column="0">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/password_label"
|
android:id="@+id/password_label"
|
||||||
|
@ -105,6 +215,40 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/username_layout"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content" android:layout_column="1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/username_label"
|
||||||
|
android:text="@string/username"
|
||||||
|
style="@style/font13"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/username"
|
||||||
|
android:background="@drawable/resizable_textfield"
|
||||||
|
android:textColor="@color/colorB"
|
||||||
|
android:inputType="text|textNoSuggestions"
|
||||||
|
android:contentDescription="@string/content_description_username_field"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:singleLine="true"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/username_error"
|
||||||
|
android:text="@string/error"
|
||||||
|
style="@style/font20"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="invisible"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
@ -115,48 +259,13 @@
|
||||||
android:layout_marginRight="10dp">
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:id="@+id/email_layout"
|
||||||
android:layout_width="0dp"
|
android:visibility="gone"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<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:orientation="vertical"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:paddingLeft="30dp"
|
android:paddingLeft="30dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content" android:layout_column="0">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/email_label"
|
android:id="@+id/email_label"
|
||||||
|
@ -188,6 +297,44 @@
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/password_confirm_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content" android:layout_column="1">
|
||||||
|
|
||||||
|
<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>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,123 @@
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="30dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/phone_number_layout"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/select_country"
|
||||||
|
style="@style/font8"
|
||||||
|
android:text="@string/select_your_country"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:background="@drawable/resizable_assistant_button"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="40dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
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"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/info_phone_number"
|
||||||
|
android:src="@drawable/info"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_width="15dp"
|
||||||
|
android:layout_height="15dp"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<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:text="+"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="65dp"
|
||||||
|
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>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/use_username"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/login_with_username"/>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_margin="10dp">
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/username_layout"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:visibility="gone"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -57,7 +162,10 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/password_layout"
|
||||||
|
android:visibility="gone"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:layout_gravity="top"
|
||||||
android:paddingLeft="30dp"
|
android:paddingLeft="30dp"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -94,7 +202,9 @@
|
||||||
android:layout_margin="10dp">
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/display_layout"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/assistant_title"
|
||||||
android:text="@string/assistant_create_account"
|
android:text="@string/assistant_create_account"
|
||||||
style="@style/font6"
|
style="@style/font6"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
|
@ -26,24 +27,21 @@
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/phone_number_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="30dp"
|
||||||
android:orientation="vertical">
|
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
|
<LinearLayout
|
||||||
|
android:id="@+id/phone_number_layout"
|
||||||
|
android:visibility="gone"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
@ -55,6 +53,28 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/info_phone_number"
|
||||||
|
android:src="@drawable/info"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
<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="40dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -65,9 +85,11 @@
|
||||||
android:background="@drawable/resizable_textfield"
|
android:background="@drawable/resizable_textfield"
|
||||||
android:textColor="@color/colorB"
|
android:textColor="@color/colorB"
|
||||||
android:inputType="phone"
|
android:inputType="phone"
|
||||||
|
android:text="+"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:layout_width="50dp"
|
android:gravity="center"
|
||||||
android:layout_height="40dp"
|
android:layout_width="65dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
android:singleLine="true"/>
|
android:singleLine="true"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
@ -97,6 +119,7 @@
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/use_username"
|
android:id="@+id/use_username"
|
||||||
|
@ -149,7 +172,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/email_layout"
|
android:id="@+id/password_layout"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -191,6 +214,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/password_confirm_layout"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
@ -226,6 +250,16 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/email_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -90,20 +90,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</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>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -49,4 +49,3 @@ username_length=-1
|
||||||
username_max_length=64
|
username_max_length=64
|
||||||
username_min_length=1
|
username_min_length=1
|
||||||
username_regex=^[a-z0-9_.\-]*$
|
username_regex=^[a-z0-9_.\-]*$
|
||||||
xmlrpc_url=https://sip3.linphone.org:444/inapp.php
|
|
||||||
|
|
|
@ -10,10 +10,15 @@
|
||||||
<bool name="force_use_of_linphone_friends">false</bool>
|
<bool name="force_use_of_linphone_friends">false</bool>
|
||||||
<bool name="use_linphone_tag">true</bool>
|
<bool name="use_linphone_tag">true</bool>
|
||||||
|
|
||||||
|
<!-- Phone numbers -->
|
||||||
|
<bool name="use_phone_number_validation">true</bool><!-- Use phone number for validation -->
|
||||||
|
<integer name="popup_time_interval">86400</integer><!-- Time between two inapp notifications in seconds -->
|
||||||
|
|
||||||
<!-- Assistant -->
|
<!-- Assistant -->
|
||||||
<string name="wizard_url">https://sip3.linphone.org:444/inapp.php</string><!-- Url of the xmlrpc script -->
|
<string name="wizard_url">https://sip3.linphone.org:444/wizard.php</string><!-- Url of the xmlrpc script -->
|
||||||
<bool name="assistant_allow_username">true</bool> <!-- Allow to use an username instead of the phone number for account creation -->
|
<bool name="assistant_allow_username">true</bool> <!-- Allow to use an username instead of the phone number for account creation -->
|
||||||
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool><!-- Start assistant in loginFragment view instead of menu -->
|
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool><!-- Start assistant in loginFragment view instead of menu -->
|
||||||
|
|
||||||
<bool name="replace_assistant_with_old_interface">false</bool>
|
<bool name="replace_assistant_with_old_interface">false</bool>
|
||||||
<bool name="hide_assistant">false</bool>
|
<bool name="hide_assistant">false</bool>
|
||||||
<bool name="assistant_cancel_move_to_back">false</bool>
|
<bool name="assistant_cancel_move_to_back">false</bool>
|
||||||
|
@ -32,7 +37,7 @@
|
||||||
<bool name="allow_cancel_remote_provisioning_login_activity">true</bool>
|
<bool name="allow_cancel_remote_provisioning_login_activity">true</bool>
|
||||||
|
|
||||||
<!-- Inapp -->
|
<!-- Inapp -->
|
||||||
<bool name="enable_in_app_purchase">true</bool>
|
<bool name="enable_in_app_purchase">false</bool>
|
||||||
<integer name="days_notification_shown">5</integer><!-- Notification shown before end of trial version in days -->
|
<integer name="days_notification_shown">5</integer><!-- Notification shown before end of trial version in days -->
|
||||||
<integer name="time_between_inapp_notification">86400</integer><!-- Time between two inapp notifications in seconds -->
|
<integer name="time_between_inapp_notification">86400</integer><!-- Time between two inapp notifications in seconds -->
|
||||||
<bool name="hide_username_in_inapp">true</bool>
|
<bool name="hide_username_in_inapp">true</bool>
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
<string name="connect">Connection</string>
|
<string name="connect">Connection</string>
|
||||||
<string name="decline">Decline</string>
|
<string name="decline">Decline</string>
|
||||||
<string name="conference">Conference</string>
|
<string name="conference">Conference</string>
|
||||||
|
<string name="link">Link</string>
|
||||||
|
<string name="link_account_popup">Do you want to link the account %s with your phone number ?</string>
|
||||||
|
|
||||||
<!-- Launch screen -->
|
<!-- Launch screen -->
|
||||||
<string name="app_description">the <i>libre</i> SIP client</string>
|
<string name="app_description">the <i>libre</i> SIP client</string>
|
||||||
|
@ -57,6 +59,7 @@
|
||||||
<string name="welcome">Welcome</string>
|
<string name="welcome">Welcome</string>
|
||||||
<string name="assistant">Assistant</string>
|
<string name="assistant">Assistant</string>
|
||||||
<string name="assistant_create_account">Create account</string>
|
<string name="assistant_create_account">Create account</string>
|
||||||
|
<string name="assistant_link_account">Link account</string>
|
||||||
<string name="assistant_continue">Continue</string>
|
<string name="assistant_continue">Continue</string>
|
||||||
<string name="assistant_activate">Activate account</string>
|
<string name="assistant_activate">Activate account</string>
|
||||||
<string name="assistant_finish">Finish configuration</string>
|
<string name="assistant_finish">Finish configuration</string>
|
||||||
|
@ -104,6 +107,8 @@
|
||||||
<string name="use_username_instead_or_phone_number">Don\'t use phone number as username</string>
|
<string name="use_username_instead_or_phone_number">Don\'t use phone number as username</string>
|
||||||
<string name="use_email_for_validation">Use email address for account validation</string>
|
<string name="use_email_for_validation">Use email address for account validation</string>
|
||||||
<string name="login_with_username">Log in with username</string>
|
<string name="login_with_username">Log in with username</string>
|
||||||
|
<string name="phone_number_info_title">What is my phone number for?</string>
|
||||||
|
<string name="phone_number_info_content">A SMS code will be sent to your phone number to validate your account.</string>
|
||||||
|
|
||||||
<!-- Status -->
|
<!-- Status -->
|
||||||
<string name="invalid_email">Invalid email</string>
|
<string name="invalid_email">Invalid email</string>
|
||||||
|
|
|
@ -14,11 +14,6 @@
|
||||||
android:key="@string/pref_add_account_key"
|
android:key="@string/pref_add_account_key"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:title="@string/pref_in_app_store"
|
|
||||||
android:key="@string/pref_in_app_store_key"
|
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_preferences_title">
|
android:title="@string/pref_preferences_title">
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ import org.linphone.assistant.AssistantActivity;
|
||||||
import org.linphone.assistant.RemoteProvisioningLoginActivity;
|
import org.linphone.assistant.RemoteProvisioningLoginActivity;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.CallDirection;
|
import org.linphone.core.CallDirection;
|
||||||
|
import org.linphone.core.LinphoneAccountCreator;
|
||||||
|
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
|
@ -100,7 +102,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class LinphoneActivity extends Activity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback {
|
public class LinphoneActivity extends Activity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback, LinphoneAccountCreator.LinphoneAccountCreatorListener {
|
||||||
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
||||||
private static final int SETTINGS_ACTIVITY = 123;
|
private static final int SETTINGS_ACTIVITY = 123;
|
||||||
private static final int CALL_ACTIVITY = 19;
|
private static final int CALL_ACTIVITY = 19;
|
||||||
|
@ -202,10 +204,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
initButtons();
|
initButtons();
|
||||||
initSideMenu();
|
initSideMenu();
|
||||||
|
|
||||||
if(getResources().getBoolean(R.bool.enable_in_app_purchase)){
|
|
||||||
isTrialAccount();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentFragment = FragmentsAvailable.EMPTY;
|
currentFragment = FragmentsAvailable.EMPTY;
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras());
|
changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras());
|
||||||
|
@ -628,6 +626,13 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
startActivity(new Intent(LinphoneActivity.this, AssistantActivity.class));
|
startActivity(new Intent(LinphoneActivity.this, AssistantActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayLinkPhoneNumber() {
|
||||||
|
Intent assistant = new Intent();
|
||||||
|
assistant.setClass(this, AssistantActivity.class);
|
||||||
|
assistant.putExtra("LinkPhoneNumber", true);
|
||||||
|
startActivity(assistant);
|
||||||
|
}
|
||||||
|
|
||||||
public void displayInapp() {
|
public void displayInapp() {
|
||||||
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
|
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
|
||||||
}
|
}
|
||||||
|
@ -981,8 +986,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
|
|
||||||
private int mAlwaysChangingPhoneAngle = -1;
|
private int mAlwaysChangingPhoneAngle = -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class LocalOrientationEventListener extends OrientationEventListener {
|
private class LocalOrientationEventListener extends OrientationEventListener {
|
||||||
public LocalOrientationEventListener(Context context) {
|
public LocalOrientationEventListener(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -1120,7 +1123,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
getIntent().putExtra("PreviousActivity", 0);
|
getIntent().putExtra("PreviousActivity", 0);
|
||||||
|
|
||||||
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled() && LinphoneManager.getLc().getDefaultProxyConfig() != null){
|
||||||
LinphoneManager.getInstance().subscribeFriendList(!isApplicationBroughtToBackground(this));
|
LinphoneManager.getInstance().subscribeFriendList(!isApplicationBroughtToBackground(this));
|
||||||
}
|
}
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
@ -1333,6 +1336,16 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
|
|
||||||
refreshAccounts();
|
refreshAccounts();
|
||||||
|
|
||||||
|
if(getResources().getBoolean(R.bool.enable_in_app_purchase)){
|
||||||
|
isTrialAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
||||||
|
if (LinphonePreferences.instance().getLinkPopupTime() == null || (LinphonePreferences.instance().getLinkPopupTime() != null && !LinphonePreferences.instance().getLinkPopupTime().equals(""))){
|
||||||
|
isAccountWithAlias();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateMissedChatCount();
|
updateMissedChatCount();
|
||||||
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
||||||
LinphoneManager.getInstance().subscribeFriendList(true);
|
LinphoneManager.getInstance().subscribeFriendList(true);
|
||||||
|
@ -1578,8 +1591,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void refreshAccounts(){
|
public void refreshAccounts(){
|
||||||
if (LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
if (LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
||||||
accountsList.setVisibility(View.VISIBLE);
|
accountsList.setVisibility(View.VISIBLE);
|
||||||
|
@ -1671,9 +1682,20 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void isAccountWithAlias(){
|
||||||
|
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
|
LinphoneAccountCreator accountCreator;
|
||||||
|
accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), getResources().getString(R.string.wizard_url));
|
||||||
|
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
||||||
|
accountCreator.setListener(this);
|
||||||
|
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
|
accountCreator.isAccountUsed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Inapp Purchase
|
//Inapp Purchase
|
||||||
private void isTrialAccount() {
|
private void isTrialAccount() {
|
||||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if(LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphonePreferences.instance().getInappPopupTime() != null) {
|
||||||
XmlRpcHelper helper = new XmlRpcHelper();
|
XmlRpcHelper helper = new XmlRpcHelper();
|
||||||
helper.isTrialAccountAsync(new XmlRpcListenerBase() {
|
helper.isTrialAccountAsync(new XmlRpcListenerBase() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1683,13 +1705,14 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error){}
|
public void onError(String error) {
|
||||||
|
}
|
||||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getExpirationAccount() {
|
private void getExpirationAccount() {
|
||||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if(LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphonePreferences.instance().getInappPopupTime() != null) {
|
||||||
XmlRpcHelper helper = new XmlRpcHelper();
|
XmlRpcHelper helper = new XmlRpcHelper();
|
||||||
helper.getAccountExpireAsync(new XmlRpcListenerBase() {
|
helper.getAccountExpireAsync(new XmlRpcListenerBase() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1708,16 +1731,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error){}
|
public void onError(String error) {
|
||||||
|
}
|
||||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayInappNotification(String date) {
|
public void displayInappNotification(String date) {
|
||||||
if (LinphonePreferences.instance().getLastDateNotificationShown() != null && timestampToHumanDate(Calendar.getInstance()).equals(LinphonePreferences.instance().getLastDateNotificationShown())) {
|
long now = Calendar.getInstance().getTimeInMillis();
|
||||||
|
if (LinphonePreferences.instance().getInappPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getInappPopupTime()) < now) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
LinphonePreferences.instance().setLastDateNotificationShown(timestampToHumanDate(Calendar.getInstance()));
|
long newDate = now + (getResources().getInteger(R.integer.time_between_inapp_notification)*60);
|
||||||
|
LinphonePreferences.instance().setInappPopupTime(String.valueOf(newDate));
|
||||||
}
|
}
|
||||||
if(isTrialAccount){
|
if(isTrialAccount){
|
||||||
LinphoneService.instance().displayInappNotification(String.format(getString(R.string.inapp_notification_trial_expire), date));
|
LinphoneService.instance().displayInappNotification(String.format(getString(R.string.inapp_notification_trial_expire), date));
|
||||||
|
@ -1742,6 +1768,65 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void askLinkWithPhoneNumber(){
|
||||||
|
long now = Calendar.getInstance().getTimeInMillis();
|
||||||
|
long newDate = now + (getResources().getInteger(R.integer.popup_time_interval)*60);
|
||||||
|
Log.w(LinphonePreferences.instance().getLinkPopupTime());
|
||||||
|
Log.w(now);
|
||||||
|
if (LinphonePreferences.instance().getLinkPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) > now) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
|
||||||
|
}
|
||||||
|
final Dialog dialog = displayDialog(String.format(getResources().getString(R.string.link_account_popup), LinphoneManager.getLc().getDefaultProxyConfig().getAddress().asStringUriOnly()));
|
||||||
|
Button delete = (Button) dialog.findViewById(R.id.delete_button);
|
||||||
|
delete.setText(getResources().getString(R.string.link));
|
||||||
|
Button cancel = (Button) dialog.findViewById(R.id.cancel);
|
||||||
|
|
||||||
|
delete.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
displayLinkPhoneNumber();
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
|
||||||
|
|
||||||
|
cancel.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
if(status.equals(LinphoneAccountCreator.Status.AccountExist)){
|
||||||
|
askLinkWithPhoneNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ContactPicked {
|
interface ContactPicked {
|
||||||
|
|
|
@ -746,7 +746,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
mLc.setCallLogsDatabasePath(mCallLogDatabaseFile);
|
mLc.setCallLogsDatabasePath(mCallLogDatabaseFile);
|
||||||
mLc.setFriendsDatabasePath(mFriendsDatabaseFile);
|
mLc.setFriendsDatabasePath(mFriendsDatabaseFile);
|
||||||
mLc.setUserCertificatesPath(mUserCertificatePath);
|
mLc.setUserCertificatesPath(mUserCertificatePath);
|
||||||
subscribeFriendList(mPrefs.isFriendlistsubscriptionEnabled());
|
//subscribeFriendList(mPrefs.isFriendlistsubscriptionEnabled());
|
||||||
//mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile);
|
//mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile);
|
||||||
enableDeviceRingtone(mPrefs.isDeviceRingtoneEnabled());
|
enableDeviceRingtone(mPrefs.isDeviceRingtoneEnabled());
|
||||||
|
|
||||||
|
|
|
@ -1311,12 +1311,20 @@ public class LinphonePreferences {
|
||||||
return purchasables;
|
return purchasables;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastDateNotificationShown(){
|
public String getInappPopupTime(){
|
||||||
return getConfig().getString("app", "notification_date", null);
|
return getConfig().getString("app", "inapp_popup_time", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastDateNotificationShown(String date){
|
public void setInappPopupTime(String date){
|
||||||
getConfig().setString("app", "notification_date", date);
|
getConfig().setString("app", "inapp_popup_time", date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkPopupTime(String date){
|
||||||
|
getConfig().setString("app", "link_popup_time", date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLinkPopupTime(){
|
||||||
|
return getConfig().getString("app", "link_popup_time", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getXmlRpcServerUrl() {
|
public String getXmlRpcServerUrl() {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.linphone.core.PayloadType;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
import org.linphone.purchase.InAppPurchaseActivity;
|
|
||||||
import org.linphone.tools.OpenH264DownloadHelper;
|
import org.linphone.tools.OpenH264DownloadHelper;
|
||||||
import org.linphone.ui.LedPreference;
|
import org.linphone.ui.LedPreference;
|
||||||
import org.linphone.ui.PreferencesListFragment;
|
import org.linphone.ui.PreferencesListFragment;
|
||||||
|
@ -65,7 +64,6 @@ import android.provider.Settings;
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class SettingsFragment extends PreferencesListFragment {
|
public class SettingsFragment extends PreferencesListFragment {
|
||||||
private static final int STORE_INTENT = 2;
|
|
||||||
private LinphonePreferences mPrefs;
|
private LinphonePreferences mPrefs;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
|
@ -61,6 +61,7 @@ import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +72,7 @@ private static AssistantActivity instance;
|
||||||
private AssistantFragmentsEnum firstFragment;
|
private AssistantFragmentsEnum firstFragment;
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
private LinphonePreferences mPrefs;
|
private LinphonePreferences mPrefs;
|
||||||
private boolean accountCreated = false, newAccount = false;
|
private boolean accountCreated = false, newAccount = false, isLink = false;
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
private LinphoneAddress address;
|
private LinphoneAddress address;
|
||||||
private StatusFragment status;
|
private StatusFragment status;
|
||||||
|
@ -96,6 +97,10 @@ private static AssistantActivity instance;
|
||||||
setContentView(R.layout.assistant);
|
setContentView(R.layout.assistant);
|
||||||
initUI();
|
initUI();
|
||||||
|
|
||||||
|
if(getIntent().getBooleanExtra("LinkPhoneNumber",false)){
|
||||||
|
isLink = true;
|
||||||
|
displayCreateAccount();
|
||||||
|
} else {
|
||||||
firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) ? AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.WELCOME;
|
firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) ? AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.WELCOME;
|
||||||
if (findViewById(R.id.fragment_container) != null) {
|
if (findViewById(R.id.fragment_container) != null) {
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
@ -104,6 +109,7 @@ private static AssistantActivity instance;
|
||||||
currentFragment = (AssistantFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
|
currentFragment = (AssistantFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
|
if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
|
||||||
echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
|
echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
|
||||||
} else {
|
} else {
|
||||||
|
@ -358,6 +364,9 @@ private static AssistantActivity instance;
|
||||||
|
|
||||||
public void displayCreateAccount() {
|
public void displayCreateAccount() {
|
||||||
fragment = new CreateAccountFragment();
|
fragment = new CreateAccountFragment();
|
||||||
|
Bundle extra = new Bundle();
|
||||||
|
extra.putBoolean("LinkPhoneNumber", isLink);
|
||||||
|
fragment.setArguments(extra);
|
||||||
changeFragment(fragment);
|
changeFragment(fragment);
|
||||||
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT;
|
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT;
|
||||||
back.setVisibility(View.VISIBLE);
|
back.setVisibility(View.VISIBLE);
|
||||||
|
@ -525,13 +534,15 @@ private static AssistantActivity instance;
|
||||||
back.setVisibility(View.INVISIBLE);
|
back.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayAssistantCodeConfirm(String username, String phone, boolean recoverAccount) {
|
public void displayAssistantCodeConfirm(String username, String phone, String dialcode, boolean recoverAccount) {
|
||||||
CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment();
|
CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment();
|
||||||
newAccount = true;
|
newAccount = true;
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString("Username", username);
|
extras.putString("Username", username);
|
||||||
extras.putString("Phone", phone);
|
extras.putString("Phone", phone);
|
||||||
|
extras.putString("Dialcode", dialcode);
|
||||||
extras.putBoolean("RecoverAccount", recoverAccount);
|
extras.putBoolean("RecoverAccount", recoverAccount);
|
||||||
|
extras.putBoolean("LinkAccount", isLink);
|
||||||
fragment.setArguments(extras);
|
fragment.setArguments(extras);
|
||||||
changeFragment(fragment);
|
changeFragment(fragment);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class CountryListFragment extends Fragment implements AdapterView.OnItemC
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Country c = (Country)view.getTag();
|
Country c = (Country)view.getTag();
|
||||||
AssistantActivity.instance().country = c;
|
AssistantActivity.instance().country = c;
|
||||||
AssistantActivity.instance().displayCreateAccount();
|
AssistantActivity.instance().onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import org.linphone.mediastream.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -34,22 +34,19 @@ import android.widget.Toast;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneXmlRpcRequest;
|
import org.linphone.core.LinphoneAccountCreator;
|
||||||
import org.linphone.core.LinphoneXmlRpcRequest.LinphoneXmlRpcRequestListener;
|
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||||
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;
|
|
||||||
|
|
||||||
public class CreateAccountCodeActivationFragment extends Fragment {
|
|
||||||
private String username, phone, ha1;
|
import static org.linphone.core.LinphoneAccountCreator.*;
|
||||||
|
|
||||||
|
public class CreateAccountCodeActivationFragment extends Fragment implements LinphoneAccountCreatorListener {
|
||||||
|
private String username, phone, dialcode, ha1;
|
||||||
private EditText code;
|
private EditText code;
|
||||||
private boolean recoverAccount;
|
private boolean recoverAccount = false, linkAccount = false;
|
||||||
private int code_length;
|
private int code_length;
|
||||||
private Handler mHandler = new Handler();
|
|
||||||
private Button checkAccount;
|
private Button checkAccount;
|
||||||
private LinphoneXmlRpcSession xmlRpcSession;
|
private LinphoneAccountCreator accountCreator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -58,12 +55,16 @@ public class CreateAccountCodeActivationFragment extends Fragment {
|
||||||
|
|
||||||
username = getArguments().getString("Username");
|
username = getArguments().getString("Username");
|
||||||
phone = getArguments().getString("Phone");
|
phone = getArguments().getString("Phone");
|
||||||
|
dialcode = getArguments().getString("Dialcode");
|
||||||
recoverAccount = getArguments().getBoolean("RecoverAccount");
|
recoverAccount = getArguments().getBoolean("RecoverAccount");
|
||||||
code_length = LinphonePreferences.instance().getCodeLength();
|
linkAccount = getArguments().getBoolean("LinkAccount");
|
||||||
|
|
||||||
if(username == null || username.length() == 0){
|
code_length = LinphonePreferences.instance().getCodeLength();
|
||||||
username = phone;
|
accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), getResources().getString(R.string.wizard_url));
|
||||||
}
|
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
||||||
|
accountCreator.setListener(this);
|
||||||
|
accountCreator.setUsername(username);
|
||||||
|
accountCreator.setPhoneNumber(phone, dialcode);
|
||||||
|
|
||||||
code = (EditText) view.findViewById(R.id.assistant_code);
|
code = (EditText) view.findViewById(R.id.assistant_code);
|
||||||
code.addTextChangedListener(new TextWatcher() {
|
code.addTextChangedListener(new TextWatcher() {
|
||||||
|
@ -89,56 +90,79 @@ public class CreateAccountCodeActivationFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
checkAccount.setEnabled(false);
|
checkAccount.setEnabled(false);
|
||||||
activateAccount(phone, username, code.getText().toString(), false);
|
accountCreator.setActivationCode(code.getText().toString());
|
||||||
|
if(linkAccount){
|
||||||
|
linkAccount();
|
||||||
|
} else {
|
||||||
|
activateAccount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url));
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activateAccount(final String phone, final String username, final String code, boolean suscribe) {
|
private void linkAccount(){
|
||||||
final Runnable runNotOk = new Runnable() {
|
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
public void run() {
|
accountCreator.setHa1(LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
|
accountCreator.activatePhoneNumberLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void activateAccount() {
|
||||||
|
if(accountCreator.getUsername() == null){
|
||||||
|
accountCreator.setUsername(accountCreator.getPhoneNumber());
|
||||||
|
}
|
||||||
|
accountCreator.activateAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
if(status.equals(Status.AccountActivated)){
|
||||||
|
checkAccount.setEnabled(true);
|
||||||
|
if(accountCreator.getUsername() != null){
|
||||||
|
AssistantActivity.instance().saveCreatedAccount(accountCreator.getUsername(), null , null, accountCreator.getHa1() , getString(R.string.default_domain), null);
|
||||||
|
AssistantActivity.instance().isAccountVerified(accountCreator.getUsername());
|
||||||
|
} else {
|
||||||
|
AssistantActivity.instance().saveCreatedAccount(accountCreator.getPhoneNumber(), null , null, accountCreator.getHa1() , getString(R.string.default_domain), null);
|
||||||
|
AssistantActivity.instance().isAccountVerified(accountCreator.getPhoneNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (status.equals(LinphoneAccountCreator.Status.Failed)){
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show();
|
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
|
@Override
|
||||||
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
|
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
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);
|
@Override
|
||||||
xmlRpcRequest.addStringArg(getString(R.string.default_domain));
|
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
xmlRpcSession.sendRequest(xmlRpcRequest);
|
if(status.equals(LinphoneAccountCreator.Status.Ok)){
|
||||||
|
LinphonePreferences.instance().setLinkPopupTime("");
|
||||||
|
AssistantActivity.instance().hideKeyboard();
|
||||||
|
AssistantActivity.instance().finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,31 +17,24 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneAccountCreator;
|
import org.linphone.core.LinphoneAccountCreator;
|
||||||
import org.linphone.core.LinphoneAccountCreatorImpl;
|
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
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.LinphoneXmlRpcSessionImpl;
|
|
||||||
import org.linphone.xmlrpc.XmlRpcHelper;
|
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -57,6 +50,7 @@ import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import static org.linphone.core.LinphoneAccountCreator.*;
|
import static org.linphone.core.LinphoneAccountCreator.*;
|
||||||
|
|
||||||
|
@ -64,78 +58,56 @@ import static org.linphone.core.LinphoneAccountCreator.*;
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class CreateAccountFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, LinphoneAccountCreatorListener {
|
public class CreateAccountFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, LinphoneAccountCreatorListener {
|
||||||
private Handler mHandler = new Handler();
|
|
||||||
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
|
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
|
||||||
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, sipUri;
|
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, assisstantTitle, sipUri;
|
||||||
|
private ImageView phoneNumberInfo;
|
||||||
|
|
||||||
private boolean phoneNumberOk = false;
|
private boolean phoneNumberOk = false;
|
||||||
private boolean usernameOk = false;
|
private boolean usernameOk = false;
|
||||||
private boolean passwordOk = false;
|
private boolean passwordOk = false;
|
||||||
private boolean emailOk = false;
|
private boolean emailOk = false;
|
||||||
private boolean confirmPasswordOk = false;
|
private boolean confirmPasswordOk = false;
|
||||||
|
private boolean linkAccount = false;
|
||||||
private Button createAccount, selectCountry;
|
private Button createAccount, selectCountry;
|
||||||
private CheckBox useUsername, useEmail;
|
private CheckBox useUsername, useEmail;
|
||||||
private LinearLayout phoneNumberLayout, usernameLayout, emailLayout;
|
private int countryCode;
|
||||||
|
private LinearLayout phoneNumberLayout, usernameLayout, emailLayout, passwordLayout, passwordConfirmLayout;
|
||||||
private final Pattern UPPER_CASE_REGEX = Pattern.compile("[A-Z]");
|
private final Pattern UPPER_CASE_REGEX = Pattern.compile("[A-Z]");
|
||||||
private LinphoneXmlRpcSession xmlRpcSession;
|
|
||||||
private CountryListFragment.Country country;
|
private CountryListFragment.Country country;
|
||||||
|
|
||||||
private LinphoneAccountCreator accountCreator;
|
private LinphoneAccountCreator accountCreator;
|
||||||
|
|
||||||
private String getUsername() {
|
|
||||||
if(usernameEdit != null) {
|
|
||||||
String username = usernameEdit.getText().toString();
|
|
||||||
return username.toLowerCase(Locale.getDefault());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
|
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
|
||||||
|
|
||||||
|
//Initialize accountCreator
|
||||||
accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), getResources().getString(R.string.wizard_url));
|
accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), getResources().getString(R.string.wizard_url));
|
||||||
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
||||||
accountCreator.setListener(this);
|
accountCreator.setListener(this);
|
||||||
|
|
||||||
phoneNumberError = (TextView) view.findViewById(R.id.phone_number_error);
|
createAccount = (Button) view.findViewById(R.id.assistant_create);
|
||||||
phoneNumberEdit = (EditText) view.findViewById(R.id.phone_number);
|
|
||||||
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
||||||
addPhoneNumberHandler(phoneNumberEdit, null);
|
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||||
|
emailLayout = (LinearLayout) view.findViewById(R.id.email_layout);
|
||||||
|
passwordLayout = (LinearLayout) view.findViewById(R.id.password_layout);
|
||||||
|
passwordConfirmLayout = (LinearLayout) view.findViewById(R.id.password_confirm_layout);
|
||||||
|
|
||||||
selectCountry = (Button) view.findViewById(R.id.select_country);
|
|
||||||
selectCountry.setOnClickListener(this);
|
|
||||||
|
|
||||||
dialCode = (EditText) view.findViewById(R.id.dial_code);
|
|
||||||
sipUri = (TextView) view.findViewById(R.id.sip_uri);
|
|
||||||
|
|
||||||
|
|
||||||
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
|
||||||
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
||||||
useUsername.setVisibility(View.VISIBLE);
|
useEmail = (CheckBox) view.findViewById(R.id.use_email);
|
||||||
useUsername.setOnCheckedChangeListener(this);
|
|
||||||
|
|
||||||
usernameError = (TextView) view.findViewById(R.id.username_error);
|
usernameError = (TextView) view.findViewById(R.id.username_error);
|
||||||
usernameEdit = (EditText) view.findViewById(R.id.username);
|
usernameEdit = (EditText) view.findViewById(R.id.username);
|
||||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
|
||||||
|
|
||||||
addUsernameHandler(usernameEdit, null);
|
phoneNumberError = (TextView) view.findViewById(R.id.phone_number_error);
|
||||||
}
|
phoneNumberEdit = (EditText) view.findViewById(R.id.phone_number);
|
||||||
|
sipUri = (TextView) view.findViewById(R.id.sip_uri);
|
||||||
|
|
||||||
if(getResources().getBoolean(R.bool.isTablet)){
|
phoneNumberInfo = (ImageView) view.findViewById(R.id.info_phone_number);
|
||||||
useEmail.setVisibility(View.VISIBLE);
|
|
||||||
useEmail = (CheckBox) view.findViewById(R.id.use_email);
|
selectCountry = (Button) view.findViewById(R.id.select_country);
|
||||||
useEmail.setOnCheckedChangeListener(this);
|
dialCode = (EditText) view.findViewById(R.id.dial_code);
|
||||||
|
assisstantTitle = (TextView) view.findViewById(R.id.assistant_title);
|
||||||
|
|
||||||
passwordError = (TextView) view.findViewById(R.id.password_error);
|
passwordError = (TextView) view.findViewById(R.id.password_error);
|
||||||
passwordEdit = (EditText) view.findViewById(R.id.password);
|
passwordEdit = (EditText) view.findViewById(R.id.password);
|
||||||
|
@ -145,11 +117,43 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
emailError = (TextView) view.findViewById(R.id.email_error);
|
emailError = (TextView) view.findViewById(R.id.email_error);
|
||||||
emailEdit = (EditText) view.findViewById(R.id.email);
|
emailEdit = (EditText) view.findViewById(R.id.email);
|
||||||
emailLayout = (LinearLayout) view.findViewById(R.id.email_layout);
|
|
||||||
|
|
||||||
addXMLRPCPasswordHandler(passwordEdit, null);
|
//Phone number
|
||||||
addXMLRPCConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
|
if(getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||||
addXMLRPCEmailHandler(emailEdit, null);
|
//Automatically get the country code from the phone
|
||||||
|
TelephonyManager tm = (TelephonyManager) getActivity().getApplicationContext().getSystemService(getActivity().getApplicationContext().TELEPHONY_SERVICE);
|
||||||
|
String countryIso = tm.getNetworkCountryIso();
|
||||||
|
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||||
|
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
|
||||||
|
|
||||||
|
phoneNumberLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
phoneNumberInfo.setOnClickListener(this);
|
||||||
|
addPhoneNumberHandler(phoneNumberEdit, null);
|
||||||
|
addPhoneNumberHandler(dialCode, null);
|
||||||
|
selectCountry.setOnClickListener(this);
|
||||||
|
|
||||||
|
String previousPhone = AssistantActivity.instance().phone_number;
|
||||||
|
if(previousPhone != null ){
|
||||||
|
phoneNumberEdit.setText(previousPhone);
|
||||||
|
}
|
||||||
|
setCountry(AssistantActivity.instance().country);
|
||||||
|
|
||||||
|
//Allow user to enter a username instead use the phone number as username
|
||||||
|
if(getResources().getBoolean(R.bool.assistant_allow_username) ) {
|
||||||
|
useUsername.setVisibility(View.VISIBLE);
|
||||||
|
useUsername.setOnCheckedChangeListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Password & email address
|
||||||
|
if (getResources().getBoolean(R.bool.isTablet) || !getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||||
|
useEmail.setVisibility(View.VISIBLE);
|
||||||
|
useEmail.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
|
addPasswordHandler(passwordEdit, null);
|
||||||
|
addConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
|
||||||
|
addEmailHandler(emailEdit, null);
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
|
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
|
||||||
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
|
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
|
||||||
|
@ -158,6 +162,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
if (isEmailCorrect(account.name)) {
|
if (isEmailCorrect(account.name)) {
|
||||||
String possibleEmail = account.name;
|
String possibleEmail = account.name;
|
||||||
emailEdit.setText(possibleEmail);
|
emailEdit.setText(possibleEmail);
|
||||||
|
accountCreator.setEmail(possibleEmail);
|
||||||
emailOk = true;
|
emailOk = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -165,77 +170,62 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String previousPhone = AssistantActivity.instance().phone_number;
|
//Hide phone number and display username/email/password
|
||||||
if(previousPhone != null ){
|
if(!getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||||
phoneNumberEdit.setText(previousPhone);
|
useEmail.setVisibility(View.GONE);
|
||||||
}
|
useUsername.setVisibility(View.GONE);
|
||||||
setCountry(AssistantActivity.instance().country);
|
|
||||||
updateApplyButton();
|
usernameLayout.setVisibility(View.VISIBLE);
|
||||||
|
passwordLayout.setVisibility(View.VISIBLE);
|
||||||
|
passwordConfirmLayout.setVisibility(View.VISIBLE);
|
||||||
|
emailLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Link account with phone number
|
||||||
|
if(getArguments().getBoolean("LinkPhoneNumber")){
|
||||||
|
linkAccount = true;
|
||||||
|
useEmail.setVisibility(View.GONE);
|
||||||
|
useUsername.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
usernameLayout.setVisibility(View.GONE);
|
||||||
|
passwordLayout.setVisibility(View.GONE);
|
||||||
|
passwordConfirmLayout.setVisibility(View.GONE);
|
||||||
|
emailLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
createAccount.setText(getResources().getString(R.string.assistant_link_account));
|
||||||
|
assisstantTitle.setText(getResources().getString(R.string.assistant_link_account));
|
||||||
|
}
|
||||||
|
addUsernameHandler(usernameEdit, null);
|
||||||
|
|
||||||
createAccount = (Button) view.findViewById(R.id.assistant_create);
|
|
||||||
createAccount.setEnabled(false);
|
createAccount.setEnabled(false);
|
||||||
createAccount.setOnClickListener(new OnClickListener() {
|
createAccount.setOnClickListener(this);
|
||||||
public void onClick(View v) {
|
|
||||||
if(getResources().getBoolean(R.bool.isTablet)) {
|
|
||||||
if (useEmail.isChecked()) {
|
|
||||||
createAccountWithEmail(getUsername(), passwordEdit.getText().toString(), emailEdit.getText().toString(), false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(getResources().getBoolean(R.bool.assistant_allow_username)){
|
|
||||||
createAccountWithPhoneNumber(getUsername(), "", getPhoneNumber(), false);
|
|
||||||
} else {
|
|
||||||
createAccountWithPhoneNumber(getPhoneNumber(), "", getPhoneNumber(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateApplyButton() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onPause() {
|
||||||
if(buttonView.getId() == R.id.use_username) {
|
super.onPause();
|
||||||
if(isChecked) {
|
accountCreator.setListener(null);
|
||||||
usernameLayout.setVisibility(View.VISIBLE);
|
|
||||||
if(usernameEdit.getText().length() > 0){
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
usernameLayout.setVisibility(View.GONE);
|
private String getUsername() {
|
||||||
if(phoneNumberEdit.getText().length() > 0){
|
if(usernameEdit != null) {
|
||||||
|
String username = usernameEdit.getText().toString();
|
||||||
|
return username.toLowerCase(Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
} else if(buttonView.getId() == R.id.use_email){
|
|
||||||
if(isChecked) {
|
private String getCountryCode() {
|
||||||
emailLayout.setVisibility(View.VISIBLE);
|
if(dialCode != null) {
|
||||||
usernameLayout.setVisibility(View.VISIBLE);
|
String code = dialCode.getText().toString();
|
||||||
useUsername.setEnabled(false);
|
if(code != null && code.startsWith("+")) {
|
||||||
} else {
|
code = code.substring(1);
|
||||||
if(!useUsername.isChecked()) {
|
|
||||||
usernameLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
emailLayout.setVisibility(View.GONE);
|
|
||||||
usernameLayout.setVisibility(View.GONE);
|
|
||||||
useUsername.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCountry(CountryListFragment.Country c) {
|
public void setCountry(CountryListFragment.Country c) {
|
||||||
|
@ -243,6 +233,43 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
if( c!= null) {
|
if( c!= null) {
|
||||||
dialCode.setText(c.dial_code);
|
dialCode.setText(c.dial_code);
|
||||||
selectCountry.setText(c.name);
|
selectCountry.setText(c.name);
|
||||||
|
} else {
|
||||||
|
if(countryCode != -1){
|
||||||
|
dialCode.setText("+" + countryCode);
|
||||||
|
} else {
|
||||||
|
dialCode.setText("+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if(buttonView.getId() == R.id.use_username) {
|
||||||
|
if(isChecked) {
|
||||||
|
usernameLayout.setVisibility(View.VISIBLE);
|
||||||
|
if(getResources().getBoolean(R.bool.isTablet)){
|
||||||
|
passwordLayout.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usernameLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else if(buttonView.getId() == R.id.use_email){
|
||||||
|
if(isChecked) {
|
||||||
|
emailLayout.setVisibility(View.VISIBLE);
|
||||||
|
passwordLayout.setVisibility(View.VISIBLE);
|
||||||
|
passwordConfirmLayout.setVisibility(View.VISIBLE);
|
||||||
|
usernameLayout.setVisibility(View.VISIBLE);
|
||||||
|
useUsername.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
if(!useUsername.isChecked()) {
|
||||||
|
usernameLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
emailLayout.setVisibility(View.GONE);
|
||||||
|
passwordLayout.setVisibility(View.GONE);
|
||||||
|
passwordConfirmLayout.setVisibility(View.GONE);
|
||||||
|
usernameLayout.setVisibility(View.GONE);
|
||||||
|
useUsername.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +278,24 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
switch (v.getId()){
|
switch (v.getId()){
|
||||||
case R.id.select_country: {
|
case R.id.select_country: {
|
||||||
AssistantActivity.instance().displayCountryChooser();
|
AssistantActivity.instance().displayCountryChooser();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case R.id.info_phone_number: {
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle(getString(R.string.phone_number_info_title))
|
||||||
|
.setMessage(getString(R.string.phone_number_info_content))
|
||||||
|
.show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case R.id.assistant_create: {
|
||||||
|
if(linkAccount){
|
||||||
|
addAlias();
|
||||||
|
} else {
|
||||||
|
createAccount();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,58 +312,6 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUsernameCorrect(String username) {
|
|
||||||
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_assistant)) {
|
|
||||||
LinphoneProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
|
|
||||||
return lpc.isPhoneNumber(username);
|
|
||||||
} else {
|
|
||||||
return username.matches("^[a-z]+[a-z0-9.\\-_]{2,}$");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void isUsernameRegistred(final String username, final ImageView icon) {
|
|
||||||
final Runnable runNotOk = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
usernameOk = false;
|
|
||||||
displayError(usernameOk, usernameError, usernameEdit, LinphoneManager.getInstance().getContext().getString(R.string.wizard_username_unavailable));
|
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final Runnable runOk = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
usernameOk = true;
|
|
||||||
displayError(usernameOk, usernameError, usernameEdit, "");
|
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final Runnable runNotReachable = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
usernameOk = false;
|
|
||||||
displayError(usernameOk, usernameError, usernameEdit, LinphoneManager.getInstance().getContext().getString(R.string.wizard_server_unavailable));
|
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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) {
|
|
||||||
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 boolean isEmailCorrect(String email) {
|
private boolean isEmailCorrect(String email) {
|
||||||
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
|
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
|
||||||
return emailPattern.matcher(email).matches();
|
return emailPattern.matcher(email).matches();
|
||||||
|
@ -328,113 +321,49 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
return password.length() >= 1;
|
return password.length() >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAccountWithPhoneNumber(final String username, final String password, final String phone, boolean suscribe) {
|
private void addAlias() {
|
||||||
|
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
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, false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final Runnable runOk = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
AssistantActivity.instance().displayAssistantConfirm(username, password);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final Runnable runNotReachable = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
//TODO errorMessage.setText(R.string.wizard_not_reachable);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("create_account_with_useragent", LinphoneXmlRpcRequest.ArgType.Int);
|
|
||||||
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 {
|
|
||||||
mHandler.post(runOk);
|
|
||||||
}
|
|
||||||
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
|
|
||||||
mHandler.post(runNotReachable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
xmlRpcRequest.addStringArg(username);
|
|
||||||
xmlRpcRequest.addStringArg(password);
|
|
||||||
xmlRpcRequest.addStringArg(email);
|
|
||||||
xmlRpcRequest.addStringArg(LinphoneManager.getInstance().getUserAgent());
|
|
||||||
xmlRpcSession.sendRequest(xmlRpcRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
|
|
||||||
field.addTextChangedListener(new TextWatcher() {
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
if (s.length() > 0) {
|
|
||||||
phoneNumberOk = false;
|
|
||||||
String countryCode = dialCode.getText().toString();
|
String countryCode = dialCode.getText().toString();
|
||||||
if(countryCode != null && countryCode.startsWith("+")) {
|
if(countryCode != null && countryCode.startsWith("+")) {
|
||||||
countryCode = countryCode.substring(1);
|
countryCode = countryCode.substring(1);
|
||||||
}
|
}
|
||||||
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
||||||
|
if(status.equals(Status.Ok)){
|
||||||
|
accountCreator.linkPhoneNumberWithAccount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createAccount() {
|
||||||
|
if(accountCreator.getUsername() == null && !useUsername.isChecked()){
|
||||||
|
accountCreator.setUsername(accountCreator.getPhoneNumber());
|
||||||
|
}
|
||||||
|
accountCreator.createAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
|
||||||
|
field.addTextChangedListener(new TextWatcher() {
|
||||||
|
public void afterTextChanged(Editable s) {}
|
||||||
|
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
|
||||||
|
public void onTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
if (s.length() > 0) {
|
||||||
|
phoneNumberOk = false;
|
||||||
|
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), getCountryCode());
|
||||||
|
|
||||||
if(status.equals(Status.Ok)){
|
if(status.equals(Status.Ok)){
|
||||||
accountCreator.isAccountUsed();
|
accountCreator.isAccountUsed();
|
||||||
|
if(useUsername.isChecked()){
|
||||||
|
accountCreator.setUsername(field.getText().toString());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, "");
|
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) {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,10 +386,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
usernameOk = false;
|
usernameOk = false;
|
||||||
Status status = accountCreator.setUsername(field.getText().toString());
|
Status status = accountCreator.setUsername(field.getText().toString());
|
||||||
if(status.equals(Status.Ok)){
|
if(status.equals(Status.Ok)){
|
||||||
accountCreator.setPhoneNumber(null,null);
|
|
||||||
accountCreator.isAccountUsed();
|
accountCreator.isAccountUsed();
|
||||||
} else {
|
} else {
|
||||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayError(true, usernameError, usernameEdit, "");
|
displayError(true, usernameError, usernameEdit, "");
|
||||||
|
@ -469,50 +398,48 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addXMLRPCEmailHandler(final EditText field, final ImageView icon) {
|
private void addEmailHandler(final EditText field, final ImageView icon) {
|
||||||
field.addTextChangedListener(new TextWatcher() {
|
field.addTextChangedListener(new TextWatcher() {
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int count, int after)
|
public void onTextChanged(CharSequence s, int start, int count, int after)
|
||||||
{
|
{
|
||||||
emailOk = false;
|
emailOk = false;
|
||||||
if (isEmailCorrect(field.getText().toString())) {
|
Status status = accountCreator.setEmail(field.getText().toString());
|
||||||
|
if (status.equals(Status.Ok)) {
|
||||||
emailOk = true;
|
emailOk = true;
|
||||||
displayError(emailOk, emailError, emailEdit, "");
|
displayError(emailOk, emailError, emailEdit, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
displayError(emailOk, emailError, emailEdit, getString(R.string.wizard_email_incorrect));
|
displayError(emailOk, emailError, emailEdit, errorForStatus(status));
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addXMLRPCPasswordHandler(final EditText field1, final ImageView icon) {
|
private void addPasswordHandler(final EditText field1, final ImageView icon) {
|
||||||
TextWatcher passwordListener = new TextWatcher() {
|
TextWatcher passwordListener = new TextWatcher() {
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int count, int after)
|
public void onTextChanged(CharSequence s, int start, int count, int after)
|
||||||
{
|
{
|
||||||
passwordOk = false;
|
passwordOk = false;
|
||||||
|
Status status = accountCreator.setPassword(field1.getText().toString());
|
||||||
if (isPasswordCorrect(field1.getText().toString())) {
|
if (isPasswordCorrect(field1.getText().toString())) {
|
||||||
passwordOk = true;
|
passwordOk = true;
|
||||||
displayError(passwordOk, passwordError, passwordEdit, "");
|
displayError(passwordOk, passwordError, passwordEdit, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
|
displayError(passwordOk, passwordError, passwordEdit, errorForStatus(status));
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
|
@ -521,26 +448,19 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
field1.addTextChangedListener(passwordListener);
|
field1.addTextChangedListener(passwordListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addXMLRPCConfirmPasswordHandler(final EditText field1, final EditText field2, final ImageView icon) {
|
private void addConfirmPasswordHandler(final EditText field1, final EditText field2, final ImageView icon) {
|
||||||
TextWatcher passwordListener = new TextWatcher() {
|
TextWatcher passwordListener = new TextWatcher() {
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int count, int after)
|
public void onTextChanged(CharSequence s, int start, int count, int after)
|
||||||
{
|
{
|
||||||
field2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
|
||||||
if (!hasFocus) {
|
|
||||||
confirmPasswordOk = false;
|
confirmPasswordOk = false;
|
||||||
if (field1.getText().toString().equals(field2.getText().toString())) {
|
if (field1.getText().toString().equals(field2.getText().toString())) {
|
||||||
confirmPasswordOk = true;
|
confirmPasswordOk = true;
|
||||||
|
|
||||||
if (!isPasswordCorrect(field1.getText().toString())) {
|
if (!isPasswordCorrect(field1.getText().toString())) {
|
||||||
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
|
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
|
||||||
} else {
|
} else {
|
||||||
|
@ -550,21 +470,15 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, getString(R.string.wizard_passwords_unmatched));
|
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, getString(R.string.wizard_passwords_unmatched));
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
} else {
|
|
||||||
displayError(true, passwordConfirmError, passwordConfirmEdit, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
field1.addTextChangedListener(passwordListener);
|
field1.addTextChangedListener(passwordListener);
|
||||||
field2.addTextChangedListener(passwordListener);
|
field2.addTextChangedListener(passwordListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
String errorForStatus(Status status) {
|
String errorForStatus(Status status) {
|
||||||
boolean isPhoneNumber = (phoneNumberEdit.getText().length() > 0);
|
|
||||||
if (status.equals(Status.EmailInvalid))
|
if (status.equals(Status.EmailInvalid))
|
||||||
return getString(R.string.invalid_email);
|
return getString(R.string.invalid_email);
|
||||||
if (status.equals(Status.UsernameInvalid)){
|
if (status.equals(Status.UsernameInvalid)){
|
||||||
|
@ -616,23 +530,38 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
|
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
|
||||||
|
if(getResources().getBoolean(R.bool.isTablet) || useEmail.isChecked()){
|
||||||
|
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||||
|
usernameOk = false;
|
||||||
|
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("");
|
||||||
|
} else {
|
||||||
|
usernameOk = true;
|
||||||
|
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("Sip uri is sip:" + accountCreator.getUsername() + "@" + getResources().getString(R.string.default_domain));
|
||||||
|
}
|
||||||
|
createAccount.setEnabled(usernameOk && emailOk);
|
||||||
|
}
|
||||||
if(getResources().getBoolean(R.bool.assistant_allow_username) && useUsername.isChecked()){
|
if(getResources().getBoolean(R.bool.assistant_allow_username) && useUsername.isChecked()){
|
||||||
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||||
usernameOk = false;
|
usernameOk = false;
|
||||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("");
|
||||||
} else {
|
} else {
|
||||||
usernameOk = true;
|
usernameOk = true;
|
||||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("Sip uri is sip:" + accountCreator.getUsername() + "@" + getResources().getString(R.string.default_domain));
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(usernameOk && phoneNumberOk);
|
createAccount.setEnabled(usernameOk);
|
||||||
} else {
|
} else {
|
||||||
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||||
phoneNumberOk = false;
|
phoneNumberOk = false;
|
||||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||||
phoneNumberOk = true;
|
sipUri.setText("");
|
||||||
} else {
|
} else {
|
||||||
phoneNumberOk = true;
|
phoneNumberOk = true;
|
||||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||||
|
sipUri.setText("Sip uri is sip:" + accountCreator.getPhoneNumber() + "@" + getResources().getString(R.string.default_domain));
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(phoneNumberOk);
|
createAccount.setEnabled(phoneNumberOk);
|
||||||
}
|
}
|
||||||
|
@ -640,6 +569,15 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
|
if(status.equals(Status.AccountCreated)) {
|
||||||
|
if(useEmail.isChecked()){
|
||||||
|
AssistantActivity.instance().displayAssistantConfirm(getUsername(), passwordEdit.getText().toString());
|
||||||
|
} else {
|
||||||
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getActivity().getApplicationContext(), errorForStatus(status), Toast.LENGTH_SHORT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -648,10 +586,16 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
|
if(status.equals(Status.Ok)){
|
||||||
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
|
if(status.equals(Status.Ok)){
|
||||||
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
|
@ -46,18 +47,15 @@ import android.widget.Toast;
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class LinphoneLoginFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, TextWatcher, LinphoneAccountCreator.LinphoneAccountCreatorListener {
|
public class LinphoneLoginFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, TextWatcher, LinphoneAccountCreator.LinphoneAccountCreatorListener {
|
||||||
private EditText login, password, displayName;
|
private EditText login, password, phoneNumberEdit, dialCode, displayName;
|
||||||
private Button apply;
|
private Button apply, selectCountry;
|
||||||
private CheckBox useUsername, usePassword;
|
private CheckBox useUsername, usePassword;
|
||||||
private LinearLayout phoneNumberLayout, usernameLayout, passwordLayout;
|
private LinearLayout phoneNumberLayout, usernameLayout, passwordLayout;
|
||||||
private TextView forgotPassword;
|
private TextView forgotPassword;
|
||||||
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
|
|
||||||
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, sipUri;
|
|
||||||
private CountryListFragment.Country country;
|
private CountryListFragment.Country country;
|
||||||
private Boolean recoverAccount = true;
|
private Boolean recoverAccount = false;
|
||||||
|
|
||||||
private LinphoneAccountCreator accountCreator;
|
private LinphoneAccountCreator accountCreator;
|
||||||
|
private int countryCode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -78,20 +76,55 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
||||||
addPhoneNumberHandler(phoneNumberEdit, null);
|
addPhoneNumberHandler(phoneNumberEdit, null);
|
||||||
|
|
||||||
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
|
||||||
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
||||||
|
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||||
|
passwordLayout = (LinearLayout) view.findViewById(R.id.password_layout);
|
||||||
|
password = (EditText) view.findViewById(R.id.assistant_password);
|
||||||
|
displayName = (EditText) view.findViewById(R.id.assistant_display_name);
|
||||||
|
|
||||||
|
forgotPassword = (TextView) view.findViewById(R.id.forgot_password);
|
||||||
|
selectCountry = (Button) view.findViewById(R.id.select_country);
|
||||||
|
|
||||||
|
//Phone number
|
||||||
|
if(getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||||
|
//Automatically get the country code from the phone
|
||||||
|
TelephonyManager tm = (TelephonyManager) getActivity().getApplicationContext().getSystemService(getActivity().getApplicationContext().TELEPHONY_SERVICE);
|
||||||
|
String countryIso = tm.getNetworkCountryIso();
|
||||||
|
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||||
|
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
|
||||||
|
|
||||||
|
phoneNumberLayout.setVisibility(View.VISIBLE);
|
||||||
|
selectCountry.setOnClickListener(this);
|
||||||
|
|
||||||
|
String previousPhone = AssistantActivity.instance().phone_number;
|
||||||
|
if(previousPhone != null ){
|
||||||
|
phoneNumberEdit.setText(previousPhone);
|
||||||
|
}
|
||||||
|
setCountry(AssistantActivity.instance().country);
|
||||||
|
|
||||||
|
//Allow user to enter a username instead use the phone number as username
|
||||||
|
if(getResources().getBoolean(R.bool.assistant_allow_username) ) {
|
||||||
useUsername.setVisibility(View.VISIBLE);
|
useUsername.setVisibility(View.VISIBLE);
|
||||||
useUsername.setOnCheckedChangeListener(this);
|
useUsername.setOnCheckedChangeListener(this);
|
||||||
|
}
|
||||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
password = (EditText) view.findViewById(R.id.assistant_password);
|
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
||||||
|
useUsername.setVisibility(View.VISIBLE);
|
||||||
|
useUsername.setOnCheckedChangeListener(this);
|
||||||
password.addTextChangedListener(this);
|
password.addTextChangedListener(this);
|
||||||
forgotPassword = (TextView) view.findViewById(R.id.forgot_password);
|
|
||||||
forgotPassword.setText(Compatibility.fromHtml("<a href=\"" + url + "\"'>" + getString(R.string.forgot_password) + "</a>"));
|
forgotPassword.setText(Compatibility.fromHtml("<a href=\"" + url + "\"'>" + getString(R.string.forgot_password) + "</a>"));
|
||||||
forgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
|
forgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
displayName = (EditText) view.findViewById(R.id.assistant_display_name);
|
}
|
||||||
|
|
||||||
|
//Hide phone number and display username/email/password
|
||||||
|
if(!getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||||
|
phoneNumberLayout.setVisibility(View.GONE);
|
||||||
|
useUsername.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
usernameLayout.setVisibility(View.VISIBLE);
|
||||||
|
passwordLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
apply = (Button) view.findViewById(R.id.assistant_apply);
|
apply = (Button) view.findViewById(R.id.assistant_apply);
|
||||||
apply.setEnabled(false);
|
apply.setEnabled(false);
|
||||||
|
@ -100,6 +133,31 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCountryCode() {
|
||||||
|
if(dialCode != null) {
|
||||||
|
String code = dialCode.getText().toString();
|
||||||
|
if(code != null && code.startsWith("+")) {
|
||||||
|
code = code.substring(1);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountry(CountryListFragment.Country c) {
|
||||||
|
country = c;
|
||||||
|
if( c!= null) {
|
||||||
|
dialCode.setText(c.dial_code);
|
||||||
|
selectCountry.setText(c.name);
|
||||||
|
} else {
|
||||||
|
if(countryCode != -1){
|
||||||
|
dialCode.setText("+" + countryCode);
|
||||||
|
} else {
|
||||||
|
dialCode.setText("+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getPhoneNumber(){
|
private String getPhoneNumber(){
|
||||||
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||||
String countryCode = dialCode.getText().toString();
|
String countryCode = dialCode.getText().toString();
|
||||||
|
@ -116,8 +174,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
Toast.makeText(getActivity(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), null, null, getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
||||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), null, displayName.getText().toString(), getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
|
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
|
||||||
|
@ -130,12 +187,10 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
countryCode = countryCode.substring(1);
|
countryCode = countryCode.substring(1);
|
||||||
}
|
}
|
||||||
LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
||||||
Log.w("Set PhoneNmuber " + status.toString());
|
|
||||||
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||||
status = accountCreator.isAccountUsed();
|
status = accountCreator.isAccountUsed();
|
||||||
Log.w("Is account activated " + status.toString());
|
|
||||||
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||||
|
recoverAccount = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
//displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||||
|
@ -164,10 +219,14 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
linphoneLogIn();
|
linphoneLogIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (id == R.id.select_country) {
|
||||||
|
AssistantActivity.instance().displayCountryChooser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recoverAccount() {
|
private void recoverAccount() {
|
||||||
accountCreator.recoverPhoneAccount();
|
//accountCreator.recoverPhoneAccount();
|
||||||
|
AssistantActivity.instance().displayAssistantCodeConfirm(accountCreator.getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -183,12 +242,20 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if(buttonView.getId() == R.id.use_username) {
|
||||||
|
if(isChecked) {
|
||||||
|
usernameLayout.setVisibility(View.VISIBLE);
|
||||||
|
passwordLayout.setVisibility(View.VISIBLE);
|
||||||
|
recoverAccount = false;
|
||||||
|
} else {
|
||||||
|
usernameLayout.setVisibility(View.GONE);
|
||||||
|
passwordLayout.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
recoverAccount = true;
|
|
||||||
apply.setEnabled(true);
|
apply.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,13 +281,11 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
Log.w("IS ACTIVATED " + status.toString());
|
|
||||||
apply.setEnabled(true);
|
apply.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
AssistantActivity.instance().displayAssistantCodeConfirm(getPhoneNumber(), getPhoneNumber(), true);
|
AssistantActivity.instance().displayAssistantCodeConfirm(accountCreator.getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue