Skip to content

Commit

Permalink
Merge pull request #33 from SirkoVZ/master
Browse files Browse the repository at this point in the history
Version 0.9.5
  • Loading branch information
SirkoVZ authored Jul 28, 2017
2 parents 509d368 + 22fe8f0 commit 9514380
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 54 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Download: [https://github.com/volkszaehler/app-android/releases/latest](https://
![ScreenShot3](http://wiki.volkszaehler.org/_media/software/frontends/vz_app/grafik.png?w=200&tok=3e01fa "ScreenShots 3 of VolkszaehlerApp")
![ScreenShot4](http://wiki.volkszaehler.org/_media/software/frontends/vz_app/einstellungen.png?w=200&tok=ede86f "ScreenShots 4 of VolkszaehlerApp")

## VolkszählerApp für Android, Version 0.9.4
## VolkszählerApp für Android, Version 0.9.5


Funktionen:
Expand Down Expand Up @@ -37,7 +37,7 @@ Wenn das Clonen bzw. das Öffnen des Projektes wegen eines ausgegrauten "Use def
---

English:
## VolkszaehlerApp for Android, Version 0.9.4
## VolkszaehlerApp for Android, Version 0.9.5


Features:
Expand All @@ -63,17 +63,22 @@ If the cloning resp. opening of the project fails due to a grayed "Use default g


## Version history:
### Version 0.9.5

#### Changed
- When reading the channels the very first time all channels are checked by default (https://github.com/volkszaehler/app-android/issues/32)


### Version 0.9.4
#### New
- now 3 Sorting modes: Off, Sorting of Channels in Groups, or Sorting all Channles independend of Groups
- now 3 Sorting modes: Off, Sorting of Channels in Groups, or Sorting all Channles independend of Groups (https://github.com/volkszaehler/app-android/issues/29)
- the backup of settings now also saves the "checked state" of the channels

#### Fixed
- small bugs

#### Changed
- Sorting of channels now also for Popup in chart view
- Sorting of channels now also for Popup in chart view (https://github.com/volkszaehler/app-android/issues/30)
- small optimizations

### Version 0.9.3
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.volkszaehler.volkszaehlerapp"
android:versionCode="94"
android:versionName="0.9.4">
android:versionCode="95"
android:versionName="0.9.5">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void prepareData() {
for (String singleUUID : mUUIDs) {
//is there a group in the list?
if ((Tools.getPropertyOfChannel(myContext, singleUUID, Tools.TAG_TYPE)).equals("group")) { // are there child uuids? (in case of a group)
String childUUIDs = Tools.getPropertyOfChannel(myContext, singleUUID, Tools.TAG_CHUILDUUIDS);
String childUUIDs = Tools.getHashMapBasedPropertyOfChannel(myContext, singleUUID, Tools.TAG_CHUILDUUIDS);

if (null != childUUIDs && !"".equals(childUUIDs)) {
if (childUUIDs.contains("|")) {
Expand All @@ -192,7 +192,7 @@ private void prepareData() {
}
}
} else if ((Tools.getPropertyOfChannel(myContext, mUUID, Tools.TAG_TYPE)).equals("group")) {
String childUUIDs = Tools.getPropertyOfChannel(myContext, mUUID, Tools.TAG_CHUILDUUIDS);
String childUUIDs = Tools.getHashMapBasedPropertyOfChannel(myContext, mUUID, Tools.TAG_CHUILDUUIDS);

if (null != childUUIDs && !"".equals(childUUIDs)) {
if (childUUIDs.contains("|")) {
Expand Down Expand Up @@ -307,7 +307,7 @@ private void addMultipleGraphs() {
int i = 0;
final LinkedHashMap<String, String> channelsToRequest = new LinkedHashMap<>();
//get the currently set Channels (in preferences)
String allCheckedChannels = Tools.getCheckedChannels(myContext);
String allCheckedChannels = Tools.getCheckedChannels(myContext, true);
for (String uuid : allCheckedChannels.split(",")) {
channelsToRequest.put(uuid, Tools.getPropertyOfChannel(myContext, uuid, Tools.TAG_TITLE));
i++;
Expand Down Expand Up @@ -643,7 +643,7 @@ protected String doInBackground(Void... arg0) {
for (String singleUUID : mUUIDs) {
//is there a group in the list?
if ((Tools.getPropertyOfChannel(myContext, singleUUID, Tools.TAG_TYPE)).equals("group")) { // are there child uuids? (in case of a group)
String childUUIDs = Tools.getPropertyOfChannel(myContext, singleUUID, Tools.TAG_CHUILDUUIDS);
String childUUIDs = Tools.getHashMapBasedPropertyOfChannel(myContext, singleUUID, Tools.TAG_CHUILDUUIDS);
Log.d("ChartDetails", "childUUIDs: " + childUUIDs);

if (null != childUUIDs && !"".equals(childUUIDs)) {
Expand All @@ -665,7 +665,7 @@ protected String doInBackground(Void... arg0) {
}
} else if ((Tools.getPropertyOfChannel(myContext, mUUID, Tools.TAG_TYPE)).equals("group")) {
// are there child uuids? (in case of a group)
String childUUIDs = Tools.getPropertyOfChannel(myContext, mUUID, Tools.TAG_CHUILDUUIDS);
String childUUIDs = Tools.getHashMapBasedPropertyOfChannel(myContext, mUUID, Tools.TAG_CHUILDUUIDS);
Log.d("ChartDetails", "childUUIDs: " + childUUIDs);

if (null != childUUIDs && !"".equals(childUUIDs)) {
Expand Down Expand Up @@ -705,7 +705,7 @@ protected String doInBackground(Void... arg0) {
} else {

// store all data stuff in a shared preference
getApplicationContext().getSharedPreferences("JSONChannelPrefs", Activity.MODE_PRIVATE).edit().putString("JSONChannelsData", jsonStr).commit();
getApplicationContext().getSharedPreferences("JSONChannelPrefs", Activity.MODE_PRIVATE).edit().putString("JSONChannelsData", jsonStr).apply();

JSONObject jsonObj;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
jsonStr = savedInstanceState.getString("JSONStr");
channelsToRequest = savedInstanceState.getString("ChannelsToRequest");
}
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
sharedPref.registerOnSharedPreferenceChangeListener(listener);
}

private void addListenerOnButton() {
Expand Down Expand Up @@ -114,6 +116,13 @@ protected void onResume() {
}
}

@Override
protected void onDestroy() {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
sharedPref.unregisterOnSharedPreferenceChangeListener(listener);
super.onDestroy();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
Expand Down Expand Up @@ -200,6 +209,17 @@ protected void onSaveInstanceState(Bundle outState) {
outState.putString("ChannelsToRequest", channelsToRequest);
}

private SharedPreferences.OnSharedPreferenceChangeListener listener =
new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (key.contains("-") && key.length() == 36) {
prefs.edit().putString(Tools.AllCheckedChannels,Tools.getCheckedChannels(myContext, false)).apply();
}
}
};


private class GetJSONData extends AsyncTask<String, Void, Void> {

boolean JSONFehler = false;
Expand Down Expand Up @@ -246,7 +266,7 @@ protected Void doInBackground(String... arg0) {
// add checked channel
allUUIDs.add(aChannelsAusParameterMitLeerstring);
// check for childs if above is a group
String childUUIDs = Tools.getPropertyOfChannel(myContext, aChannelsAusParameterMitLeerstring, Tools.TAG_CHUILDUUIDS);
String childUUIDs = Tools.getHashMapBasedPropertyOfChannel(myContext, aChannelsAusParameterMitLeerstring, Tools.TAG_CHUILDUUIDS);
if (null != childUUIDs && !"".equals(childUUIDs)) {
if (childUUIDs.contains("|")) {
String[] children = (childUUIDs.split("\\|"));
Expand Down
37 changes: 22 additions & 15 deletions app/src/main/java/org/volkszaehler/volkszaehlerapp/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,27 @@ public boolean onPreferenceClick(Preference arg0) {
tuples = prefs.getString("Tuples", "1000");
privateChannelString = prefs.getString("privateChannelUUIDs", "");
//keep all checked channels
allCheckedChannels = Tools.getCheckedChannels(getApplicationContext());
allCheckedChannels = prefs.getString(Tools.AllCheckedChannels, "");
// remove all
prefs.edit().clear().commit();
// and put back
prefs.edit().putString("volkszaehlerURL", url).commit();
prefs.edit().putString("username", uname).commit();
prefs.edit().putString("password", pwd).commit();
prefs.edit().putBoolean("ZeroBasedYAxis", bZeroBased).commit();
prefs.edit().putBoolean("autoReload", bAutoReload).commit();
prefs.edit().putString("sortChannelMode", sortChannelMode).commit();
prefs.edit().putString("Tuples", tuples).commit();
prefs.edit().putString("privateChannelUUIDs", privateChannelString).commit();
prefs.edit().putString("volkszaehlerURL", url).apply();
prefs.edit().putString("username", uname).apply();
prefs.edit().putString("password", pwd).apply();
prefs.edit().putBoolean("ZeroBasedYAxis", bZeroBased).apply();
prefs.edit().putBoolean("autoReload", bAutoReload).apply();
prefs.edit().putString("sortChannelMode", sortChannelMode).apply();
prefs.edit().putString("Tuples", tuples).apply();
prefs.edit().putString("privateChannelUUIDs", privateChannelString).apply();
prefs.edit().putString(Tools.AllCheckedChannels, allCheckedChannels).apply();
// call Channels from VZ installation
new GetChannels().execute();
return true;
}
});
}
// fill PreferenceScreen dynamically with new channels
addPreferenceChannels(allCheckedChannels);
addPreferenceChannels();
}

@Override
Expand All @@ -90,8 +91,9 @@ public void onBackPressed() {
super.onBackPressed();
}

private void addPreferenceChannels(String allCheckedChannels) {
private void addPreferenceChannels() {
SharedPreferences prefs = getSharedPreferences(Tools.JSON_CHANNEL_PREFS, Activity.MODE_PRIVATE);
String allCheckedChannels = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(Tools.AllCheckedChannels, "");
String JSONChannels = prefs.getString(Tools.JSON_CHANNELS, "");
Log.d("Preferences", "JSONChannels: " + JSONChannels);
if (JSONChannels.equals("")) {
Expand Down Expand Up @@ -125,11 +127,16 @@ private void addPreferenceChannels(String allCheckedChannels) {
checkBoxPreference.setKey(channel.get(Tools.TAG_UUID));
checkBoxPreference.setSummary(channel.get(Tools.TAG_DESCRIPTION) + "\n" + channel.get(Tools.TAG_UUID));
targetCategory.addPreference(checkBoxPreference);
//first load: check all channels
if("".equals(allCheckedChannels)) {
checkBoxPreference.setChecked(true);
prefs.edit().putBoolean(channel.get(Tools.TAG_UUID), true).apply();
}
// check preference
for(String checkedChannel : allCheckedChannels.split(",")) {
if (channel.get(Tools.TAG_UUID).equals(checkedChannel)) {
checkBoxPreference.setChecked(true);
prefs.edit().putBoolean(checkedChannel, true).commit();
prefs.edit().putBoolean(checkedChannel, true).apply();
}
}
}
Expand Down Expand Up @@ -217,7 +224,7 @@ protected String doInBackground(Void... arg0) {
if (jsonStrDefObj.has("capabilities")) {
Log.d("Preferences", "jsonStrDef: " + jsonStrDef);
// store all definitions stuff in a shared preference
getApplicationContext().getSharedPreferences(Tools.JSON_CHANNEL_PREFS, Activity.MODE_PRIVATE).edit().putString(Tools.JSON_DEFINITIONS, jsonStrDef).commit();
getApplicationContext().getSharedPreferences(Tools.JSON_CHANNEL_PREFS, Activity.MODE_PRIVATE).edit().putString(Tools.JSON_DEFINITIONS, jsonStrDef).apply();
}
} catch (JSONException e) {
JSONFehler = true;
Expand Down Expand Up @@ -270,7 +277,7 @@ else if (sharedPref.getString("sortChannelMode", "off").equals("groups")) {
else if (sharedPref.getString("sortChannelMode", "off").equals("plain")) {
jsonStr = Tools.sortJSONChannels(jsonStrObj, Tools.TAG_ENTITIES, "plain").toString().replace("\\", "").replace("\"[", "[").replace("]\"","]"); //not sure why the quotes are escaped after put, so remove escaped quotes a.s.o.
}
getApplicationContext().getSharedPreferences(Tools.JSON_CHANNEL_PREFS, Activity.MODE_PRIVATE).edit().putString(Tools.JSON_CHANNELS, jsonStr).commit();
getApplicationContext().getSharedPreferences(Tools.JSON_CHANNEL_PREFS, Activity.MODE_PRIVATE).edit().putString(Tools.JSON_CHANNELS, jsonStr).apply();
}
return null;
}
Expand All @@ -293,7 +300,7 @@ protected void onPostExecute(String result) {
new AlertDialog.Builder(Preferences.this).setTitle(getString(R.string.Error)).setMessage(fehlerAusgabe2).setNeutralButton(getString(R.string.Close), null).show();
}
} else {
addPreferenceChannels(allCheckedChannels);
addPreferenceChannels();
}
}
}
Expand Down
Loading

0 comments on commit 9514380

Please sign in to comment.