Christoph Haas 5 years ago
commit
55ca4db95a
51 changed files with 551 additions and 0 deletions
  1. 9
    0
      .classpath
  2. 33
    0
      .project
  3. 4
    0
      .settings/org.eclipse.jdt.core.prefs
  4. 33
    0
      AndroidManifest.xml
  5. 33
    0
      bin/AndroidManifest.xml
  6. BIN
      bin/classes/at/sprinternet/mvnoroaming/BuildConfig.class
  7. BIN
      bin/classes/at/sprinternet/mvnoroaming/ExecuteAsRoot.class
  8. BIN
      bin/classes/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger$1.class
  9. BIN
      bin/classes/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger$2.class
  10. BIN
      bin/classes/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger.class
  11. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$attr.class
  12. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$dimen.class
  13. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$drawable.class
  14. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$id.class
  15. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$layout.class
  16. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$menu.class
  17. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$string.class
  18. BIN
      bin/classes/at/sprinternet/mvnoroaming/R$style.class
  19. BIN
      bin/classes/at/sprinternet/mvnoroaming/R.class
  20. BIN
      bin/classes/at/sprinternet/mvnoroaming/RebootService.class
  21. BIN
      bin/classes/at/sprinternet/mvnoroaming/RebootServiceReceiver.class
  22. BIN
      bin/dexedLibs/android-support-v4-fdaef44f6c6e5e528d87159766bd7e19.jar
  23. BIN
      bin/res/crunch/drawable-hdpi/ic_launcher.png
  24. BIN
      bin/res/crunch/drawable-mdpi/ic_launcher.png
  25. BIN
      bin/res/crunch/drawable-xhdpi/ic_launcher.png
  26. BIN
      bin/res/crunch/drawable-xxhdpi/ic_launcher.png
  27. 6
    0
      gen/at/sprinternet/mvnoroaming/BuildConfig.java
  28. 79
    0
      gen/at/sprinternet/mvnoroaming/R.java
  29. BIN
      ic_launcher-web.png
  30. BIN
      libs/android-support-v4.jar
  31. 20
    0
      proguard-project.txt
  32. 14
    0
      project.properties
  33. BIN
      res/drawable-hdpi/ic_launcher.png
  34. BIN
      res/drawable-mdpi/ic_launcher.png
  35. BIN
      res/drawable-xhdpi/ic_launcher.png
  36. BIN
      res/drawable-xxhdpi/ic_launcher.png
  37. 66
    0
      res/layout/activity_mvno.xml
  38. 9
    0
      res/menu/mvnoroaming_status_changer.xml
  39. 8
    0
      res/values-sw600dp/dimens.xml
  40. 9
    0
      res/values-sw720dp-land/dimens.xml
  41. 11
    0
      res/values-v11/styles.xml
  42. 12
    0
      res/values-v14/styles.xml
  43. 7
    0
      res/values/dimens.xml
  44. 13
    0
      res/values/strings.xml
  45. 20
    0
      res/values/styles.xml
  46. 22
    0
      src/at/sprinternet/mvnoroaming/ExecuteAsRoot.java
  47. 73
    0
      src/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger.java
  48. 54
    0
      src/at/sprinternet/mvnoroaming/RebootService.java
  49. 16
    0
      src/at/sprinternet/mvnoroaming/RebootServiceReceiver.java
  50. BIN
      srcres/icon_roam.png
  51. BIN
      srcres/icon_roam.xcf

+ 9
- 0
.classpath View File

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<classpath>
3
+	<classpathentry kind="src" path="src"/>
4
+	<classpathentry kind="src" path="gen"/>
5
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
8
+	<classpathentry kind="output" path="bin/classes"/>
9
+</classpath>

+ 33
- 0
.project View File

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>MVNOroaming</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10
+			<arguments>
11
+			</arguments>
12
+		</buildCommand>
13
+		<buildCommand>
14
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15
+			<arguments>
16
+			</arguments>
17
+		</buildCommand>
18
+		<buildCommand>
19
+			<name>org.eclipse.jdt.core.javabuilder</name>
20
+			<arguments>
21
+			</arguments>
22
+		</buildCommand>
23
+		<buildCommand>
24
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25
+			<arguments>
26
+			</arguments>
27
+		</buildCommand>
28
+	</buildSpec>
29
+	<natures>
30
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31
+		<nature>org.eclipse.jdt.core.javanature</nature>
32
+	</natures>
33
+</projectDescription>

