Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e22e67e authored by Steve Kondik's avatar Steve Kondik
Browse files

Setting for proxy on wifi only.

parent 1986cd21
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:scrollHorizontally="true" />

    <CheckBox android:id="@+id/wifi_only"
        android:layout_marginTop="2dip"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:text="@string/proxy_wifi_only" />
       
    <LinearLayout 
        android:orientation="horizontal"
        android:paddingTop="8dip"
+1 −0
Original line number Diff line number Diff line
@@ -2065,5 +2065,6 @@ found in the list of installed applications.</string>
    <!-- Proxy settings -->
    <string name="proxy_setting">Proxy settings</string>
    <string name="proxy_setting_summary">Configure a proxy to access the internet</string>
    <string name="proxy_wifi_only">Use proxy only on wifi</string>

</resources>
+10 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

@@ -65,6 +66,7 @@ public class ProxySelector extends Activity
    EditText    mHostnameField;
    EditText    mPortField;
    Button      mOKButton;
    CheckBox    mProxyWifiOnly;
    
    // Matches blank input, ips, and domain names
    private static final String HOSTNAME_REGEXP = "^$|^[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*(\\.[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*)*$";
@@ -102,6 +104,8 @@ public class ProxySelector extends Activity
        mPortField.setOnClickListener(mOKHandler);
        mPortField.setOnFocusChangeListener(mOnFocusChangeHandler);

        mProxyWifiOnly = (CheckBox)findViewById(R.id.wifi_only);
        
        mOKButton = (Button)findViewById(R.id.action);
        mOKButton.setOnClickListener(mOKHandler);

@@ -134,6 +138,8 @@ public class ProxySelector extends Activity
        String portStr = port == -1 ? "" : Integer.toString(port);
        mPortField.setText(portStr);

        mProxyWifiOnly.setChecked(Proxy.isProxyForWifiOnly(this));
        
        Intent intent = getIntent();

        String buttonLabel = intent.getStringExtra("button-label");
@@ -223,6 +229,8 @@ public class ProxySelector extends Activity
            hostname += ':' + portStr;
        }
        Settings.Secure.putString(res, Settings.Secure.HTTP_PROXY, hostname);
        Settings.Secure.putInt(res, Settings.Secure.HTTP_PROXY_WIFI_ONLY,
                mProxyWifiOnly.isChecked() ? 1 : 0);
        sendBroadcast(new Intent(Proxy.PROXY_CHANGE_ACTION));

        return true;
@@ -240,6 +248,7 @@ public class ProxySelector extends Activity
            public void onClick(View v) {
                mHostnameField.setText("");
                mPortField.setText("");
                mProxyWifiOnly.setChecked(true);
            }
        };