Skip to content
This repository was archived by the owner on Aug 2, 2019. It is now read-only.

Commit 181e248

Browse files
committed
refactoring of action execution logic
last state of geofence is now saved to database geofence actions will now trigger only if state changes to a different one than the last known receiver/room/scene button actions are now executed async added day/night theme support
1 parent 3e5c8b2 commit 181e248

File tree

95 files changed

+917
-276
lines changed

Some content is hidden

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

95 files changed

+917
-276
lines changed

Diff for: Shared/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ android {
4747
dependencies {
4848
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
4949
compile fileTree(include: ['*.jar'], dir: 'libraries')
50-
compile 'com.android.support:appcompat-v7:23.2.0'
50+
compile 'com.android.support:appcompat-v7:23.2.1'
5151
testCompile 'junit:junit:4.12'
5252
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* PowerSwitch by Max Rosin & Markus Ressel
3+
* Copyright (C) 2015 Markus Ressel
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package eu.power_switch.shared;
20+
21+
import android.content.Context;
22+
import android.support.annotation.AttrRes;
23+
import android.support.annotation.ColorInt;
24+
import android.support.v4.content.ContextCompat;
25+
import android.util.TypedValue;
26+
27+
/**
28+
* Created by Markus on 07.03.2016.
29+
*/
30+
public class ThemeHelper {
31+
32+
/**
33+
* Get Color from Theme attribute
34+
*
35+
* @param context Activity context
36+
* @param attr Attribute ressource ID
37+
* @return Color as Int
38+
*/
39+
@ColorInt
40+
public static int getThemeAttrColor(Context context, @AttrRes int attr) {
41+
TypedValue typedValue = new TypedValue();
42+
if (context.getTheme().resolveAttribute(attr, typedValue, true)) {
43+
if (typedValue.type >= TypedValue.TYPE_FIRST_INT
44+
&& typedValue.type <= TypedValue.TYPE_LAST_INT) {
45+
return typedValue.data;
46+
} else if (typedValue.type == TypedValue.TYPE_STRING) {
47+
return ContextCompat.getColor(context, typedValue.resourceId);
48+
}
49+
}
50+
51+
return 0;
52+
}
53+
}

Diff for: Shared/src/main/java/eu/power_switch/shared/constants/SettingsConstants.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
package eu.power_switch.shared.constants;
2020

21+
import android.support.annotation.IntDef;
22+
23+
import java.lang.annotation.Retention;
24+
import java.lang.annotation.RetentionPolicy;
25+
2126
/**
2227
* Class holding constants related to Settings for both Smartphone and Wearable Module
2328
* <p/>
@@ -63,27 +68,20 @@ public class SettingsConstants {
6368
public static final int KEEP_HISTORY_6_MONTHS = 2;
6469
public static final int KEEP_HISTORY_1_MONTH = 3;
6570
public static final int KEEP_HISTORY_14_DAYS = 4;
66-
67-
68-
// Theme
6971
public static final int THEME_DARK_BLUE = 0;
7072
public static final int THEME_DARK_RED = 1;
7173
public static final int THEME_LIGHT_BLUE = 2;
7274
public static final int THEME_LIGHT_RED = 3;
73-
75+
public static final int THEME_DAY_NIGHT_BLUE = 4;
7476
// Google API
7577
public static final String VOK_ZWEQ =
7678
"jVMU2RnWW1oelVoMVF4ZXJkV1B1cDcwWFRYc3g0c0hScmN2WjhmR21NN3R0V3E5YlF4cWtVSUFiYjFUQ0EzcW9ScU00bUxNY0E0T29ZVjVsTE1hSGxXanVyVHdJREFRQUI=";
77-
7879
public static final String KDH_SDSA =
7980
"TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF3UDlkSk9QYVZQNnBHZ1kxeUYzRVBVVHRRbkJMaHVwN2xYVnNyTzAyMFdXZlp4YmFSRnQ5c1I";
80-
8181
public static final String DJA_IOVJ =
8282
"VvWE9iYnB2NTNJMmJVeEFkSkZyUm9pWVNaa3BQV1hXb201dVN4UHdSQ2x5cVdDZXlmeFZTYlN6NGdSNFAwOVlyODlIMXFzNFBQdHRIZ2k1cDNsd2FVT2pwNzlGSVFZb1pmZ";
83-
8483
public static final String JKD_COAP =
8584
"0K0RzZDlHS3EvbjYyLzMySFFydkJXcVVQK1FrOE1FNDUvYWM2UTh2YmNtdmlCV0h1T3hUSVB2d1RucU5mdzNpMjJXd1VTZVV0WHRReURLVVpZODJYVjJwY0ZoSGkydnpmWW";
86-
8785
public static final int GOOGLE_API_CLIENT_TIMEOUT = 10;
8886

8987
/**
@@ -94,4 +92,10 @@ public class SettingsConstants {
9492
private SettingsConstants() {
9593
throw new UnsupportedOperationException("This class is non-instantiable");
9694
}
95+
96+
// Theme
97+
@IntDef({THEME_DARK_BLUE, THEME_DARK_RED, THEME_LIGHT_BLUE, THEME_LIGHT_RED, THEME_DAY_NIGHT_BLUE})
98+
@Retention(RetentionPolicy.SOURCE)
99+
public @interface Theme {
100+
}
97101
}

Diff for: Shared/src/main/res/values-de/strings.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
<string name="permission_granted">Berechtigung erhalten</string>
6161
<string name="permission_denied">Keine Berechtigung</string>
6262
<string name="no_active_gateway">Kein aktives Gateway</string>
63-
<string name="missing_wifi_connection">Keine WLAN Verbindung!</string>
64-
<string name="missing_network_connection">Keine Netzwerkverbindung!</string>
63+
<string name="missing_wifi_connection">Keine WLAN Verbindung</string>
64+
<string name="missing_network_connection">Keine Netzwerkverbindung</string>
6565

6666
<string name="no_elements">Keine Elemente</string>
6767

Diff for: Shared/src/main/res/values-de/strings_geofence.xml

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<string name="enter">Eintritt</string>
3737
<string name="exit">Austritt</string>
3838

39+
<string name="inside">Innerhalb</string>
40+
<string name="outside">Außerhalb</string>
41+
3942
<string name="enter_actions">Aktionen beim Eintreten</string>
4043
<string name="exit_actions">Aktionen beim Verlassen</string>
4144

Diff for: Shared/src/main/res/values-de/strings_settings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<string name="theme_dark_red">Dunkel Rot</string>
4747
<string name="theme_light_blue">Hell Blau</string>
4848
<string name="theme_light_red">Hell Rot</string>
49+
<string name="theme_dayNight_blue">Tag/Nacht Blau</string>
4950

5051
<string name="create_gateway">Gateway erstellen</string>
5152
<string name="search_gateway">Gateway suchen</string>

Diff for: Shared/src/main/res/values/attrs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
<declare-styleable name="colorPrimaryLight">
2323
<attr name="colorPrimaryLight" format="color"/>
24+
<attr name="textColorInactive" format="color"/>
2425
</declare-styleable>
2526

2627
<declare-styleable name="cardview">

Diff for: Shared/src/main/res/values/colors.xml

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
<color name="color_gray_100">#FFF5F5F5</color>
2525
<!-- Grey 200 #EEEEEE -->
2626
<color name="color_gray_200">#FFEEEEEE</color>
27+
<!-- Grey 500 #9E9E9E -->
28+
<color name="color_gray_500">#FF9E9E9E</color>
29+
<!-- Grey 600 #757575 -->
30+
<color name="color_gray_600">#FF757575</color>
31+
<!-- Grey 700 #616161 -->
32+
<color name="color_gray_700">#FF616161</color>
2733
<!-- Grey 800 #424242 -->
2834
<color name="color_gray_800">#FF424242</color>
2935
<!-- Grey 900 #212121 -->
@@ -78,6 +84,8 @@
7884
<!-- inverse text color: 87% black -->
7985
<color name="textColorPrimaryInverse">#DE000000</color>
8086
<color name="textColorSecondaryInverse">#8A000000</color>
87+
<color name="textColorInactive">#FFFFFFFF</color>
88+
8189

8290
<color name="delete_color">@color/color_red_900</color>
8391

Diff for: Shared/src/main/res/values/strings.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@
6969
<string name="missing_external_storage_permission">Missing Permission for External Storage</string>
7070
<string name="permission_granted">Permission granted</string>
7171
<string name="permission_denied">Permission denied</string>
72-
<string name="no_active_gateway">No active Gateway!</string>
73-
<string name="missing_wifi_connection">No WLAN connection!</string>
72+
<string name="no_active_gateway">No active Gateway</string>
73+
<string name="missing_wifi_connection">No WLAN connection</string>
74+
<string name="missing_network_connection">No Network connection</string>
7475

7576
<string name="no_elements">No elements</string>
7677

77-
<string name="missing_network_connection">No Network connection!</string>
7878
<string name="missing_permission">Missing permission</string>
7979
<string name="missing_location_permission">Missing location permission</string>
8080
<string name="details">Details</string>

Diff for: Shared/src/main/res/values/strings_geofence.xml

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<string name="enter">Enter</string>
3838
<string name="exit">Exit</string>
3939

40+
<string name="inside">Inside</string>
41+
<string name="outside">Outside</string>
42+
4043
<string name="enter_actions">Enter actions</string>
4144
<string name="exit_actions">Exit actions</string>
4245

Diff for: Shared/src/main/res/values/strings_settings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<string name="theme_dark_red">Dark Red</string>
5050
<string name="theme_light_blue">Light Blue</string>
5151
<string name="theme_light_red">Light Red</string>
52+
<string name="theme_dayNight_blue">Day/Night Blue</string>
5253

5354
<string name="create_gateway">Add Gateway</string>
5455
<string name="search_gateway">Search Gateway</string>

Diff for: Smartphone/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ android {
5555

5656
dependencies {
5757
// Support Library stuff
58-
compile 'com.android.support:cardview-v7:23.2.0'
59-
compile 'com.android.support:recyclerview-v7:23.2.0'
60-
compile 'com.android.support:gridlayout-v7:23.2.0'
61-
compile 'com.android.support:support-v4:23.2.0'
62-
compile 'com.android.support:design:23.2.0'
63-
compile 'com.android.support:support-annotations:23.2.0'
58+
compile 'com.android.support:cardview-v7:23.2.1'
59+
compile 'com.android.support:recyclerview-v7:23.2.1'
60+
compile 'com.android.support:gridlayout-v7:23.2.1'
61+
compile 'com.android.support:support-v4:23.2.1'
62+
compile 'com.android.support:design:23.2.1'
63+
compile 'com.android.support:support-annotations:23.2.1'
6464

6565
// Google Play Services
6666
compile 'com.google.android.gms:play-services-location:8.4.0'
@@ -118,7 +118,7 @@ sourceSets {
118118
}
119119

120120
configurations.all {
121-
resolutionStrategy.force 'com.android.support:support-annotations:23.2.0'
121+
resolutionStrategy.force 'com.android.support:support-annotations:23.2.1'
122122
}
123123

124124
//apply plugin: 'com.google.gms.google-services'

0 commit comments

Comments
 (0)