+ 4
- 0
.settings/org.eclipse.jdt.core.prefs View File

@@ -0,0 +1,4 @@
1
+eclipse.preferences.version=1
2
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3
+org.eclipse.jdt.core.compiler.compliance=1.6
4
+org.eclipse.jdt.core.compiler.source=1.6

+ 33
- 0
AndroidManifest.xml View File

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="at.sprinternet.mvnoroaming"
4
+    android:versionCode="1"
5
+    android:versionName="1.0" >
6
+
7
+    <uses-sdk
8
+        android:minSdkVersion="14"
9
+        android:targetSdkVersion="19" />
10
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
11
+    <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
12
+
13
+    <application
14
+        android:allowBackup="true"
15
+        android:icon="@drawable/ic_launcher"
16
+        android:label="@string/app_name"
17
+        android:theme="@style/AppTheme" android:testOnly="false">
18
+        <activity
19
+            android:name="at.sprinternet.mvnoroaming.MVNORoamingStatusChanger"
20
+            android:label="@string/app_name" >
21
+            <intent-filter>
22
+                <action android:name="android.intent.action.MAIN" />
23
+                <category android:name="android.intent.category.LAUNCHER" />
24
+            </intent-filter>
25
+        </activity>		
26
+		<receiver android:name=".RebootServiceReceiver">
27
+		    <intent-filter>
28
+		        <action android:name="android.intent.action.BOOT_COMPLETED" />
29
+		    </intent-filter>
30
+		</receiver>
31
+		<service android:name=".RebootService" />
32
+    </application>
33
+</manifest>

+ 33
- 0
bin/AndroidManifest.xml View File

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="at.sprinternet.mvnoroaming"
4
+    android:versionCode="1"
5
+    android:versionName="1.0" >
6
+
7
+    <uses-sdk
8
+        android:minSdkVersion="14"
9
+        android:targetSdkVersion="19" />
10
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
11
+    <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
12
+
13
+    <application
14
+        android:allowBackup="true"
15
+        android:icon="@drawable/ic_launcher"
16
+        android:label="@string/app_name"
17
+        android:theme="@style/AppTheme" android:testOnly="false">
18
+        <activity
19
+            android:name="at.sprinternet.mvnoroaming.MVNORoamingStatusChanger"
20
+            android:label="@string/app_name" >
21
+            <intent-filter>
22
+                <action android:name="android.intent.action.MAIN" />
23
+                <category android:name="android.intent.category.LAUNCHER" />
24
+            </intent-filter>
25
+        </activity>		
26
+		<receiver android:name=".RebootServiceReceiver">
27
+		    <intent-filter>
28
+		        <action android:name="android.intent.action.BOOT_COMPLETED" />
29
+		    </intent-filter>
30
+		</receiver>
31
+		<service android:name=".RebootService" />
32
+    </application>
33
+</manifest>

BIN
bin/classes/at/sprinternet/mvnoroaming/BuildConfig.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/ExecuteAsRoot.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger$1.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger$2.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$attr.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$dimen.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$drawable.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$id.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$layout.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$menu.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$string.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R$style.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/R.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/RebootService.class View File


BIN
bin/classes/at/sprinternet/mvnoroaming/RebootServiceReceiver.class View File


BIN
bin/dexedLibs/android-support-v4-fdaef44f6c6e5e528d87159766bd7e19.jar View File


BIN
bin/res/crunch/drawable-hdpi/ic_launcher.png View File


BIN
bin/res/crunch/drawable-mdpi/ic_launcher.png View File


BIN
bin/res/crunch/drawable-xhdpi/ic_launcher.png View File


BIN
bin/res/crunch/drawable-xxhdpi/ic_launcher.png View File


+ 6
- 0
gen/at/sprinternet/mvnoroaming/BuildConfig.java View File

@@ -0,0 +1,6 @@
1
+/** Automatically generated file. DO NOT MODIFY */
2
+package at.sprinternet.mvnoroaming;
3
+
4
+public final class BuildConfig {
5
+    public final static boolean DEBUG = true;
6
+}

+ 79
- 0
gen/at/sprinternet/mvnoroaming/R.java View File

