Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
c6889da4
Commit
c6889da4
authored
Apr 08, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AccountAdd use AccountAddFragment now.
parent
822f8cb9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
262 additions
and
192 deletions
+262
-192
AccountAdd.java
app/src/main/java/com/xabber/android/ui/AccountAdd.java
+24
-80
AccountAddFragment.java
...c/main/java/com/xabber/android/ui/AccountAddFragment.java
+107
-0
AccountList.java
...n/java/com/xabber/android/ui/preferences/AccountList.java
+1
-1
account_add.xml
app/src/main/res/layout/account_add.xml
+17
-109
account_add_fragment.xml
app/src/main/res/layout/account_add_fragment.xml
+111
-0
account_editor.xml
app/src/main/res/values-ru/account_editor.xml
+1
-1
account_editor.xml
app/src/main/res/values/account_editor.xml
+1
-1
No files found.
app/src/main/java/com/xabber/android/ui/AccountAdd.java
View file @
c6889da4
...
...
@@ -18,30 +18,15 @@ import android.content.Context;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.v7.widget.Toolbar
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.CheckBox
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.AccountType
;
import
com.xabber.android.data.intent.AccountIntentBuilder
;
import
com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.android.ui.helper.OrbotHelper
;
import
com.xabber.androiddev.R
;
public
class
AccountAdd
extends
ManagedActivity
implements
View
.
OnClickListener
{
private
CheckBox
storePasswordView
;
private
CheckBox
useOrbotView
;
private
CheckBox
createAccount
;
private
AccountType
accountType
;
public
class
AccountAdd
extends
ManagedActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -51,84 +36,43 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener
setContentView
(
R
.
layout
.
account_add
);
accountType
=
AccountManager
.
getInstance
().
getAccountTypes
().
get
(
0
);
storePasswordView
=
(
CheckBox
)
findViewById
(
R
.
id
.
store_password
);
useOrbotView
=
(
CheckBox
)
findViewById
(
R
.
id
.
use_orbot
);
createAccount
=
(
CheckBox
)
findViewById
(
R
.
id
.
register_account
);
findViewById
(
R
.
id
.
ok
).
setOnClickListener
(
this
);
createAccount
.
setOnClickListener
(
this
);
InputMethodManager
inputManager
=
(
InputMethodManager
)
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
inputManager
.
hideSoftInputFromWindow
(
findViewById
(
R
.
id
.
ok
)
.
getWindowToken
(),
InputMethodManager
.
HIDE_NOT_ALWAYS
);
if
(
savedInstanceState
==
null
)
{
getSupportFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
container
,
AccountAddFragment
.
newInstance
()).
commit
();
}
setSupportActionBar
((
Toolbar
)
findViewById
(
R
.
id
.
toolbar_default
));
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
findViewById
(
R
.
id
.
auth_panel
).
setVisibility
(
View
.
VISIBLE
);
((
TextView
)
findViewById
(
R
.
id
.
account_user_name
)).
setHint
(
accountType
.
getHint
());
((
TextView
)
findViewById
(
R
.
id
.
account_help
)).
setText
(
accountType
.
getHelp
());
getSupportActionBar
().
setHomeAsUpIndicator
(
R
.
drawable
.
ic_clear_white_24dp
);
getSupportActionBar
().
setTitle
(
null
);
}
@Override
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
ok
:
addAccount
();
break
;
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
MenuInflater
inflater
=
getMenuInflater
();
inflater
.
inflate
(
R
.
menu
.
add_account
,
menu
);
menu
.
findItem
(
R
.
id
.
action_add_account
).
setIcon
(
null
);
case
R
.
id
.
register_account
:
LinearLayout
passwordConfirmView
=
(
LinearLayout
)
findViewById
(
R
.
id
.
confirm_password_layout
);
if
(
createAccount
.
isChecked
())
{
passwordConfirmView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
passwordConfirmView
.
setVisibility
(
View
.
GONE
);
}
default
:
break
;
}
return
true
;
}
private
void
addAccount
()
{
if
(
useOrbotView
.
isChecked
()
&&
!
OrbotHelper
.
isOrbotInstalled
()
)
{
OrbotInstallerDialogBuilder
.
show
(
this
);
return
;
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
action_add_account
:
((
AccountAddFragment
)
getSupportFragmentManager
().
findFragmentById
(
R
.
id
.
container
)).
addAccount
();
EditText
userView
=
(
EditText
)
findViewById
(
R
.
id
.
account_user_name
);
EditText
passwordView
=
(
EditText
)
findViewById
(
R
.
id
.
account_password
);
EditText
passwordConfirmView
=
(
EditText
)
findViewById
(
R
.
id
.
confirm_password
);
if
(
createAccount
.
isChecked
()
&&
!
passwordView
.
getText
().
toString
().
contentEquals
(
passwordConfirmView
.
getText
().
toString
()))
{
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
CONFIRM_PASSWORD
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
String
account
;
try
{
account
=
AccountManager
.
getInstance
().
addAccount
(
userView
.
getText
().
toString
(),
passwordView
.
getText
().
toString
(),
accountType
,
false
,
storePasswordView
.
isChecked
(),
useOrbotView
.
isChecked
(),
createAccount
.
isChecked
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
return
;
return
true
;
default
:
return
super
.
onOptionsItemSelected
(
item
);
}
setResult
(
RESULT_OK
,
createAuthenticatorResult
(
account
));
finish
();
}
public
static
Intent
createIntent
(
Context
context
)
{
return
new
Intent
(
context
,
AccountAdd
.
class
);
}
p
rivate
static
Intent
createAuthenticatorResult
(
String
account
)
{
p
ublic
static
Intent
createAuthenticatorResult
(
String
account
)
{
return
new
AccountIntentBuilder
(
null
,
null
).
setAccount
(
account
).
build
();
}
}
app/src/main/java/com/xabber/android/ui/AccountAddFragment.java
0 → 100644
View file @
c6889da4
package
com
.
xabber
.
android
.
ui
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.CheckBox
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.AccountType
;
import
com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder
;
import
com.xabber.android.ui.helper.OrbotHelper
;
import
com.xabber.androiddev.R
;
public
class
AccountAddFragment
extends
Fragment
implements
View
.
OnClickListener
{
private
CheckBox
storePasswordView
;
private
CheckBox
useOrbotView
;
private
CheckBox
createAccountCheckBox
;
private
AccountType
accountType
;
private
LinearLayout
passwordConfirmView
;
private
EditText
userView
;
private
EditText
passwordView
;
private
EditText
passwordConfirmEditText
;
public
static
AccountAddFragment
newInstance
()
{
return
new
AccountAddFragment
();
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
account_add_fragment
,
container
,
false
);
accountType
=
AccountManager
.
getInstance
().
getAccountTypes
().
get
(
0
);
storePasswordView
=
(
CheckBox
)
view
.
findViewById
(
R
.
id
.
store_password
);
useOrbotView
=
(
CheckBox
)
view
.
findViewById
(
R
.
id
.
use_orbot
);
createAccountCheckBox
=
(
CheckBox
)
view
.
findViewById
(
R
.
id
.
register_account
);
createAccountCheckBox
.
setOnClickListener
(
this
);
userView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
account_user_name
);
passwordView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
account_password
);
passwordConfirmEditText
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
confirm_password
);
passwordConfirmView
=
(
LinearLayout
)
view
.
findViewById
(
R
.
id
.
confirm_password_layout
);
view
.
findViewById
(
R
.
id
.
auth_panel
).
setVisibility
(
View
.
VISIBLE
);
userView
.
setHint
(
accountType
.
getHint
());
((
TextView
)
view
.
findViewById
(
R
.
id
.
account_help
)).
setText
(
accountType
.
getHelp
());
return
view
;
}
@Override
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
case
R
.
id
.
register_account
:
if
(
createAccountCheckBox
.
isChecked
())
{
passwordConfirmView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
passwordConfirmView
.
setVisibility
(
View
.
GONE
);
}
default
:
break
;
}
}
public
void
addAccount
()
{
if
(
useOrbotView
.
isChecked
()
&&
!
OrbotHelper
.
isOrbotInstalled
())
{
OrbotInstallerDialogBuilder
.
show
(
getActivity
());
return
;
}
if
(
createAccountCheckBox
.
isChecked
()
&&
!
passwordView
.
getText
().
toString
().
contentEquals
(
passwordConfirmEditText
.
getText
().
toString
()))
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
CONFIRM_PASSWORD
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
String
account
;
try
{
account
=
AccountManager
.
getInstance
().
addAccount
(
userView
.
getText
().
toString
(),
passwordView
.
getText
().
toString
(),
accountType
,
false
,
storePasswordView
.
isChecked
(),
useOrbotView
.
isChecked
(),
createAccountCheckBox
.
isChecked
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
return
;
}
getActivity
().
setResult
(
Activity
.
RESULT_OK
,
AccountAdd
.
createAuthenticatorResult
(
account
));
getActivity
().
finish
();
}
}
app/src/main/java/com/xabber/android/ui/preferences/AccountList.java
View file @
c6889da4
...
...
@@ -46,7 +46,7 @@ public class AccountList extends BaseListEditor<String> implements
setSupportActionBar
((
Toolbar
)
findViewById
(
R
.
id
.
toolbar_default
));
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
setTitle
(
PreferenceSummaryHelper
.
getPreferenceTitle
(
getString
(
R
.
string
.
preference_accounts
)));
getSupportActionBar
().
setTitle
(
PreferenceSummaryHelper
.
getPreferenceTitle
(
getString
(
R
.
string
.
preference_accounts
)));
}
@Override
...
...
app/src/main/res/layout/account_add.xml
View file @
c6889da4
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<ScrollView
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<include
layout=
"@layout/toolbar_default"
/>
<LinearLayout
android:id=
"@+id/auth_panel"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:text=
"@string/account_user_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/account_user_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textEmailAddress"
android:singleLine=
"true"
android:text=
""
android:hint=
""
/>
<TextView
android:text=
"@string/account_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/account_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:password=
"true"
android:singleLine=
"true"
android:text=
""
/>
<CheckBox
android:id=
"@+id/store_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:checked=
"true"
android:text=
"@string/account_store_password"
/>
android:layout_height=
"match_parent"
>
</LinearLayout>
<CheckBox
android:id=
"@+id/use_orbot"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:checked=
"false"
android:text=
"@string/account_use_orbot"
/>
<CheckBox
android:id=
"@+id/register_account"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:checked=
"false"
android:text=
"@string/account_register"
/>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/confirm_password_layout"
android:visibility=
"gone"
>
<TextView
android:text=
"@string/confirm_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/confirm_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:password=
"true"
android:singleLine=
"true"
android:text=
""
/>
</LinearLayout>
<LinearLayout
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<Button
android:text=
"@string/account_add"
android:id=
"@+id/ok"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
<TextView
android:id=
"@+id/account_help"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:autoLink=
"all"
<include
layout=
"@layout/toolbar_default"
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
android:layout_alignParentTop=
"true"
android:id=
"@+id/toolbar_default"
/>
</LinearLayout>
</ScrollView>
<FrameLayout
android:id=
"@+id/container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_below=
"@+id/toolbar_default"
>
</FrameLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/account_add_fragment.xml
0 → 100644
View file @
c6889da4
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"16dp"
>
<LinearLayout
android:id=
"@+id/auth_panel"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:descendantFocusability=
"beforeDescendants"
android:focusableInTouchMode=
"true"
>
<TextView
android:text=
"@string/account_user_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/account_user_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textEmailAddress"
android:singleLine=
"true"
android:text=
""
android:hint=
""
/>
<TextView
android:text=
"@string/account_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/account_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textPassword"
android:singleLine=
"true"
android:text=
""
/>
<CheckBox
android:id=
"@+id/store_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:checked=
"true"
android:text=
"@string/account_store_password"
/>
</LinearLayout>
<CheckBox
android:id=
"@+id/use_orbot"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:checked=
"false"
android:text=
"@string/account_use_orbot"
/>
<CheckBox
android:id=
"@+id/register_account"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:checked=
"false"
android:text=
"@string/account_register"
/>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/confirm_password_layout"
android:visibility=
"gone"
>
<TextView
android:text=
"@string/confirm_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<EditText
android:id=
"@+id/confirm_password"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textPassword"
android:singleLine=
"true"
android:text=
""
/>
</LinearLayout>
<TextView
android:id=
"@+id/account_help"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:autoLink=
"all"
/>
</LinearLayout>
app/src/main/res/values-ru/account_editor.xml
View file @
c6889da4
...
...
@@ -154,7 +154,7 @@
<string
name=
"account_type_names_odnoklassniki"
>
Одноклассники
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_add_type.png -->
<string
name=
"account_type_names_wlm"
>
Windows Live Messenger
</string>
<string
name=
"account_use_orbot"
>
Использовать анонимное соединения через TOR и требовать TLS шифрования
\nНе рекомендуется для Google Talk
</string>
<string
name=
"account_use_orbot"
>
Использовать анонимное соединения через TOR и требовать TLS шифрования
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_confirm.png -->
<string
name=
"confirm_cancellation"
>
Вы уверены, что хотите отменить все не сохраненные изменения?
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_add_error.png -->
...
...
app/src/main/res/values/account_editor.xml
View file @
c6889da4
...
...
@@ -154,7 +154,7 @@
<string
name=
"account_type_names_odnoklassniki"
>
Odnoklassniki
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_add_type.png -->
<string
name=
"account_type_names_wlm"
>
Windows Live Messenger
</string>
<string
name=
"account_use_orbot"
>
Chat through TOR anonymity network and force TLS cryptographic protocol
\nNot recommended for Google Talk
</string>
<string
name=
"account_use_orbot"
>
Chat through TOR anonymity network and force TLS cryptographic protocol
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_confirm.png -->
<string
name=
"confirm_cancellation"
>
Are you sure you want to discard all the changes?
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_add_error.png -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment