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

Commit 02fff9d2 authored by piafinho's avatar piafinho Committed by Steve Kondik
Browse files

Added support for disable 2G when WIFI is turned on + usage of brightness from the CMParts

parent 90ec51f0
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -604,6 +604,62 @@

			</LinearLayout>

			<View android:layout_width="fill_parent" android:layout_height="1dp"
				android:background="?android:attr/listDivider" />

			<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
				android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight"
				android:padding="6dip">

				<LinearLayout android:orientation="vertical"
					android:layout_width="0dip" android:layout_weight="1"
					android:layout_height="fill_parent">

					<TextView android:textSize="20dip" android:layout_width="fill_parent"
						android:layout_height="0dip" android:layout_weight="1"
						android:textColor="#FFFFFF" android:gravity="center_vertical"
						android:text="@string/autoDisable3GWithWifi" />

					<TextView android:textSize="14dip" android:layout_width="fill_parent"
						android:layout_height="0dip" android:layout_weight="1"
						android:textColor="#808080" android:singleLine="true"
						android:text="@string/autoDisable3GWithWifiDescription" />

				</LinearLayout>

				<CheckBox android:id="@+id/autoDisable3GWithWifi" android:checked="false"
					android:layout_width="wrap_content" android:layout_height="wrap_content" />

			</LinearLayout>

			<View android:layout_width="fill_parent" android:layout_height="1dp"
				android:background="?android:attr/listDivider" />

			<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
				android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight"
				android:padding="6dip">

				<LinearLayout android:orientation="vertical"
					android:layout_width="0dip" android:layout_weight="1"
					android:layout_height="fill_parent">

					<TextView android:textSize="20dip" android:layout_width="fill_parent"
						android:layout_height="0dip" android:layout_weight="1"
						android:textColor="#FFFFFF" android:gravity="center_vertical"
						android:text="@string/autoEnable3GWithWifi" />

					<TextView android:textSize="14dip" android:layout_width="fill_parent"
						android:layout_height="0dip" android:layout_weight="1"
						android:textColor="#808080" android:singleLine="true"
						android:text="@string/autoEnable3GWithWifiDescription" />

				</LinearLayout>

				<CheckBox android:id="@+id/autoEnable3GWithWifi" android:checked="false"
					android:layout_width="wrap_content" android:layout_height="wrap_content" />

			</LinearLayout>

			<View android:layout_width="fill_parent" android:layout_height="1dp"
				android:background="?android:attr/listDivider" />
				
+6 −2
Original line number Diff line number Diff line
@@ -2624,8 +2624,10 @@ found in the list of installed applications.</string>
    
    <string name="generalSettings">General Settings</string>

    <string name="autoDisable3G">Automatic disables 3G</string>
    <string name="autoEnable3G">Automatic enables 3G</string>
    <string name="autoDisable3G">Data disables 3G</string>
    <string name="autoEnable3G">Data enables 3G</string>
    <string name="autoDisable3GWithWifi">Wifi disables 3G</string>
    <string name="autoEnable3GWithWifi">Wifi enables 3G</string>
    <string name="useRoundCorners">Round corners</string>
    <string name="useVertical">Vertical Layout</string>
    <string name="useTransparent">Transparent Widget</string>
@@ -2636,6 +2638,8 @@ found in the list of installed applications.</string>

    <string name="autoDisable3GDescription">2G when mobile data is disabled</string>
    <string name="autoEnable3GDescription">3G when mobile data is enabled</string>
    <string name="autoDisable3GWithWifiDescription">2G when Wifi is enabled</string>
    <string name="autoEnable3GWithWifiDescription">3G when Wifi is disbled</string>
    <string name="useRoundCornersDescription">Use round widget icons</string>
    <string name="useTransparentDescription">No widget background</string>
    <string name="useVerticalDescription">Show with vertical orientation</string>
