enable backwards compat to Android SDK 10 (Android 2.3.*)
This commit is contained in:
parent
e1d46c49b9
commit
bac16a57fc
|
@ -1 +1 @@
|
|||
Subproject commit be997be8fff6dc00cd249fdfd128d6820461db99
|
||||
Subproject commit 834a50146a2dc07c57f02d37ecd7f2d521b52c2b
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
package org.torproject.android;
|
||||
|
||||
import static org.torproject.android.OrbotConstants.TAG;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -25,8 +27,7 @@ import org.torproject.android.ui.PromoAppsActivity;
|
|||
import org.torproject.android.ui.Rotate3dAnimation;
|
||||
import org.torproject.android.vpn.VPNEnableActivity;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningServiceInfo;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -49,10 +50,10 @@ import android.os.Message;
|
|||
import android.os.RemoteException;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
|
@ -124,6 +125,14 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
|
||||
private ArrayList<Bridge> alBridges = null;
|
||||
|
||||
//this is needed for backwards compat back to Android 2.3.*
|
||||
@SuppressLint("NewApi")
|
||||
public View onCreateView(View parent, String name, Context context, AttributeSet attrs)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= 11)
|
||||
return super.onCreateView(parent, name, context, attrs);
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -261,29 +270,39 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
|
||||
mBtnVPN = (ToggleButton)findViewById(R.id.btnVPN);
|
||||
|
||||
boolean useVPN = Prefs.useVpn();
|
||||
mBtnVPN.setChecked(useVPN);
|
||||
boolean canDoVPN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||
|
||||
//auto start VPN if VPN is enabled
|
||||
if (useVPN)
|
||||
if (!canDoVPN)
|
||||
{
|
||||
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
|
||||
//if not SDK 14 or higher, we can't use the VPN feature
|
||||
mBtnVPN.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mBtnVPN.setOnClickListener(new View.OnClickListener ()
|
||||
else
|
||||
{
|
||||
boolean useVPN = Prefs.useVpn();
|
||||
mBtnVPN.setChecked(useVPN);
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (mBtnVPN.isChecked())
|
||||
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
|
||||
else
|
||||
stopVpnService();
|
||||
|
||||
//auto start VPN if VPN is enabled
|
||||
if (useVPN)
|
||||
{
|
||||
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
|
||||
}
|
||||
|
||||
});
|
||||
mBtnVPN.setOnClickListener(new View.OnClickListener ()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (mBtnVPN.isChecked())
|
||||
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
|
||||
else
|
||||
stopVpnService();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
mBtnBridges = (ToggleButton)findViewById(R.id.btnBridges);
|
||||
|
@ -1019,21 +1038,6 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
public void startVpnService ()
|
||||
{
|
||||
Intent intent = VpnService.prepare(getApplicationContext());
|
||||
if (intent != null) {
|
||||
startActivityForResult(intent,REQUEST_VPN);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendIntentToService(TorServiceConstants.CMD_VPN);
|
||||
}
|
||||
}*/
|
||||
|
||||
public void stopVpnService ()
|
||||
{
|
||||
sendIntentToService(TorServiceConstants.CMD_VPN_CLEAR);
|
||||
|
|
Loading…
Reference in New Issue