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_height="wrap_content"/>
|
||||
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<TableRow
|
||||
android:layout_weight="1"
|
||||
|
@ -38,44 +39,153 @@
|
|||
android:layout_marginRight="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/phone_number_layout"
|
||||
android:visibility="visible"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username_label"
|
||||
android:text="@string/username"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
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/phone_number_label"
|
||||
android:text="@string/phone_number"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username_error"
|
||||
android:text="@string/error"
|
||||
style="@style/font20"
|
||||
<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_height="wrap_content"
|
||||
android:visibility="invisible"/>
|
||||
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
|
||||
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>
|
||||
|
||||
<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
|
||||
</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
|
||||
android:id="@+id/password_layout"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
android:paddingLeft="30dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content" android:layout_column="0">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/password_label"
|
||||
|
@ -106,7 +216,41 @@
|
|||
android:visibility="invisible"/>
|
||||
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
<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>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_weight="1"
|
||||
|
@ -115,48 +259,13 @@
|
|||
android:layout_marginRight="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="0dp"
|
||||
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:id="@+id/email_layout"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingLeft="30dp"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content" android:layout_column="0">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/email_label"
|
||||
|
@ -188,6 +297,44 @@
|
|||
android:visibility="invisible"/>
|
||||
|
||||
</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>
|
||||
</TableLayout>
|
||||
|
||||
|
|
|
@ -21,18 +21,123 @@
|
|||
android:paddingTop="10dp"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
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
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:layout_margin="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/username_layout"
|
||||
android:layout_gravity="top"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
@ -57,7 +162,10 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/password_layout"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="top"
|
||||
android:paddingLeft="30dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
@ -94,7 +202,9 @@
|
|||
android:layout_margin="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/display_layout"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content">
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/assistant_title"
|
||||
android:text="@string/assistant_create_account"
|
||||
style="@style/font6"
|
||||
android:textAllCaps="true"
|
||||
|
@ -26,76 +27,98 @@
|
|||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/phone_number_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_country"
|
||||
style="@style/font8"
|
||||
android:text="@string/select_your_country"
|
||||
android:background="@drawable/resizable_assistant_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/phone_number_layout"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phone_number_label"
|
||||
android:text="@string/phone_number"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
<RelativeLayout
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dial_code"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="phone"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/phone_number"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:contentDescription="@string/content_description_phone_number_field"
|
||||
android:inputType="phone"
|
||||
<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="40dp"
|
||||
android:singleLine="true"/>
|
||||
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
|
||||
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="42dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/phone_number"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:contentDescription="@string/content_description_phone_number_field"
|
||||
android:inputType="phone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phone_number_error"
|
||||
android:text="@string/error"
|
||||
style="@style/font20"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sip_uri"
|
||||
style="@style/font9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phone_number_error"
|
||||
android:text="@string/error"
|
||||
style="@style/font20"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sip_uri"
|
||||
style="@style/font9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
|
@ -149,7 +172,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/email_layout"
|
||||
android:id="@+id/password_layout"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -191,6 +214,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/password_confirm_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -226,6 +250,16 @@
|
|||
|
||||
</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
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -90,20 +90,6 @@
|
|||
|
||||
</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>
|
||||
|
||||
|
|
|
@ -49,4 +49,3 @@ username_length=-1
|
|||
username_max_length=64
|
||||
username_min_length=1
|
||||
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="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 -->
|
||||
<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_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="hide_assistant">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>
|
||||
|
||||
<!-- 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="time_between_inapp_notification">86400</integer><!-- Time between two inapp notifications in seconds -->
|
||||
<bool name="hide_username_in_inapp">true</bool>
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
<string name="connect">Connection</string>
|
||||
<string name="decline">Decline</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 -->
|
||||
<string name="app_description">the <i>libre</i> SIP client</string>
|
||||
|
@ -57,6 +59,7 @@
|
|||
<string name="welcome">Welcome</string>
|
||||
<string name="assistant">Assistant</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_activate">Activate account</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_email_for_validation">Use email address for account validation</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 -->
|
||||
<string name="invalid_email">Invalid email</string>
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
android:key="@string/pref_add_account_key"
|
||||
android:persistent="false"/>
|
||||
|
||||
<Preference
|
||||
android:title="@string/pref_in_app_store"
|
||||
android:key="@string/pref_in_app_store_key"
|
||||
android:persistent="false"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_preferences_title">
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.linphone.assistant.AssistantActivity;
|
|||
import org.linphone.assistant.RemoteProvisioningLoginActivity;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.CallDirection;
|
||||
import org.linphone.core.LinphoneAccountCreator;
|
||||
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
|
@ -100,7 +102,7 @@ import android.widget.Toast;
|
|||
/**
|
||||
* @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";
|
||||
private static final int SETTINGS_ACTIVITY = 123;
|
||||
private static final int CALL_ACTIVITY = 19;
|
||||
|
@ -202,10 +204,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
initButtons();
|
||||
initSideMenu();
|
||||
|
||||
if(getResources().getBoolean(R.bool.enable_in_app_purchase)){
|
||||
isTrialAccount();
|
||||
}
|
||||
|
||||
currentFragment = FragmentsAvailable.EMPTY;
|
||||
if (savedInstanceState == null) {
|
||||
changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras());
|
||||
|
@ -628,6 +626,13 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
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() {
|
||||
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
|
||||
}
|
||||
|
@ -981,8 +986,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
private int mAlwaysChangingPhoneAngle = -1;
|
||||
|
||||
|
||||
|
||||
private class LocalOrientationEventListener extends OrientationEventListener {
|
||||
public LocalOrientationEventListener(Context context) {
|
||||
super(context);
|
||||
|
@ -1120,7 +1123,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
protected void onPause() {
|
||||
getIntent().putExtra("PreviousActivity", 0);
|
||||
|
||||
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
||||
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled() && LinphoneManager.getLc().getDefaultProxyConfig() != null){
|
||||
LinphoneManager.getInstance().subscribeFriendList(!isApplicationBroughtToBackground(this));
|
||||
}
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
@ -1333,6 +1336,16 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
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();
|
||||
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
||||
LinphoneManager.getInstance().subscribeFriendList(true);
|
||||
|
@ -1578,8 +1591,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void refreshAccounts(){
|
||||
if (LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
||||
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
|
||||
private void isTrialAccount() {
|
||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphonePreferences.instance().getInappPopupTime() != null) {
|
||||
XmlRpcHelper helper = new XmlRpcHelper();
|
||||
helper.isTrialAccountAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
|
@ -1683,13 +1705,14 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error){}
|
||||
public void onError(String error) {
|
||||
}
|
||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
private void getExpirationAccount() {
|
||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphonePreferences.instance().getInappPopupTime() != null) {
|
||||
XmlRpcHelper helper = new XmlRpcHelper();
|
||||
helper.getAccountExpireAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
|
@ -1708,16 +1731,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error){}
|
||||
public void onError(String error) {
|
||||
}
|
||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
} 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){
|
||||
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;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -746,7 +746,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
mLc.setCallLogsDatabasePath(mCallLogDatabaseFile);
|
||||
mLc.setFriendsDatabasePath(mFriendsDatabaseFile);
|
||||
mLc.setUserCertificatesPath(mUserCertificatePath);
|
||||
subscribeFriendList(mPrefs.isFriendlistsubscriptionEnabled());
|
||||
//subscribeFriendList(mPrefs.isFriendlistsubscriptionEnabled());
|
||||
//mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile);
|
||||
enableDeviceRingtone(mPrefs.isDeviceRingtoneEnabled());
|
||||
|
||||
|
|
|
@ -1311,12 +1311,20 @@ public class LinphonePreferences {
|
|||
return purchasables;
|
||||
}
|
||||
|
||||
public String getLastDateNotificationShown(){
|
||||
return getConfig().getString("app", "notification_date", null);
|
||||
public String getInappPopupTime(){
|
||||
return getConfig().getString("app", "inapp_popup_time", null);
|
||||
}
|
||||
|
||||
public void setLastDateNotificationShown(String date){
|
||||
getConfig().setString("app", "notification_date", date);
|
||||
public void setInappPopupTime(String 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() {
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.linphone.core.PayloadType;
|
|||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.purchase.InAppPurchaseActivity;
|
||||
import org.linphone.tools.OpenH264DownloadHelper;
|
||||
import org.linphone.ui.LedPreference;
|
||||
import org.linphone.ui.PreferencesListFragment;
|
||||
|
@ -65,7 +64,6 @@ import android.provider.Settings;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class SettingsFragment extends PreferencesListFragment {
|
||||
private static final int STORE_INTENT = 2;
|
||||
private LinphonePreferences mPrefs;
|
||||
private Handler mHandler = new Handler();
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
|
|
|
@ -61,6 +61,7 @@ import android.view.WindowManager;
|
|||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -71,7 +72,7 @@ private static AssistantActivity instance;
|
|||
private AssistantFragmentsEnum firstFragment;
|
||||
private Fragment fragment;
|
||||
private LinphonePreferences mPrefs;
|
||||
private boolean accountCreated = false, newAccount = false;
|
||||
private boolean accountCreated = false, newAccount = false, isLink = false;
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
private LinphoneAddress address;
|
||||
private StatusFragment status;
|
||||
|
@ -96,14 +97,19 @@ private static AssistantActivity instance;
|
|||
setContentView(R.layout.assistant);
|
||||
initUI();
|
||||
|
||||
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 (savedInstanceState == null) {
|
||||
display(firstFragment);
|
||||
} else {
|
||||
currentFragment = (AssistantFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
|
||||
}
|
||||
}
|
||||
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;
|
||||
if (findViewById(R.id.fragment_container) != null) {
|
||||
if (savedInstanceState == null) {
|
||||
display(firstFragment);
|
||||
} else {
|
||||
currentFragment = (AssistantFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
|
||||
echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
|
||||
} else {
|
||||
|
@ -358,6 +364,9 @@ private static AssistantActivity instance;
|
|||
|
||||
public void displayCreateAccount() {
|
||||
fragment = new CreateAccountFragment();
|
||||
Bundle extra = new Bundle();
|
||||
extra.putBoolean("LinkPhoneNumber", isLink);
|
||||
fragment.setArguments(extra);
|
||||
changeFragment(fragment);
|
||||
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT;
|
||||
back.setVisibility(View.VISIBLE);
|
||||
|
@ -525,13 +534,15 @@ private static AssistantActivity instance;
|
|||
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();
|
||||
newAccount = true;
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("Username", username);
|
||||
extras.putString("Phone", phone);
|
||||
extras.putString("Dialcode", dialcode);
|
||||
extras.putBoolean("RecoverAccount", recoverAccount);
|
||||
extras.putBoolean("LinkAccount", isLink);
|
||||
fragment.setArguments(extras);
|
||||
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) {
|
||||
Country c = (Country)view.getTag();
|
||||
AssistantActivity.instance().country = c;
|
||||
AssistantActivity.instance().displayCreateAccount();
|
||||
AssistantActivity.instance().onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import org.linphone.mediastream.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -34,23 +34,20 @@ import android.widget.Toast;
|
|||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.LinphoneXmlRpcRequest;
|
||||
import org.linphone.core.LinphoneXmlRpcRequest.LinphoneXmlRpcRequestListener;
|
||||
import org.linphone.core.LinphoneXmlRpcRequestImpl;
|
||||
import org.linphone.core.LinphoneXmlRpcSession;
|
||||
import org.linphone.core.LinphoneXmlRpcSession;
|
||||
import org.linphone.core.LinphoneXmlRpcSessionImpl;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.core.LinphoneAccountCreator;
|
||||
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||
|
||||
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 boolean recoverAccount;
|
||||
private boolean recoverAccount = false, linkAccount = false;
|
||||
private int code_length;
|
||||
private Handler mHandler = new Handler();
|
||||
private Button checkAccount;
|
||||
private LinphoneXmlRpcSession xmlRpcSession;
|
||||
|
||||
private LinphoneAccountCreator accountCreator;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -58,12 +55,16 @@ public class CreateAccountCodeActivationFragment extends Fragment {
|
|||
|
||||
username = getArguments().getString("Username");
|
||||
phone = getArguments().getString("Phone");
|
||||
dialcode = getArguments().getString("Dialcode");
|
||||
recoverAccount = getArguments().getBoolean("RecoverAccount");
|
||||
code_length = LinphonePreferences.instance().getCodeLength();
|
||||
linkAccount = getArguments().getBoolean("LinkAccount");
|
||||
|
||||
if(username == null || username.length() == 0){
|
||||
username = phone;
|
||||
}
|
||||
code_length = LinphonePreferences.instance().getCodeLength();
|
||||
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.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -89,56 +90,79 @@ public class CreateAccountCodeActivationFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
checkAccount.setEnabled(false);
|
||||
activateAccount(phone, username, code.getText().toString(), false);
|
||||
}
|
||||
});
|
||||
|
||||
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void activateAccount(final String phone, final String username, final String code, boolean suscribe) {
|
||||
final Runnable runNotOk = new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
final Runnable runOk = new Runnable() {
|
||||
public void run() {
|
||||
checkAccount.setEnabled(true);
|
||||
AssistantActivity.instance().saveCreatedAccount(username, null, null, ha1, getString(R.string.default_domain), null);
|
||||
AssistantActivity.instance().isAccountVerified(username);
|
||||
}
|
||||
};
|
||||
final Runnable runNotReachable = new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
|
||||
LinphoneXmlRpcRequest xmlRpcRequest = new LinphoneXmlRpcRequestImpl("activate_phone_account", LinphoneXmlRpcRequest.ArgType.String);
|
||||
xmlRpcRequest.setListener(new LinphoneXmlRpcRequestListener() {
|
||||
@Override
|
||||
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
|
||||
if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) {
|
||||
String response = request.getStringResponse();
|
||||
if (response.contains("ERROR")) {
|
||||
mHandler.post(runNotOk);
|
||||
} else {
|
||||
ha1 = response;
|
||||
mHandler.post(runOk);
|
||||
}
|
||||
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
|
||||
mHandler.post(runNotReachable);
|
||||
accountCreator.setActivationCode(code.getText().toString());
|
||||
if(linkAccount){
|
||||
linkAccount();
|
||||
} else {
|
||||
activateAccount();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
xmlRpcRequest.addStringArg(phone);
|
||||
xmlRpcRequest.addStringArg(username);
|
||||
xmlRpcRequest.addStringArg(code);
|
||||
xmlRpcRequest.addStringArg(getString(R.string.default_domain));
|
||||
xmlRpcSession.sendRequest(xmlRpcRequest);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void linkAccount(){
|
||||
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
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
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.LinphoneAccountCreator;
|
||||
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||
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 android.Manifest;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -57,6 +50,7 @@ import android.widget.EditText;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import static org.linphone.core.LinphoneAccountCreator.*;
|
||||
|
||||
|
@ -64,92 +58,102 @@ import static org.linphone.core.LinphoneAccountCreator.*;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class CreateAccountFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, LinphoneAccountCreatorListener {
|
||||
private Handler mHandler = new Handler();
|
||||
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 usernameOk = false;
|
||||
private boolean passwordOk = false;
|
||||
private boolean emailOk = false;
|
||||
private boolean confirmPasswordOk = false;
|
||||
private boolean linkAccount = false;
|
||||
private Button createAccount, selectCountry;
|
||||
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 LinphoneXmlRpcSession xmlRpcSession;
|
||||
private CountryListFragment.Country country;
|
||||
|
||||
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
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
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.setDomain(getResources().getString(R.string.default_domain));
|
||||
accountCreator.setListener(this);
|
||||
|
||||
createAccount = (Button) view.findViewById(R.id.assistant_create);
|
||||
|
||||
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
||||
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);
|
||||
|
||||
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
||||
useEmail = (CheckBox) view.findViewById(R.id.use_email);
|
||||
|
||||
usernameError = (TextView) view.findViewById(R.id.username_error);
|
||||
usernameEdit = (EditText) view.findViewById(R.id.username);
|
||||
|
||||
phoneNumberError = (TextView) view.findViewById(R.id.phone_number_error);
|
||||
phoneNumberEdit = (EditText) view.findViewById(R.id.phone_number);
|
||||
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
||||
addPhoneNumberHandler(phoneNumberEdit, null);
|
||||
|
||||
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);
|
||||
|
||||
phoneNumberInfo = (ImageView) view.findViewById(R.id.info_phone_number);
|
||||
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
||||
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
||||
useUsername.setVisibility(View.VISIBLE);
|
||||
useUsername.setOnCheckedChangeListener(this);
|
||||
selectCountry = (Button) view.findViewById(R.id.select_country);
|
||||
dialCode = (EditText) view.findViewById(R.id.dial_code);
|
||||
assisstantTitle = (TextView) view.findViewById(R.id.assistant_title);
|
||||
|
||||
usernameError = (TextView) view.findViewById(R.id.username_error);
|
||||
usernameEdit = (EditText) view.findViewById(R.id.username);
|
||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||
passwordError = (TextView) view.findViewById(R.id.password_error);
|
||||
passwordEdit = (EditText) view.findViewById(R.id.password);
|
||||
|
||||
addUsernameHandler(usernameEdit, null);
|
||||
passwordConfirmError = (TextView) view.findViewById(R.id.confirm_password_error);
|
||||
passwordConfirmEdit = (EditText) view.findViewById(R.id.confirm_password);
|
||||
|
||||
emailError = (TextView) view.findViewById(R.id.email_error);
|
||||
emailEdit = (EditText) view.findViewById(R.id.email);
|
||||
|
||||
//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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if(getResources().getBoolean(R.bool.isTablet)){
|
||||
//Password & email address
|
||||
if (getResources().getBoolean(R.bool.isTablet) || !getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||
useEmail.setVisibility(View.VISIBLE);
|
||||
useEmail = (CheckBox) view.findViewById(R.id.use_email);
|
||||
useEmail.setOnCheckedChangeListener(this);
|
||||
|
||||
passwordError = (TextView) view.findViewById(R.id.password_error);
|
||||
passwordEdit = (EditText) view.findViewById(R.id.password);
|
||||
|
||||
passwordConfirmError = (TextView) view.findViewById(R.id.confirm_password_error);
|
||||
passwordConfirmEdit = (EditText) view.findViewById(R.id.confirm_password);
|
||||
|
||||
emailError = (TextView) view.findViewById(R.id.email_error);
|
||||
emailEdit = (EditText) view.findViewById(R.id.email);
|
||||
emailLayout = (LinearLayout) view.findViewById(R.id.email_layout);
|
||||
|
||||
addXMLRPCPasswordHandler(passwordEdit, null);
|
||||
addXMLRPCConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
|
||||
addXMLRPCEmailHandler(emailEdit, null);
|
||||
addPasswordHandler(passwordEdit, null);
|
||||
addConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
|
||||
addEmailHandler(emailEdit, null);
|
||||
|
||||
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
|
||||
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
|
||||
|
@ -158,6 +162,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
if (isEmailCorrect(account.name)) {
|
||||
String possibleEmail = account.name;
|
||||
emailEdit.setText(possibleEmail);
|
||||
accountCreator.setEmail(possibleEmail);
|
||||
emailOk = true;
|
||||
break;
|
||||
}
|
||||
|
@ -165,77 +170,62 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
}
|
||||
}
|
||||
|
||||
String previousPhone = AssistantActivity.instance().phone_number;
|
||||
if(previousPhone != null ){
|
||||
phoneNumberEdit.setText(previousPhone);
|
||||
}
|
||||
setCountry(AssistantActivity.instance().country);
|
||||
updateApplyButton();
|
||||
//Hide phone number and display username/email/password
|
||||
if(!getResources().getBoolean(R.bool.use_phone_number_validation)){
|
||||
useEmail.setVisibility(View.GONE);
|
||||
useUsername.setVisibility(View.GONE);
|
||||
|
||||
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.setOnClickListener(new OnClickListener() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
createAccount.setOnClickListener(this);
|
||||
|
||||
|
||||
int phoneStatePermission = getActivity().getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getActivity().getPackageName());
|
||||
|
||||
if (phoneStatePermission == PackageManager.PERMISSION_GRANTED) {
|
||||
TelephonyManager mTelephonyManager;
|
||||
mTelephonyManager = (TelephonyManager) getActivity().getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
|
||||
String yourNumber = mTelephonyManager.getLine1Number();
|
||||
String iso = mTelephonyManager.getNetworkCountryIso();
|
||||
}
|
||||
|
||||
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), getString(R.string.wizard_url));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void updateApplyButton() {
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
accountCreator.setListener(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if(buttonView.getId() == R.id.use_username) {
|
||||
if(isChecked) {
|
||||
usernameLayout.setVisibility(View.VISIBLE);
|
||||
if(usernameEdit.getText().length() > 0){
|
||||
}
|
||||
} else {
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
if(phoneNumberEdit.getText().length() > 0){
|
||||
}
|
||||
}
|
||||
} else if(buttonView.getId() == R.id.use_email){
|
||||
if(isChecked) {
|
||||
emailLayout.setVisibility(View.VISIBLE);
|
||||
usernameLayout.setVisibility(View.VISIBLE);
|
||||
useUsername.setEnabled(false);
|
||||
} else {
|
||||
if(!useUsername.isChecked()) {
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
}
|
||||
emailLayout.setVisibility(View.GONE);
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
useUsername.setEnabled(true);
|
||||
}
|
||||
private String getUsername() {
|
||||
if(usernameEdit != null) {
|
||||
String username = usernameEdit.getText().toString();
|
||||
return username.toLowerCase(Locale.getDefault());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -243,6 +233,43 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
if( c!= null) {
|
||||
dialCode.setText(c.dial_code);
|
||||
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()){
|
||||
case R.id.select_country: {
|
||||
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) {
|
||||
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
|
||||
return emailPattern.matcher(email).matches();
|
||||
|
@ -327,114 +320,50 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
private boolean isPasswordCorrect(String password) {
|
||||
return password.length() >= 1;
|
||||
}
|
||||
|
||||
private void createAccountWithPhoneNumber(final String username, final String password, final String phone, 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().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 addAlias() {
|
||||
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
String countryCode = dialCode.getText().toString();
|
||||
if(countryCode != null && countryCode.startsWith("+")) {
|
||||
countryCode = countryCode.substring(1);
|
||||
}
|
||||
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
||||
if(status.equals(Status.Ok)){
|
||||
accountCreator.linkPhoneNumberWithAccount();
|
||||
}
|
||||
}
|
||||
|
||||
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 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 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;
|
||||
String countryCode = dialCode.getText().toString();
|
||||
if(countryCode != null && countryCode.startsWith("+")) {
|
||||
countryCode = countryCode.substring(1);
|
||||
}
|
||||
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
||||
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), getCountryCode());
|
||||
|
||||
if(status.equals(Status.Ok)){
|
||||
accountCreator.isAccountUsed();
|
||||
if(useUsername.isChecked()){
|
||||
accountCreator.setUsername(field.getText().toString());
|
||||
}
|
||||
} else {
|
||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||
sipUri.setText("");
|
||||
}
|
||||
} else {
|
||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, "");
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -457,10 +386,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
usernameOk = false;
|
||||
Status status = accountCreator.setUsername(field.getText().toString());
|
||||
if(status.equals(Status.Ok)){
|
||||
accountCreator.setPhoneNumber(null,null);
|
||||
accountCreator.isAccountUsed();
|
||||
} else {
|
||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||
sipUri.setText("");
|
||||
}
|
||||
} else {
|
||||
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() {
|
||||
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)
|
||||
{
|
||||
emailOk = false;
|
||||
if (isEmailCorrect(field.getText().toString())) {
|
||||
Status status = accountCreator.setEmail(field.getText().toString());
|
||||
if (status.equals(Status.Ok)) {
|
||||
emailOk = true;
|
||||
displayError(emailOk, emailError, emailEdit, "");
|
||||
}
|
||||
else {
|
||||
displayError(emailOk, emailError, emailEdit, getString(R.string.wizard_email_incorrect));
|
||||
displayError(emailOk, emailError, emailEdit, errorForStatus(status));
|
||||
}
|
||||
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() {
|
||||
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)
|
||||
{
|
||||
passwordOk = false;
|
||||
Status status = accountCreator.setPassword(field1.getText().toString());
|
||||
if (isPasswordCorrect(field1.getText().toString())) {
|
||||
passwordOk = true;
|
||||
displayError(passwordOk, passwordError, passwordEdit, "");
|
||||
}
|
||||
else {
|
||||
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
|
||||
displayError(passwordOk, passwordError, passwordEdit, errorForStatus(status));
|
||||
}
|
||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||
}
|
||||
|
@ -521,50 +448,37 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
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() {
|
||||
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)
|
||||
{
|
||||
field2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus) {
|
||||
confirmPasswordOk = false;
|
||||
if (field1.getText().toString().equals(field2.getText().toString())) {
|
||||
confirmPasswordOk = true;
|
||||
|
||||
if (!isPasswordCorrect(field1.getText().toString())) {
|
||||
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
|
||||
} else {
|
||||
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, "");
|
||||
}
|
||||
} else {
|
||||
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, getString(R.string.wizard_passwords_unmatched));
|
||||
}
|
||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||
} else {
|
||||
displayError(true, passwordConfirmError, passwordConfirmEdit, "");
|
||||
}
|
||||
confirmPasswordOk = false;
|
||||
if (field1.getText().toString().equals(field2.getText().toString())) {
|
||||
confirmPasswordOk = true;
|
||||
if (!isPasswordCorrect(field1.getText().toString())) {
|
||||
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
|
||||
} else {
|
||||
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, "");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, getString(R.string.wizard_passwords_unmatched));
|
||||
}
|
||||
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
field1.addTextChangedListener(passwordListener);
|
||||
field2.addTextChangedListener(passwordListener);
|
||||
}
|
||||
|
||||
String errorForStatus(Status status) {
|
||||
boolean isPhoneNumber = (phoneNumberEdit.getText().length() > 0);
|
||||
if (status.equals(Status.EmailInvalid))
|
||||
return getString(R.string.invalid_email);
|
||||
if (status.equals(Status.UsernameInvalid)){
|
||||
|
@ -616,23 +530,38 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
@Override
|
||||
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 (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 && phoneNumberOk);
|
||||
createAccount.setEnabled(usernameOk);
|
||||
} else {
|
||||
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||
phoneNumberOk = false;
|
||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||
phoneNumberOk = true;
|
||||
sipUri.setText("");
|
||||
} else {
|
||||
phoneNumberOk = true;
|
||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||
sipUri.setText("Sip uri is sip:" + accountCreator.getPhoneNumber() + "@" + getResources().getString(R.string.default_domain));
|
||||
}
|
||||
createAccount.setEnabled(phoneNumberOk);
|
||||
}
|
||||
|
@ -640,6 +569,15 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
@Override
|
||||
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
|
||||
|
@ -648,10 +586,16 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
@Override
|
||||
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status) {
|
||||
if(status.equals(Status.Ok)){
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status) {
|
||||
if(status.equals(Status.Ok)){
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.linphone.mediastream.Log;
|
|||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
|
@ -46,18 +47,15 @@ import android.widget.Toast;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class LinphoneLoginFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, TextWatcher, LinphoneAccountCreator.LinphoneAccountCreatorListener {
|
||||
private EditText login, password, displayName;
|
||||
private Button apply;
|
||||
private EditText login, password, phoneNumberEdit, dialCode, displayName;
|
||||
private Button apply, selectCountry;
|
||||
private CheckBox useUsername, usePassword;
|
||||
private LinearLayout phoneNumberLayout, usernameLayout, passwordLayout;
|
||||
private TextView forgotPassword;
|
||||
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
|
||||
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, sipUri;
|
||||
private CountryListFragment.Country country;
|
||||
private Boolean recoverAccount = true;
|
||||
|
||||
private Boolean recoverAccount = false;
|
||||
private LinphoneAccountCreator accountCreator;
|
||||
|
||||
private int countryCode;
|
||||
|
||||
@Override
|
||||
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);
|
||||
addPhoneNumberHandler(phoneNumberEdit, null);
|
||||
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
||||
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
||||
useUsername.setVisibility(View.VISIBLE);
|
||||
useUsername.setOnCheckedChangeListener(this);
|
||||
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);
|
||||
|
||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||
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.setOnCheckedChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
password = (EditText) view.findViewById(R.id.assistant_password);
|
||||
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.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
displayName = (EditText) view.findViewById(R.id.assistant_display_name);
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
||||
useUsername.setVisibility(View.VISIBLE);
|
||||
useUsername.setOnCheckedChangeListener(this);
|
||||
password.addTextChangedListener(this);
|
||||
forgotPassword.setText(Compatibility.fromHtml("<a href=\"" + url + "\"'>" + getString(R.string.forgot_password) + "</a>"));
|
||||
forgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
//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.setEnabled(false);
|
||||
|
@ -100,6 +133,31 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
|||
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(){
|
||||
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), null, displayName.getText().toString(), getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), null, null, getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
|
||||
Log.w("Set PhoneNmuber " + status.toString());
|
||||
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||
status = accountCreator.isAccountUsed();
|
||||
Log.w("Is account activated " + status.toString());
|
||||
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||
|
||||
recoverAccount = true;
|
||||
}
|
||||
} else {
|
||||
//displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||
|
@ -164,10 +219,14 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
|||
linphoneLogIn();
|
||||
}
|
||||
}
|
||||
if (id == R.id.select_country) {
|
||||
AssistantActivity.instance().displayCountryChooser();
|
||||
}
|
||||
}
|
||||
|
||||
private void recoverAccount() {
|
||||
accountCreator.recoverPhoneAccount();
|
||||
//accountCreator.recoverPhoneAccount();
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(accountCreator.getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,12 +242,20 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
@Override
|
||||
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
|
||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
recoverAccount = true;
|
||||
apply.setEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -214,13 +281,11 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
@Override
|
||||
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
Log.w("IS ACTIVATED " + status.toString());
|
||||
apply.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
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