@@ -0,0 +1,79 @@
1
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
2
+ *
3
+ * This class was automatically generated by the
4
+ * aapt tool from the resource data it found.  It
5
+ * should not be modified by hand.
6
+ */
7
+
8
+package at.sprinternet.mvnoroaming;
9
+
10
+public final class R {
11
+    public static final class attr {
12
+    }
13
+    public static final class dimen {
14
+        /**  Default screen margins, per the Android Design guidelines. 
15
+
16
+         Customize dimensions originally defined in res/values/dimens.xml (such as
17
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
18
+    
19
+         */
20
+        public static final int activity_horizontal_margin=0x7f040000;
21
+        public static final int activity_vertical_margin=0x7f040001;
22
+    }
23
+    public static final class drawable {
24
+        public static final int ic_launcher=0x7f020000;
25
+    }
26
+    public static final class id {
27
+        public static final int action_settings=0x7f080006;
28
+        public static final int buttonUpdate=0x7f080002;
29
+        public static final int editTextProvider=0x7f080001;
30
+        public static final int switchReboot=0x7f080004;
31
+        public static final int textView2=0x7f080003;
32
+        public static final int textView3=0x7f080005;
33
+        public static final int textViewDescription=0x7f080000;
34
+    }
35
+    public static final class layout {
36
+        public static final int activity_mvno=0x7f030000;
37
+    }
38
+    public static final class menu {
39
+        public static final int mvnoroaming_status_changer=0x7f070000;
40
+    }
41
+    public static final class string {
42
+        public static final int action_settings=0x7f050001;
43
+        public static final int app_name=0x7f050000;
44
+        public static final int copyright=0x7f050007;
45
+        public static final int description=0x7f050002;
46
+        public static final int enableOnBoot=0x7f050004;
47
+        public static final int inputHint=0x7f050003;
48
+        public static final int rebootSwitch=0x7f050006;
49
+        public static final int update=0x7f050005;
50
+    }
51
+    public static final class style {
52
+        /** 
53
+        Base application theme, dependent on API level. This theme is replaced
54
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
55
+    
56
+
57
+            Theme customizations available in newer API levels can go in
58
+            res/values-vXX/styles.xml, while customizations related to
59
+            backward-compatibility can go here.
60
+        
61
+
62
+        Base application theme for API 11+. This theme completely replaces
63
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
64
+    
65
+ API 11 theme customizations can go here. 
66
+
67
+        Base application theme for API 14+. This theme completely replaces
68
+        AppBaseTheme from BOTH res/values/styles.xml and
69
+        res/values-v11/styles.xml on API 14+ devices.
70
+    
71
+ API 14 theme customizations can go here. 
72
+         */
73
+        public static final int AppBaseTheme=0x7f060000;
74
+        /**  Application theme. 
75
+ All customizations that are NOT specific to a particular API-level can go here. 
76
+         */
77
+        public static final int AppTheme=0x7f060001;
78
+    }
79
+}

BIN
ic_launcher-web.png View File


BIN
libs/android-support-v4.jar View File


+ 20
- 0
proguard-project.txt View File

@@ -0,0 +1,20 @@
1
+# To enable ProGuard in your project, edit project.properties
2
+# to define the proguard.config property as described in that file.
3
+#
4
+# Add project specific ProGuard rules here.
5
+# By default, the flags in this file are appended to flags specified
6
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
7
+# You can edit the include path and order by changing the ProGuard
8
+# include property in project.properties.
9
+#
10
+# For more details, see
11
+#   http://developer.android.com/guide/developing/tools/proguard.html
12
+
13
+# Add any project specific keep options here:
14
+
15
+# If your project uses WebView with JS, uncomment the following
16
+# and specify the fully qualified class name to the JavaScript interface
17
+# class:
18
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19
+#   public *;
20
+#}

+ 14
- 0
project.properties View File

@@ -0,0 +1,14 @@
1
+# This file is automatically generated by Android Tools.
2
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3
+#
4
+# This file must be checked in Version Control Systems.
5
+#
6
+# To customize properties used by the Ant build system edit
7
+# "ant.properties", and override values to adapt the script to your
8
+# project structure.
9
+#
10
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12
+
13
+# Project target.
14
+target=android-19

BIN
res/drawable-hdpi/ic_launcher.png View File


BIN
res/drawable-mdpi/ic_launcher.png View File


BIN
res/drawable-xhdpi/ic_launcher.png View File


BIN
res/drawable-xxhdpi/ic_launcher.png View File


+ 66
- 0
res/layout/activity_mvno.xml View File

