├── .gitignore
├── LICENSE
├── NetInfo_Widget
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── ultrafunk
│ │ └── network_info
│ │ ├── Constants.java
│ │ ├── WidgetProvider.java
│ │ ├── config
│ │ ├── ConfigActivity.java
│ │ ├── SettingsScreenDialogFragment.java
│ │ └── WidgetConfig.java
│ │ ├── receiver
│ │ ├── MobileDataOnOffReceiver.java
│ │ ├── MobileDataStatusReceiver.java
│ │ ├── MobileDataUtils.java
│ │ ├── WidgetBroadcastReceiver.java
│ │ ├── WifiOnOffReceiver.java
│ │ ├── WifiStatusReceiver.java
│ │ └── WifiUtils.java
│ │ ├── service
│ │ ├── MobileDataSettingObserver.java
│ │ ├── MobileDataStateListener.java
│ │ └── NetworkStateService.java
│ │ └── util
│ │ ├── EnabledWidgets.java
│ │ └── Utils.java
│ └── res
│ ├── drawable-hdpi
│ ├── btn_radio_off.png
│ ├── btn_radio_on.png
│ ├── ic_launcher.png
│ ├── ic_signal_cellular_disabled.png
│ ├── ic_signal_cellular_disabled_off.png
│ ├── ic_signal_cellular_enabled.png
│ ├── ic_signal_cellular_enabled_off.png
│ ├── ic_signal_cellular_on.png
│ ├── ic_signal_wifi_enabled.png
│ ├── ic_signal_wifi_off.png
│ ├── ic_signal_wifi_on.png
│ └── ic_widget_preview.png
│ ├── drawable-xhdpi
│ ├── btn_radio_off.png
│ ├── btn_radio_on.png
│ ├── ic_launcher.png
│ ├── ic_signal_cellular_disabled.png
│ ├── ic_signal_cellular_disabled_off.png
│ ├── ic_signal_cellular_enabled.png
│ ├── ic_signal_cellular_enabled_off.png
│ ├── ic_signal_cellular_on.png
│ ├── ic_signal_wifi_enabled.png
│ ├── ic_signal_wifi_off.png
│ ├── ic_signal_wifi_on.png
│ └── ic_widget_preview.png
│ ├── drawable-xxhdpi
│ ├── btn_radio_off.png
│ ├── btn_radio_on.png
│ ├── ic_launcher.png
│ ├── ic_signal_cellular_disabled.png
│ ├── ic_signal_cellular_disabled_off.png
│ ├── ic_signal_cellular_enabled.png
│ ├── ic_signal_cellular_enabled_off.png
│ ├── ic_signal_cellular_on.png
│ ├── ic_signal_wifi_enabled.png
│ ├── ic_signal_wifi_off.png
│ ├── ic_signal_wifi_on.png
│ └── ic_widget_preview.png
│ ├── drawable-xxxhdpi
│ ├── btn_radio_off.png
│ ├── btn_radio_on.png
│ ├── ic_launcher.png
│ ├── ic_signal_cellular_disabled.png
│ ├── ic_signal_cellular_disabled_off.png
│ ├── ic_signal_cellular_enabled.png
│ ├── ic_signal_cellular_enabled_off.png
│ ├── ic_signal_cellular_on.png
│ ├── ic_signal_wifi_enabled.png
│ ├── ic_signal_wifi_off.png
│ ├── ic_signal_wifi_on.png
│ └── ic_widget_preview.png
│ ├── drawable
│ └── btn_radio_material.xml
│ ├── layout
│ ├── activity_config.xml
│ ├── widget_homescreen.xml
│ ├── widget_homescreen_mobile.xml
│ ├── widget_homescreen_wifi.xml
│ ├── widget_keyguard.xml
│ ├── widget_keyguard_mobile.xml
│ └── widget_keyguard_wifi.xml
│ ├── values-ja
│ └── strings.xml
│ ├── values-w600dp-port
│ └── dimens.xml
│ ├── values-w820dp
│ └── dimens.xml
│ ├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── widget_info.xml
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | build/
13 |
14 | # Gradle cache
15 | .gradle
16 |
17 | # Local configuration file (sdk path, etc)
18 | local.properties
19 |
20 | # IDEA/Android Studio project files, because the project can be imported from settings.gradle
21 | .idea
22 | *.iml
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/NetInfo_Widget/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /src/androidTest
3 |
--------------------------------------------------------------------------------
/NetInfo_Widget/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.ultrafunk.network_info"
9 | minSdkVersion 16
10 | targetSdkVersion 22
11 | versionCode 30
12 | versionName "1.9.2"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled true
17 | shrinkResources true
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | compile "com.android.support:support-v4:25.0.1"
26 | compile "com.android.support:appcompat-v7:25.0.1"
27 | }
28 |
--------------------------------------------------------------------------------
/NetInfo_Widget/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Program Files (x86)\Android\android-studio\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
41 |
42 |
43 |
44 |
45 |
46 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
62 |
63 |
64 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info;
18 |
19 | public class Constants
20 | {
21 | private static final String APP_ID = BuildConfig.APPLICATION_ID;
22 |
23 | public static final String ACTION_UPDATE_SERVICE_STATE = "action.UPDATE_SERVICE_STATE";
24 | public static final String EXTRA_ENABLED_WIDGETS_MOBILE_DATA = "extra.ENABLED_WIDGETS_MOBILE_DATA";
25 | public static final String EXTRA_ENABLED_WIDGETS_WIFI = "extra.ENABLED_WIDGETS_WIFI";
26 |
27 | // Broadcasts
28 | // ToDo: Should use permissions to exclude other apps from sending this broadcast to us
29 | public static final String ACTION_UPDATE_WIDGET = APP_ID + ".action.UPDATE_WIDGET";
30 | public static final String EXTRA_APPWIDGET_ID = APP_ID + ".extra.APPWIDGET_ID";
31 |
32 | public static final String ONCLICK_MOBILE_DATA_ONOFF = APP_ID + ".onclick.MOBILE_DATA_ONOFF";
33 | public static final String ONCLICK_WIFI_ONOFF = APP_ID + ".onclick.WIFI_ONOFF";
34 |
35 | // Local broadcasts
36 | public static final String ACTION_SERVICE_STATE_CHANGED = "action.SERVICE_STATE_CHANGED";
37 | public static final String ACTION_DATA_CONNECTION_CHANGED = "action.DATA_CONNECTION_CHANGED";
38 | public static final String ACTION_DATA_STATE_CHANGED = "action.DATA_STATE_CHANGED";
39 | public static final String ACTION_DATA_CONNECTED = "action.DATA_CONNECTED";
40 | public static final String ACTION_DATA_USAGE_UPDATE = "action.DATA_USAGE_UPDATE";
41 |
42 | public static final String ACTION_WIFI_CONNECTING = "action.WIFI_CONNECTING";
43 | public static final String ACTION_WIFI_CONNECTED = "action.WIFI_CONNECTED";
44 | public static final String ACTION_WIFI_SCANNING = "action.WIFI_SCANNING";
45 | public static final String ACTION_WIFI_LINK_SPEED = "action.WIFI_LINK_SPEED";
46 |
47 | // Prefs
48 | public static final String PREFS_NAME = APP_ID + "_";
49 | public static final String PREF_IS_LOCKSCREEN_WIDGET = "isLockscreenWidget";
50 | public static final String PREF_MOBILE_DATA_WIDGET = "mobileDataWidget";
51 | public static final String PREF_WIFI_WIDGET = "wifiWidget";
52 | public static final String PREF_LAYOUT_ID = "layoutId";
53 | public static final String PREF_MOBILE_DATA_SETTINGS_SCREEN = "mobileDataSettingsScreen";
54 | public static final String PREF_LOCKSCREEN_GRAVITY = "lockscreenGravity";
55 | public static final String PREF_BACKGROUND_TRANSPARENCY = "backgroundTransparency";
56 | }
57 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/WidgetProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info;
18 |
19 | import android.app.PendingIntent;
20 | import android.appwidget.AppWidgetManager;
21 | import android.appwidget.AppWidgetProvider;
22 | import android.appwidget.AppWidgetProviderInfo;
23 | import android.content.ComponentName;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.content.pm.PackageManager;
27 | import android.content.pm.ResolveInfo;
28 | import android.graphics.Color;
29 | import android.os.Build;
30 | import android.os.Bundle;
31 | import android.provider.Settings;
32 | import android.util.TypedValue;
33 | import android.widget.RemoteViews;
34 |
35 | import com.ultrafunk.network_info.config.WidgetConfig;
36 | import com.ultrafunk.network_info.receiver.MobileDataOnOffReceiver;
37 | import com.ultrafunk.network_info.receiver.MobileDataStatusReceiver;
38 | import com.ultrafunk.network_info.receiver.WifiOnOffReceiver;
39 | import com.ultrafunk.network_info.receiver.WifiStatusReceiver;
40 | import com.ultrafunk.network_info.service.NetworkStateService;
41 | import com.ultrafunk.network_info.util.EnabledWidgets;
42 | import com.ultrafunk.network_info.util.Utils;
43 |
44 | public class WidgetProvider extends AppWidgetProvider
45 | {
46 | private static final String PACKAGENAME_SETTINGS = "com.android.settings";
47 | private static final String CLASSNAME_DATA_USAGE_SUMMARY = PACKAGENAME_SETTINGS + ".Settings$DataUsageSummaryActivity";
48 | private static final String CLASSNAME_TETHER_SETTINGS = PACKAGENAME_SETTINGS + ".TetherSettings";
49 |
50 | @Override
51 | public void onDisabled(Context context)
52 | {
53 | super.onDisabled(context);
54 | setReceiversAndServiceState(context);
55 | }
56 |
57 | @Override
58 | public void onDeleted(Context context, int[] appWidgetIds)
59 | {
60 | super.onDeleted(context, appWidgetIds);
61 | setReceiversAndServiceState(context);
62 | }
63 |
64 | @Override
65 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
66 | {
67 | super.onUpdate(context, appWidgetManager, appWidgetIds);
68 |
69 | WidgetConfig widgetConfig = new WidgetConfig(context);
70 |
71 | for (int appWidgetId : appWidgetIds)
72 | {
73 | widgetConfig.read(appWidgetId);
74 | updateWidget(context, appWidgetManager, appWidgetId, widgetConfig);
75 | }
76 |
77 | setReceiversAndServiceState(context);
78 | }
79 |
80 | @Override
81 | public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions)
82 | {
83 | super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
84 |
85 | if (newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1) == AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN)
86 | {
87 | RemoteViews remoteViews = new RemoteViews(context.getPackageName(), newOptions.getInt(Constants.PREF_LAYOUT_ID, 0));
88 | int minWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
89 |
90 | setWidgetTextSize(remoteViews, newOptions, (minWidth > 175) ? 14 : 12);
91 | appWidgetManager.partiallyUpdateAppWidget(appWidgetId, remoteViews);
92 | }
93 | }
94 |
95 | private void setWidgetTextSize(RemoteViews remoteViews, Bundle newOptions, int textSize)
96 | {
97 | if (newOptions.getBoolean(Constants.PREF_MOBILE_DATA_WIDGET, false))
98 | {
99 | remoteViews.setTextViewTextSize(R.id.mobileNameTextView, TypedValue.COMPLEX_UNIT_SP, textSize + 1);
100 | remoteViews.setTextViewTextSize(R.id.mobileInfoTopTextView, TypedValue.COMPLEX_UNIT_SP, textSize);
101 | remoteViews.setTextViewTextSize(R.id.mobileInfoBottomTextView, TypedValue.COMPLEX_UNIT_SP, textSize);
102 | }
103 |
104 | if (newOptions.getBoolean(Constants.PREF_WIFI_WIDGET, false))
105 | {
106 | remoteViews.setTextViewTextSize(R.id.wifiNameTextView, TypedValue.COMPLEX_UNIT_SP, textSize + 1);
107 | remoteViews.setTextViewTextSize(R.id.wifiInfoTopTextView, TypedValue.COMPLEX_UNIT_SP, textSize);
108 | remoteViews.setTextViewTextSize(R.id.wifiInfoBottomTextView, TypedValue.COMPLEX_UNIT_SP, textSize);
109 | }
110 | }
111 |
112 | public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, WidgetConfig widgetConfig)
113 | {
114 | RemoteViews remoteViews = new RemoteViews(context.getPackageName(), widgetConfig.getLayoutId());
115 |
116 | if (widgetConfig.isLockscreenWidget())
117 | remoteViews.setInt(widgetConfig.showBothWidgets() ? R.id.keyguardLinearLayout : R.id.containerRelativeLayout, "setGravity", widgetConfig.getLockscreenGravity());
118 |
119 | if (widgetConfig.showMobileDataWidget())
120 | {
121 | remoteViews.setInt(R.id.mobileParentRelativeLayout, "setBackgroundColor", Color.argb(widgetConfig.getBackgroundTransparencyAlpha(), 0, 0, 0));
122 |
123 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
124 | remoteViews.setOnClickPendingIntent(R.id.mobileOnOffRelativeLayout, getBroadcastPendingIntent(context, MobileDataOnOffReceiver.class, Constants.ONCLICK_MOBILE_DATA_ONOFF));
125 | else
126 | remoteViews.setOnClickPendingIntent(R.id.mobileOnOffRelativeLayout, getSettingsPagePendingIntent(context, PACKAGENAME_SETTINGS, CLASSNAME_DATA_USAGE_SUMMARY, getBroadcastPendingIntent(context, MobileDataOnOffReceiver.class, Constants.ONCLICK_MOBILE_DATA_ONOFF)));
127 |
128 | if (widgetConfig.getMobileDataSettingsScreen() == WidgetConfig.MOBILE_DATA_SETTINGS_MOBILE_NETWORK_SETTINGS)
129 | remoteViews.setOnClickPendingIntent(R.id.mobileChangeRelativeLayout, getSettingsPendingIntent(context, Settings.ACTION_DATA_ROAMING_SETTINGS));
130 | else if (widgetConfig.getMobileDataSettingsScreen() == WidgetConfig.MOBILE_DATA_SETTINGS_DATA_USAGE)
131 | remoteViews.setOnClickPendingIntent(R.id.mobileChangeRelativeLayout, getSettingsPagePendingIntent(context, PACKAGENAME_SETTINGS, CLASSNAME_DATA_USAGE_SUMMARY, getSettingsPendingIntent(context, Settings.ACTION_DATA_ROAMING_SETTINGS)));
132 | else if (widgetConfig.getMobileDataSettingsScreen() == WidgetConfig.MOBILE_DATA_SETTINGS_TETHERING_SETTINGS)
133 | remoteViews.setOnClickPendingIntent(R.id.mobileChangeRelativeLayout, getSettingsPagePendingIntent(context, PACKAGENAME_SETTINGS, CLASSNAME_TETHER_SETTINGS, getSettingsPendingIntent(context, Settings.ACTION_DATA_ROAMING_SETTINGS)));
134 |
135 | broadcastUpdateWidget(context, MobileDataStatusReceiver.class, appWidgetId);
136 | }
137 |
138 | if (widgetConfig.showWifiWidget())
139 | {
140 | remoteViews.setInt(R.id.wifiParentRelativeLayout, "setBackgroundColor", Color.argb(widgetConfig.getBackgroundTransparencyAlpha(), 0, 0, 0));
141 | remoteViews.setOnClickPendingIntent(R.id.wifiOnOffRelativeLayout, getBroadcastPendingIntent(context, WifiOnOffReceiver.class, Constants.ONCLICK_WIFI_ONOFF));
142 | remoteViews.setOnClickPendingIntent(R.id.wifiChangeRelativeLayout, getSettingsPendingIntent(context, Settings.ACTION_WIFI_SETTINGS));
143 | broadcastUpdateWidget(context, WifiStatusReceiver.class, appWidgetId);
144 | }
145 |
146 | appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
147 | }
148 |
149 | private void setReceiversAndServiceState(Context context)
150 | {
151 | EnabledWidgets enabledWidgets = Utils.getEnabledWidgets(context, AppWidgetManager.getInstance(context));
152 | enableDisableReceivers(context, enabledWidgets);
153 | startStopService(context, enabledWidgets);
154 | }
155 |
156 | public static void enableDisableReceivers(Context context, EnabledWidgets enabledWidgets)
157 | {
158 | PackageManager packageManager = context.getPackageManager();
159 |
160 | int receiverEnableDisable = enabledWidgets.mobileData ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
161 | packageManager.setComponentEnabledSetting(new ComponentName(context, MobileDataStatusReceiver.class), receiverEnableDisable, PackageManager.DONT_KILL_APP);
162 |
163 | receiverEnableDisable = enabledWidgets.wifi ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
164 | packageManager.setComponentEnabledSetting(new ComponentName(context, WifiStatusReceiver.class), receiverEnableDisable, PackageManager.DONT_KILL_APP);
165 | }
166 |
167 | public static void startStopService(Context context, EnabledWidgets enabledWidgets)
168 | {
169 | if ((enabledWidgets.mobileData) || (enabledWidgets.wifi))
170 | {
171 | Intent intent = new Intent(context, NetworkStateService.class);
172 | intent.setAction(Constants.ACTION_UPDATE_SERVICE_STATE);
173 | intent.putExtra(Constants.EXTRA_ENABLED_WIDGETS_MOBILE_DATA, enabledWidgets.mobileData);
174 | intent.putExtra(Constants.EXTRA_ENABLED_WIDGETS_WIFI, enabledWidgets.wifi);
175 | context.startService(intent);
176 | }
177 | else
178 | {
179 | context.stopService(new Intent(context, NetworkStateService.class));
180 | }
181 | }
182 |
183 | private static PendingIntent getBroadcastPendingIntent(Context context, Class> intentClass, String action)
184 | {
185 | Intent intent = new Intent(context, intentClass);
186 | intent.setAction(action);
187 | return PendingIntent.getBroadcast(context, 0, intent, 0);
188 | }
189 |
190 | private static PendingIntent getSettingsPendingIntent(Context context, String action)
191 | {
192 | return PendingIntent.getActivity(context, 0, new Intent(action), PendingIntent.FLAG_UPDATE_CURRENT);
193 | }
194 |
195 | private static PendingIntent getSettingsPagePendingIntent(Context context, String packageName, String className, PendingIntent defaultPendingIntent)
196 | {
197 | Intent intent = new Intent();
198 | intent.setClassName(packageName, className);
199 |
200 | PackageManager packageManager = context.getPackageManager();
201 | ResolveInfo resolveInfo = packageManager.resolveActivity(intent, 0);
202 |
203 | if (resolveInfo != null)
204 | return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
205 |
206 | return defaultPendingIntent;
207 | }
208 |
209 | private static void broadcastUpdateWidget(Context context, Class> intentClass, int appWidgetId)
210 | {
211 | Intent intent = new Intent(context, intentClass);
212 | intent.setAction(Constants.ACTION_UPDATE_WIDGET);
213 | intent.putExtra(Constants.EXTRA_APPWIDGET_ID, appWidgetId);
214 | context.sendBroadcast(intent);
215 | }
216 | }
217 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/config/ConfigActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.config;
18 |
19 | import android.appwidget.AppWidgetManager;
20 | import android.appwidget.AppWidgetProviderInfo;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.os.Build;
24 | import android.os.Bundle;
25 | import android.support.v4.app.DialogFragment;
26 | import android.support.v7.app.AppCompatActivity;
27 | import android.view.Gravity;
28 | import android.view.View;
29 | import android.widget.Button;
30 | import android.widget.CheckedTextView;
31 | import android.widget.LinearLayout;
32 | import android.widget.RadioGroup;
33 | import android.widget.RelativeLayout;
34 | import android.widget.SeekBar;
35 | import android.widget.TextView;
36 |
37 | import com.ultrafunk.network_info.Constants;
38 | import com.ultrafunk.network_info.util.EnabledWidgets;
39 | import com.ultrafunk.network_info.R;
40 | import com.ultrafunk.network_info.util.Utils;
41 | import com.ultrafunk.network_info.WidgetProvider;
42 |
43 | public class ConfigActivity extends AppCompatActivity implements SettingsScreenDialogFragment.DialogListener
44 | {
45 | private AppWidgetManager appAppWidgetManager;
46 | private WidgetConfig widgetConfig;
47 |
48 | private int appWidgetId;
49 |
50 | private CheckedTextView gravityCheckedTextView;
51 | private TextView bgTransValTextView;
52 |
53 | @Override
54 | protected void onCreate(Bundle savedInstanceState)
55 | {
56 | super.onCreate(savedInstanceState);
57 |
58 | /*
59 | ToDo: So we can show the ConfigActivity when started from a lock screen widget
60 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
61 | */
62 |
63 | // Set the result to CANCELED. This will cause the widget host to cancel out of the widget placement if they press the back button.
64 | setResult(RESULT_CANCELED);
65 |
66 | setContentView(R.layout.activity_config);
67 |
68 | // Find the widget id from the intent.
69 | Bundle extras = getIntent().getExtras();
70 |
71 | if (extras != null)
72 | appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
73 |
74 | if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
75 | finish();
76 |
77 | appAppWidgetManager = AppWidgetManager.getInstance(this);
78 |
79 | widgetConfig = new WidgetConfig(this);
80 | widgetConfig.read(appWidgetId);
81 |
82 | // ToDo: Needs to change if/when the ConfigActivity is started from a widget or home screen
83 | widgetConfig.setBothWidgets(true);
84 |
85 | TextView configurationTextView = (TextView) findViewById(R.id.configurationTextView);
86 | configurationTextView.setText((isLockscreenWidget(appAppWidgetManager, appWidgetId) ? getString(R.string.lockscreen_configuration) : getString(R.string.homescreen_configuration)));
87 |
88 | initShowWidgetView();
89 | initMobileSettingsScreenView();
90 | initLockscreenGravityView();
91 | initTransparencyView();
92 | initOkAndCancelButtons();
93 | }
94 |
95 | @Override
96 | public void onDestroy()
97 | {
98 | super.onDestroy();
99 | widgetConfig.write(appWidgetId);
100 | }
101 |
102 | @Override
103 | public void onDialogSelectionChanged(int selected)
104 | {
105 | TextView mobileCurrentSettingsScreenTextView = (TextView) findViewById(R.id.mobileCurrentSettingsScreenTextView);
106 | widgetConfig.setMobileDataSettingsScreen(selected);
107 |
108 | if (selected == WidgetConfig.MOBILE_DATA_SETTINGS_MOBILE_NETWORK_SETTINGS)
109 | mobileCurrentSettingsScreenTextView.setText(getString(R.string.mobile_network_settings));
110 | else if (selected == WidgetConfig.MOBILE_DATA_SETTINGS_DATA_USAGE)
111 | mobileCurrentSettingsScreenTextView.setText(getString(R.string.data_usage));
112 | else if (selected == WidgetConfig.MOBILE_DATA_SETTINGS_TETHERING_SETTINGS)
113 | mobileCurrentSettingsScreenTextView.setText(getString(R.string.tethering_and_portable_hotspot));
114 | }
115 |
116 | private void initShowWidgetView()
117 | {
118 | RadioGroup showWidgetRadioGroup = (RadioGroup) findViewById(R.id.showWidgetRadioGroup);
119 |
120 | if (widgetConfig.showBothWidgets())
121 | showWidgetRadioGroup.check(R.id.showBothRadioButton);
122 | else if (widgetConfig.showMobileDataWidget())
123 | showWidgetRadioGroup.check(R.id.showMobileRadioButton);
124 | else
125 | showWidgetRadioGroup.check(R.id.showWifiRadioButton);
126 |
127 | showWidgetRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
128 | {
129 | public void onCheckedChanged(RadioGroup radioGroup, int checkedId)
130 | {
131 | RelativeLayout mobileSettingsScreenRelativeLayout = (RelativeLayout) findViewById(R.id.mobileSettingsScreenRelativeLayout);
132 |
133 | widgetConfig.setBothWidgets(false);
134 |
135 | if (checkedId == R.id.showBothRadioButton)
136 | {
137 | widgetConfig.setBothWidgets(true);
138 | mobileSettingsScreenRelativeLayout.setVisibility(View.VISIBLE);
139 | }
140 |
141 | if (checkedId == R.id.showMobileRadioButton)
142 | {
143 | widgetConfig.setMobileDataWidget(true);
144 | mobileSettingsScreenRelativeLayout.setVisibility(View.VISIBLE);
145 | }
146 |
147 | if (checkedId == R.id.showWifiRadioButton)
148 | {
149 | widgetConfig.setWifiWidget(true);
150 | mobileSettingsScreenRelativeLayout.setVisibility(View.GONE);
151 | }
152 | }
153 | });
154 | }
155 |
156 | private void initMobileSettingsScreenView()
157 | {
158 | LinearLayout mobileSettingsScreenLinearLayout = (LinearLayout) findViewById(R.id.mobileSettingsScreenLinearLayout);
159 | onDialogSelectionChanged(widgetConfig.getMobileDataSettingsScreen());
160 |
161 | mobileSettingsScreenLinearLayout.setOnClickListener(new View.OnClickListener()
162 | {
163 | @Override
164 | public void onClick(View view) {
165 | DialogFragment dialogFragment = new SettingsScreenDialogFragment();
166 |
167 | Bundle bundle = new Bundle();
168 | bundle.putInt(Constants.PREF_MOBILE_DATA_SETTINGS_SCREEN, widgetConfig.getMobileDataSettingsScreen());
169 | dialogFragment.setArguments(bundle);
170 | dialogFragment.show(getSupportFragmentManager(), "SettingsScreenDialogFragment");
171 | }
172 | });
173 | }
174 |
175 | private void initLockscreenGravityView()
176 | {
177 | if (!isLockscreenWidget(appAppWidgetManager, appWidgetId))
178 | {
179 | widgetConfig.setLockscreenWidget(false);
180 | RelativeLayout lockscreenRelativeLayout = (RelativeLayout) findViewById(R.id.lockscreenRelativeLayout);
181 | lockscreenRelativeLayout.setVisibility(View.GONE);
182 | }
183 | else
184 | {
185 | widgetConfig.setLockscreenWidget(true);
186 | gravityCheckedTextView = (CheckedTextView) findViewById(R.id.gravityCheckedTextView);
187 | gravityCheckedTextView.setChecked((widgetConfig.getLockscreenGravity() == Gravity.TOP) ? false : true);
188 |
189 | gravityCheckedTextView.setOnClickListener(new View.OnClickListener()
190 | {
191 | @Override
192 | public void onClick(View view)
193 | {
194 | if (gravityCheckedTextView.isChecked())
195 | {
196 | widgetConfig.setLockscreenGravity(Gravity.TOP);
197 | gravityCheckedTextView.setChecked(false);
198 | }
199 | else
200 | {
201 | widgetConfig.setLockscreenGravity(Gravity.CENTER_VERTICAL);
202 | gravityCheckedTextView.setChecked(true);
203 | }
204 | }
205 | });
206 | }
207 | }
208 |
209 | private void initTransparencyView()
210 | {
211 | bgTransValTextView = (TextView) findViewById(R.id.bgTransValTextView);
212 | bgTransValTextView.setText(String.format("%d%%", widgetConfig.getBackgroundTransparency()));
213 |
214 | SeekBar bgTransSeekBar = (SeekBar) findViewById(R.id.bgTransSeekBar);
215 | bgTransSeekBar.setProgress(widgetConfig.getBackgroundTransparency());
216 |
217 | bgTransSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
218 | {
219 | @Override
220 | public void onStopTrackingTouch(SeekBar seekBar) {}
221 |
222 | @Override
223 | public void onStartTrackingTouch(SeekBar seekBar) {}
224 |
225 | @Override
226 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
227 | {
228 | widgetConfig.setBackgroundTransparency(progress);
229 | bgTransValTextView.setText(String.format("%d%%", progress));
230 | }
231 | });
232 | }
233 |
234 | private void initOkAndCancelButtons()
235 | {
236 | Button okButton = (Button) findViewById(R.id.okButton);
237 |
238 | okButton.setOnClickListener(new View.OnClickListener()
239 | {
240 | @Override
241 | public void onClick(View view)
242 | {
243 | final Context context = ConfigActivity.this;
244 |
245 | widgetConfig.write(appWidgetId);
246 |
247 | EnabledWidgets enabledWidgets = Utils.getEnabledWidgets(context, appAppWidgetManager);
248 | WidgetProvider.enableDisableReceivers(context, enabledWidgets);
249 | WidgetProvider.updateWidget(context, appAppWidgetManager, appWidgetId, widgetConfig);
250 | WidgetProvider.startStopService(context, enabledWidgets);
251 |
252 | // Make sure we pass back the original appWidgetId
253 | Intent resultValue = new Intent();
254 | resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
255 | setResult(RESULT_OK, resultValue);
256 | finish();
257 | }
258 | });
259 |
260 | Button cancelButton = (Button) findViewById(R.id.cancelButton);
261 |
262 | cancelButton.setOnClickListener(new View.OnClickListener()
263 | {
264 | @Override
265 | public void onClick(View view)
266 | {
267 | setResult(RESULT_CANCELED);
268 | finish();
269 | }
270 | });
271 | }
272 |
273 | private static boolean isLockscreenWidget(AppWidgetManager appWidgetManager, int appWidgetId)
274 | {
275 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
276 | {
277 | Bundle widgetOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
278 | int category = widgetOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
279 | return category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
280 | }
281 |
282 | return false;
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/config/SettingsScreenDialogFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.config;
18 |
19 | import android.app.Activity;
20 | import android.app.Dialog;
21 | import android.content.DialogInterface;
22 | import android.os.Bundle;
23 | import android.support.v4.app.DialogFragment;
24 | import android.support.v7.app.AlertDialog;
25 |
26 |
27 | import com.ultrafunk.network_info.Constants;
28 | import com.ultrafunk.network_info.R;
29 |
30 | import java.util.ArrayList;
31 |
32 | public class SettingsScreenDialogFragment extends DialogFragment
33 | {
34 | public interface DialogListener
35 | {
36 | void onDialogSelectionChanged(int selected);
37 | }
38 |
39 | DialogListener mListener;
40 |
41 | @Override
42 | public Dialog onCreateDialog(Bundle savedInstanceState)
43 | {
44 | AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
45 | Bundle bundle = getArguments();
46 |
47 | alertDialog.setTitle(getString(R.string.mobile_data_settings_shortcut));
48 | alertDialog.setPositiveButton(getString(android.R.string.cancel), new PositiveButtonClickListener());
49 |
50 | ArrayList arrayList = new ArrayList<>();
51 | arrayList.add(getString(R.string.mobile_network_settings));
52 | arrayList.add(getString(R.string.data_usage));
53 | arrayList.add(getString(R.string.tethering_and_portable_hotspot));
54 |
55 | alertDialog.setSingleChoiceItems(arrayList.toArray(new CharSequence[arrayList.size()]),
56 | bundle.getInt(Constants.PREF_MOBILE_DATA_SETTINGS_SCREEN, WidgetConfig.MOBILE_DATA_SETTINGS_MOBILE_NETWORK_SETTINGS),
57 | selectItemListener);
58 |
59 | return alertDialog.create();
60 | }
61 |
62 | @Override
63 | public void onAttach(Activity activity)
64 | {
65 | super.onAttach(activity);
66 | mListener = (DialogListener) activity;
67 | }
68 |
69 | class PositiveButtonClickListener implements DialogInterface.OnClickListener
70 | {
71 | @Override
72 | public void onClick(DialogInterface dialog, int which)
73 | {
74 | dialog.dismiss();
75 | }
76 | }
77 |
78 | DialogInterface.OnClickListener selectItemListener = new DialogInterface.OnClickListener()
79 | {
80 | @Override
81 | public void onClick(DialogInterface dialog, int which)
82 | {
83 | mListener.onDialogSelectionChanged(which);
84 | dialog.dismiss();
85 | }
86 | };
87 | }
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/config/WidgetConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.config;
18 |
19 | import android.appwidget.AppWidgetManager;
20 | import android.content.Context;
21 | import android.content.SharedPreferences;
22 | import android.os.Bundle;
23 | import android.view.Gravity;
24 |
25 | import com.ultrafunk.network_info.Constants;
26 | import com.ultrafunk.network_info.R;
27 |
28 | public class WidgetConfig
29 | {
30 | public static final int MOBILE_DATA_SETTINGS_MOBILE_NETWORK_SETTINGS = 0;
31 | public static final int MOBILE_DATA_SETTINGS_DATA_USAGE = 1;
32 | public static final int MOBILE_DATA_SETTINGS_TETHERING_SETTINGS = 2;
33 |
34 | private final Context context;
35 | private SharedPreferences sharedPreferences;
36 |
37 | private boolean isLockscreenWidget;
38 | private boolean mobileDataWidget;
39 | private boolean wifiWidget;
40 | private int layoutId;
41 | private int mobileDataSettingsScreen;
42 | private int lockscreenGravity;
43 | private int backgroundTransparency;
44 |
45 | public WidgetConfig(Context context)
46 | {
47 | this.context = context;
48 | sharedPreferences = null;
49 |
50 | isLockscreenWidget = false;
51 | mobileDataWidget = false;
52 | wifiWidget = false;
53 | layoutId = R.layout.widget_homescreen;
54 | mobileDataSettingsScreen = MOBILE_DATA_SETTINGS_MOBILE_NETWORK_SETTINGS;
55 | lockscreenGravity = Gravity.TOP;
56 | backgroundTransparency = 25;
57 | }
58 |
59 | public void read(int appWidgetId)
60 | {
61 | sharedPreferences = context.getSharedPreferences(Constants.PREFS_NAME + String.valueOf(appWidgetId), Context.MODE_PRIVATE);
62 |
63 | isLockscreenWidget = sharedPreferences.getBoolean(Constants.PREF_IS_LOCKSCREEN_WIDGET, isLockscreenWidget);
64 | mobileDataWidget = sharedPreferences.getBoolean(Constants.PREF_MOBILE_DATA_WIDGET, mobileDataWidget);
65 | wifiWidget = sharedPreferences.getBoolean(Constants.PREF_WIFI_WIDGET, wifiWidget);
66 | layoutId = sharedPreferences.getInt(Constants.PREF_LAYOUT_ID, layoutId);
67 | mobileDataSettingsScreen = sharedPreferences.getInt(Constants.PREF_MOBILE_DATA_SETTINGS_SCREEN, mobileDataSettingsScreen);
68 | lockscreenGravity = sharedPreferences.getInt(Constants.PREF_LOCKSCREEN_GRAVITY, lockscreenGravity);
69 | backgroundTransparency = sharedPreferences.getInt(Constants.PREF_BACKGROUND_TRANSPARENCY, backgroundTransparency);
70 |
71 | setWidgetOptions(appWidgetId);
72 | }
73 |
74 | void write(int appWidgetId)
75 | {
76 | if (sharedPreferences != null)
77 | {
78 | SharedPreferences.Editor editor = sharedPreferences.edit();
79 |
80 | editor.putBoolean(Constants.PREF_IS_LOCKSCREEN_WIDGET, isLockscreenWidget);
81 | editor.putBoolean(Constants.PREF_MOBILE_DATA_WIDGET, mobileDataWidget);
82 | editor.putBoolean(Constants.PREF_WIFI_WIDGET, wifiWidget);
83 | editor.putInt(Constants.PREF_LAYOUT_ID, layoutId);
84 | editor.putInt(Constants.PREF_MOBILE_DATA_SETTINGS_SCREEN, mobileDataSettingsScreen);
85 | editor.putInt(Constants.PREF_LOCKSCREEN_GRAVITY, lockscreenGravity);
86 | editor.putInt(Constants.PREF_BACKGROUND_TRANSPARENCY, backgroundTransparency);
87 |
88 | editor.commit();
89 | }
90 |
91 | setWidgetOptions(appWidgetId);
92 | }
93 |
94 | private void setWidgetOptions(int appWidgetId)
95 | {
96 | if (isLockscreenWidget)
97 | {
98 | if (showBothWidgets())
99 | layoutId = R.layout.widget_keyguard;
100 | else if (mobileDataWidget)
101 | layoutId = R.layout.widget_keyguard_mobile;
102 | else
103 | layoutId = R.layout.widget_keyguard_wifi;
104 | }
105 | else
106 | {
107 | if (showBothWidgets())
108 | layoutId = R.layout.widget_homescreen;
109 | else if (mobileDataWidget)
110 | layoutId = R.layout.widget_homescreen_mobile;
111 | else
112 | layoutId = R.layout.widget_homescreen_wifi;
113 | }
114 |
115 | Bundle options = new Bundle();
116 | options.putBoolean(Constants.PREF_MOBILE_DATA_WIDGET, mobileDataWidget);
117 | options.putBoolean(Constants.PREF_WIFI_WIDGET, wifiWidget);
118 | options.putInt(Constants.PREF_LAYOUT_ID, layoutId);
119 |
120 | AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
121 | appWidgetManager.updateAppWidgetOptions(appWidgetId, options);
122 | }
123 |
124 | public boolean isLockscreenWidget() { return isLockscreenWidget; }
125 | void setLockscreenWidget(boolean isLockscreenWidget) { this.isLockscreenWidget = isLockscreenWidget; }
126 |
127 | public boolean showMobileDataWidget() { return mobileDataWidget; }
128 | void setMobileDataWidget(boolean mobileDataWidget) { this.mobileDataWidget = mobileDataWidget; }
129 |
130 | public boolean showWifiWidget() { return wifiWidget; }
131 | void setWifiWidget(boolean wifiWidget) { this.wifiWidget = wifiWidget; }
132 |
133 | public boolean showBothWidgets() { return mobileDataWidget && wifiWidget; }
134 | void setBothWidgets(boolean bothWidgets) { mobileDataWidget = bothWidgets; wifiWidget = bothWidgets; }
135 |
136 | public int getLayoutId() { return layoutId; }
137 |
138 | public int getMobileDataSettingsScreen() { return mobileDataSettingsScreen; }
139 | void setMobileDataSettingsScreen(int mobileDataSettingsScreen) { this.mobileDataSettingsScreen = mobileDataSettingsScreen; }
140 |
141 | public int getLockscreenGravity() { return lockscreenGravity; }
142 | void setLockscreenGravity(int lockscreenGravity) { this.lockscreenGravity = lockscreenGravity; }
143 |
144 | int getBackgroundTransparency() { return backgroundTransparency; }
145 | public int getBackgroundTransparencyAlpha() { return (int) ((100 - backgroundTransparency) * 2.55); }
146 | void setBackgroundTransparency(int backgroundTransparency) { this.backgroundTransparency = backgroundTransparency; }
147 | }
148 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/MobileDataOnOffReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.receiver;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.view.View;
23 | import android.widget.RemoteViews;
24 | import android.widget.Toast;
25 |
26 | import com.ultrafunk.network_info.Constants;
27 | import com.ultrafunk.network_info.R;
28 | import com.ultrafunk.network_info.util.Utils;
29 | import com.ultrafunk.network_info.service.NetworkStateService;
30 |
31 | public class MobileDataOnOffReceiver extends WidgetBroadcastReceiver
32 | {
33 | private boolean turningOn;
34 |
35 | @Override
36 | public void onReceive(Context context, Intent intent)
37 | {
38 | // Log.e(this.getClass().getSimpleName(), "onReceive(): " + intent.getAction());
39 |
40 | updateMobileDataViews = true;
41 |
42 | if (Constants.ONCLICK_MOBILE_DATA_ONOFF.equals(intent.getAction()))
43 | turnOnOff(context);
44 | }
45 |
46 | private void turnOnOff(Context context)
47 | {
48 | boolean isMobileDataEnabled = MobileDataUtils.isMobileDataEnabled(context);
49 | boolean isAirplaneModeOn = MobileDataUtils.isAirplaneModeOn(context);
50 | boolean isOutMobileOfService = NetworkStateService.isMobileOutOfService();
51 |
52 | if (isAirplaneModeOn)
53 | {
54 | Toast.makeText(context, context.getString(R.string.error_mobile_data_on_flight_mode), Toast.LENGTH_LONG).show();
55 | }
56 | else
57 | {
58 | boolean isWifiConnected = Utils.isWifiConnected(context);
59 |
60 | if (isMobileDataEnabled)
61 | {
62 | if (!isWifiConnected && !isOutMobileOfService)
63 | {
64 | turningOn = false;
65 | partiallyUpdateWidgets(context);
66 | }
67 |
68 | MobileDataUtils.setMobileDataEnabled(context, false);
69 | }
70 | else
71 | {
72 | if (!isWifiConnected && !isOutMobileOfService)
73 | {
74 | turningOn = true;
75 | partiallyUpdateWidgets(context);
76 | }
77 |
78 | MobileDataUtils.setMobileDataEnabled(context, true);
79 | }
80 | }
81 | }
82 |
83 | @Override
84 | protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions)
85 | {
86 | remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE);
87 | remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
88 | remoteViews.setTextViewText(R.id.mobileInfoTopTextView, turningOn ? context.getString(R.string.turning_on) : context.getString(R.string.turning_off));
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/MobileDataStatusReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.receiver;
18 |
19 | import android.appwidget.AppWidgetManager;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.net.ConnectivityManager;
23 | import android.net.NetworkInfo;
24 | import android.os.Bundle;
25 | import android.support.v4.content.ContextCompat;
26 | import android.telephony.TelephonyManager;
27 | import android.view.View;
28 | import android.widget.RemoteViews;
29 |
30 | import com.ultrafunk.network_info.Constants;
31 | import com.ultrafunk.network_info.R;
32 | import com.ultrafunk.network_info.service.NetworkStateService;
33 |
34 | public class MobileDataStatusReceiver extends WidgetBroadcastReceiver
35 | {
36 | private TelephonyManager telephonyManager = null;
37 | private int dataState = -1;
38 | private boolean isMobileDataEnabled = false;
39 | private boolean isAirplaneModeOn = false;
40 | private boolean isMobileOutOfService = false;
41 | private boolean isDataRoaming = false;
42 | private int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
43 | private String networkOperatorAndServiceProvider = null;
44 | private long dataUsageBytes = 0;
45 |
46 | @Override
47 | public void onReceive(Context context, Intent intent)
48 | {
49 | final String action = intent.getAction();
50 |
51 | // Log.e(this.getClass().getSimpleName(), "onReceive(): " + action);
52 |
53 | updateMobileDataViews = true;
54 |
55 | telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
56 | dataState = telephonyManager.getDataState();
57 | isMobileDataEnabled = MobileDataUtils.isMobileDataEnabled(context);
58 | isAirplaneModeOn = MobileDataUtils.isAirplaneModeOn(context);
59 | isMobileOutOfService = NetworkStateService.isMobileOutOfService();
60 | isDataRoaming = isDataRoaming(context);
61 | networkType = telephonyManager.getNetworkType();
62 | networkOperatorAndServiceProvider = getNetworkOperatorAndServiceProvider(context);
63 | dataUsageBytes = NetworkStateService.setGetDataUsageBytes();
64 |
65 | if (Constants.ACTION_DATA_CONNECTION_CHANGED.equals(action) ||
66 | Constants.ACTION_DATA_STATE_CHANGED.equals(action) ||
67 | Constants.ACTION_SERVICE_STATE_CHANGED.equals(action))
68 | {
69 | // Needed to get around a known bug in Android 5.x: https://code.google.com/p/android/issues/detail?id=78924
70 | if ((dataState == TelephonyManager.DATA_CONNECTED) && (dataUsageBytes == 0) && !NetworkStateService.isWaitingForDataUsage())
71 | {
72 | NetworkStateService.setWaitingForDataUsage(true);
73 | Intent serviceIntent = new Intent(context, NetworkStateService.class);
74 | serviceIntent.setAction(Constants.ACTION_DATA_CONNECTED);
75 | context.startService(serviceIntent);
76 | }
77 |
78 | partiallyUpdateWidgets(context);
79 | }
80 | else if (Constants.ACTION_DATA_USAGE_UPDATE.equals(action) || Intent.ACTION_SCREEN_ON.equals(action))
81 | {
82 | partiallyUpdateWidgets(context);
83 | }
84 | else if (Constants.ACTION_UPDATE_WIDGET.equals(action))
85 | {
86 | partiallyUpdateWidget(context, AppWidgetManager.getInstance(context), intent.getIntExtra(Constants.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID));
87 | }
88 | }
89 |
90 | private boolean isDataRoaming(Context context)
91 | {
92 | if ((dataState == TelephonyManager.DATA_CONNECTED) && telephonyManager.isNetworkRoaming())
93 | {
94 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
95 | NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
96 |
97 | return (networkInfo != null) ? networkInfo.isRoaming() : false;
98 | }
99 | else
100 | {
101 | return telephonyManager.isNetworkRoaming() && MobileDataUtils.isDataRoaming(context);
102 | }
103 | }
104 |
105 | private String getNetworkOperatorAndServiceProvider(Context context)
106 | {
107 | String networkOperatorName = telephonyManager.getNetworkOperatorName();
108 |
109 | if (networkOperatorName.isEmpty())
110 | networkOperatorName = context.getString(R.string.not_available);
111 |
112 | if (isDataRoaming)
113 | {
114 | String simOperatorName = telephonyManager.getSimOperatorName();
115 | String networkOperator = telephonyManager.getNetworkOperator();
116 | String simOperator = telephonyManager.getSimOperator();
117 |
118 | if (!simOperatorName.isEmpty() && !networkOperator.equalsIgnoreCase(simOperator))
119 | return networkOperatorName + " - " + simOperatorName;
120 | }
121 |
122 | return networkOperatorName;
123 | }
124 |
125 | private void setStateColor(Context context, RemoteViews remoteViews, int state)
126 | {
127 | int color = (state == STATE_ON) ? ContextCompat.getColor(context, android.R.color.white) : ContextCompat.getColor(context, R.color.medium_gray);
128 | remoteViews.setTextColor(R.id.mobileNameTextView, color);
129 | remoteViews.setInt(R.id.mobileHeaderSpacerTextView, "setBackgroundColor", color);
130 | remoteViews.setTextColor(R.id.mobileInfoTopTextView, color);
131 | remoteViews.setTextColor(R.id.mobileInfoBottomTextView, color);
132 | }
133 |
134 | @Override
135 | protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions)
136 | {
137 | if (isMobileOutOfService)
138 | {
139 | setStateColor(context, remoteViews, isMobileDataEnabled ? STATE_ON : STATE_OFF);
140 | remoteViews.setTextViewText(R.id.mobileNameTextView, context.getString(R.string.mobile_data));
141 | remoteViews.setImageViewResource(R.id.mobileStateImageView, isMobileDataEnabled ? R.drawable.ic_signal_cellular_disabled : R.drawable.ic_signal_cellular_disabled_off);
142 | remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
143 | remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.no_service));
144 | remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE);
145 | return;
146 | }
147 |
148 | if (dataState == TelephonyManager.DATA_DISCONNECTED)
149 | {
150 | remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
151 | remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.VISIBLE);
152 |
153 | if (isMobileDataEnabled && !isAirplaneModeOn)
154 | {
155 | setStateColor(context, remoteViews, STATE_ON);
156 | remoteViews.setTextViewText(R.id.mobileNameTextView, networkOperatorAndServiceProvider);
157 | remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_enabled);
158 | remoteViews.setTextViewText(R.id.mobileInfoTopTextView, String.format("%s - %s", MobileDataUtils.getNetworkTypeString(networkType, true), context.getString(R.string.not_connected)));
159 | remoteViews.setTextColor(R.id.mobileInfoBottomTextView, ContextCompat.getColor(context, R.color.medium_gray));
160 | remoteViews.setTextViewText(R.id.mobileInfoBottomTextView, MobileDataUtils.getDataUsageString(context, NetworkStateService.getDataUsageBytes()));
161 | }
162 | else
163 | {
164 | setStateColor(context, remoteViews, STATE_OFF);
165 | remoteViews.setTextViewText(R.id.mobileNameTextView, isAirplaneModeOn ? context.getString(R.string.mobile_data) : networkOperatorAndServiceProvider);
166 |
167 | if (isAirplaneModeOn)
168 | {
169 | remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.airplane_mode));
170 | remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE);
171 | remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_disabled_off);
172 | }
173 | else
174 | {
175 | remoteViews.setTextViewText(R.id.mobileInfoTopTextView, MobileDataUtils.getNetworkTypeString(networkType, false) + (isDataRoaming ? " - " + context.getString(R.string.roaming) : ""));
176 | remoteViews.setTextViewText(R.id.mobileInfoBottomTextView, MobileDataUtils.getDataUsageString(context, NetworkStateService.getDataUsageBytes()));
177 | remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_enabled_off);
178 | }
179 | }
180 | }
181 | else
182 | {
183 | setStateColor(context, remoteViews, STATE_ON);
184 | remoteViews.setTextViewText(R.id.mobileNameTextView, networkOperatorAndServiceProvider);
185 | remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_on);
186 | remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
187 | remoteViews.setTextViewText(R.id.mobileInfoTopTextView, MobileDataUtils.getNetworkTypeString(networkType, false) + (isDataRoaming ? " - " + context.getString(R.string.roaming) : ""));
188 | remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.VISIBLE);
189 |
190 | boolean isConnecting = ((dataState == TelephonyManager.DATA_CONNECTING) || NetworkStateService.isWaitingForDataUsage());
191 | remoteViews.setTextViewText(R.id.mobileInfoBottomTextView, isConnecting ? context.getString(R.string.connecting) : MobileDataUtils.getDataUsageString(context, dataUsageBytes));
192 | }
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/MobileDataUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.receiver;
18 |
19 | import android.content.Context;
20 | import android.net.ConnectivityManager;
21 | import android.os.Build;
22 | import android.os.SystemClock;
23 | import android.provider.Settings;
24 | import android.telephony.TelephonyManager;
25 | import android.widget.Toast;
26 |
27 | import com.ultrafunk.network_info.R;
28 |
29 | import java.lang.reflect.Method;
30 | import java.text.DecimalFormat;
31 |
32 | public class MobileDataUtils
33 | {
34 | static boolean isMobileDataEnabled(Context context)
35 | {
36 | try
37 | {
38 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
39 | Method method = connectivityManager.getClass().getDeclaredMethod("getMobileDataEnabled");
40 | return (Boolean) method.invoke(connectivityManager);
41 | }
42 | catch (Exception exception)
43 | {
44 | Toast.makeText(context, "Failed to get Mobile data enabled state!", Toast.LENGTH_LONG).show();
45 | }
46 |
47 | return false;
48 | }
49 |
50 | static void setMobileDataEnabled(Context context, boolean enable)
51 | {
52 | try
53 | {
54 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
55 | Method setMobileDataEnabledMethod = ConnectivityManager.class.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
56 | setMobileDataEnabledMethod.setAccessible(true);
57 | setMobileDataEnabledMethod.invoke(connectivityManager, enable);
58 | }
59 | catch (Exception exception)
60 | {
61 | Toast.makeText(context, "Failed to enable or disable Mobile data!", Toast.LENGTH_LONG).show();
62 | }
63 | }
64 |
65 | static boolean isAirplaneModeOn(Context context)
66 | {
67 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
68 | return Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;
69 | else
70 | return Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
71 | }
72 |
73 | public static boolean isDataRoaming(Context context)
74 | {
75 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
76 | return Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.DATA_ROAMING, 0) == 1;
77 | else
78 | return Settings.Global.getInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 0) == 1;
79 | }
80 |
81 | static String getNetworkTypeString(int networkType, boolean shortString)
82 | {
83 | switch (networkType)
84 | {
85 | case TelephonyManager.NETWORK_TYPE_GPRS: return shortString ? "2G" : "GPRS 2G";
86 | case TelephonyManager.NETWORK_TYPE_EDGE: return shortString ? "2G" : "EDGE 2G";
87 | case TelephonyManager.NETWORK_TYPE_UMTS: return shortString ? "3G" : "UMTS 3G";
88 | case TelephonyManager.NETWORK_TYPE_CDMA: return shortString ? "3G" : "CDMA 3G";
89 | case TelephonyManager.NETWORK_TYPE_EVDO_0: return shortString ? "3G" : "EVDO 0 3G";
90 | case TelephonyManager.NETWORK_TYPE_EVDO_A: return shortString ? "3G" : "EVDO A 3G";
91 | case TelephonyManager.NETWORK_TYPE_EVDO_B: return shortString ? "3G" : "EVDO B 3G";
92 | case TelephonyManager.NETWORK_TYPE_1xRTT: return shortString ? "3G" : "1xRTT 3G";
93 | case TelephonyManager.NETWORK_TYPE_HSDPA: return shortString ? "3G" : "HSDPA 3G";
94 | case TelephonyManager.NETWORK_TYPE_HSUPA: return shortString ? "3G" : "HSUPA 3G";
95 | case TelephonyManager.NETWORK_TYPE_HSPA: return shortString ? "3G" : "HSPA 3G";
96 | case TelephonyManager.NETWORK_TYPE_LTE: return shortString ? "4G" : "LTE 4G";
97 | case TelephonyManager.NETWORK_TYPE_EHRPD: return shortString ? "3/4G" : "eHRPD 3/4G";
98 | case TelephonyManager.NETWORK_TYPE_HSPAP: return shortString ? "3G" : "HSPA+ 3G";
99 | }
100 |
101 | return shortString ? "N/A" : "Unknown";
102 | }
103 |
104 | private static String readableSize(long size)
105 | {
106 | if(size <= 0)
107 | return "0";
108 |
109 | final String[] units = new String[] { "bytes", "KB", "MB", "GB", "TB" };
110 | int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
111 |
112 | return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
113 | }
114 |
115 | static String getDataUsageString(Context context, long dataUsageBytes)
116 | {
117 | if (dataUsageBytes <= 0)
118 | return context.getString(R.string.data_usage_na);
119 |
120 | long elapsedTime = SystemClock.elapsedRealtime();
121 | int hours = (int) (elapsedTime / (1000 * 60 * 60));
122 |
123 | if (hours < 1)
124 | return String.format("~ %s", readableSize(dataUsageBytes));
125 |
126 | // Avoid division by zero
127 | long usagePerHour = dataUsageBytes / hours;
128 |
129 | if (hours < 24)
130 | return String.format("~ %s / %s", readableSize(usagePerHour), context.getString(R.string.hour));
131 |
132 | int days = hours / 24;
133 |
134 | if (days < 7)
135 | return String.format("~ %s / %s", readableSize(usagePerHour * 24), context.getString(R.string.day));
136 |
137 | return String.format("~ %s / %s", readableSize(usagePerHour * 24 * 7), context.getString(R.string.week));
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/WidgetBroadcastReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.receiver;
18 |
19 | import android.appwidget.AppWidgetManager;
20 | import android.content.BroadcastReceiver;
21 | import android.content.ComponentName;
22 | import android.content.Context;
23 | import android.os.Bundle;
24 | import android.widget.RemoteViews;
25 |
26 | import com.ultrafunk.network_info.Constants;
27 | import com.ultrafunk.network_info.WidgetProvider;
28 |
29 | public abstract class WidgetBroadcastReceiver extends BroadcastReceiver
30 | {
31 | protected static final int STATE_OFF = 0;
32 | protected static final int STATE_ON = 1;
33 |
34 | protected boolean updateMobileDataViews = false;
35 | protected boolean updateWifiViews = false;
36 |
37 | protected void partiallyUpdateWidgets(Context context)
38 | {
39 | AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
40 | int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
41 |
42 | for (int appWidgetId : appWidgetIds)
43 | {
44 | partiallyUpdateWidget(context, appWidgetManager, appWidgetId);
45 | }
46 | }
47 |
48 | protected void partiallyUpdateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId)
49 | {
50 | if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID)
51 | {
52 | Bundle widgetOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
53 | int layoutId = widgetOptions.getInt(Constants.PREF_LAYOUT_ID, 0);
54 |
55 | if ((layoutId != 0) && updateThisWidget(widgetOptions))
56 | {
57 | RemoteViews remoteViews = new RemoteViews(context.getPackageName(), layoutId);
58 | updateView(context, remoteViews, widgetOptions);
59 | appWidgetManager.partiallyUpdateAppWidget(appWidgetId, remoteViews);
60 | }
61 | }
62 | }
63 |
64 | private boolean updateThisWidget(Bundle widgetOptions)
65 | {
66 | boolean mobileDataWidget = widgetOptions.getBoolean(Constants.PREF_MOBILE_DATA_WIDGET, false);
67 | boolean wifiWidget = widgetOptions.getBoolean(Constants.PREF_WIFI_WIDGET, false);
68 |
69 | return (updateMobileDataViews == mobileDataWidget) || (updateWifiViews == wifiWidget);
70 | }
71 |
72 | protected abstract void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions);
73 | }
74 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/WifiOnOffReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.receiver;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.net.wifi.WifiManager;
22 | import android.os.Bundle;
23 | import android.view.View;
24 | import android.widget.RemoteViews;
25 |
26 | import com.ultrafunk.network_info.Constants;
27 | import com.ultrafunk.network_info.R;
28 | import com.ultrafunk.network_info.service.NetworkStateService;
29 |
30 | public class WifiOnOffReceiver extends WidgetBroadcastReceiver
31 | {
32 | private boolean turningOn;
33 |
34 | @Override
35 | public void onReceive(Context context, Intent intent)
36 | {
37 | // Log.e(this.getClass().getSimpleName(), "onReceive(): " + intent.getAction());
38 |
39 | updateWifiViews = true;
40 |
41 | if (Constants.ONCLICK_WIFI_ONOFF.equals(intent.getAction()))
42 | turnOnOff(context);
43 | }
44 |
45 | private void turnOnOff(Context context)
46 | {
47 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
48 |
49 | if (wifiManager.isWifiEnabled())
50 | {
51 | turningOn = false;
52 | partiallyUpdateWidgets(context);
53 | wifiManager.setWifiEnabled(false);
54 | }
55 | else
56 | {
57 | turningOn = true;
58 | partiallyUpdateWidgets(context);
59 | wifiManager.setWifiEnabled(true);
60 |
61 | Intent serviceIntent = new Intent(context, NetworkStateService.class);
62 | serviceIntent.setAction(Constants.ACTION_WIFI_CONNECTING);
63 | context.startService(serviceIntent);
64 | }
65 | }
66 |
67 | @Override
68 | protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions)
69 | {
70 | remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.GONE);
71 | remoteViews.setViewVisibility(R.id.wifiInfoTopTextView, View.VISIBLE);
72 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, turningOn ? context.getString(R.string.turning_on) : context.getString(R.string.turning_off));
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/WifiStatusReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.receiver;
18 |
19 | import android.appwidget.AppWidgetManager;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.net.NetworkInfo;
23 | import android.net.wifi.WifiInfo;
24 | import android.net.wifi.WifiManager;
25 | import android.os.Build;
26 | import android.os.Bundle;
27 | import android.support.v4.content.ContextCompat;
28 | import android.view.View;
29 | import android.widget.RemoteViews;
30 |
31 | import com.ultrafunk.network_info.Constants;
32 | import com.ultrafunk.network_info.R;
33 | import com.ultrafunk.network_info.service.NetworkStateService;
34 |
35 | public class WifiStatusReceiver extends WidgetBroadcastReceiver
36 | {
37 | private WifiManager wifiManager = null;
38 | private int wifiState = -1;
39 | private WifiInfo wifiInfo = null;
40 | private String detailsString = "";
41 |
42 | @Override
43 | public void onReceive(Context context, Intent intent)
44 | {
45 | final String action = intent.getAction();
46 |
47 | // Log.e(this.getClass().getSimpleName(), "onReceive(): " + action);
48 |
49 | updateWifiViews = true;
50 |
51 | wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
52 | wifiState = wifiManager.getWifiState();
53 | wifiInfo = wifiManager.getConnectionInfo();
54 |
55 | if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action))
56 | {
57 | if (isConnectionReady(intent))
58 | {
59 | String securityString = WifiUtils.getSecurityString(context, wifiManager, wifiInfo.getBSSID());
60 | NetworkStateService.setWifiSecurityString(securityString);
61 | detailsString = context.getString(R.string.security) + securityString;
62 |
63 | Intent serviceIntent = new Intent(context, NetworkStateService.class);
64 | serviceIntent.setAction(Constants.ACTION_WIFI_CONNECTED);
65 | context.startService(serviceIntent);
66 | }
67 |
68 | partiallyUpdateWidgets(context);
69 | }
70 | else if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action) ||
71 | Constants.ACTION_WIFI_SCANNING.equals(action))
72 | {
73 | partiallyUpdateWidgets(context);
74 | }
75 | else if (Intent.ACTION_SCREEN_ON.equals(action) ||
76 | Constants.ACTION_WIFI_LINK_SPEED.equals(action))
77 | {
78 | if (isConnected())
79 | {
80 | setDetailsString(context);
81 | partiallyUpdateWidgets(context);
82 | }
83 | }
84 | else if (Constants.ACTION_UPDATE_WIDGET.equals(action))
85 | {
86 | if (isConnected())
87 | setDetailsString(context);
88 |
89 | partiallyUpdateWidget(context, AppWidgetManager.getInstance(context), intent.getIntExtra(Constants.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID));
90 | }
91 | }
92 |
93 | private boolean isConnected()
94 | {
95 | return ((wifiState == WifiManager.WIFI_STATE_ENABLED) && (wifiInfo.getIpAddress() != 0));
96 | }
97 |
98 | private boolean isConnectionReady(Intent intent)
99 | {
100 | if (isConnected() && (intent.getExtras() != null))
101 | {
102 | NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
103 |
104 | if ((networkInfo != null) && (networkInfo.getDetailedState() == NetworkInfo.DetailedState.CONNECTED))
105 | return true;
106 | }
107 |
108 | return false;
109 | }
110 |
111 | private void setDetailsString(Context context)
112 | {
113 | String securityString = NetworkStateService.getWifiSecurityString();
114 |
115 | if (securityString == null)
116 | securityString = WifiUtils.getSecurityString(context, wifiManager, wifiInfo.getBSSID());
117 |
118 | if (wifiInfo.getLinkSpeed() != -1)
119 | detailsString = String.format("%s - %d %s", securityString, wifiInfo.getLinkSpeed(), WifiInfo.LINK_SPEED_UNITS);
120 | else
121 | detailsString = context.getString(R.string.security) + securityString;
122 | }
123 |
124 | private void setStateColor(Context context, RemoteViews remoteViews, int state)
125 | {
126 | int color = (state == STATE_ON) ? ContextCompat.getColor(context, android.R.color.white) : ContextCompat.getColor(context, R.color.medium_gray);
127 | remoteViews.setTextColor(R.id.wifiNameTextView, color);
128 | remoteViews.setInt(R.id.wifiHeaderSpacerTextView, "setBackgroundColor", color);
129 | remoteViews.setTextColor(R.id.wifiInfoTopTextView, color);
130 | remoteViews.setTextColor(R.id.wifiInfoBottomTextView, color);
131 | }
132 |
133 | @Override
134 | protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions)
135 | {
136 | if ((wifiState == WifiManager.WIFI_STATE_DISABLED) || (wifiState == WifiManager.WIFI_STATE_UNKNOWN))
137 | {
138 | setStateColor(context, remoteViews, STATE_OFF);
139 | remoteViews.setTextViewText(R.id.wifiNameTextView, context.getString(R.string.wifi));
140 | remoteViews.setImageViewResource(R.id.wifiStateImageView, R.drawable.ic_signal_wifi_off);
141 | remoteViews.setViewVisibility(R.id.wifiInfoTopTextView, View.VISIBLE);
142 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.tap_to_change));
143 | remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.GONE);
144 | }
145 | else if (wifiState == WifiManager.WIFI_STATE_ENABLED)
146 | {
147 | setStateColor(context, remoteViews, STATE_ON);
148 | remoteViews.setViewVisibility(R.id.wifiInfoTopTextView, View.VISIBLE);
149 |
150 | if (wifiInfo.getIpAddress() != 0)
151 | {
152 | remoteViews.setImageViewResource(R.id.wifiStateImageView, R.drawable.ic_signal_wifi_on);
153 | remoteViews.setTextViewText(R.id.wifiNameTextView, wifiInfo.getSSID().replace("\"", ""));
154 |
155 | if(!detailsString.isEmpty())
156 | {
157 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, detailsString);
158 | remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.VISIBLE);
159 |
160 | String bottomText = "";
161 |
162 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
163 | bottomText = String.format("%s - %s", WifiUtils.getIpAddressString(wifiInfo.getIpAddress()), WifiUtils.getWifiFrequencyString(context, wifiInfo.getFrequency()));
164 | else
165 | bottomText = String.format("IP: %s", WifiUtils.getIpAddressString(wifiInfo.getIpAddress()));
166 |
167 | remoteViews.setTextViewText(R.id.wifiInfoBottomTextView, bottomText);
168 | }
169 | }
170 | else
171 | {
172 | remoteViews.setImageViewResource(R.id.wifiStateImageView, R.drawable.ic_signal_wifi_enabled);
173 | remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.GONE);
174 |
175 | switch (wifiInfo.getSupplicantState())
176 | {
177 | case DORMANT:
178 | case INTERFACE_DISABLED:
179 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.disconnecting));
180 | break;
181 |
182 | case SCANNING:
183 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.scanning));
184 | break;
185 |
186 | case DISCONNECTED:
187 | case INVALID:
188 | case UNINITIALIZED:
189 | case INACTIVE:
190 | remoteViews.setTextViewText(R.id.wifiNameTextView, context.getString(R.string.wifi));
191 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.no_network));
192 | break;
193 |
194 | default:
195 | remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.connecting));
196 | break;
197 | }
198 | }
199 | }
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/receiver/WifiUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010 The Android Open Source Project
3 | * Copyright 2014 ultrafunk.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.ultrafunk.network_info.receiver;
19 |
20 | import android.content.Context;
21 | import android.net.wifi.ScanResult;
22 | import android.net.wifi.WifiManager;
23 |
24 | import com.ultrafunk.network_info.R;
25 |
26 | class WifiUtils
27 | {
28 | static String getIpAddressString(int ipAddress)
29 | {
30 | return String.format("%d.%d.%d.%d", (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff));
31 | }
32 |
33 | // START: android-5.1.1_r33
34 | // https://android.googlesource.com/platform/packages/apps/Settings/+/android-5.1.1_r33/src/com/android/settings/wifi/AccessPoint.java
35 |
36 | // Lower bound on the 2.4 GHz (802.11b/g/n) WLAN channels
37 | private static final int LOWER_FREQ_24GHZ = 2400;
38 | // Upper bound on the 2.4 GHz (802.11b/g/n) WLAN channels
39 | private static final int HIGHER_FREQ_24GHZ = 2500;
40 | // Lower bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
41 | private static final int LOWER_FREQ_5GHZ = 4900;
42 | // Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
43 | private static final int HIGHER_FREQ_5GHZ = 5900;
44 |
45 | // END: android-5.1.1_r33
46 |
47 | static String getWifiFrequencyString(Context context, int frequency)
48 | {
49 | if (frequency >= LOWER_FREQ_24GHZ && frequency < HIGHER_FREQ_24GHZ)
50 | return context.getString(R.string.wifi_band_24ghz);
51 | else if (frequency >= LOWER_FREQ_5GHZ && frequency < HIGHER_FREQ_5GHZ)
52 | return context.getString(R.string.wifi_band_5ghz);
53 |
54 | return context.getString(R.string.not_available);
55 | }
56 |
57 | static String getSecurityString(Context context, WifiManager wifiManager, String connectedBSSID)
58 | {
59 | ScanResult connectedScanResult = null;
60 |
61 | for (ScanResult scanResult : wifiManager.getScanResults())
62 | {
63 | if (scanResult.BSSID.equals(connectedBSSID))
64 | {
65 | connectedScanResult = scanResult;
66 | break;
67 | }
68 | }
69 |
70 | if (connectedScanResult != null)
71 | return getSecurityString(context, connectedScanResult);
72 | else
73 | return context.getString(R.string.not_available);
74 | }
75 |
76 | // START: android-4.4.4_r2.0.1
77 | // https://android.googlesource.com/platform/packages/apps/Settings/+/android-4.4.4_r2.0.1/src/com/android/settings/wifi/AccessPoint.java
78 |
79 | private static final int SECURITY_NONE = 0;
80 | private static final int SECURITY_WEP = 1;
81 | private static final int SECURITY_PSK = 2;
82 | private static final int SECURITY_EAP = 3;
83 |
84 | private enum PskType
85 | {
86 | UNKNOWN,
87 | WPA,
88 | WPA2,
89 | WPA_WPA2
90 | }
91 |
92 | private static String getSecurityString(Context context, ScanResult scanResult) {
93 |
94 | int security = getSecurity(scanResult);
95 | PskType pskType = getPskType(scanResult);
96 |
97 | switch(security) {
98 | case SECURITY_EAP:
99 | return context.getString(R.string.wifi_security_eap);
100 | case SECURITY_PSK:
101 | switch (pskType) {
102 | case WPA:
103 | return context.getString(R.string.wifi_security_wpa);
104 | case WPA2:
105 | return context.getString(R.string.wifi_security_wpa2);
106 | case WPA_WPA2:
107 | return context.getString(R.string.wifi_security_wpa_wpa2);
108 | case UNKNOWN:
109 | default:
110 | return context.getString(R.string.wifi_security_psk_generic);
111 | }
112 | case SECURITY_WEP:
113 | return context.getString(R.string.wifi_security_wep);
114 | case SECURITY_NONE:
115 | default:
116 | return context.getString(R.string.wifi_security_none);
117 | }
118 | }
119 |
120 | private static int getSecurity(ScanResult result) {
121 | if (result.capabilities.contains("WEP")) {
122 | return SECURITY_WEP;
123 | } else if (result.capabilities.contains("PSK")) {
124 | return SECURITY_PSK;
125 | } else if (result.capabilities.contains("EAP")) {
126 | return SECURITY_EAP;
127 | }
128 | return SECURITY_NONE;
129 | }
130 |
131 | private static PskType getPskType(ScanResult result) {
132 | boolean wpa = result.capabilities.contains("WPA-PSK");
133 | boolean wpa2 = result.capabilities.contains("WPA2-PSK");
134 | if (wpa2 && wpa) {
135 | return PskType.WPA_WPA2;
136 | } else if (wpa2) {
137 | return PskType.WPA2;
138 | } else if (wpa) {
139 | return PskType.WPA;
140 | } else {
141 | return PskType.UNKNOWN;
142 | }
143 | }
144 |
145 | // END: android-4.4.4_r2.0.1
146 | }
147 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/service/MobileDataSettingObserver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.service;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.database.ContentObserver;
22 | import android.net.Uri;
23 | import android.support.v4.content.LocalBroadcastManager;
24 | import android.telephony.TelephonyManager;
25 |
26 | import com.ultrafunk.network_info.Constants;
27 | import com.ultrafunk.network_info.receiver.MobileDataUtils;
28 | import com.ultrafunk.network_info.util.Utils;
29 |
30 | class MobileDataSettingObserver extends ContentObserver
31 | {
32 | private final Context context;
33 |
34 | MobileDataSettingObserver(Context context)
35 | {
36 | super(null);
37 | this.context = context;
38 | }
39 |
40 | @Override
41 | public void onChange(boolean selfChange)
42 | {
43 | onChange(selfChange, null);
44 | }
45 |
46 | @Override
47 | public void onChange(boolean selfChange, Uri uri)
48 | {
49 | if (Utils.isWifiConnected(context) || NetworkStateService.isMobileOutOfService() || isMobileDataDisconnectedDueToRoaming())
50 | LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_DATA_STATE_CHANGED));
51 | }
52 |
53 | // https://android.googlesource.com/platform/packages/apps/Phone/+/ics-mr0/src/com/android/phone/PhoneApp.java
54 | // Line: 1450 - boolean disconnectedDueToRoaming =
55 | private boolean isMobileDataDisconnectedDueToRoaming()
56 | {
57 | TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
58 | return (MobileDataUtils.isDataRoaming(context) == false) && telephonyManager.isNetworkRoaming();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/service/MobileDataStateListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.service;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.support.v4.content.LocalBroadcastManager;
22 | import android.telephony.PhoneStateListener;
23 | import android.telephony.ServiceState;
24 | import android.telephony.TelephonyManager;
25 |
26 | import com.ultrafunk.network_info.Constants;
27 |
28 | class MobileDataStateListener extends PhoneStateListener
29 | {
30 | private final Context context;
31 |
32 | MobileDataStateListener(Context context)
33 | {
34 | this.context = context;
35 | }
36 |
37 | @Override
38 | public void onDataConnectionStateChanged(int state)
39 | {
40 | switch (state)
41 | {
42 | case TelephonyManager.DATA_CONNECTED:
43 | case TelephonyManager.DATA_DISCONNECTED:
44 | LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_DATA_CONNECTION_CHANGED));
45 | break;
46 | }
47 | }
48 |
49 | @Override
50 | public void onServiceStateChanged(ServiceState serviceState)
51 | {
52 | switch (serviceState.getState())
53 | {
54 | case ServiceState.STATE_EMERGENCY_ONLY:
55 | case ServiceState.STATE_OUT_OF_SERVICE:
56 | NetworkStateService.setMobileOutOfService(true);
57 | LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_SERVICE_STATE_CHANGED));
58 | break;
59 |
60 | default:
61 | {
62 | NetworkStateService.setMobileOutOfService(false);
63 |
64 | // If the device is network roaming but mobile data roaming is disabled, this
65 | // broadcast is necessary to properly update the widget on service state changes.
66 | if ((serviceState.getState() == ServiceState.STATE_IN_SERVICE) && serviceState.getRoaming())
67 | LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_SERVICE_STATE_CHANGED));
68 | }
69 | break;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/service/NetworkStateService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.service;
18 |
19 | import android.app.Service;
20 | import android.appwidget.AppWidgetManager;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.content.IntentFilter;
24 | import android.database.ContentObserver;
25 | import android.net.TrafficStats;
26 | import android.net.Uri;
27 | import android.net.wifi.SupplicantState;
28 | import android.net.wifi.WifiInfo;
29 | import android.net.wifi.WifiManager;
30 | import android.os.Build;
31 | import android.os.Handler;
32 | import android.os.IBinder;
33 | import android.provider.Settings;
34 | import android.support.v4.content.LocalBroadcastManager;
35 | import android.telephony.PhoneStateListener;
36 | import android.telephony.TelephonyManager;
37 |
38 | import com.ultrafunk.network_info.Constants;
39 | import com.ultrafunk.network_info.util.EnabledWidgets;
40 | import com.ultrafunk.network_info.util.Utils;
41 | import com.ultrafunk.network_info.receiver.MobileDataStatusReceiver;
42 | import com.ultrafunk.network_info.receiver.WifiStatusReceiver;
43 |
44 | public class NetworkStateService extends Service
45 | {
46 | private LocalBroadcastManager localBroadcastManager;
47 | private TelephonyManager telephonyManager;
48 | private WifiManager wifiManager;
49 |
50 | private MobileDataStatusReceiver mobileDataStatusReceiver;
51 | private MobileDataStateListener mobileDataStateListener;
52 | private ContentObserver mobileDataSettingObserver;
53 | private Uri mobileDataSettingUri;
54 |
55 | private WifiStatusReceiver wifiStatusReceiver;
56 |
57 | private static boolean isMobileOutOfService = false;
58 | private static String wifiSecurityString = null;
59 | private static long dataUsageBytes = 0;
60 | private static boolean isWaitingForDataUsage = false;
61 |
62 | @Override
63 | public void onCreate()
64 | {
65 | super.onCreate();
66 |
67 | // Log.e(this.getClass().getSimpleName(), "onCreate()");
68 |
69 | localBroadcastManager = LocalBroadcastManager.getInstance(this);
70 | telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
71 | wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
72 |
73 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
74 | mobileDataSettingUri = Uri.withAppendedPath(Settings.System.CONTENT_URI, "mobile_data");
75 | else
76 | mobileDataSettingUri = Uri.withAppendedPath(Settings.Global.CONTENT_URI, "mobile_data");
77 |
78 | initEnabledWidgets(Utils.getEnabledWidgets(this, AppWidgetManager.getInstance(this)));
79 | }
80 |
81 | @Override
82 | public int onStartCommand(Intent intent, int flags, int startId)
83 | {
84 | if ((intent != null) && (intent.getAction() != null))
85 | {
86 | final String action = intent.getAction();
87 |
88 | // Log.e(this.getClass().getSimpleName(), "onStartCommand(): " + action);
89 |
90 | if (Constants.ACTION_UPDATE_SERVICE_STATE.equals(action))
91 | {
92 | initEnabledWidgets(new EnabledWidgets(intent.getBooleanExtra(Constants.EXTRA_ENABLED_WIDGETS_MOBILE_DATA, false),
93 | intent.getBooleanExtra(Constants.EXTRA_ENABLED_WIDGETS_WIFI, false)));
94 | }
95 | else
96 | {
97 | final Handler handler = new Handler();
98 |
99 | if (Constants.ACTION_WIFI_CONNECTING.equals(action))
100 | {
101 | handler.postDelayed(new Runnable()
102 | {
103 | public void run()
104 | {
105 | WifiInfo wifiInfo = wifiManager.getConnectionInfo();
106 |
107 | if ((wifiInfo != null) && (wifiInfo.getSupplicantState() == SupplicantState.SCANNING))
108 | localBroadcastManager.sendBroadcastSync(new Intent(Constants.ACTION_WIFI_SCANNING));
109 | }
110 | }, 5 * 1000);
111 | }
112 | else if (Constants.ACTION_WIFI_CONNECTED.equals(action))
113 | {
114 | handler.postDelayed(new Runnable()
115 | {
116 | public void run()
117 | {
118 | WifiInfo wifiInfo = wifiManager.getConnectionInfo();
119 |
120 | if ((wifiInfo != null) && (wifiInfo.getLinkSpeed() != -1))
121 | localBroadcastManager.sendBroadcastSync(new Intent(Constants.ACTION_WIFI_LINK_SPEED));
122 | }
123 | }, 3 * 1000);
124 | }
125 | else if (Constants.ACTION_DATA_CONNECTED.equals(action))
126 | {
127 | handler.postDelayed(new Runnable()
128 | {
129 | public void run()
130 | {
131 | isWaitingForDataUsage = false;
132 |
133 | if (telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED)
134 | localBroadcastManager.sendBroadcastSync(new Intent(Constants.ACTION_DATA_USAGE_UPDATE));
135 | }
136 | }, 500);
137 | }
138 | }
139 | }
140 |
141 | return Service.START_STICKY;
142 | }
143 |
144 | @Override
145 | public void onDestroy()
146 | {
147 | super.onDestroy();
148 |
149 | // Log.e(this.getClass().getSimpleName(), "onDestroy()");
150 |
151 | mobileDataDestroy();
152 | wifiDestroy();
153 | }
154 |
155 | @Override
156 | public IBinder onBind(Intent intent)
157 | {
158 | return null;
159 | }
160 |
161 | public static boolean isMobileOutOfService() { return isMobileOutOfService; }
162 | public static void setMobileOutOfService(boolean isOutOfService) { NetworkStateService.isMobileOutOfService = isOutOfService; }
163 |
164 | public static String getWifiSecurityString() { return wifiSecurityString; }
165 | public static void setWifiSecurityString(String wifiSecurityString) { NetworkStateService.wifiSecurityString = wifiSecurityString; }
166 |
167 | public static long getDataUsageBytes() { return dataUsageBytes; }
168 | public static long setGetDataUsageBytes()
169 | {
170 | long dataUsageBytes = TrafficStats.getMobileRxBytes() + TrafficStats.getMobileTxBytes();
171 |
172 | if (dataUsageBytes > 0 )
173 | NetworkStateService.dataUsageBytes = dataUsageBytes;
174 |
175 | return dataUsageBytes;
176 | }
177 |
178 | public static boolean isWaitingForDataUsage() { return isWaitingForDataUsage; }
179 | public static void setWaitingForDataUsage(boolean isWaitingForDataUsage) { NetworkStateService.isWaitingForDataUsage = isWaitingForDataUsage; }
180 |
181 | private void initEnabledWidgets(EnabledWidgets enabledWidgets)
182 | {
183 | mobileDataDestroy();
184 | wifiDestroy();
185 |
186 | if (enabledWidgets.mobileData)
187 | mobileDataInit();
188 |
189 | if (enabledWidgets.wifi)
190 | wifiInit();
191 | }
192 |
193 | private void mobileDataInit()
194 | {
195 | mobileDataStatusReceiver = new MobileDataStatusReceiver();
196 | mobileDataStateListener = new MobileDataStateListener(this);
197 | mobileDataSettingObserver = new MobileDataSettingObserver(this);
198 |
199 | IntentFilter intentFilter = new IntentFilter();
200 | intentFilter.addAction(Constants.ACTION_SERVICE_STATE_CHANGED);
201 | intentFilter.addAction(Constants.ACTION_DATA_CONNECTION_CHANGED);
202 | intentFilter.addAction(Constants.ACTION_DATA_STATE_CHANGED);
203 | intentFilter.addAction(Constants.ACTION_DATA_USAGE_UPDATE);
204 | localBroadcastManager.registerReceiver(mobileDataStatusReceiver, intentFilter);
205 |
206 | registerReceiver(mobileDataStatusReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
207 |
208 | telephonyManager.listen(mobileDataStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE);
209 | getContentResolver().registerContentObserver(mobileDataSettingUri, false, mobileDataSettingObserver);
210 | }
211 |
212 | private void mobileDataDestroy()
213 | {
214 | if (mobileDataStatusReceiver != null)
215 | {
216 | telephonyManager.listen(mobileDataStateListener, PhoneStateListener.LISTEN_NONE);
217 | mobileDataStateListener = null;
218 |
219 | getContentResolver().unregisterContentObserver(mobileDataSettingObserver);
220 | mobileDataSettingObserver = null;
221 |
222 | localBroadcastManager.unregisterReceiver(mobileDataStatusReceiver);
223 | unregisterReceiver(mobileDataStatusReceiver);
224 | mobileDataStatusReceiver = null;
225 | }
226 | }
227 |
228 | private void wifiInit()
229 | {
230 | wifiStatusReceiver = new WifiStatusReceiver();
231 |
232 | IntentFilter intentFilter = new IntentFilter();
233 | intentFilter.addAction(Constants.ACTION_WIFI_SCANNING);
234 | intentFilter.addAction(Constants.ACTION_WIFI_LINK_SPEED);
235 | localBroadcastManager.registerReceiver(wifiStatusReceiver, intentFilter);
236 |
237 | registerReceiver(wifiStatusReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
238 | }
239 |
240 | private void wifiDestroy()
241 | {
242 | if (wifiStatusReceiver != null)
243 | {
244 | localBroadcastManager.unregisterReceiver(wifiStatusReceiver);
245 | unregisterReceiver(wifiStatusReceiver);
246 | wifiStatusReceiver = null;
247 | }
248 | }
249 | }
250 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/util/EnabledWidgets.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.util;
18 |
19 | public class EnabledWidgets
20 | {
21 | public boolean mobileData;
22 | public boolean wifi;
23 |
24 | public EnabledWidgets(boolean mobileDataWidgets, boolean wifiWidgets)
25 | {
26 | mobileData = mobileDataWidgets;
27 | wifi = wifiWidgets;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/java/com/ultrafunk/network_info/util/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ultrafunk.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ultrafunk.network_info.util;
18 |
19 | import android.appwidget.AppWidgetManager;
20 | import android.content.ComponentName;
21 | import android.content.Context;
22 | import android.net.wifi.WifiInfo;
23 | import android.net.wifi.WifiManager;
24 | import android.os.Bundle;
25 |
26 | import com.ultrafunk.network_info.Constants;
27 | import com.ultrafunk.network_info.WidgetProvider;
28 |
29 | public class Utils
30 | {
31 | public static boolean isWifiConnected(Context context)
32 | {
33 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
34 |
35 | if (wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED)
36 | {
37 | WifiInfo wifiInfo = wifiManager.getConnectionInfo();
38 |
39 | if (wifiInfo.getIpAddress() != 0)
40 | return true;
41 | }
42 |
43 | return false;
44 | }
45 |
46 | public static EnabledWidgets getEnabledWidgets(Context context, AppWidgetManager appWidgetManager)
47 | {
48 | int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
49 | boolean mobileDataWidgets = false, wifiWidgets = false;
50 |
51 | if (appWidgetIds != null)
52 | {
53 | for (int appWidgetId : appWidgetIds)
54 | {
55 | Bundle widgetOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
56 |
57 | if (widgetOptions.getBoolean(Constants.PREF_MOBILE_DATA_WIDGET, false))
58 | mobileDataWidgets = true;
59 |
60 | if (widgetOptions.getBoolean(Constants.PREF_WIFI_WIDGET, false))
61 | wifiWidgets = true;
62 | }
63 | }
64 |
65 | return new EnabledWidgets(mobileDataWidgets, wifiWidgets);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/btn_radio_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/btn_radio_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/btn_radio_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/btn_radio_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_disabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_disabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_disabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_enabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_enabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_cellular_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_wifi_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_wifi_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_wifi_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_wifi_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_wifi_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_signal_wifi_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-hdpi/ic_widget_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-hdpi/ic_widget_preview.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/btn_radio_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/btn_radio_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/btn_radio_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/btn_radio_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_disabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_disabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_disabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_enabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_enabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_cellular_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_wifi_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_wifi_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_wifi_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_wifi_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_wifi_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_signal_wifi_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_widget_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xhdpi/ic_widget_preview.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/btn_radio_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/btn_radio_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/btn_radio_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/btn_radio_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_disabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_disabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_disabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_enabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_enabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_cellular_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_wifi_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_wifi_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_wifi_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_wifi_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_wifi_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_signal_wifi_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_widget_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxhdpi/ic_widget_preview.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/btn_radio_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/btn_radio_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/btn_radio_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/btn_radio_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_disabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_disabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_disabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_enabled_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_enabled_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_cellular_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_wifi_enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_wifi_enabled.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_wifi_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_wifi_off.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_wifi_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_signal_wifi_on.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_widget_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/NetInfo_Widget/src/main/res/drawable-xxxhdpi/ic_widget_preview.png
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/drawable/btn_radio_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/activity_config.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
13 |
18 |
19 |
27 |
28 |
37 |
38 |
42 |
43 |
47 |
48 |
62 |
63 |
67 |
68 |
82 |
83 |
87 |
88 |
102 |
103 |
104 |
105 |
106 |
107 |
113 |
114 |
118 |
119 |
128 |
129 |
140 |
141 |
149 |
150 |
151 |
152 |
153 |
154 |
160 |
161 |
165 |
166 |
183 |
184 |
185 |
186 |
192 |
193 |
197 |
198 |
214 |
215 |
226 |
227 |
239 |
240 |
250 |
251 |
259 |
260 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
282 |
283 |
289 |
290 |
298 |
299 |
309 |
310 |
320 |
321 |
322 |
323 |
324 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/widget_homescreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/widget_homescreen_mobile.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
34 |
35 |
42 |
43 |
44 |
45 |
53 |
54 |
66 |
67 |
75 |
76 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/widget_homescreen_wifi.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
34 |
35 |
42 |
43 |
44 |
45 |
53 |
54 |
66 |
67 |
75 |
76 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/widget_keyguard.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
12 |
13 |
17 |
18 |
21 |
22 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/widget_keyguard_mobile.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
39 |
40 |
47 |
48 |
49 |
50 |
58 |
59 |
69 |
70 |
78 |
79 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/layout/widget_keyguard_wifi.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
39 |
40 |
47 |
48 |
49 |
50 |
58 |
59 |
69 |
70 |
78 |
79 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values-ja/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | NetInfo Widget
5 | NetInfo
6 |
7 |
8 | モバイル通信
9 | Wi-Fi
10 |
11 | タップして変更
12 | オンにしています…
13 | オフにしています…
14 |
15 | N/A
16 | サービスなし
17 | 未接続
18 | 機内モード
19 | 機内モードがオンの間、モバイル通信をオンにできません。
20 | ローミング
21 | 時間
22 | 日
23 | 週
24 | データ使用 n/a
25 |
26 | "セキュリティ: "
27 | ネットワークなし
28 | 接続中…
29 | 切断中…
30 | スキャン中…
31 |
32 |
33 | ロック画面の設定
34 | ホーム画面の設定
35 |
36 | モバイル通信 (2 x 1)
37 | Wi-Fi (2 x 1)
38 | モバイル通信 & Wi-Fi (2 x 2)
39 |
40 | モバイル通信の設定ショートカット
41 | モバイルネットワーク設定
42 | データ使用
43 | テザリング & ポータブルホットスポット
44 |
45 | 中央で垂直に
46 | 背景の透明度
47 |
48 |
52 |
53 |
56 |
57 |
61 |
62 |
63 | 開く
64 |
65 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values-w600dp-port/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 64dp
4 | 32dp
5 |
6 | 24sp
7 |
8 |
9 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 192dp
4 | 32dp
5 |
6 | 24sp
7 |
8 |
9 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #7f7f7f
4 | #dddddd
5 | #0f4caf
6 |
7 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
7 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | NetInfo Widget
5 | NetInfo
6 |
7 |
8 | Mobile data
9 | Wi-Fi
10 |
11 | tap to change
12 | turning on…
13 | turning off…
14 |
15 | N/A
16 | no service
17 | not connected
18 | airplane mode
19 | Unable to turn Mobile data on while Flight mode is enabled.
20 | roaming
21 | hour
22 | day
23 | week
24 | data usage n/a
25 |
26 | "Security: "
27 | no network
28 | connecting…
29 | disconnecting…
30 | scanning…
31 |
32 |
33 | Lock Screen Configuration
34 | Home Screen Configuration
35 |
36 | Mobile data (2 x 1)
37 | Wi-Fi (2 x 1)
38 | Mobile data & Wi-Fi (2 x 2)
39 |
40 | Mobile data settings shortcut
41 | Mobile network settings
42 | Data usage
43 | Tethering & portable hotspot
44 |
45 | Center vertically
46 | Background transparency
47 | 0
48 | 50
49 | 100
50 |
51 |
55 |
56 |
57 | 2.4 GHz
58 |
59 | 5 GHz
60 |
61 |
64 |
65 |
69 |
70 |
71 | open
72 |
73 | WEP
74 |
75 | WPA PSK
76 |
77 | WPA2 PSK
78 |
79 | WPA/WPA2 PSK
80 |
81 | @string/wifi_security_wpa_wpa2
82 |
83 | 802.1x EAP
84 |
85 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
22 |
23 |
26 |
27 |
--------------------------------------------------------------------------------
/NetInfo_Widget/src/main/res/xml/widget_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | NetInfo
2 | =======
3 |
4 | NetInfo Widget for Android - This app / project has been discontinued by [Ultrafunk](https://old.ultrafunk.com)
5 |
6 | The last version of the NetInfo widget APK can still be downloaded (and installed) from [F-Droid](https://f-droid.org/en/packages/com.ultrafunk.network_info/)
7 |
8 | 
9 |
10 | 
11 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | org.gradle.jvmargs=-Xmx4096m
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ultrafunk/NetInfo/de46d99843dda1bde098a649cf2155608cfa7cbe/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Aug 22 19:39:22 CEST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':NetInfo_Widget'
2 |
--------------------------------------------------------------------------------