Skip to content

Commit

Permalink
v0.1.138
Browse files Browse the repository at this point in the history
- #41 App Crashes when removing GeoFence Location
- #33 Check Domoticz for updates on boot (and in show in settings
screen)
- #17 Configure Radius for Geofences
- #11 GPS not stopped when losing focus while in the Geofence screen
  • Loading branch information
galadril committed Nov 24, 2015
1 parent caf4e10 commit 909c47d
Show file tree
Hide file tree
Showing 22 changed files with 301 additions and 92 deletions.
9 changes: 9 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId 'nl.hnogames.domoticz'
minSdkVersion 17
targetSdkVersion 23
versionCode 19
versionName '0.1.136'
versionCode 21
versionName '0.1.138'
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public View getView(int position, View convertView, ViewGroup parent) {

holder.enable = (CheckBox) convertView.findViewById(R.id.enableSwitch);
holder.name = (TextView) convertView.findViewById(R.id.location_name);
holder.radius = (TextView) convertView.findViewById(R.id.location_radius);
holder.longitude = (TextView) convertView.findViewById(R.id.location_longitude);
holder.latitude = (TextView) convertView.findViewById(R.id.location_latitude);
holder.connectedSwitch = (TextView) convertView.findViewById(R.id.location_connectedswitch);
Expand All @@ -81,6 +82,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder.name.setText(mLocationInfo.getName());
holder.latitude.setText(context.getString(R.string.latitude) + ": " + mLocationInfo.getLocation().latitude);
holder.longitude.setText(context.getString(R.string.longitude) + ": " + mLocationInfo.getLocation().longitude);
holder.radius.setText(context.getString(R.string.radius) + ": " + mLocationInfo.getRange());

if(mLocationInfo.getSwitchidx()>0)
holder.connectedSwitch.setText(context.getString(R.string.connectedswitch) + ": " + mLocationInfo.getSwitchidx());
Expand Down Expand Up @@ -125,6 +127,7 @@ private void handleEnableChanged(LocationInfo location, boolean enabled) {
static class ViewHolder {
TextView name;
TextView latitude;
TextView radius;
TextView longitude;
TextView connectedSwitch;
CheckBox enable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class LocationInfo {
boolean enabled = false;


public LocationInfo(int i, String n, LatLng l) {
public LocationInfo(int i, String n, LatLng l, int radius) {
this.Name = n;
this.Location = l;
this.id = i;
Expand Down
43 changes: 31 additions & 12 deletions app/src/main/java/nl/hnogames/domoticz/Domoticz/Domoticz.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import nl.hnogames.domoticz.Interfaces.SwitchTimerReceiver;
import nl.hnogames.domoticz.Interfaces.SwitchesReceiver;
import nl.hnogames.domoticz.Interfaces.TemperatureReceiver;
import nl.hnogames.domoticz.Interfaces.UpdateReceiver;
import nl.hnogames.domoticz.Interfaces.UtilitiesReceiver;
import nl.hnogames.domoticz.Interfaces.VersionReceiver;
import nl.hnogames.domoticz.Interfaces.WeatherReceiver;
Expand Down Expand Up @@ -301,6 +302,10 @@ private String getJsonGetUrl(int jsonGetUrl) {
url = Url.Category.SWITCHTIMER;
break;

case Json.Url.Request.UPDATE:
url = Url.System.UPDATE;
break;

default:
throw new NullPointerException("getJsonGetUrl: No known JSON URL specified");
}
Expand Down Expand Up @@ -513,10 +518,19 @@ public void getVersion(VersionReceiver receiver) {
url);
}

public void getUpdate(UpdateReceiver receiver) {
UpdateParser parser = new UpdateParser(receiver);
String url = constructGetUrl(Json.Url.Request.UPDATE);
RequestUtil.makeJsonGetRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url);
}

public void getScenes(ScenesReceiver receiver) {
ScenesParser parser = new ScenesParser(receiver);
String url = constructGetUrl(Json.Url.Request.SCENES);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -526,7 +540,7 @@ public void getScenes(ScenesReceiver receiver) {
public void getPlans(PlansReceiver receiver) {
PlanParser parser = new PlanParser(receiver);
String url = constructGetUrl(Json.Url.Request.PLANS);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -537,7 +551,7 @@ public void getCameras(CameraReceiver receiver) {
CameraParser parser = new CameraParser(receiver);
String url = constructGetUrl(Json.Url.Request.CAMERAS);

RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -547,7 +561,7 @@ public void getCameras(CameraReceiver receiver) {
public void getSwitches(SwitchesReceiver switchesReceiver) {
SwitchesParser parser = new SwitchesParser(switchesReceiver);
String url = constructGetUrl(Json.Url.Request.SWITCHES);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -559,7 +573,7 @@ public void getSwitchLogs(int idx, SwitchLogReceiver switchesReceiver) {
logger("for idx: " + String.valueOf(idx));
String url = constructGetUrl(Json.Url.Request.SWITCHLOG) + String.valueOf(idx);
;
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -571,7 +585,7 @@ public void getSwitchTimers(int idx, SwitchTimerReceiver switchesReceiver) {
logger("for idx: " + String.valueOf(idx));
String url = constructGetUrl(Json.Url.Request.SWITCHTIMER) + String.valueOf(idx);
;
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -597,7 +611,7 @@ public void getStatus(int idx, StatusReceiver receiver) {
String url = constructGetUrl(Json.Get.STATUS) + String.valueOf(idx);
logger("for idx: " + String.valueOf(idx));

RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -607,7 +621,7 @@ public void getStatus(int idx, StatusReceiver receiver) {
public void getUtilities(UtilitiesReceiver receiver) {
UtilitiesParser parser = new UtilitiesParser(receiver);
String url = constructGetUrl(Json.Url.Request.UTILITIES);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -617,7 +631,7 @@ public void getUtilities(UtilitiesReceiver receiver) {
public void getTemperatures(TemperatureReceiver receiver) {
TemperaturesParser parser = new TemperaturesParser(receiver);
String url = constructGetUrl(Json.Url.Request.TEMPERATURE);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -627,7 +641,7 @@ public void getTemperatures(TemperatureReceiver receiver) {
public void getWeathers(WeatherReceiver receiver) {
WeatherParser parser = new WeatherParser(receiver);
String url = constructGetUrl(Json.Url.Request.WEATHER);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -641,7 +655,7 @@ public void getDevices(DevicesReceiver receiver, int plan) {
if (plan > 0)
url += "&plan=" + plan;

RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand All @@ -651,7 +665,7 @@ public void getDevices(DevicesReceiver receiver, int plan) {
public void getLogs(LogsReceiver receiver) {
LogsParser parser = new LogsParser(receiver);
String url = constructGetUrl(Json.Url.Request.LOG);
RequestUtil.makeJsonGetRequest(parser,
RequestUtil.makeJsonGetResultRequest(parser,
getUserCredentials(Authentication.USERNAME),
getUserCredentials(Authentication.PASSWORD),
url,
Expand Down Expand Up @@ -856,6 +870,7 @@ interface Request {
int LOG = 13;
int SWITCHLOG = 14;
int SWITCHTIMER = 15;
int UPDATE = 16;
}

interface Set {
Expand Down Expand Up @@ -956,6 +971,10 @@ interface Log {
interface Security {
String GET = "/json.htm?type=command&param=getsecstatus";
}

interface System {
String UPDATE = "/json.htm?type=command&param=checkforupdate&forced=true";
}
}

private interface FavoriteAction {
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/nl/hnogames/domoticz/Domoticz/UpdateParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package nl.hnogames.domoticz.Domoticz;

import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import nl.hnogames.domoticz.Interfaces.JSONParserInterface;
import nl.hnogames.domoticz.Interfaces.UpdateReceiver;
import nl.hnogames.domoticz.Interfaces.VersionReceiver;

public class UpdateParser implements JSONParserInterface {

private static final String TAG = UpdateParser.class.getSimpleName();
private UpdateReceiver receiver;

public UpdateParser(UpdateReceiver receiver) {
this.receiver = receiver;
}

@Override
public void parseResult(String result) {
try {
JSONObject response = new JSONObject(result);
String version = "";
if(response.has("revision"))
version= response.getString("revision");
if(response.has("HaveUpdate") && !response.getBoolean("HaveUpdate"))
version= "";

receiver.onReceiveUpdate(version);
} catch (JSONException e) {
e.printStackTrace();
}
}

@Override
public void onError(Exception error) {
Log.e(TAG, "VersionParser of JSONParserInterface exception");
receiver.onError(error);
}
}
14 changes: 9 additions & 5 deletions app/src/main/java/nl/hnogames/domoticz/Fragments/Preference.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,24 @@ private void setVersionInfo() {
domoticz.getVersion(new VersionReceiver() {
@Override
public void onReceiveVersion(String version) {
domoticzversion.setSummary(version);
try {
String sVersion = version;
String sUpdateVersion = mSharedPrefs.getUpdateAvailable();
if (sUpdateVersion != null && sUpdateVersion.length() > 0)
sVersion += " " + getString(R.string.update_available) + ": " + sUpdateVersion;

domoticzversion.setSummary(sVersion);
}
catch(Exception ex){}
}

@Override
public void onError(Exception error) {}
});
}

private void setStartUpScreenDefaultValue() {

int defaultValue = mSharedPrefs.getStartupScreenIndex();

ListPreference startup_screen = (ListPreference) findPreference("startup_screen");
startup_screen.setValueIndex(defaultValue);

}
}
29 changes: 0 additions & 29 deletions app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,8 @@ public void getLocation(String usedLocationService) {
return;
}
//locationManager.requestLocationUpdates(usedLocationService, 0, 0, this);

Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
setMarker(new LatLng(location.getLatitude(), location.getLongitude()));

}

private void setMarker(LatLng currentLatLng) {
Expand Down Expand Up @@ -332,7 +330,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}


public void showAddLocationDialog() {
LocationDialog infoDialog = new LocationDialog(
this,
Expand Down Expand Up @@ -368,27 +365,6 @@ public void onDismissEmpty() {
});
infoDialog.show();
}
/*
@Override
public void onLocationChanged(Location location) {
Log.d("Location Found", location.getLatitude() + " " + location.getLongitude());
}
@Override
public void onProviderDisabled(String provider) {
Log.d(TAG, "Disabled: " + provider);
}
@Override
public void onProviderEnabled(String provider) {
Log.d(TAG, "Enabled: " + provider);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d(TAG, "Status: " + status);
}
*/

/**
* Checks if Google Play services is available.
Expand Down Expand Up @@ -424,11 +400,6 @@ public void onConnected(Bundle bundle) {

public void setGeoFenceService() {
if (mGeofenceList != null && mGeofenceList.size() > 0) {
/*LocationServices.GeofencingApi.removeGeofences(
mApiClient,
getGeofenceTransitionPendingIntent()
);*/

mGeofenceRequestIntent = getGeofenceTransitionPendingIntent();
LocationServices.GeofencingApi
.addGeofences(mApiClient, mGeofenceList, mGeofenceRequestIntent);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package nl.hnogames.domoticz.Interfaces;

public interface UpdateReceiver {

void onReceiveUpdate(String version);
void onError(Exception error);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public interface VersionReceiver {

void onReceiveVersion(String version);

void onError(Exception error);

}
Loading

0 comments on commit 909c47d

Please sign in to comment.