[tor-commits] [orbot/master] fix browser install request
n8fr8 at torproject.org
n8fr8 at torproject.org
Mon Oct 24 20:54:08 UTC 2016
commit ac037a9dc5b4e83cd352c55184dae2582dc7d8f5
Author: Nathan Freitas <nathan at freitas.net>
Date: Mon Oct 24 15:00:47 2016 -0400
fix browser install request
---
.../org/torproject/android/OrbotMainActivity.java | 24 ++++++-----
.../torproject/android/ui/PromoAppsActivity.java | 17 ++++----
app/src/main/res/layout/layout_main.xml | 48 ++++++++--------------
3 files changed, 40 insertions(+), 49 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 202cff5..d95e0f2 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -737,8 +737,12 @@ public class OrbotMainActivity extends AppCompatActivity
private void openBrowser(final String browserLaunchUrl,boolean forceExternal)
{
boolean isBrowserInstalled = appInstalledOrNot(TorServiceConstants.BROWSER_APP_USERNAME);
-
- if (mBtnVPN.isChecked()||forceExternal)
+
+ if (isBrowserInstalled)
+ {
+ startIntent(TorServiceConstants.BROWSER_APP_USERNAME,Intent.ACTION_VIEW,Uri.parse(browserLaunchUrl));
+ }
+ else if (mBtnVPN.isChecked()||forceExternal)
{
//use the system browser since VPN is on
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
@@ -751,10 +755,6 @@ public class OrbotMainActivity extends AppCompatActivity
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
- else if (isBrowserInstalled)
- {
- startIntent(TorServiceConstants.BROWSER_APP_USERNAME,Intent.ACTION_VIEW,Uri.parse(browserLaunchUrl));
- }
else
{
AlertDialog aDialog = new AlertDialog.Builder(OrbotMainActivity.this)
@@ -768,10 +768,13 @@ public class OrbotMainActivity extends AppCompatActivity
public void onClick(DialogInterface dialog, int which) {
//prompt to install Orweb
- Intent intent = new Intent(OrbotMainActivity.this,PromoAppsActivity.class);
- startActivity(intent);
-
- }
+ //Intent intent = new Intent(OrbotMainActivity.this,PromoAppsActivity.class);
+ //startActivity(intent);
+
+ startActivity(PromoAppsActivity.getInstallIntent(TorServiceConstants.BROWSER_APP_USERNAME,OrbotMainActivity.this));
+
+
+ }
})
.setNegativeButton(R.string.standard_browser, new Dialog.OnClickListener ()
@@ -1291,7 +1294,6 @@ public class OrbotMainActivity extends AppCompatActivity
if (torStatus == null && newTorStatus != null) //first time status
{
torStatus = newTorStatus;
- findViewById(R.id.pbConnecting).setVisibility(View.GONE);
findViewById(R.id.frameMain).setVisibility(View.VISIBLE);
updateStatus(log);
diff --git a/app/src/main/java/org/torproject/android/ui/PromoAppsActivity.java b/app/src/main/java/org/torproject/android/ui/PromoAppsActivity.java
index 01c2483..2fdf2df 100644
--- a/app/src/main/java/org/torproject/android/ui/PromoAppsActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/PromoAppsActivity.java
@@ -1,6 +1,7 @@
package org.torproject.android.ui;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -69,7 +70,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
@Override
public void onClick(View view) {
finish();
- startActivity(getInstallIntent("info.guardianproject.otr.app.im"));
+ startActivity(getInstallIntent("info.guardianproject.otr.app.im",PromoAppsActivity.this));
}
});
@@ -81,7 +82,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
@Override
public void onClick(View view) {
finish();
- startActivity(getInstallIntent(TorServiceConstants.BROWSER_APP_USERNAME));
+ startActivity(getInstallIntent(TorServiceConstants.BROWSER_APP_USERNAME,PromoAppsActivity.this));
}
});
@@ -94,7 +95,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
public void onClick(View view) {
finish();
- startActivity(getInstallIntent("com.duckduckgo.mobile.android"));
+ startActivity(getInstallIntent("com.duckduckgo.mobile.android",PromoAppsActivity.this));
}
});
@@ -120,7 +121,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
@Override
public void onClick(View view) {
finish();
- startActivity(getInstallIntent("info.guardianproject.mrapp"));
+ startActivity(getInstallIntent("info.guardianproject.mrapp",PromoAppsActivity.this));
}
});
@@ -132,7 +133,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
@Override
public void onClick(View view) {
finish();
- startActivity(getInstallIntent("org.martus.android"));
+ startActivity(getInstallIntent("org.martus.android",PromoAppsActivity.this));
}
});
@@ -179,7 +180,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
}
- boolean isAppInstalled(PackageManager pm, String packageName) {
+ public static boolean isAppInstalled(PackageManager pm, String packageName) {
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
return true;
@@ -188,11 +189,11 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
}
}
- Intent getInstallIntent(String packageName) {
+ public static Intent getInstallIntent(String packageName, Context context) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(MARKET_URI + packageName));
- PackageManager pm = getPackageManager();
+ PackageManager pm = context.getPackageManager();
List<ResolveInfo> resInfos = pm.queryIntentActivities(intent, 0);
String foundPackageName = null;
diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml
index 2759cf5..3dfd15a 100644
--- a/app/src/main/res/layout/layout_main.xml
+++ b/app/src/main/res/layout/layout_main.xml
@@ -2,7 +2,9 @@
<LinearLayout android:gravity="center_vertical|center_horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+
+ android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dark_purple"
@@ -23,32 +25,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_frame"
- >
-
- <LinearLayout android:gravity="center_vertical|center_horizontal"
- android:orientation="vertical" android:layout_width="match_parent"
- android:layout_height="wrap_content"
-
- >
-
- <ProgressBar
- android:id="@+id/pbConnecting"
- style="?android:attr/progressBarStyleLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="60dp"
- android:visibility="gone"
-
-android:layout_gravity="center_horizontal|center_vertical"/>
-
+ >
+
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="400dp"
android:id="@+id/frameMain"
android:visibility="visible"
android:orientation="vertical"
- android:layout_gravity="center_horizontal|center_vertical"
+ android:gravity="center_horizontal|center_vertical"
>
<org.torproject.android.ui.ImageProgressView
android:id="@+id/imgStatus"
@@ -58,7 +44,7 @@ android:layout_gravity="center_horizontal|center_vertical"/>
android:padding="0dp"
android:layout_margin="0dp"
android:src="@drawable/toroff" />
-
+
<LinearLayout android:gravity="center_horizontal"
@@ -88,9 +74,6 @@ android:layout_gravity="center_horizontal|center_vertical"/>
/>
</LinearLayout>
- </LinearLayout>
-
-
</LinearLayout>
<LinearLayout
@@ -116,31 +99,36 @@ android:layout_gravity="center_horizontal|center_vertical"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/btnVPN"
- android:layout_width="80dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu_vpn"
android:layout_margin="3dp"
- android:ellipsize="end"
android:singleLine="true"
- />
+ app:switchPadding="9dp"
+
+ />
<android.support.v7.widget.SwitchCompat
android:id="@+id/btnBridges"
- android:layout_width="100dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bridges"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="3dp"
- android:ellipsize="end"
android:singleLine="true"
+ app:switchPadding="9dp"
/>
<Spinner
android:id="@+id/spinnerCountry"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_weight="1"
+
+ android:layout_marginTop="3dp"
+ android:layout_marginLeft="5dp"
+ android:layout_marginBottom="3dp"
/>
</LinearLayout>
More information about the tor-commits
mailing list