Skip to content

Commit 6f39d74

Browse files
author
David Gräff
committed
refactor donate. refactor alarms. debug app has own application id now. remove gdrive+neighbour sync. refactor storage.
1 parent 2857db3 commit 6f39d74

File tree

216 files changed

+8183
-3796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+8183
-3796
lines changed

.idea/dictionaries/david.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 1648 additions & 646 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/app.iml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
99
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
1010
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
11+
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
1112
<option name="ALLOW_USER_CONFIGURATION" value="false" />
1213
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
1314
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -81,14 +82,13 @@
8182
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
8283
<orderEntry type="sourceFolder" forTests="false" />
8384
<orderEntry type="library" exported="" name="support-v13-20.0.0" level="project" />
84-
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12-beta-1" level="project" />
85-
<orderEntry type="library" exported="" name="library-0.9" level="project" />
8685
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
8786
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
88-
<orderEntry type="library" exported="" name="play-services-5.0.89" level="project" />
8987
<orderEntry type="library" exported="" name="acra-4.5.0" level="project" />
9088
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
9189
<orderEntry type="library" exported="" name="library-1.5.1" level="project" />
90+
<orderEntry type="library" exported="" scope="TEST" name="junit-4.11" level="project" />
91+
<orderEntry type="module" module-name="Donations" exported="" />
9292
</component>
9393
</module>
9494