@@ -0,0 +1,66 @@
1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:paddingBottom="@dimen/activity_vertical_margin"
6
+    android:paddingLeft="@dimen/activity_horizontal_margin"
7
+    android:paddingRight="@dimen/activity_horizontal_margin"
8
+    android:paddingTop="@dimen/activity_vertical_margin"
9
+    tools:context=".MVNORoamingStatusChanger" >
10
+
11
+    <TextView
12
+        android:id="@+id/textViewDescription"
13
+        android:layout_width="match_parent"
14
+        android:layout_height="wrap_content"
15
+        android:layout_alignParentLeft="true"
16
+        android:layout_alignParentTop="true"
17
+        android:text="@string/description" />
18
+
19
+    <EditText
20
+        android:id="@+id/editTextProvider"
21
+        android:layout_width="match_parent"
22
+        android:layout_height="wrap_content"
23
+        android:layout_alignLeft="@+id/textViewDescription"
24
+        android:layout_alignRight="@+id/textViewDescription"
25
+        android:layout_below="@+id/textViewDescription"
26
+        android:ems="10"
27
+        android:inputType="text"
28
+        android:hint="@string/inputHint" >
29
+
30
+        <requestFocus />
31
+    </EditText>
32
+
33
+    <Button
34
+        android:id="@+id/buttonUpdate"
35
+        android:layout_width="match_parent"
36
+        android:layout_height="wrap_content"
37
+        android:layout_alignLeft="@+id/editTextProvider"
38
+        android:layout_below="@+id/editTextProvider"
39
+        android:layout_marginTop="24dp"
40
+        android:text="@string/update" />
41
+
42
+    <TextView
43
+        android:id="@+id/textView2"
44
+        android:layout_width="match_parent"
45
+        android:layout_height="wrap_content"
46
+        android:layout_alignLeft="@+id/buttonUpdate"
47
+        android:layout_centerVertical="true"
48
+        android:text="@string/enableOnBoot" />
49
+
50
+    <Switch
51
+        android:id="@+id/switchReboot"
52
+        android:layout_width="match_parent"
53
+        android:layout_height="wrap_content"
54
+        android:layout_alignLeft="@+id/textView2"
55
+        android:layout_below="@+id/textView2"
56
+        android:text="@string/rebootSwitch"
57
+        android:checked="true" />
58
+
59
+    <TextView
60
+        android:id="@+id/textView3"
61
+        android:layout_width="match_parent"
62
+        android:layout_height="wrap_content"
63
+        android:layout_alignParentBottom="true"
64
+        android:text="@string/copyright" />
65
+
66
+</RelativeLayout>

+ 9
- 0
res/menu/mvnoroaming_status_changer.xml View File

@@ -0,0 +1,9 @@
1
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
2
+
3
+    <item
4
+        android:id="@+id/action_settings"
5
+        android:orderInCategory="100"
6
+        android:showAsAction="never"
7
+        android:title="@string/action_settings"/>
8
+
9
+</menu>

+ 8
- 0
res/values-sw600dp/dimens.xml View File

