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
97e326bb
Commit
97e326bb
authored
Mar 03, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AccountEditorFragment: light refactoring.
parent
cfacbc7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
78 deletions
+60
-78
AccountEditorFragment.java
.../xabber/android/ui/preferences/AccountEditorFragment.java
+60
-78
No files found.
app/src/main/java/com/xabber/android/ui/preferences/AccountEditorFragment.java
View file @
97e326bb
...
...
@@ -27,19 +27,19 @@ public class AccountEditorFragment extends BaseSettingsFragment
@Override
protected
void
onInflate
(
Bundle
savedInstanceState
)
{
AccountProtocol
protocol
=
mListener
.
getAccountItem
().
getConnectionSettings
()
.
getProtocol
();
if
(
protocol
==
AccountProtocol
.
xmpp
)
AccountProtocol
protocol
=
mListener
.
getAccountItem
().
getConnectionSettings
().
getProtocol
();
if
(
protocol
==
AccountProtocol
.
xmpp
)
{
addPreferencesFromResource
(
R
.
xml
.
account_editor_xmpp
);
else
if
(
protocol
==
AccountProtocol
.
gtalk
)
}
else
if
(
protocol
==
AccountProtocol
.
gtalk
)
{
addPreferencesFromResource
(
R
.
xml
.
account_editor_xmpp
);
else
if
(
protocol
==
AccountProtocol
.
wlm
)
}
else
if
(
protocol
==
AccountProtocol
.
wlm
)
{
addPreferencesFromResource
(
R
.
xml
.
account_editor_oauth
);
else
}
else
{
throw
new
IllegalStateException
();
if
(!
Application
.
getInstance
().
isContactsSupported
())
getPreferenceScreen
().
removePreference
(
findPreference
(
getString
(
R
.
string
.
account_syncable_key
)));
}
if
(!
Application
.
getInstance
().
isContactsSupported
())
{
getPreferenceScreen
().
removePreference
(
findPreference
(
getString
(
R
.
string
.
account_syncable_key
)));
}
oauthPreference
=
findPreference
(
getString
(
R
.
string
.
account_oauth_key
));
if
(
oauthPreference
!=
null
)
{
...
...
@@ -57,7 +57,9 @@ public class AccountEditorFragment extends BaseSettingsFragment
@Override
public
boolean
onPreferenceChange
(
Preference
preference
,
Object
newValue
)
{
if
(
getString
(
R
.
string
.
account_port_key
).
equals
(
preference
.
getKey
()))
String
key
=
preference
.
getKey
();
if
(
getString
(
R
.
string
.
account_port_key
).
equals
(
key
))
{
try
{
Integer
.
parseInt
((
String
)
newValue
);
}
catch
(
NumberFormatException
e
)
{
...
...
@@ -65,45 +67,42 @@ public class AccountEditorFragment extends BaseSettingsFragment
Toast
.
LENGTH_LONG
).
show
();
return
false
;
}
if
(
getString
(
R
.
string
.
account_tls_mode_key
)
.
equals
(
preference
.
getKey
())
||
getString
(
R
.
string
.
account_archive_mode_key
).
equals
(
preference
.
getKey
())
||
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
preference
.
getKey
()))
}
if
(
getString
(
R
.
string
.
account_tls_mode_key
).
equals
(
key
)
||
getString
(
R
.
string
.
account_archive_mode_key
).
equals
(
key
)
||
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
key
))
{
preference
.
setSummary
((
String
)
newValue
);
else
if
(!
getString
(
R
.
string
.
account_password_key
).
equals
(
preference
.
getKey
())
&&
!
getString
(
R
.
string
.
account_proxy_password_key
).
equals
(
preference
.
getKey
())
&&
!
getString
(
R
.
string
.
account_priority_key
).
equals
(
preference
.
getKey
()))
}
else
if
(!
getString
(
R
.
string
.
account_password_key
).
equals
(
key
)
&&
!
getString
(
R
.
string
.
account_proxy_password_key
).
equals
(
key
)
&&
!
getString
(
R
.
string
.
account_priority_key
).
equals
(
key
))
{
super
.
onPreferenceChange
(
preference
,
newValue
);
if
(
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
preference
.
getKey
()))
{
boolean
enabled
=
!
getString
(
R
.
string
.
account_proxy_type_none
)
.
equals
(
newValue
)
&&
!
getString
(
R
.
string
.
account_proxy_type_orbot
).
equals
(
newValue
);
}
if
(
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
key
))
{
boolean
enabled
=
!
getString
(
R
.
string
.
account_proxy_type_none
).
equals
(
newValue
)
&&
!
getString
(
R
.
string
.
account_proxy_type_orbot
).
equals
(
newValue
);
for
(
int
id
:
new
Integer
[]{
R
.
string
.
account_proxy_host_key
,
R
.
string
.
account_proxy_port_key
,
R
.
string
.
account_proxy_user_key
,
R
.
string
.
account_proxy_port_key
,
R
.
string
.
account_proxy_user_key
,
R
.
string
.
account_proxy_password_key
,})
{
Preference
proxyPreference
=
findPreference
(
getString
(
id
));
if
(
proxyPreference
!=
null
)
if
(
proxyPreference
!=
null
)
{
proxyPreference
.
setEnabled
(
enabled
);
}
}
}
return
true
;
}
public
void
onOAuthChange
()
{
if
(
oauthPreference
==
null
)
if
(
oauthPreference
==
null
)
{
return
;
if
(
AccountEditor
.
INVALIDATED_TOKEN
.
equals
(
mListener
.
getToken
()))
}
if
(
AccountEditor
.
INVALIDATED_TOKEN
.
equals
(
mListener
.
getToken
()))
{
oauthPreference
.
setSummary
(
R
.
string
.
account_oauth_invalidated
);
else
}
else
{
oauthPreference
.
setSummary
(
R
.
string
.
account_oauth_summary
);
}
}
@Override
...
...
@@ -120,59 +119,44 @@ public class AccountEditorFragment extends BaseSettingsFragment
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
AccountItem
accountItem
=
mListener
.
getAccountItem
();
putValue
(
source
,
R
.
string
.
account_custom_key
,
accountItem
.
getConnectionSettings
().
isCustom
());
putValue
(
source
,
R
.
string
.
account_host_key
,
accountItem
.
getConnectionSettings
().
getHost
());
putValue
(
source
,
R
.
string
.
account_port_key
,
accountItem
.
getConnectionSettings
().
getPort
());
putValue
(
source
,
R
.
string
.
account_server_key
,
accountItem
.
getConnectionSettings
().
getServerName
());
putValue
(
source
,
R
.
string
.
account_username_key
,
accountItem
.
getConnectionSettings
().
getUserName
());
putValue
(
source
,
R
.
string
.
account_store_password_key
,
accountItem
.
isStorePassword
());
putValue
(
source
,
R
.
string
.
account_password_key
,
accountItem
.
getConnectionSettings
().
getPassword
());
putValue
(
source
,
R
.
string
.
account_resource_key
,
accountItem
.
getConnectionSettings
().
getResource
());
putValue
(
source
,
R
.
string
.
account_priority_key
,
accountItem
.
getPriority
());
putValue
(
source
,
R
.
string
.
account_enabled_key
,
accountItem
.
isEnabled
());
putValue
(
source
,
R
.
string
.
account_sasl_key
,
accountItem
.
getConnectionSettings
().
isSaslEnabled
());
putValue
(
source
,
R
.
string
.
account_tls_mode_key
,
accountItem
.
getConnectionSettings
().
getTlsMode
().
ordinal
());
putValue
(
source
,
R
.
string
.
account_compression_key
,
accountItem
.
getConnectionSettings
().
useCompression
());
putValue
(
source
,
R
.
string
.
account_proxy_type_key
,
accountItem
.
getConnectionSettings
().
getProxyType
().
ordinal
());
putValue
(
source
,
R
.
string
.
account_proxy_host_key
,
accountItem
.
getConnectionSettings
().
getProxyHost
());
putValue
(
source
,
R
.
string
.
account_proxy_port_key
,
accountItem
.
getConnectionSettings
().
getProxyPort
());
putValue
(
source
,
R
.
string
.
account_proxy_user_key
,
accountItem
.
getConnectionSettings
().
getProxyUser
());
putValue
(
source
,
R
.
string
.
account_proxy_password_key
,
accountItem
.
getConnectionSettings
().
getProxyPassword
());
putValue
(
source
,
R
.
string
.
account_syncable_key
,
accountItem
.
isSyncable
());
putValue
(
source
,
R
.
string
.
account_archive_mode_key
,
accountItem
.
getArchiveMode
().
ordinal
());
putValue
(
source
,
R
.
string
.
account_store_password_key
,
accountItem
.
isStorePassword
());
putValue
(
source
,
R
.
string
.
account_syncable_key
,
accountItem
.
isSyncable
());
putValue
(
source
,
R
.
string
.
account_archive_mode_key
,
accountItem
.
getArchiveMode
().
ordinal
());
com
.
xabber
.
android
.
data
.
connection
.
ConnectionSettings
connectionSettings
=
accountItem
.
getConnectionSettings
();
putValue
(
source
,
R
.
string
.
account_custom_key
,
connectionSettings
.
isCustom
());
putValue
(
source
,
R
.
string
.
account_host_key
,
connectionSettings
.
getHost
());
putValue
(
source
,
R
.
string
.
account_port_key
,
connectionSettings
.
getPort
());
putValue
(
source
,
R
.
string
.
account_server_key
,
connectionSettings
.
getServerName
());
putValue
(
source
,
R
.
string
.
account_username_key
,
connectionSettings
.
getUserName
());
putValue
(
source
,
R
.
string
.
account_password_key
,
connectionSettings
.
getPassword
());
putValue
(
source
,
R
.
string
.
account_resource_key
,
connectionSettings
.
getResource
());
putValue
(
source
,
R
.
string
.
account_sasl_key
,
connectionSettings
.
isSaslEnabled
());
putValue
(
source
,
R
.
string
.
account_tls_mode_key
,
connectionSettings
.
getTlsMode
().
ordinal
());
putValue
(
source
,
R
.
string
.
account_compression_key
,
connectionSettings
.
useCompression
());
putValue
(
source
,
R
.
string
.
account_proxy_type_key
,
connectionSettings
.
getProxyType
().
ordinal
());
putValue
(
source
,
R
.
string
.
account_proxy_host_key
,
connectionSettings
.
getProxyHost
());
putValue
(
source
,
R
.
string
.
account_proxy_port_key
,
connectionSettings
.
getProxyPort
());
putValue
(
source
,
R
.
string
.
account_proxy_user_key
,
connectionSettings
.
getProxyUser
());
putValue
(
source
,
R
.
string
.
account_proxy_password_key
,
connectionSettings
.
getProxyPassword
());
return
source
;
}
@Override
protected
Map
<
String
,
Object
>
getPreferences
(
Map
<
String
,
Object
>
source
)
{
Map
<
String
,
Object
>
result
=
super
.
getPreferences
(
source
);
if
(
oauthPreference
!=
null
)
if
(
oauthPreference
!=
null
)
{
putValue
(
result
,
R
.
string
.
account_password_key
,
mListener
.
getAccount
());
}
return
result
;
}
@Override
protected
boolean
setValues
(
Map
<
String
,
Object
>
source
,
Map
<
String
,
Object
>
result
)
{
ProxyType
proxyType
=
ProxyType
.
values
()[
getInt
(
result
,
R
.
string
.
account_proxy_type_key
)];
protected
boolean
setValues
(
Map
<
String
,
Object
>
source
,
Map
<
String
,
Object
>
result
)
{
ProxyType
proxyType
=
ProxyType
.
values
()[
getInt
(
result
,
R
.
string
.
account_proxy_type_key
)];
if
(
proxyType
==
ProxyType
.
orbot
&&
!
OrbotHelper
.
isOrbotInstalled
())
{
mListener
.
showOrbotDialog
();
return
false
;
...
...
@@ -199,12 +183,14 @@ public class AccountEditorFragment extends BaseSettingsFragment
getString
(
result
,
R
.
string
.
account_proxy_password_key
),
getBoolean
(
result
,
R
.
string
.
account_syncable_key
),
ArchiveMode
.
values
()[
getInt
(
result
,
R
.
string
.
account_archive_mode_key
)]);
return
true
;
}
@Override
public
void
onAttach
(
Activity
activity
)
{
super
.
onAttach
(
activity
);
try
{
mListener
=
(
AccountEditorFragmentInteractionListener
)
activity
;
}
catch
(
ClassCastException
e
)
{
...
...
@@ -221,13 +207,9 @@ public class AccountEditorFragment extends BaseSettingsFragment
public
interface
AccountEditorFragmentInteractionListener
{
public
String
getAccount
();
public
AccountItem
getAccountItem
();
public
String
getToken
();
public
void
onOAuthClick
();
public
void
showOrbotDialog
();
}
}
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