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
9950a86b
Commit
9950a86b
authored
Apr 09, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Account type selection returned: xmpp and gtalk. New icons.
parent
ac7d67a5
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
210 additions
and
12 deletions
+210
-12
AccountManager.java
.../java/com/xabber/android/data/account/AccountManager.java
+9
-2
AccountAddFragment.java
...c/main/java/com/xabber/android/ui/AccountAddFragment.java
+51
-7
AccountTypeAdapter.java
...ava/com/xabber/android/ui/adapter/AccountTypeAdapter.java
+80
-0
ic_hangouts_grey600_24dp.png
app/src/main/res/drawable-hdpi/ic_hangouts_grey600_24dp.png
+0
-0
ic_hangouts_grey600_24dp.png
app/src/main/res/drawable-mdpi/ic_hangouts_grey600_24dp.png
+0
-0
ic_hangouts_grey600_24dp.png
app/src/main/res/drawable-xhdpi/ic_hangouts_grey600_24dp.png
+0
-0
ic_hangouts_grey600_24dp.png
...src/main/res/drawable-xxhdpi/ic_hangouts_grey600_24dp.png
+0
-0
ic_hangouts_grey600_24dp.png
...rc/main/res/drawable-xxxhdpi/ic_hangouts_grey600_24dp.png
+0
-0
account_add_fragment.xml
app/src/main/res/layout/account_add_fragment.xml
+14
-0
account_type_item.xml
app/src/main/res/layout/account_type_item.xml
+37
-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
connections.xml
app/src/main/res/values/connections.xml
+17
-1
No files found.
app/src/main/java/com/xabber/android/data/account/AccountManager.java
View file @
9950a86b
...
...
@@ -138,7 +138,7 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
servers
.
add
(
values
.
getString
(
i
));
}
accountTypes
.
add
(
new
AccountType
(
id
,
protocol
,
values
.
getString
(
1
),
values
.
getString
(
2
),
values
.
getString
(
3
),
null
,
values
.
getString
(
2
),
values
.
getString
(
3
),
values
.
getDrawable
(
4
)
,
values
.
getBoolean
(
5
,
false
),
values
.
getString
(
6
),
values
.
getInt
(
7
,
5222
),
values
.
getBoolean
(
8
,
false
),
servers
));
values
.
recycle
();
...
...
@@ -404,7 +404,14 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
resource
=
"android"
+
StringUtils
.
randomString
(
8
);
}
accountItem
=
addAccount
(
accountType
.
getProtocol
(),
false
,
host
,
port
,
serverName
,
userName
,
boolean
useCustomHost
=
false
;
if
(
accountType
.
getProtocol
()
==
AccountProtocol
.
gtalk
)
{
useCustomHost
=
true
;
}
accountItem
=
addAccount
(
accountType
.
getProtocol
(),
useCustomHost
,
host
,
port
,
serverName
,
userName
,
storePassword
,
password
,
resource
,
getNextColorIndex
(),
0
,
StatusMode
.
available
,
SettingsManager
.
statusText
(),
true
,
true
,
tlsRequired
?
TLSMode
.
required
:
TLSMode
.
enabled
,
false
,
useOrbot
?
ProxyType
.
orbot
:
ProxyType
.
none
,
"localhost"
,
8080
,
...
...
app/src/main/java/com/xabber/android/ui/AccountAddFragment.java
View file @
9950a86b
...
...
@@ -6,9 +6,11 @@ import android.support.v4.app.Fragment;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.CheckBox
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -16,22 +18,26 @@ 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.adapter.AccountTypeAdapter
;
import
com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder
;
import
com.xabber.android.ui.helper.OrbotHelper
;
import
com.xabber.android.ui.preferences.AccountEditor
;
import
com.xabber.androiddev.R
;
public
class
AccountAddFragment
extends
Fragment
implements
View
.
OnClickListener
{
public
class
AccountAddFragment
extends
Fragment
implements
View
.
OnClickListener
,
AdapterView
.
OnItemSelectedListener
{
private
CheckBox
storePasswordView
;
private
CheckBox
useOrbotView
;
private
CheckBox
createAccountCheckBox
;
private
AccountType
accountType
;
private
Spinner
accountTypeView
;
private
LinearLayout
passwordConfirmView
;
private
EditText
userView
;
private
EditText
passwordView
;
private
EditText
passwordConfirmEditText
;
private
static
final
String
SAVED_ACCOUNT_TYPE
=
"com.xabber.android.ui.AccountAdd.ACCOUNT_TYPE"
;
private
View
authPanel
;
private
TextView
accountHelpView
;
public
static
AccountAddFragment
newInstance
()
{
return
new
AccountAddFragment
();
...
...
@@ -41,26 +47,49 @@ public class AccountAddFragment extends Fragment implements View.OnClickListener
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
);
accountTypeView
=
(
Spinner
)
view
.
findViewById
(
R
.
id
.
account_type
);
accountTypeView
.
setAdapter
(
new
AccountTypeAdapter
(
getActivity
()));
accountTypeView
.
setOnItemSelectedListener
(
this
);
String
accountType
;
if
(
savedInstanceState
==
null
)
{
accountType
=
null
;
}
else
{
accountType
=
savedInstanceState
.
getString
(
SAVED_ACCOUNT_TYPE
);
}
accountTypeView
.
setSelection
(
0
);
for
(
int
position
=
0
;
position
<
accountTypeView
.
getCount
();
position
++)
{
if
(((
AccountType
)
accountTypeView
.
getItemAtPosition
(
position
)).
getName
().
equals
(
accountType
)){
accountTypeView
.
setSelection
(
position
);
break
;
}
}
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
);
authPanel
=
view
.
findViewById
(
R
.
id
.
auth_panel
);
userView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
account_user_name
);
accountHelpView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
account_help
);
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
onSaveInstanceState
(
Bundle
outState
)
{
super
.
onSaveInstanceState
(
outState
);
outState
.
putString
(
SAVED_ACCOUNT_TYPE
,
((
AccountType
)
accountTypeView
.
getSelectedItem
()).
getName
());
}
@Override
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
...
...
@@ -86,6 +115,9 @@ public class AccountAddFragment extends Fragment implements View.OnClickListener
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
CONFIRM_PASSWORD
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
AccountType
accountType
=
(
AccountType
)
accountTypeView
.
getSelectedItem
();
String
account
;
try
{
account
=
AccountManager
.
getInstance
().
addAccount
(
...
...
@@ -106,4 +138,16 @@ public class AccountAddFragment extends Fragment implements View.OnClickListener
}
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
AccountType
accountType
=
(
AccountType
)
accountTypeView
.
getSelectedItem
();
authPanel
.
setVisibility
(
View
.
VISIBLE
);
accountHelpView
.
setText
(
accountType
.
getHelp
());
userView
.
setHint
(
accountType
.
getHint
());
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
accountTypeView
.
setSelection
(
0
);
}
}
app/src/main/java/com/xabber/android/ui/adapter/AccountTypeAdapter.java
0 → 100644
View file @
9950a86b
/**
* 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/.
*/
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
java.util.List
;
import
android.app.Activity
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseAdapter
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.AccountType
;
import
com.xabber.androiddev.R
;
/**
* Adapter for drop down list of account's types.
*
* @author alexander.ivanov
*/
public
class
AccountTypeAdapter
extends
BaseAdapter
{
private
final
Activity
activity
;
private
final
List
<
AccountType
>
accountTypes
;
public
AccountTypeAdapter
(
Activity
activity
)
{
super
();
this
.
activity
=
activity
;
accountTypes
=
AccountManager
.
getInstance
().
getAccountTypes
();
}
@Override
public
int
getCount
()
{
return
accountTypes
.
size
();
}
@Override
public
Object
getItem
(
int
position
)
{
return
accountTypes
.
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
return
position
;
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
final
View
view
;
if
(
convertView
==
null
)
{
view
=
activity
.
getLayoutInflater
().
inflate
(
R
.
layout
.
account_type_item
,
parent
,
false
);
}
else
{
view
=
convertView
;
}
final
AccountType
type
=
(
AccountType
)
getItem
(
position
);
((
ImageView
)
view
.
findViewById
(
R
.
id
.
avatar
)).
setImageDrawable
(
type
.
getIcon
());
((
TextView
)
view
.
findViewById
(
R
.
id
.
name
)).
setText
(
type
.
getName
());
return
view
;
}
@Override
public
View
getDropDownView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
return
getView
(
position
,
convertView
,
parent
);
}
}
\ No newline at end of file
app/src/main/res/drawable-hdpi/ic_hangouts_grey600_24dp.png
0 → 100644
View file @
9950a86b
832 Bytes
app/src/main/res/drawable-mdpi/ic_hangouts_grey600_24dp.png
0 → 100644
View file @
9950a86b
561 Bytes
app/src/main/res/drawable-xhdpi/ic_hangouts_grey600_24dp.png
0 → 100644
View file @
9950a86b
882 Bytes
app/src/main/res/drawable-xxhdpi/ic_hangouts_grey600_24dp.png
0 → 100644
View file @
9950a86b
1.36 KB
app/src/main/res/drawable-xxxhdpi/ic_hangouts_grey600_24dp.png
0 → 100644
View file @
9950a86b
1.75 KB
app/src/main/res/layout/account_add_fragment.xml
View file @
9950a86b
...
...
@@ -21,6 +21,20 @@
android:padding=
"16dp"
>
<TextView
android:text=
"@string/account_type"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<Spinner
android:id=
"@+id/account_type"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingTop=
"4dip"
android:paddingBottom=
"8dip"
android:prompt=
"@string/account_type"
/>
<LinearLayout
android:id=
"@+id/auth_panel"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/account_type_item.xml
0 → 100644
View file @
9950a86b
<?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:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:gravity=
"center_vertical"
>
<ImageView
android:id=
"@+id/avatar"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_hangouts_grey600_24dp"
/>
<TextView
android:id=
"@+id/name"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:singleLine=
"true"
android:gravity=
"center_vertical"
android:text=
"GTalk"
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:paddingLeft=
"8dp"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values-ru/account_editor.xml
View file @
9950a86b
...
...
@@ -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 шифрования
</string>
<string
name=
"account_use_orbot"
>
Использовать анонимное соединения через TOR и требовать TLS шифрования
\nНе рекомендуется для Google Talk
</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 @
9950a86b
...
...
@@ -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
</string>
<string
name=
"account_use_orbot"
>
Chat through TOR anonymity network and force TLS cryptographic protocol
\nNot recommended for Google Talk
</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 -->
...
...
app/src/main/res/values/connections.xml
View file @
9950a86b
...
...
@@ -14,6 +14,7 @@
-->
<resources
xmlns:tools=
"http://schemas.android.com/tools"
tools:ignore=
"MissingTranslation"
>
<string
name=
"account_protocol_xmpp"
>
xmpp
</string>
<string
name=
"account_protocol_gtalk"
>
gtalk
</string>
<!--
<array name="account_type_name">
...
...
@@ -37,7 +38,7 @@
<item>
@string/account_type_names_xmpp
</item>
<item>
@string/account_type_hints_xmpp
</item>
<item>
@string/account_type_helps_xmpp
</item>
<item></item>
<item>
@drawable/ic_xmpp_24dp
</item>
<item>
True
</item>
<item></item>
<item>
5222
</item>
...
...
@@ -45,8 +46,23 @@
<item></item>
</array>
<array
name=
"account_type_gtalk"
>
<item>
@string/account_protocol_gtalk
</item>
<item>
@string/account_type_names_gtalk
</item>
<item>
@string/account_type_hints_gtalk
</item>
<item>
@string/account_type_helps_gtalk
</item>
<item>
@drawable/ic_hangouts_grey600_24dp
</item>
<item>
True
</item>
<item>
talk.google.com
</item>
<item>
5222
</item>
<item>
True
</item>
<item>
gmail.com
</item>
<item>
googlemail.com
</item>
</array>
<array
name=
"account_types"
>
<item>
@array/account_type_xmpp
</item>
<item>
@array/account_type_gtalk
</item>
</array>
</resources>
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