show warning about removal of transproxy support
- also make app selection more streamlining
This commit is contained in:
parent
9140ba6a47
commit
440290e9d7
|
@ -1,21 +1,32 @@
|
|||
|
||||
package org.torproject.android;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.VpnService;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import org.torproject.android.service.OrbotConstants;
|
||||
import org.torproject.android.service.TorEventHandler;
|
||||
import org.torproject.android.service.TorService;
|
||||
import org.torproject.android.service.util.Prefs;
|
||||
|
||||
import org.torproject.android.settings.Languages;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class OrbotApp extends Application implements OrbotConstants
|
||||
{
|
||||
|
@ -30,6 +41,7 @@ public class OrbotApp extends Application implements OrbotConstants
|
|||
Languages.setup(OrbotMainActivity.class, R.string.menu_settings);
|
||||
Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
|
||||
|
||||
checkTransparentProxyingLegacy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,4 +65,47 @@ public class OrbotApp extends Application implements OrbotConstants
|
|||
public static Languages getLanguages(Activity activity) {
|
||||
return Languages.get(activity);
|
||||
}
|
||||
|
||||
private void checkTransparentProxyingLegacy ()
|
||||
{
|
||||
if (Prefs.useTransparentProxying())
|
||||
{
|
||||
showToolbarNotification(getString(R.string.no_transproxy_warning_short),getString(R.string.no_transproxy_warning), 9999, org.torproject.android.service.R.drawable.ic_stat_notifyerr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
protected void showToolbarNotification (String shortMsg, String notifyMsg, int notifyId, int icon)
|
||||
{
|
||||
|
||||
NotificationCompat.Builder notifyBuilder;
|
||||
|
||||
//Reusable code.
|
||||
PackageManager pm = getPackageManager();
|
||||
Intent intent = pm.getLaunchIntentForPackage(getPackageName());
|
||||
PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
notifyBuilder = new NotificationCompat.Builder(this)
|
||||
.setContentTitle(getString(org.torproject.android.service.R.string.app_name));
|
||||
|
||||
|
||||
notifyBuilder.setContentIntent(pendIntent);
|
||||
|
||||
notifyBuilder.setContentText(shortMsg);
|
||||
notifyBuilder.setSmallIcon(icon);
|
||||
notifyBuilder.setTicker(notifyMsg);
|
||||
|
||||
notifyBuilder.setOngoing(false);
|
||||
|
||||
notifyBuilder.setStyle(new NotificationCompat.BigTextStyle()
|
||||
.bigText(notifyMsg).setBigContentTitle(getString(org.torproject.android.service.R.string.app_name)));
|
||||
|
||||
Notification notification = notifyBuilder.build();
|
||||
|
||||
notificationManager.notify(notifyId, notification);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -852,10 +852,6 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
//use the system browser since VPN is on
|
||||
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
||||
}
|
||||
else if (Prefs.useTransparentProxying())
|
||||
{
|
||||
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
||||
}
|
||||
else
|
||||
{
|
||||
AlertDialog aDialog = new AlertDialog.Builder(OrbotMainActivity.this)
|
||||
|
@ -1173,6 +1169,13 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
|
||||
updateStatus(null);
|
||||
|
||||
if (Prefs.useTransparentProxying())
|
||||
{
|
||||
showAlert(getString(R.string.no_transproxy_warning_short),getString(R.string.no_transproxy_warning),true);
|
||||
Prefs.disableTransparentProxying();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
AlertDialog aDialog = null;
|
||||
|
|
|
@ -15,16 +15,20 @@ import org.torproject.android.R;
|
|||
import org.torproject.android.service.util.TorServiceUtils;
|
||||
import org.torproject.android.service.vpn.TorifiedApp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -34,6 +38,7 @@ import android.widget.Button;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
@ -41,27 +46,22 @@ import android.widget.TextView;
|
|||
|
||||
public class AppManager extends AppCompatActivity implements OnCheckedChangeListener, OnClickListener, OrbotConstants {
|
||||
|
||||
private ListView listApps;
|
||||
private GridView listApps;
|
||||
private final static String TAG = "Orbot";
|
||||
PackageManager pMgr = null;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
pMgr = getPackageManager();
|
||||
|
||||
this.setContentView(R.layout.layout_apps);
|
||||
setTitle(R.string.apps_mode);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
View buttonSelectAll, buttonSelectNone, buttonInvert;
|
||||
|
||||
buttonSelectAll = findViewById(R.id.button_proxy_all);
|
||||
buttonSelectNone = findViewById(R.id.button_proxy_none);
|
||||
buttonInvert = findViewById(R.id.button_invert_selection);
|
||||
|
||||
buttonSelectAll.setOnClickListener(new OnAutoClickListener(0));
|
||||
buttonSelectNone.setOnClickListener(new OnAutoClickListener(1));
|
||||
buttonInvert.setOnClickListener(new OnAutoClickListener(2));
|
||||
}
|
||||
|
||||
/**
|
||||
class OnAutoClickListener implements Button.OnClickListener {
|
||||
private int status;
|
||||
public OnAutoClickListener(int status){
|
||||
|
@ -69,7 +69,7 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onClick(View button){
|
||||
ListView listView;
|
||||
GridView listView;
|
||||
ViewGroup viewGroup;
|
||||
View parentView, currentView;
|
||||
ArrayAdapter<TorifiedApp> adapter;
|
||||
|
@ -80,7 +80,7 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
int posI, selectedI, lvSz;
|
||||
|
||||
buttonId = button.getId();
|
||||
listView = (ListView) findViewById(R.id.applistview);
|
||||
listView = (GridView) findViewById(R.id.applistview);
|
||||
lvSz = listView.getCount();
|
||||
isSelected = new boolean[lvSz];
|
||||
|
||||
|
@ -127,26 +127,14 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
saveAppSettings(context);
|
||||
loadApps(prefs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
return true;
|
||||
}**/
|
||||
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
listApps = (ListView)findViewById(R.id.applistview);
|
||||
listApps = (GridView)findViewById(R.id.applistview);
|
||||
|
||||
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||
loadApps(mPrefs);
|
||||
|
@ -198,16 +186,23 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
final TorifiedApp app = mApps.get(position);
|
||||
|
||||
if (entry.icon != null) {
|
||||
if (app.getIcon() != null)
|
||||
entry.icon.setImageDrawable(app.getIcon());
|
||||
else
|
||||
entry.icon.setVisibility(View.GONE);
|
||||
|
||||
try {
|
||||
entry.icon.setImageDrawable(pMgr.getApplicationIcon(app.getPackageName()));
|
||||
entry.icon.setOnClickListener(AppManager.this);
|
||||
|
||||
if (entry.box != null)
|
||||
entry.icon.setTag(entry.box);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.text != null) {
|
||||
entry.text.setText(app.getName());
|
||||
entry.text.setOnClickListener(AppManager.this);
|
||||
entry.text.setOnClickListener(AppManager.this);
|
||||
|
||||
if (entry.box != null)
|
||||
entry.text.setTag(entry.box);
|
||||
|
@ -219,7 +214,6 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
entry.box.setTag(app);
|
||||
entry.box.setChecked(app.isTorified());
|
||||
|
||||
|
||||
}
|
||||
|
||||
return convertView;
|
||||
|
@ -246,7 +240,7 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
}
|
||||
|
||||
|
||||
public static ArrayList<TorifiedApp> getApps (Context context, SharedPreferences prefs)
|
||||
public ArrayList<TorifiedApp> getApps (Context context, SharedPreferences prefs)
|
||||
{
|
||||
|
||||
String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
|
||||
|
@ -263,7 +257,6 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
Arrays.sort(tordApps);
|
||||
|
||||
//else load the apps up
|
||||
PackageManager pMgr = context.getPackageManager();
|
||||
|
||||
List<ApplicationInfo> lAppInfo = pMgr.getInstalledApplications(0);
|
||||
|
||||
|
@ -304,10 +297,22 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)
|
||||
{
|
||||
//System app
|
||||
app.setUsesInternet(true);
|
||||
}**/
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
app.setName(pMgr.getApplicationLabel(aInfo).toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// no name
|
||||
continue; //we only show apps with names
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,24 +323,12 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
|||
apps.add(app);
|
||||
}
|
||||
|
||||
|
||||
app.setEnabled(aInfo.enabled);
|
||||
app.setUid(aInfo.uid);
|
||||
app.setUsername(pMgr.getNameForUid(app.getUid()));
|
||||
app.setProcname(aInfo.processName);
|
||||
app.setPackageName(aInfo.packageName);
|
||||
|
||||
try
|
||||
{
|
||||
app.setName(pMgr.getApplicationLabel(aInfo).toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
app.setName(aInfo.packageName);
|
||||
}
|
||||
|
||||
|
||||
//app.setIcon(pMgr.getApplicationIcon(aInfo));
|
||||
|
||||
// check if this application is allowed
|
||||
if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) {
|
||||
|
|
|
@ -5,65 +5,13 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<!--
|
||||
<TextView android:text="Select apps to use with Tor:"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:padding="3px"
|
||||
android:layout_above="@+id/applistview"
|
||||
/>
|
||||
-->
|
||||
|
||||
<ListView
|
||||
<GridView
|
||||
android:id="@+id/applistview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/layout_button_filters"
|
||||
android:numColumns="3"
|
||||
android:layout_alignParentTop="true" >
|
||||
|
||||
</ListView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_button_filters"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<android.support.v7.widget.AppCompatImageButton
|
||||
android:id="@+id/button_proxy_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@+id/button_proxy_none"
|
||||
android:layout_toStartOf="@+id/button_proxy_none"
|
||||
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_playlist_add_check_black_36dp"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageButton
|
||||
android:id="@+id/button_invert_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_autorenew_black_36dp"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageButton
|
||||
android:id="@+id/button_proxy_none"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_weight="1"
|
||||
android:layout_toLeftOf="@+id/button_invert_selection"
|
||||
android:layout_toStartOf="@+id/button_invert_selection"
|
||||
android:src='@drawable/ic_filter_none_black_36dp' />
|
||||
|
||||
</LinearLayout>
|
||||
</GridView>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,18 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:stretchColumns="1">
|
||||
<TableRow>
|
||||
|
||||
<ImageView android:id="@+id/itemicon" android:layout_width="50dp" android:layout_height="50dp" android:padding="3dp" android:visibility="gone"></ImageView>
|
||||
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="150dp" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
>
|
||||
<ImageView android:id="@+id/itemicon" android:layout_width="50dp" android:layout_height="50dp" android:padding="3dp" ></ImageView>
|
||||
<TextView android:layout_height="20dp" android:layout_width="120dp" android:lines="1" android:id="@+id/itemtext"
|
||||
android:text="uid:packages" android:textSize="12sp" android:gravity="center_horizontal" android:padding="3dip"></TextView>
|
||||
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck" ></CheckBox>
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -380,4 +380,7 @@
|
|||
<string name="enable">Enable</string>
|
||||
<string name="consider_disable_battery_optimizations">Consider disable battery optimizations</string>
|
||||
<string name="consider_enable_battery_optimizations">Consider enable battery optimizations</string>
|
||||
|
||||
<string name="no_transproxy_warning_short">WARNING: Transproxying no longer supported</string>
|
||||
<string name="no_transproxy_warning">WARNING: Transparent proxying not supported. Use Orbot Apps VPN instead.</string>
|
||||
</resources>
|
||||
|
|
|
@ -143,9 +143,6 @@ public interface TorServiceConstants {
|
|||
|
||||
// public static final String MEEK_ASSET_KEY = "meek-client";
|
||||
|
||||
//name of the iptables binary
|
||||
public final static String IPTABLES_ASSET_KEY = "xtables";
|
||||
|
||||
//DNS daemon for TCP DNS over TOr
|
||||
public final static String PDNSD_ASSET_KEY = "pdnsd";
|
||||
|
||||
|
|
|
@ -76,6 +76,10 @@ public class Prefs {
|
|||
return prefs.getBoolean(PREF_TRANSPARENT, false);
|
||||
}
|
||||
|
||||
public static void disableTransparentProxying() {
|
||||
prefs.getBoolean(PREF_TRANSPARENT, false);
|
||||
}
|
||||
|
||||
public static boolean transparentProxyAll() {
|
||||
return prefs.getBoolean(PREF_TRANSPARENT_ALL, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue