Skip to content

Commit 2277aa4

Browse files
authored
Merge pull request #28 from SirkoVZ/master
new version 0.9.3
2 parents ca84564 + 94df342 commit 2277aa4

11 files changed

Lines changed: 127 additions & 35 deletions

File tree

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Download: [https://github.com/volkszaehler/app-android/releases/latest](https://
99
![ScreenShot3](http://wiki.volkszaehler.org/_media/software/frontends/vz_app/grafik.png?w=200&tok=3e01fa "ScreenShots 3 of VolkszaehlerApp")
1010
![ScreenShot4](http://wiki.volkszaehler.org/_media/software/frontends/vz_app/einstellungen.png?w=200&tok=ede86f "ScreenShots 4 of VolkszaehlerApp")
1111

12-
## VolkszählerApp für Android, Version 0.9.2
12+
## VolkszählerApp für Android, Version 0.9.3
1313

1414

1515
Funktionen:
@@ -37,7 +37,7 @@ Wenn das Clonen bzw. das Öffnen des Projektes wegen eines ausgegrauten "Use def
3737
---
3838

3939
English:
40-
## VolkszaehlerApp for Android, Version 0.9.2
40+
## VolkszaehlerApp for Android, Version 0.9.3
4141

4242

4343
Features:
@@ -64,6 +64,17 @@ If the cloning resp. opening of the project fails due to a grayed "Use default g
6464

6565
## Version history:
6666

67+
### Version 0.9.3
68+
#### New
69+
- Channels can be sorted in Preferences, channels must be relaoded once after changing the preference
70+
71+
#### Fixed
72+
- error message in table view for groups (there is no table view for groups)
73+
74+
#### Changed
75+
- small optimizations, Colors in table view, naming
76+
77+
6778
### Version 0.9.2
6879
#### New
6980
- new TabelView of Values

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="org.volkszaehler.volkszaehlerapp"
4-
android:versionCode="92"
5-
android:versionName="0.9.2">
4+
android:versionCode="93"
5+
android:versionName="0.9.3">
66

77
<uses-permission android:name="android.permission.INTERNET"/>
88
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

app/src/main/java/org/volkszaehler/volkszaehlerapp/ChannelDetails.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ChannelDetails extends Activity {
3535
private boolean gas = false;
3636
private boolean water = false;
3737
private boolean temp = false;
38+
private boolean group = false;
3839

3940
public void onCreate(Bundle savedInstanceState) {
4041
super.onCreate(savedInstanceState);
@@ -66,6 +67,9 @@ public void onCreate(Bundle savedInstanceState) {
6667
case "water":
6768
water = true;
6869
break;
70+
case "group":
71+
group = true;
72+
break;
6973
default:
7074
Log.e("ChannelDetails", "Unknown channel type: " + typeOfChannel);
7175
}
@@ -156,6 +160,13 @@ public void onCreate(Bundle savedInstanceState) {
156160
findViewById(R.id.textViewTitleGesamt).setVisibility(View.GONE);
157161
findViewById(R.id.textViewGesamt).setVisibility(View.GONE);
158162
}
163+
164+
//remove table for type Group
165+
if(group)
166+
{
167+
findViewById(R.id.linearLayout620).setVisibility(View.GONE);
168+
}
169+
159170
}
160171

161172
public void chartsDetailsHandler(View view) {

app/src/main/java/org/volkszaehler/volkszaehlerapp/Preferences.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public boolean onPreferenceClick(Preference arg0) {
5454
pwd = prefs.getString("password", "");
5555
boolean bZeroBased = prefs.getBoolean("ZeroBasedYAxis", false);
5656
boolean bAutoReload = prefs.getBoolean("autoReload", false);
57+
boolean bSortChannels = prefs.getBoolean("sortChannels", false);
5758
tuples = prefs.getString("Tuples", "1000");
5859
privateChannelString = prefs.getString("privateChannelUUIDs", "");
5960

@@ -66,6 +67,7 @@ public boolean onPreferenceClick(Preference arg0) {
6667
prefs.edit().putString("password", pwd).commit();
6768
prefs.edit().putBoolean("ZeroBasedYAxis", bZeroBased).commit();
6869
prefs.edit().putBoolean("autoReload", bAutoReload).commit();
70+
prefs.edit().putBoolean("sortChannels", bSortChannels).commit();
6971
prefs.edit().putString("Tuples", tuples).commit();
7072
prefs.edit().putString("privateChannelUUIDs", privateChannelString).commit();
7173
// call Channels from VZ installation
@@ -249,13 +251,18 @@ protected String doInBackground(Void... arg0) {
249251
}
250252
}
251253
}
252-
253254
// store all channel stuff in a shared preference
254255
if (jsonStrObj != null) {
255-
jsonStr = jsonStrObj.toString();
256+
if(sharedPref.getBoolean("sortChannels", false))
257+
{
258+
jsonStr = Tools.sortJSONChannels(jsonStrObj, Tools.TAG_ENTITIES).toString().replace("\\", "").replace("\"[", "[").replace("]\"","]"); //not sure why the quotes are escaped after put, so remove escaped quotes a.s.o.
259+
}
260+
else
261+
{
262+
jsonStrObj.toString();
263+
}
256264
getApplicationContext().getSharedPreferences(Tools.JSON_CHANNEL_PREFS, Activity.MODE_PRIVATE).edit().putString(Tools.JSON_CHANNELS, jsonStr).commit();
257265
}
258-
259266
return null;
260267
}
261268

app/src/main/java/org/volkszaehler/volkszaehlerapp/Tools.java

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.text.DecimalFormat;
2929
import java.util.ArrayList;
3030
import java.util.Calendar;
31+
import java.util.Collections;
32+
import java.util.Comparator;
3133
import java.util.Date;
3234
import java.util.HashMap;
3335
import java.util.Locale;
@@ -62,14 +64,15 @@ class Tools {
6264
static final DecimalFormat f0 = new DecimalFormat("#0.0");
6365
static final DecimalFormat f00 = new DecimalFormat("#0.00");
6466
static final DecimalFormat f000 = new DecimalFormat("#0.000");
65-
private static final String TAG_ENTITIES = "entities";
67+
public static final String TAG_ENTITIES = "entities";
6668
private static final String TAG_ACTIVE = "active";
6769
private static final String TAG_FILLSTYLE = "fillstyle";
6870
private static final String TAG_PUBLIC = "public";
6971
private static final String TAG_STYLE = "style";
7072
private static final String TAG_YAXIS = "yaxis";
7173
private static final String TAG_CHILDREN = "children";
7274
private static final String BACKUP_FILENAME = "volkszaehler_settings_backup.txt";
75+
private static final Object TAG_GROUP = "group";
7376
private static String unit = "";
7477

7578
private static SharedPreferences getPrefs(Context context) {
@@ -298,7 +301,7 @@ private static void getGroupChannels(JSONObject channel, HashMap<String, String>
298301
}
299302
catch (JSONException jex)
300303
{
301-
Log.d("getGroupChannels:", String.format("no children found for UUID: %s", channel));
304+
Log.e("getGroupChannels:", String.format("no children found for UUID: %s", channel));
302305
jex.printStackTrace();
303306
}
304307

@@ -448,6 +451,7 @@ static boolean saveFile(Context context) {
448451
fw.write("privateChannelUUIDs" + "=" + sharedPrefs.getString("privateChannelUUIDs", "") + "\n");
449452
fw.write("ZeroBasedYAxis" + "=" + (sharedPrefs.getBoolean("ZeroBasedYAxis", false) ? "true" : "false") + "\n");
450453
fw.write("autoReload" + "=" + (sharedPrefs.getBoolean("autoReload", false) ? "true" : "false"));
454+
fw.write("sortChannels" + "=" + (sharedPrefs.getBoolean("sortChannels", false) ? "true" : "false"));
451455
} catch (IOException e) {
452456
e.printStackTrace();
453457
return false;
@@ -513,6 +517,13 @@ static boolean loadFile(Context context) {
513517
continue;
514518
}
515519
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("ZeroBasedYAxis", Boolean.parseBoolean(line)).commit();
520+
} else if (line.startsWith("sortChannels")) {
521+
try {
522+
line = line.split("=")[1];
523+
} catch (IndexOutOfBoundsException iobx) {
524+
continue;
525+
}
526+
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("sortChannels", Boolean.parseBoolean(line)).commit();
516527
} else if (line.startsWith("autoReload")) {
517528
try {
518529
line = line.split("=")[1];
@@ -629,4 +640,46 @@ public static float determineStufe(float min, float max, float stufen, String va
629640
float stufe = (Float.parseFloat(value) - min) / stufengroesse;
630641
return Math.round(stufe);
631642
}
643+
644+
public static JSONObject sortJSONChannels(JSONObject JSONChannels, String sortWhat)
645+
{
646+
ArrayList<JSONObject> list = null;
647+
JSONArray what_Array = null;
648+
try {
649+
what_Array = (JSONArray) JSONChannels.get(sortWhat);
650+
list = new ArrayList<>();
651+
for (int i = 0; i < what_Array.length(); i++) {
652+
JSONObject channel = (JSONObject) what_Array.get(i);
653+
if(TAG_GROUP.equals(channel.get(TAG_TYPE)))
654+
{
655+
if(channel.get(TAG_CHILDREN)!="" && channel.get(TAG_CHILDREN) != null) {
656+
channel = sortJSONChannels((JSONObject) channel,TAG_CHILDREN);
657+
}
658+
}
659+
list.add(channel);
660+
}
661+
Collections.sort(list, new MyJSONComparator());
662+
JSONChannels.remove(sortWhat);
663+
JSONChannels.put(sortWhat, list);
664+
665+
} catch (Exception e) {
666+
e.printStackTrace();
667+
}
668+
return JSONChannels;
669+
}
670+
}
671+
672+
class MyJSONComparator implements Comparator<JSONObject> {
673+
674+
@Override
675+
public int compare(JSONObject jo1, JSONObject jo2) {
676+
String v1 = "", v2 = "";
677+
try {
678+
v1 = (String) jo1.get(Tools.TAG_TITLE);
679+
v2 = (String) jo2.get(Tools.TAG_TITLE);
680+
} catch (JSONException e) {
681+
e.printStackTrace();
682+
}
683+
return v1.compareTo(v2);
684+
}
632685
}

app/src/main/res/layout/activity_table_details.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:layout_width="fill_parent"
4-
android:layout_height="fill_parent"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
55
android:scrollbars="none"
66
android:layout_weight="1"
77
>
88
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
9-
android:layout_width="fill_parent"
10-
android:layout_height="fill_parent"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
1111
android:scrollbars="none"
1212
android:layout_weight="1"
1313
>
@@ -19,7 +19,7 @@
1919

2020
<TextView
2121
android:id="@+id/table_ChannelName"
22-
android:layout_width="fill_parent"
22+
android:layout_width="match_parent"
2323
android:layout_height="wrap_content"
2424
android:ellipsize="end"
2525
android:gravity="left"
@@ -43,8 +43,6 @@
4343
android:textAppearance="?android:attr/textAppearanceSmall"
4444
android:textIsSelectable="true" />
4545

46-
47-
4846
<TableLayout
4947
xmlns:android="http://schemas.android.com/apk/res/android"
5048
android:id="@+id/main_table"
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="wrap_content"
4-
android:layout_height="wrap_content"
5-
>
4+
android:layout_height="wrap_content">
65
<TextView
76
android:id="@+id/tableColumnTime"
87
android:layout_marginRight="8dp"
@@ -13,29 +12,29 @@
1312
android:id="@+id/tableColumnMin"
1413
android:layout_marginRight="8dp"
1514
android:gravity="right"
16-
android:textIsSelectable="true"
17-
android:textStyle="normal"/>
15+
android:textColor="@color/Black"
16+
android:textIsSelectable="true"/>
1817
<TextView
1918
android:id="@+id/tableColumnMax"
2019
android:layout_marginRight="8dp"
2120
android:gravity="right"
22-
android:textIsSelectable="true"
23-
android:textStyle="normal"/>
21+
android:textColor="@color/Black"
22+
android:textIsSelectable="true"/>
2423
<TextView
2524
android:id="@+id/tableColumnAverage"
2625
android:layout_marginRight="8dp"
2726
android:gravity="right"
28-
android:textIsSelectable="true"
29-
android:textStyle="normal"/>
27+
android:textColor="@color/Black"
28+
android:textIsSelectable="true"/>
3029
<TextView
3130
android:id="@+id/tableColumnConsumption"
3231
android:layout_marginRight="8dp"
3332
android:gravity="right"
34-
android:textIsSelectable="true"
35-
android:textStyle="normal"/>
33+
android:textColor="@color/Black"
34+
android:textIsSelectable="true"/>
3635
<TextView
3736
android:id="@+id/tableColumnCost"
3837
android:gravity="right"
39-
android:textIsSelectable="true"
40-
android:textStyle="normal"/>
38+
android:textColor="@color/Black"
39+
android:textIsSelectable="true"/>
4140
</TableRow>

app/src/main/res/values-de/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,21 @@
8181
<string name="aboutLinks"><a href="http://www.volkszaehler.org">http://www.volkszaehler.org</a>\n<a href="http://github.com/volkszaehler/app-android/releases/latest">Download neuste Version</a></string>
8282
<string name="MultipleGraphsPopupDone">OK</string>
8383
<string name="MultipleGraphsPopupCancel">Abbrechen</string>
84-
<string name="MultipleGraphsPopupTitel">Channels wählen</string>
84+
<string name="MultipleGraphsPopupTitel">Kanäle wählen</string>
8585
<string name="GesamtTitle">Gesamt</string>
8686
<string name="VolkszaehlerCat_titleTuplesSettings">Anzahl Tuples</string>
8787
<string name="TuplesSummary">höhere Werte führen zu detaillierteren, aber langsameren Graphen</string>
8888
<string name="Tuples">Tuples</string>
8989
<string name="TableDay">Letzte 24 Stunden</string>
9090
<string name="TableWeek">Letzte 7 Tage</string>
9191
<string name="TableMonth">Letzte 30 Tage</string>
92-
<string name="TableYear">Letzte 12 Monate</string>
92+
<string name="TableYear">Letzte 53 Wochen</string>
9393
<string name="Table">Tabelle</string>
9494
<string name="timeRange">Zeitraum</string>
9595
<string name="ChannelName">ChannelName</string>
9696
<string name="please_wait_infinite">Bitte warten...</string>
97+
<string name="sortChannelsTitle">Kanäle Sortieren</string>
98+
<string name="sortChannelsSummary">Kanäle werden alphabetisch sortiert, Kanäle müssen neu abgerufen werden" </string>
99+
<string name="VolkszaehlerCat_titleSortChannels">Sortierungseinstellungen</string>
97100

98101
</resources>

app/src/main/res/values/colors.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@
104104
<color name="LightGreen">#90EE90</color>
105105
<color name="DarkSeaGreen">#8FBC8F</color>
106106
<color name="SaddleBrown">#8B4513</color>
107-
<color name="DarkMagenta">#8B008B</color>
107+
<color name="DarkMagenta">#8b008b</color>
108108
<color name="DarkRed">#8B0000</color>
109-
<color name="BlueViolet">#8A2BE2</color>
109+
<color name="BlueViolet">#8a2be2</color>
110110
<color name="LightSkyBlue">#87CEFA</color>
111111
<color name="SkyBlue">#87CEEB</color>
112112
<color name="Gray">#808080</color>
@@ -123,7 +123,7 @@
123123
<color name="SlateBlue">#6A5ACD</color>
124124
<color name="DimGray">#696969</color>
125125
<color name="MediumAquamarine">#66CDAA</color>
126-
<color name="CornflowerBlue">#6495ED</color>
126+
<color name="CornflowerBlue">#6495ed</color>
127127
<color name="CadetBlue">#5F9EA0</color>
128128
<color name="DarkOliveGreen">#556B2F</color>
129129
<color name="Indigo">#4B0082</color>
@@ -151,7 +151,7 @@
151151
<color name="Teal">#008080</color>
152152
<color name="Green">#008000</color>
153153
<color name="DarkGreen">#006400</color>
154-
<color name="Blue">#0000FF</color>
154+
<color name="Blue">#0000ff</color>
155155
<color name="MediumBlue">#0000CD</color>
156156
<color name="DarkBlue">#00008B</color>
157157
<color name="Navy">#000080</color>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@
9292
<string name="TableDay">Last 24 Hours</string>
9393
<string name="TableWeek">Last 7 Days</string>
9494
<string name="TableMonth">Last 30 Days</string>
95-
<string name="TableYear">Last 12 Months</string>
95+
<string name="TableYear">Last 53 Weeks</string>
9696
<string name="title_activity_table_details">TableDetails</string>
9797
<string name="Table">Table</string>
9898
<string name="timeRange">Time Range</string>
9999
<string name="ChannelName">ChannelName</string>
100100
<string name="please_wait_infinite">Please wait...</string>
101+
<string name="sortChannelsTitle">Sort Channels</string>
102+
<string name="sortChannelsSummary">Channels are sorted in List, Channels must be re-loaded</string>
103+
<string name="VolkszaehlerCat_titleSortChannels">Sort Settings</string>
101104

102105
</resources>

0 commit comments

Comments
 (0)