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
60825441
Commit
60825441
authored
Aug 25, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prompt to install Orbot if selected in account preferences.
parent
629e17bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
2 deletions
+112
-2
account_editor.xml
res/values/account_editor.xml
+2
-0
AccountEditor.java
src/com/xabber/android/ui/AccountEditor.java
+20
-2
OrbotInstallerDialogBuilder.java
...xabber/android/ui/dialog/OrbotInstallerDialogBuilder.java
+53
-0
OrbotHelper.java
src/com/xabber/android/ui/helper/OrbotHelper.java
+37
-0
No files found.
res/values/account_editor.xml
View file @
60825441
...
...
@@ -114,6 +114,8 @@
<string
name=
"account_proxy_port"
>
Proxy port
</string>
<string
name=
"account_proxy_user"
>
Proxy user
</string>
<string
name=
"account_proxy_password"
>
Proxy password
</string>
<string
name=
"orbot_required_title"
>
Install Orbot?
</string>
<string
name=
"orbot_required_message"
>
In order to process using TOR you must have Orbot installed and activated to proxy traffic through it. Would you like to install it from Google Play?
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
<string
name=
"account_sasl"
>
Use SASL Authentication (recommended)
</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
...
...
src/com/xabber/android/ui/AccountEditor.java
View file @
60825441
...
...
@@ -33,7 +33,9 @@ import com.xabber.android.data.account.ArchiveMode;
import
com.xabber.android.data.connection.ProxyType
;
import
com.xabber.android.data.connection.TLSMode
;
import
com.xabber.android.data.intent.AccountIntentBuilder
;
import
com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder
;
import
com.xabber.android.ui.helper.BaseSettingsActivity
;
import
com.xabber.android.ui.helper.OrbotHelper
;
import
com.xabber.androiddev.R
;
public
class
AccountEditor
extends
BaseSettingsActivity
implements
...
...
@@ -45,6 +47,8 @@ public class AccountEditor extends BaseSettingsActivity implements
private
static
final
String
INVALIDATED_TOKEN
=
"com.xabber.android.ui.AccountEditor.INVALIDATED"
;
private
static
final
int
ORBOT_DIALOG_ID
=
9050
;
private
String
account
;
private
AccountItem
accountItem
;
...
...
@@ -242,6 +246,12 @@ public class AccountEditor extends BaseSettingsActivity implements
@Override
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
())
{
showDialog
(
ORBOT_DIALOG_ID
);
return
false
;
}
AccountManager
.
getInstance
()
.
updateAccount
(
...
...
@@ -260,8 +270,7 @@ public class AccountEditor extends BaseSettingsActivity implements
TLSMode
.
values
()[
getInt
(
result
,
R
.
string
.
account_tls_mode_key
)],
getBoolean
(
result
,
R
.
string
.
account_compression_key
),
ProxyType
.
values
()[
getInt
(
result
,
R
.
string
.
account_proxy_type_key
)],
proxyType
,
getString
(
result
,
R
.
string
.
account_proxy_host_key
),
getInt
(
result
,
R
.
string
.
account_proxy_port_key
),
getString
(
result
,
R
.
string
.
account_proxy_user_key
),
...
...
@@ -272,6 +281,15 @@ public class AccountEditor extends BaseSettingsActivity implements
return
true
;
}
@Override
protected
Dialog
onCreateDialog
(
int
id
)
{
if
(
id
==
ORBOT_DIALOG_ID
)
{
return
new
OrbotInstallerDialogBuilder
(
this
,
ORBOT_DIALOG_ID
)
.
create
();
}
return
super
.
onCreateDialog
(
id
);
}
private
static
String
getAccount
(
Intent
intent
)
{
return
AccountIntentBuilder
.
getAccount
(
intent
);
}
...
...
src/com/xabber/android/ui/dialog/OrbotInstallerDialogBuilder.java
0 → 100644
View file @
60825441
/**
* 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
.
dialog
;
import
android.app.Activity
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.net.Uri
;
import
com.xabber.android.ui.helper.OrbotHelper
;
import
com.xabber.androiddev.R
;
/**
* Orbot installer dialog builder.
*
* @author alexander.ivanov
*
*/
public
class
OrbotInstallerDialogBuilder
extends
DialogBuilder
{
private
final
static
String
MARKET_SEARCH
=
"market://search?q=pname:%s"
;
public
OrbotInstallerDialogBuilder
(
final
Activity
activity
,
int
dialogId
)
{
super
(
activity
,
dialogId
);
setIcon
(
android
.
R
.
drawable
.
ic_dialog_alert
);
setTitle
(
R
.
string
.
orbot_required_title
);
setMessage
(
R
.
string
.
orbot_required_message
);
setPositiveButton
(
android
.
R
.
string
.
yes
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
w
)
{
Uri
uri
=
Uri
.
parse
(
String
.
format
(
MARKET_SEARCH
,
OrbotHelper
.
URI_ORBOT
));
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
);
activity
.
startActivity
(
intent
);
}
});
setNegativeButton
(
android
.
R
.
string
.
no
,
null
);
}
}
src/com/xabber/android/ui/helper/OrbotHelper.java
0 → 100644
View file @
60825441
/**
* 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
.
helper
;
import
android.content.pm.PackageManager
;
import
com.xabber.android.data.Application
;
public
class
OrbotHelper
{
public
final
static
String
URI_ORBOT
=
"org.torproject.android"
;
public
static
boolean
isOrbotInstalled
()
{
PackageManager
packageManager
=
Application
.
getInstance
()
.
getPackageManager
();
try
{
packageManager
.
getPackageInfo
(
URI_ORBOT
,
PackageManager
.
GET_ACTIVITIES
);
return
true
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
return
false
;
}
}
}
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