@@ -0,0 +1,8 @@
1
+<resources>
2
+
3
+    <!--
4
+         Customize dimensions originally defined in res/values/dimens.xml (such as
5
+         screen margins) for sw600dp devices (e.g. 7" tablets) here.
6
+    -->
7
+
8
+</resources>

+ 9
- 0
res/values-sw720dp-land/dimens.xml View File

@@ -0,0 +1,9 @@
1
+<resources>
2
+
3
+    <!--
4
+         Customize dimensions originally defined in res/values/dimens.xml (such as
5
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
6
+    -->
7
+    <dimen name="activity_horizontal_margin">128dp</dimen>
8
+
9
+</resources>

+ 11
- 0
res/values-v11/styles.xml View File

@@ -0,0 +1,11 @@
1
+<resources>
2
+
3
+    <!--
4
+        Base application theme for API 11+. This theme completely replaces
5
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
6
+    -->
7
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
8
+        <!-- API 11 theme customizations can go here. -->
9
+    </style>
10
+
11
+</resources>

+ 12
- 0
res/values-v14/styles.xml View File

@@ -0,0 +1,12 @@
1
+<resources>
2
+
3
+    <!--
4
+        Base application theme for API 14+. This theme completely replaces
5
+        AppBaseTheme from BOTH res/values/styles.xml and
6
+        res/values-v11/styles.xml on API 14+ devices.
7
+    -->
8
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
9
+        <!-- API 14 theme customizations can go here. -->
10
+    </style>
11
+
12
+</resources>

+ 7
- 0
res/values/dimens.xml View File

@@ -0,0 +1,7 @@
1
+<resources>
2
+
3
+    <!-- Default screen margins, per the Android Design guidelines. -->
4
+    <dimen name="activity_horizontal_margin">16dp</dimen>
5
+    <dimen name="activity_vertical_margin">16dp</dimen>
6
+
7
+</resources>

+ 13
- 0
res/values/strings.xml View File

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<resources>
3
+
4
+    <string name="app_name">MVNO roaming</string>
5
+    <string name="action_settings">Settings</string>
6
+    <string name="description">With this app you can disable the roaming icon if your service provider is a mvno (mobile virtual network operator)! Just enter your providername in the textfield.</string>
7
+    <string name="inputHint">Your provider. e.g. tmobile</string>
8
+    <string name="enableOnBoot">Enable this switch to set the correct providername after a reboot, so you do not need to run this app manually!</string>
9
+    <string name="update">Update</string>
10
+    <string name="rebootSwitch">Set on reboot:</string>
11
+    <string name="copyright">Written by h44z 2013. v1.0</string>
12
+
13
+</resources>

+ 20
- 0
res/values/styles.xml View File

@@ -0,0 +1,20 @@
1
+<resources>
2
+
3
+    <!--
4
+        Base application theme, dependent on API level. This theme is replaced
5
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6
+    -->
7
+    <style name="AppBaseTheme" parent="android:Theme.Light">
8
+        <!--
9
+            Theme customizations available in newer API levels can go in
10
+            res/values-vXX/styles.xml, while customizations related to
11
+            backward-compatibility can go here.
12
+        -->
13
+    </style>
14
+
15
+    <!-- Application theme. -->
16
+    <style name="AppTheme" parent="AppBaseTheme">
17
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
18
+    </style>
19
+
20
+</resources>

+ 22
- 0
src/at/sprinternet/mvnoroaming/ExecuteAsRoot.java View File

@@ -0,0 +1,22 @@
1
+package at.sprinternet.mvnoroaming;
2
+
3
+import java.io.IOException;
4
+
5
+import android.util.Log;
6
+
7
+public class ExecuteAsRoot {
8
+	public static boolean exec(String command) {
9
+		try {
10
+			Process process = Runtime.getRuntime().exec(
11
+					new String[] { "su", "-c", command });
12
+			process.waitFor();			
13
+		} catch (IOException ex) {
14
+			Log.w("ROOT", "Can't get root access", ex);
15
+			return false;
16
+		} catch (InterruptedException ex) {
17
+			Log.w("ROOT", "Can't get root access", ex);
18
+			return false;
19
+		}
20
+		return true;
21
+	}
22
+}

+ 73
- 0
src/at/sprinternet/mvnoroaming/MVNORoamingStatusChanger.java View File

@@ -0,0 +1,73 @@
1
+package at.sprinternet.mvnoroaming;
2
+
3
+import android.os.Bundle;
4
+import android.app.Activity;
5
+import android.content.Context;
6
+import android.content.SharedPreferences;
7
+import android.util.Log;
8
+import android.view.View;
9
+import android.widget.Button;
10
+import android.widget.CompoundButton;
11
+import android.widget.EditText;
12
+import android.widget.Switch;
13
+import android.widget.Toast;
14
+
15
+public class MVNORoamingStatusChanger extends Activity {
16
+
17
+	private static final String PROVIDER_KEY = "mvno_provider";
18
+	private static final String REBOOTSERVICE_KEY = "mvno_setonreboot";
19
+	private static final String TAG = "MVNOroaming";
20
+	
21
+	private EditText editTextProvider;
22
+	private Button buttonUpdate;
23
+	private Switch switchReboot;
24
+	
25
+	private SharedPreferences prefs;
26
+	
27
+    @Override
28
+    protected void onCreate(Bundle savedInstanceState) {
29
+        super.onCreate(savedInstanceState);
30
+        setContentView(R.layout.activity_mvno);
31
+        
32
+        editTextProvider = (EditText) findViewById(R.id.editTextProvider);
33
+        buttonUpdate = (Button) findViewById(R.id.buttonUpdate);
34
+        switchReboot = (Switch) findViewById(R.id.switchReboot);
35
+        prefs = this.getSharedPreferences("at.sprinternet.mvnoroaming", Context.MODE_PRIVATE);
36
+        
37
+        //set listeners
38
+        switchReboot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
39
+			@Override
40
+			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
41
+			    Log.v(TAG, "Switch State="+isChecked);
42
+			    prefs.edit().putBoolean(REBOOTSERVICE_KEY, isChecked).commit();
43
+			}       
44
+		
45
+		});
46
+        
47
+        buttonUpdate.setOnClickListener(new Button.OnClickListener() {
48
+			@Override
49
+			public void onClick(View v) {
50
+				Log.v(TAG, "Button clicked");
51
+				prefs.edit().putString(PROVIDER_KEY, editTextProvider.getText().toString()).commit();
52
+				Boolean done = ExecuteAsRoot.exec("setprop gsm.sim.operator.alpha " + editTextProvider.getText().toString());
53
+				
54
+				if(!done) {
55
+					Toast.makeText(getApplicationContext(), "Setting Service-Provider failed!", Toast.LENGTH_LONG).show();
56
+				} else {
57
+					Toast.makeText(getApplicationContext(), "Updated Service-Provider!", Toast.LENGTH_LONG).show();
58
+				}
59
+			}
60
+		});
61
+        
62
+        
63
+        //init gui
64
+        String currentProvider = "";
65
+        Boolean setOnReboot = true;
66
+        
67
+        currentProvider = prefs.getString(PROVIDER_KEY, "");  // default: empty
68
+        setOnReboot = prefs.getBoolean(REBOOTSERVICE_KEY, true);
69
+        
70
+        editTextProvider.setText(currentProvider);
71
+        switchReboot.setChecked(setOnReboot);
72
+    }
73
+}