app/build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ android {
1111
// }
1212
// }
1313

14+
def appID = "oly.netpowerctrl"
15+
1416
defaultConfig {
1517
minSdkVersion 14
1618
targetSdkVersion 20
1719
versionCode 83
1820
versionName "5.7.2"
19-
applicationId "oly.netpowerctrl"
21+
applicationId appID
2022
testApplicationId "oly.netpowerctrl.tests"
2123
}
2224

@@ -33,10 +35,15 @@ android {
3335
release {
3436
zipAlign true
3537
runProguard true
38+
resValue "string", "authority", appID + ".utils.AssetDocumentProvider"
39+
//buildConfigField "String", "AUTHORITY", appID + ".utils.AssetDocumentProvider"
3640
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
3741
debuggable false
3842
}
3943
debug {
44+
applicationIdSuffix ".debug"
45+
resValue "string", "authority", appID + ".utils.AssetDocumentProvider.Debug"
46+
//buildConfigField "String", "AUTHORITY", appID + ".utils.AssetDocumentProvider.Debug"
4047
zipAlign true
4148
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
4249
runProguard false
@@ -46,11 +53,11 @@ android {
4653
}
4754

4855
dependencies {
49-
//compile fileTree(dir: 'libs', include: ['*.jar']) :5.2.08
50-
compile 'com.google.android.gms:play-services:5.0.89'
56+
compile project(':libraries:Donations')
57+
//compile fileTree(dir: 'libs', include: ['*.jar']) :5.2.08 5.0.89
58+
//compile 'com.google.android.gms:play-services:5.2.08'
5159
compile 'com.github.gabrielemariotti.changeloglib:library:1.5.1'
5260
compile 'ch.acra:acra:4.5.0'
5361
compile 'com.android.support:support-v13:20.0.0'
54-
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9'
55-
androidTestCompile 'junit:junit:4.+'
62+
androidTestCompile 'junit:junit:4.11'
5663
}

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<uses-permission android:name="android.permission.NFC" />
1414
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1515
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
16+
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
1617
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1718
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
1819
<uses-permission android:name="com.android.vending.BILLING" />
@@ -25,7 +26,7 @@
2526
<uses-sdk tools:node="replace" />
2627

2728
<application
28-
android:name=".application_state.NetpowerctrlApplication"
29+
android:name=".main.App"
2930
android:allowBackup="true"
3031
android:icon="@drawable/netpowerctrl"
3132
android:label="@string/app_name"
@@ -34,7 +35,7 @@
3435
<!--android:permission="android.permission.MANAGE_DOCUMENTS"-->
3536
<provider
3637
android:name=".utils.AssetDocumentProvider"
37-
android:authorities="oly.netpowerctrl.utils.AssetDocumentProvider"
38+
android:authorities="@string/authority"
3839
android:enabled="@bool/atLeastKitKat"
3940
android:exported="true"
4041
android:grantUriPermissions="true"
@@ -49,9 +50,9 @@
4950
</intent-filter>
5051
</provider>
5152

52-
<meta-data
53-
android:name="com.google.android.gms.version"
54-
android:value="@integer/google_play_services_version" />
53+
<!--<meta-data-->
54+
<!--android:name="com.google.android.gms.version"-->
55+
<!--android:value="@integer/google_play_services_version" />-->
5556

5657
<activity
5758
android:name=".main.MainActivity"
@@ -131,12 +132,10 @@
131132
</receiver>
132133

133134
<service
134-
android:name=".application_state.NetpowerctrlService"
135+
android:name=".listen_service.ListenService"
135136
android:permission="android.permission.INTERNET" />
136137

137138
<service android:name="oly.netpowerctrl.widget.WidgetUpdateService" />
138-
139-
<service android:name=".backup.neighbours.NeighbourDataReceiveService" />
140139
</application>
141140

142141

app/src/main/java/oly/netpowerctrl/anel/AnelBroadcastSendJob.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
import java.util.Set;
1414

1515
import oly.netpowerctrl.R;
16-
import oly.netpowerctrl.application_state.NetpowerctrlApplication;
17-
import oly.netpowerctrl.application_state.NetpowerctrlService;
18-
import oly.netpowerctrl.application_state.PluginInterface;
19-
import oly.netpowerctrl.application_state.RuntimeDataController;
16+
import oly.netpowerctrl.data.AppData;
2017
import oly.netpowerctrl.devices.Device;
2118
import oly.netpowerctrl.devices.DeviceConnection;
19+
import oly.netpowerctrl.listen_service.ListenService;
20+
import oly.netpowerctrl.listen_service.PluginInterface;
21+
import oly.netpowerctrl.main.App;
2222
import oly.netpowerctrl.network.UDPSending;
2323

2424
/**
@@ -44,11 +44,11 @@ private void sendPacket(Context context, UDPSending udpSending, InetAddress ip,
4444

4545
@Override
4646
public void process(UDPSending UDPSending) {
47-
Context context = NetpowerctrlService.getService();
47+
Context context = ListenService.getService();
4848
if (context == null)
4949
return;
5050

51-
Set<Integer> ports = RuntimeDataController.getDataController().getAllSendPorts();
51+
Set<Integer> ports = AppData.getInstance().getAllSendPorts();
5252
boolean foundBroadcastAddresses = false;
5353

5454
Enumeration list;
@@ -85,12 +85,12 @@ public void process(UDPSending UDPSending) {
8585

8686
// Query all existing anel devices directly
8787

88-
List<Device> devices = RuntimeDataController.getDataController().deviceCollection.devices;
88+
List<Device> devices = AppData.getInstance().deviceCollection.getItems();
8989
for (Device device : devices) {
9090
if (device.pluginID.equals(AnelPlugin.PLUGIN_ID)) {
9191
PluginInterface i = device.getPluginInterface();
9292
if (i == null) {
93-
device.setNotReachableAll(NetpowerctrlApplication.getAppString(R.string.error_plugin_not_installed));
93+
device.setNotReachableAll(App.getAppString(R.string.error_plugin_not_installed));
9494
continue;
9595
}
9696
for (DeviceConnection ci : device.DeviceConnections) {

app/src/main/java/oly/netpowerctrl/anel/AnelCreateDevice.java

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55

66
import java.util.List;
77

8-
import oly.netpowerctrl.application_state.PluginInterface;
8+
import oly.netpowerctrl.data.ObserverUpdateActions;
9+
import oly.netpowerctrl.data.onCollectionUpdated;
910
import oly.netpowerctrl.device_ports.DevicePort;
1011
import oly.netpowerctrl.devices.Device;
12+
import oly.netpowerctrl.devices.DeviceCollection;
13+
import oly.netpowerctrl.listen_service.PluginInterface;
1114
import oly.netpowerctrl.network.DeviceObserverResult;
1215
import oly.netpowerctrl.network.DeviceQuery;
13-
import oly.netpowerctrl.network.onConfiguredDeviceUpdate;
1416

1517
/**
1618
* Created by david on 20.08.14.
1719
*/
18-
public class AnelCreateDevice implements DeviceObserverResult, onConfiguredDeviceUpdate {
20+
public class AnelCreateDevice implements DeviceObserverResult, onCollectionUpdated<DeviceCollection, Device> {
1921
public final Device device;
2022
public AnelCreateDeviceResult listener = null;
2123
TestStates test_state = TestStates.TEST_INIT;
@@ -49,15 +51,45 @@ public boolean wakeupPlugin(Context context) {
4951
}
5052

5153
@Override
52-
public void onDeviceUpdated(Device di) {
53-
onConfiguredDeviceUpdated(di, false);
54+
public void onObserverDeviceUpdated(Device di) {
55+
updated(null, di, ObserverUpdateActions.UpdateAction);
5456
}
5557

5658
@Override
57-
public void onConfiguredDeviceUpdated(Device updated_device, boolean willBeRemoved) {
58-
if (!updated_device.equalsByUniqueID(device))
59+
public void onObserverJobFinished(List<Device> timeout_devices) {
60+
if (test_state != TestStates.TEST_REACHABLE)
5961
return;
6062

63+
for (Device di : timeout_devices) {
64+
if (!di.equalsByUniqueID(device))
65+
continue;
66+
test_state = TestStates.TEST_INIT;
67+
if (listener != null)
68+
listener.testFinished(false);
69+
break;
70+
}
71+
}
72+
73+
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
74+
public boolean startTest(Context context) {
75+
test_state = TestStates.TEST_REACHABLE;
76+
77+
if (wakeupPlugin(context))
78+
deviceQuery = new DeviceQuery(context, this, device);
79+
else
80+
return false;
81+
return true;
82+
}
83+
84+
public boolean isTesting() {
85+
return test_state != TestStates.TEST_INIT && test_state != TestStates.TEST_OK;
86+
}
87+
88+
@Override
89+
public boolean updated(DeviceCollection deviceCollection, Device updated_device, ObserverUpdateActions action) {
90+
if (!updated_device.equalsByUniqueID(device))
91+
return true;
92+
6193
if (!updated_device.isReachable()) {
6294
test_state = TestStates.TEST_INIT;
6395
if (listener != null)
@@ -99,38 +131,10 @@ public void run() {
99131
device.copyValuesFromUpdated(updated_device);
100132
test_state = TestStates.TEST_OK;
101133
}
102-
}
103-
104-
@Override
105-
public void onObserverJobFinished(List<Device> timeout_devices) {
106-
if (test_state != TestStates.TEST_REACHABLE)
107-
return;
108-
109-
for (Device di : timeout_devices) {
110-
if (!di.equalsByUniqueID(device))
111-
continue;
112-
test_state = TestStates.TEST_INIT;
113-
if (listener != null)
114-
listener.testFinished(false);
115-
break;
116-
}
117-
}
118-
119-
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
120-
public boolean startTest(Context context) {
121-
test_state = TestStates.TEST_REACHABLE;
122134

123-
if (wakeupPlugin(context))
124-
deviceQuery = new DeviceQuery(context, this, device);
125-
else
126-
return false;
127135
return true;
128136
}
129137

130-
public boolean isTesting() {
131-
return test_state != TestStates.TEST_INIT && test_state != TestStates.TEST_OK;
132-
}
133-
134138
enum TestStates {TEST_INIT, TEST_REACHABLE, TEST_ACCESS, TEST_OK}
135139

136140
public interface AnelCreateDeviceResult {

0 commit comments

Comments
 (0)