+7 −0
Original line number Diff line number Diff line
@@ -50,6 +50,9 @@ public class WidgetSettings extends Activity {
	public static final String AUTO_ENABLE_3G = "autoEnable3G";
	public static final String AUTO_DISABLE_3G = "autoDisable3G";

	public static final String AUTO_ENABLE_3G_WITH_WIFI = "autoEnable3GWithWifi";
	public static final String AUTO_DISABLE_3G_WITH_WIFI = "autoDisable3GWithWifi";

	public static final String NETWORK_MODE_SPINNER = "networkModeSpinner";
	public static final String BRIGHTNESS_SPINNER = "brightnessSpinner";
	public static final String RING_MODE_SPINNER = "ringModeSpinner";
@@ -96,6 +99,8 @@ public class WidgetSettings extends Activity {
		preferencesGeneral = getSharedPreferences(WIDGET_PREF_MAIN,Context.MODE_PRIVATE);
		((CheckBox)findViewById(R.id.autoDisable3G)).setChecked(preferencesGeneral.getBoolean(AUTO_DISABLE_3G, false));
		((CheckBox)findViewById(R.id.autoEnable3G)).setChecked(preferencesGeneral.getBoolean(AUTO_ENABLE_3G, false));
		((CheckBox)findViewById(R.id.autoDisable3GWithWifi)).setChecked(preferencesGeneral.getBoolean(AUTO_DISABLE_3G_WITH_WIFI, false));
		((CheckBox)findViewById(R.id.autoEnable3GWithWifi)).setChecked(preferencesGeneral.getBoolean(AUTO_ENABLE_3G_WITH_WIFI, false));
		((CheckBox)findViewById(R.id.autoDisableSyncWithWifi)).setChecked(preferencesGeneral.getBoolean(AUTO_DISABLE_SYNC_WITH_WIFI, false));
		((CheckBox)findViewById(R.id.autoEnableSyncWithWifi)).setChecked(preferencesGeneral.getBoolean(AUTO_ENABLE_SYNC_WITH_WIFI, false));
		((CheckBox)findViewById(R.id.monitorDataRoaming)).setChecked(preferencesGeneral.getBoolean(MONITOR_DATA_ROAMING, false));		
@@ -203,6 +208,8 @@ public class WidgetSettings extends Activity {
        	editorGeneral.putBoolean(AUTO_ENABLE_3G, ((CheckBox)findViewById(R.id.autoEnable3G)).isChecked());
        	editorGeneral.putBoolean(AUTO_DISABLE_SYNC_WITH_WIFI, ((CheckBox)findViewById(R.id.autoDisableSyncWithWifi)).isChecked());
        	editorGeneral.putBoolean(AUTO_ENABLE_SYNC_WITH_WIFI, ((CheckBox)findViewById(R.id.autoEnableSyncWithWifi)).isChecked());
        	editorGeneral.putBoolean(AUTO_DISABLE_3G_WITH_WIFI, ((CheckBox)findViewById(R.id.autoDisable3GWithWifi)).isChecked());
        	editorGeneral.putBoolean(AUTO_ENABLE_3G_WITH_WIFI, ((CheckBox)findViewById(R.id.autoEnable3GWithWifi)).isChecked());
        	editorGeneral.putBoolean(MONITOR_DATA_ROAMING, ((CheckBox)findViewById(R.id.monitorDataRoaming)).isChecked());
        	editorGeneral.putBoolean(RING_MODE_VIBRATE_AS_ON, ((CheckBox)findViewById(R.id.ringModeVibrateAsOn)).isChecked());

+12 −2
Original line number Diff line number Diff line
@@ -60,6 +60,16 @@ Low High Max

	 */
	
	public static int getMinBacklight(Context context) {		
		if (Settings.System.getInt(context.getContentResolver(),Settings.System.LIGHT_SENSOR_CUSTOM, 0) != 0) {
			   return Settings.System.getInt(context.getContentResolver(),Settings.System.LIGHT_SCREEN_DIM, MINIMUM_BACKLIGHT);
		} else {
			return MINIMUM_BACKLIGHT;
		}
		
		
	}


	private static boolean isAutomaticModeSupported(Context context) {
		if (supportsAutomaticMode==null) {
@@ -112,7 +122,7 @@ Low High Max
			if (currentMode==MODE_AUTO_LOW_MAX) {
				return LOW_BACKLIGHT;
			} else {
				return MINIMUM_BACKLIGHT;				
				return getMinBacklight(context);				
			}
		} else if (brightness < LOW_BACKLIGHT) {
			if (currentMode==MODE_AUTO_LOW_MAX) {
@@ -147,7 +157,7 @@ Low High Max
		} else if(currentMode == MODE_AUTO_LOW_MAX){
			return LOW_BACKLIGHT;				
		} else {
			return MINIMUM_BACKLIGHT;
			return getMinBacklight(context);
		}
	}

+5 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.provider.Settings.SettingNotFoundException;
import android.widget.Toast;

import com.android.internal.telephony.Phone;
import com.android.settings.R;
@@ -99,8 +100,9 @@ public class NetworkModeButton extends WidgetButton{
	public void toggleState(Context context, int newState) {
		if (currentState!=SettingsAppWidgetProvider.STATE_INTERMEDIATE && currentState!=newState) {
			toggleState(context,true);
		} else {
			SettingsAppWidgetProvider.logD("NetworkMode: Ignored request. currentState="+currentState+" newState="+newState);
		} else if (currentState==SettingsAppWidgetProvider.STATE_INTERMEDIATE){
			Toast toast = Toast.makeText(context, "Network mode state unknown. Please change it manually!",Toast.LENGTH_SHORT);
			toast.show();
		} 
	}	

Loading