+ 54
- 0
src/at/sprinternet/mvnoroaming/RebootService.java View File

@@ -0,0 +1,54 @@
1
+package at.sprinternet.mvnoroaming;
2
+
3
+import android.app.Service;
4
+import android.content.Context;
5
+import android.content.Intent;
6
+import android.content.SharedPreferences;
7
+import android.os.IBinder;
8
+import android.util.Log;
9
+import android.widget.Toast;
10
+
11
+public class RebootService extends Service{
12
+	
13
+	private static final String PROVIDER_KEY = "mvno_provider";
14
+	private static final String REBOOTSERVICE_KEY = "mvno_setonreboot";
15
+	private static final String TAG = "MVNOroaming";
16
+	
17
+	private SharedPreferences prefs;
18
+
19
+    @Override  
20
+    public void onCreate() {  
21
+        super.onCreate();
22
+        
23
+        prefs = this.getSharedPreferences("at.sprinternet.mvnoroaming", Context.MODE_PRIVATE);
24
+    }  
25
+
26
+    @Override  
27
+    public int onStartCommand(Intent intent, int flags, int startId) {
28
+        String currentProvider = prefs.getString(PROVIDER_KEY, null);
29
+        Boolean runOnReboot = prefs.getBoolean(REBOOTSERVICE_KEY, true);
30
+        
31
+        if(runOnReboot && currentProvider != null && "".compareTo(currentProvider) != 0 ) {
32
+			Boolean done = ExecuteAsRoot.exec("setprop gsm.sim.operator.alpha " + currentProvider);
33
+			Log.v(TAG, "Setprop result:" + done);
34
+			
35
+			if(!done) {
36
+				Toast.makeText(getApplicationContext(), "Setting Service-Provider failed!", Toast.LENGTH_LONG).show();
37
+			} else {
38
+				Toast.makeText(getApplicationContext(), "Updated Service-Provider!", Toast.LENGTH_LONG).show();
39
+			}
40
+        }
41
+        return Service.START_STICKY;  
42
+    }  
43
+
44
+    @Override
45
+    public void onDestroy() {
46
+        super.onDestroy();
47
+        Log.v(TAG, "Service destroyed");
48
+    }
49
+
50
+    @Override  
51
+    public IBinder onBind(Intent arg0) {  
52
+        return null;  
53
+    }  
54
+}

+ 16
- 0
src/at/sprinternet/mvnoroaming/RebootServiceReceiver.java View File

@@ -0,0 +1,16 @@
1
+package at.sprinternet.mvnoroaming;
2
+
3
+import android.content.BroadcastReceiver;
4
+import android.content.Context;
5
+import android.content.Intent;
6
+
7
+public class RebootServiceReceiver extends BroadcastReceiver {
8
+
9
+	@Override
10
+	public void onReceive(Context context, Intent intent) {
11
+		if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
12
+            Intent serviceIntent = new Intent(context, RebootService.class);
13
+            context.startService(serviceIntent);
14
+        }
15
+	}
16
+}

BIN
srcres/icon_roam.png View File


BIN
srcres/icon_roam.xcf View File


Loading…
Cancel
Save