diff --git a/app/app.iml b/app/app.iml index b5d4ef63e..c2a75c9d5 100644 --- a/app/app.iml +++ b/app/app.iml @@ -32,12 +32,14 @@ + + @@ -81,7 +83,7 @@ - + @@ -92,10 +94,12 @@ + + @@ -107,11 +111,11 @@ - - - + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 0a3e5bea5..810e5dcaa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.supla.android" minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) - versionCode 8 - versionName "1.1" + versionCode 15 + versionName "1.2.1" sourceSets.main { jniLibs.srcDir 'src/main/libs' @@ -31,7 +31,7 @@ android { abi { enable true reset() - include 'x86', 'armeabi', 'armeabi-v7a' + include 'armeabi-v7a', 'x86', 'armeabi' universalApk true } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 48bb33887..f2f391c8b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ + = MIN_UPDATE_DELAY ) { - channelDataToViews(null); + channelDataToViews(); } else { diff --git a/app/src/main/java/org/supla/android/MainActivity.java b/app/src/main/java/org/supla/android/MainActivity.java index 8e2c847d6..76294130c 100644 --- a/app/src/main/java/org/supla/android/MainActivity.java +++ b/app/src/main/java/org/supla/android/MainActivity.java @@ -21,9 +21,11 @@ of the License, or (at your option) any later version. import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.content.Context; import android.graphics.Typeface; import android.os.Handler; import android.os.Bundle; +import android.os.Vibrator; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; @@ -129,6 +131,10 @@ protected void onResume() { cLV.hideDetail(false); + + RateApp ra = new RateApp(this); + ra.showDialog(1000); + } @Override @@ -145,7 +151,7 @@ protected void OnDataChangedMsg(int ChannelId) { Channel c = cLV.detail_getChannel(); if ( c != null && !c.getOnLine() ) - cLV.hideDetail(true); + cLV.hideDetail(false); else cLV.detail_OnChannelDataChanged(); @@ -305,6 +311,19 @@ public void onChannelButtonTouch(boolean left, boolean up, int channelId, int ch if ( client == null ) return; + + if ( !up + || channelFunc == SuplaConst.SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER ) { + + + Vibrator v = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE); + + if ( v != null ) + v.vibrate(100); + + } + + if ( up ) { if ( channelFunc == SuplaConst.SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER ) @@ -347,4 +366,6 @@ public void onChannelDetailShow() { public void onChannelDetailHide() { showMenuButton(); } + } + diff --git a/app/src/main/java/org/supla/android/RateApp.java b/app/src/main/java/org/supla/android/RateApp.java new file mode 100644 index 000000000..4cb03bd75 --- /dev/null +++ b/app/src/main/java/org/supla/android/RateApp.java @@ -0,0 +1,144 @@ +package org.supla.android; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.view.Window; +import org.supla.android.db.DbHelper; + +import java.util.Date; + + +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Author: Przemyslaw Zygmunt przemek@supla.org + */ + +public class RateApp { + + private final String PN_RATE_TIME = "rate_time"; + private Context context; + + private void moreTime(int days) { + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + Date now = new Date(); + long rt = new Date(now.getTime() + (days * 0x5265C00)).getTime(); + + SharedPreferences.Editor editor = prefs.edit(); + editor.putLong(PN_RATE_TIME, rt); + editor.commit(); + + } + + + RateApp(Context context) { + this.context = context; + } + + private void ShowAlertDialog() { + + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setMessage(R.string.rate_msg); + builder.setPositiveButton(R.string.rate_now, + + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=org.supla.android"))); + + moreTime(36500); + dialog.cancel(); + + } + }); + + builder.setNeutralButton(R.string.rate_later, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + moreTime(6); + dialog.cancel(); + + } + }); + + builder.setNegativeButton(R.string.rate_no_thanks, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + moreTime(36500); + dialog.cancel(); + + } + }); + + AlertDialog alert = builder.create(); + alert.requestWindowFeature(Window.FEATURE_NO_TITLE); + alert.show(); + } + + boolean showDialog(int delay) { + + boolean result = false; + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + long rt = prefs.getLong(PN_RATE_TIME, Long.valueOf(0)); + + Date now = new Date(); + + if ( rt == 0 ) { + + moreTime(1); + + } else if ( now.getTime() >= rt ) { + + DbHelper DbH = new DbHelper(context); + if ( DbH.getChannelCount() > 0 ) { + + moreTime(1); + + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + public void run() { + + ShowAlertDialog(); + + } + }, delay); + + result = true; + + } + + + } + + + return result; + + + } + + +} + + diff --git a/app/src/main/java/org/supla/android/StatusActivity.java b/app/src/main/java/org/supla/android/StatusActivity.java index 9431d0818..ca3cdfe74 100644 --- a/app/src/main/java/org/supla/android/StatusActivity.java +++ b/app/src/main/java/org/supla/android/StatusActivity.java @@ -34,6 +34,7 @@ of the License, or (at your option) any later version. import org.supla.android.lib.SuplaClient; import org.supla.android.lib.SuplaClientMsg; +import org.supla.android.lib.SuplaConnError; import org.supla.android.lib.SuplaConst; import org.supla.android.lib.SuplaRegisterError; import org.supla.android.lib.SuplaRegisterResult; @@ -230,6 +231,12 @@ protected void OnVersionErrorMsg(SuplaVersionError error) { setStatusError(getResources().getString(R.string.status_version_error)); }; + @Override + protected void OnConnErrorMsg(SuplaConnError error) { + if ( error.Code == SuplaConst.SUPLA_RESULTCODE_HOSTNOTFOUND ) + setStatusError(getResources().getString(R.string.err_hostnotfound)); + }; + @Override public void onBackPressed() { gotoMain(); diff --git a/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java b/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java index 8b8a2046c..cdecdde2a 100644 --- a/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java +++ b/app/src/main/java/org/supla/android/SuplaColorBrightnessPicker.java @@ -30,7 +30,7 @@ of the License, or (at your option) any later version. Author: Przemyslaw Zygmunt przemek@supla.org - Code fragments based on: + Fragments of code based on: https://github.com/chiralcode/Android-Color-Picker/blob/master/src/com/chiralcode/colorpicker/ColorPicker.java https://github.com/LarsWerkman/HoloColorPicker/blob/master/libary/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java @@ -581,8 +581,7 @@ public void setColor(int color) { selectedColor = calculateColor((float)outerWheelPointerAngle, Colors); setBWcolor(); - - invalidate(); + setBrightnessValue(selectedBrightness); } } @@ -675,25 +674,24 @@ public void setBrightnessValue(double value) { else if ( value > 100 ) value = 100; - if ( selectedBrightness != value ) { - if ( value == 100 ) { - innerWheelPointerAngle = m90_01d; - } else { + if ( value == 100 ) { + innerWheelPointerAngle = m90_01d; + } else { - double a = 360*value/100; + double a = 360*value/100; - if ( a > 180 ) - a-=360; + if ( a > 180 ) + a-=360; - innerWheelPointerAngle = Math.toRadians(a)+m90d; - } + innerWheelPointerAngle = Math.toRadians(a)+m90d; + } - selectedBrightnessColor = calculateColor((float)(innerWheelPointerAngle-m90d), BW); - selectedBrightness = value; - invalidate(); - } + selectedBrightnessColor = calculateColor((float)(innerWheelPointerAngle-m90d), BW); + selectedBrightness = value; + invalidate(); + } diff --git a/app/src/main/java/org/supla/android/Trace.java b/app/src/main/java/org/supla/android/Trace.java index c63d8bd5d..f18d77e0f 100644 --- a/app/src/main/java/org/supla/android/Trace.java +++ b/app/src/main/java/org/supla/android/Trace.java @@ -10,7 +10,7 @@ public class Trace public static final int ERRORS_WARNINGS_INFO = 3; public static final int ERRORS_WARNINGS_INFO_DEBUG = 4; - private static final int LOGGING_LEVEL = ERRORS_ONLY; // Errors + warnings + info + debug (default) + private static final int LOGGING_LEVEL = ERRORS_ONLY; //ERRORS_WARNINGS_INFO_DEBUG; public static void e(String tag, String msg) { diff --git a/app/src/main/java/org/supla/android/db/Channel.java b/app/src/main/java/org/supla/android/db/Channel.java index 42a43fd11..9e82e4f9d 100644 --- a/app/src/main/java/org/supla/android/db/Channel.java +++ b/app/src/main/java/org/supla/android/db/Channel.java @@ -135,6 +135,12 @@ private String getCaption(Context context) { case SuplaConst.SUPLA_CHANNELFNC_DIMMERANDRGBLIGHTING: idx = R.string.channel_func_dimmerandrgblighting; break; + case SuplaConst.SUPLA_CHANNELFNC_DEPTHSENSOR: + idx = R.string.channel_func_depthsensor; + break; + case SuplaConst.SUPLA_CHANNELFNC_DISTANCESENSOR: + idx = R.string.channel_func_distancesensor; + break; } @@ -255,6 +261,29 @@ public ContentValues getContentValues() { return values; } + public double getDouble(double unknown) { + + byte[] t = Value.getChannelValue(); + + if ( t.length > 0 ) { + + byte b; + int l = t.length; + int hl = l/2; + + for(int a=0;a 0 ) { - - byte b; - int l = t.length; - int hl = l/2; - - for(int a=0;a 0 ? true : false; } + public int getChannelCount() { + + String selection = "SELECT count(*) FROM " + SuplaContract.ChannelEntry.TABLE_NAME + + " WHERE " + SuplaContract.ChannelEntry.COLUMN_NAME_LOCATIONID + + " IN ( SELECT "+SuplaContract.LocationEntry._ID+" FROM "+SuplaContract.LocationEntry.TABLE_NAME+" WHERE "+SuplaContract.LocationEntry.COLUMN_NAME_ACCESSID+" = ? )"; + + int count = 0; + long accessid = getCurrentAccessId(); + + SQLiteDatabase db = getReadableDatabase(); + Cursor c = db.rawQuery(selection, new String[] {String.valueOf(accessid)}); + c.moveToFirst(); + count = c.getInt(0); + c.close(); + db.close(); + + return count; + + } + public Cursor getChannelListCursor() { diff --git a/app/src/main/java/org/supla/android/lib/SuplaClient.java b/app/src/main/java/org/supla/android/lib/SuplaClient.java index 4b643c9ea..e60cdb6bb 100644 --- a/app/src/main/java/org/supla/android/lib/SuplaClient.java +++ b/app/src/main/java/org/supla/android/lib/SuplaClient.java @@ -134,6 +134,8 @@ private boolean Connect() { return result; } + + public void Reconnect() { if ( Connected() ) Disconnect(); } @@ -205,6 +207,8 @@ private void onVersionError(SuplaVersionError versionError) { SuplaClientMsg msg = new SuplaClientMsg(this, SuplaClientMsg.onVersionError); msg.setVersionError(versionError); sendMessage(msg); + + cancel(); } private void onConnecting() { @@ -213,6 +217,19 @@ private void onConnecting() { sendMessage(new SuplaClientMsg(this, SuplaClientMsg.onConnecting)); } + private void onConnError(SuplaConnError connError) { + + Trace.d(log_tag, connError.codeToString(_context)); + + SuplaClientMsg msg = new SuplaClientMsg(this, SuplaClientMsg.onConnError); + msg.setConnError(connError); + sendMessage(msg); + + if ( connError.Code == SuplaConst.SUPLA_RESULTCODE_HOSTNOTFOUND ) { + cancel(); + } + } + private void onConnected() { Trace.d(log_tag, "Connected"); @@ -298,7 +315,7 @@ private void ChannelValueUpdate(SuplaChannelValueUpdate channelValueUpdate) { if ( DbH.updateChannelValue(channelValueUpdate) ) { Trace.d(log_tag, "Channel id"+Integer.toString(channelValueUpdate.Id)+" value updated"); - onDataChanged(); + onDataChanged(channelValueUpdate.Id); } } diff --git a/app/src/main/java/org/supla/android/lib/SuplaClientMsg.java b/app/src/main/java/org/supla/android/lib/SuplaClientMsg.java index de1785bb7..0a22c1450 100644 --- a/app/src/main/java/org/supla/android/lib/SuplaClientMsg.java +++ b/app/src/main/java/org/supla/android/lib/SuplaClientMsg.java @@ -25,6 +25,7 @@ public class SuplaClientMsg { private SuplaVersionError VersionError; private SuplaRegisterResult RegisterResult; private SuplaRegisterError RegisterError; + private SuplaConnError ConnError; private SuplaEvent Event; private int ChannelId; @@ -37,6 +38,7 @@ public class SuplaClientMsg { public final static int onConnected = 7; public final static int onVersionError = 8; public final static int onEvent = 9; + public final static int onConnError = 10; public SuplaClientMsg(SuplaClient sender, int type) { Type = type; @@ -76,6 +78,14 @@ public void setRegisterError(SuplaRegisterError registerError) { RegisterError = registerError; } + public SuplaConnError getConnError() { + return ConnError; + } + + public void setConnError(SuplaConnError connError) { + ConnError = connError; + } + public SuplaEvent getEvent() { return Event; } diff --git a/app/src/main/java/org/supla/android/lib/SuplaConnError.java b/app/src/main/java/org/supla/android/lib/SuplaConnError.java new file mode 100644 index 000000000..a84b9dbdb --- /dev/null +++ b/app/src/main/java/org/supla/android/lib/SuplaConnError.java @@ -0,0 +1,48 @@ +package org.supla.android.lib; + +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Author: Przemyslaw Zygmunt p.zygmunt@acsoftware.pl [AC SOFTWARE] + */ + +import android.content.Context; + +import org.supla.android.R; + +public class SuplaConnError { + + public int Code; + + public String codeToString(Context context) { + + int resid = 0; + + switch(Code) { + + case SuplaConst.SUPLA_RESULTCODE_HOSTNOTFOUND: + resid = R.string.err_hostnotfound; + break; + + case SuplaConst.SUPLA_RESULTCODE_CANTCONNECTTOHOST: + resid = R.string.err_cantconnecttohost; + break; + + } + + return resid != 0 ? context.getResources().getString(resid) : new Integer(Code).toString(); + } + +} diff --git a/app/src/main/java/org/supla/android/lib/SuplaConst.java b/app/src/main/java/org/supla/android/lib/SuplaConst.java index f17769c33..db0f3446b 100644 --- a/app/src/main/java/org/supla/android/lib/SuplaConst.java +++ b/app/src/main/java/org/supla/android/lib/SuplaConst.java @@ -40,7 +40,8 @@ public class SuplaConst { public final static int SUPLA_RESULTCODE_CLIENT_LIMITEXCEEDED = 12; public final static int SUPLA_RESULTCODE_DEVICE_LIMITEXCEEDED = 13; public final static int SUPLA_RESULTCODE_GUID_ERROR = 14; - + public final static int SUPLA_RESULTCODE_HOSTNOTFOUND = 15; + public final static int SUPLA_RESULTCODE_CANTCONNECTTOHOST = 16; public final static int SUPLA_CHANNELFNC_NONE = 0; public final static int SUPLA_CHANNELFNC_CONTROLLINGTHEGATEWAYLOCK = 10; @@ -65,6 +66,8 @@ public class SuplaConst { public final static int SUPLA_CHANNELFNC_DIMMER = 180; public final static int SUPLA_CHANNELFNC_RGBLIGHTING = 190; public final static int SUPLA_CHANNELFNC_DIMMERANDRGBLIGHTING = 200; + public final static int SUPLA_CHANNELFNC_DEPTHSENSOR = 210; + public final static int SUPLA_CHANNELFNC_DISTANCESENSOR = 220; public final static int SUPLA_EVENT_CONTROLLINGTHEGATEWAYLOCK = 10; public final static int SUPLA_EVENT_CONTROLLINGTHEGATE = 20; diff --git a/app/src/main/java/org/supla/android/listview/ChannelLayout.java b/app/src/main/java/org/supla/android/listview/ChannelLayout.java index e8f8ed02e..15b801c29 100644 --- a/app/src/main/java/org/supla/android/listview/ChannelLayout.java +++ b/app/src/main/java/org/supla/android/listview/ChannelLayout.java @@ -15,7 +15,7 @@ of the License, or (at your option) any later version. along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Author: Przemyslaw Zygmunt p.zygmunt@acsoftware.pl [AC SOFTWARE] + Author: Przemyslaw Zygmunt przemek@supla.org */ @@ -242,6 +242,13 @@ public static int getImageIdx(int StateUp, int func, int img) { break; + case SuplaConst.SUPLA_CHANNELFNC_DEPTHSENSOR: + img_idx = R.drawable.depthsensor; + break; + + case SuplaConst.SUPLA_CHANNELFNC_DISTANCESENSOR: + img_idx = R.drawable.distancesensor; + break; } return img_idx; @@ -297,10 +304,11 @@ private TextView newTextView(Context context) { return Text; } - private void SetTextDimensions(TextView Text, ImageView Img, Boolean visible) { + private void SetTextDimensions(TextView Text, ImageView Img, Boolean visible, int width, int height) { - RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( - getResources().getDimensionPixelSize(R.dimen.channel_imgtext_width), getResources().getDimensionPixelSize(R.dimen.channel_imgtext_height)); + Text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); + + RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, height); lp.addRule(RelativeLayout.RIGHT_OF, Img.getId()); @@ -309,10 +317,16 @@ private void SetTextDimensions(TextView Text, ImageView Img, Boolean visible) { } - private void SetImgDimensions(ImageView Img, Boolean img2, int leftMargin) { + private void SetTextDimensions(TextView Text, ImageView Img, Boolean visible) { + + SetTextDimensions(Text, Img, visible, getResources().getDimensionPixelSize(R.dimen.channel_imgtext_width), getResources().getDimensionPixelSize(R.dimen.channel_imgtext_height)); + + } + + private void SetImgDimensions(ImageView Img, Boolean img2, int leftMargin, int width, int height) { RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( - getResources().getDimensionPixelSize(R.dimen.channel_img_width), getResources().getDimensionPixelSize(R.dimen.channel_img_height)); + width, height); if ( img2 == false ) { @@ -328,14 +342,26 @@ private void SetImgDimensions(ImageView Img, Boolean img2, int leftMargin) { } + private void SetImgDimensions(ImageView Img, Boolean img2, int leftMargin) { + SetImgDimensions(Img, img2, leftMargin, getResources().getDimensionPixelSize(R.dimen.channel_img_width), getResources().getDimensionPixelSize(R.dimen.channel_img_height)); + } + private void SetDimensions() { int width = getResources().getDimensionPixelSize(R.dimen.channel_img_width); if ( Func == SuplaConst.SUPLA_CHANNELFNC_THERMOMETER ) { + width*=2.5; + } else if ( Func == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE ) { + width*=4.3; + } else if ( Func == SuplaConst.SUPLA_CHANNELFNC_DEPTHSENSOR + || Func == SuplaConst.SUPLA_CHANNELFNC_DISTANCESENSOR ) { + + width*=2.8; + } RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( @@ -347,13 +373,45 @@ private void SetDimensions() { setLayoutParams(lp); - SetImgDimensions(Img1, false, Func == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE ? getResources().getDimensionPixelSize(R.dimen.channel_img_left_margin) : 0); - SetImgDimensions(Img2, true, 0); - SetTextDimensions(Text1, Img1, Func == SuplaConst.SUPLA_CHANNELFNC_THERMOMETER - || Func == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE); + if ( Func == SuplaConst.SUPLA_CHANNELFNC_DISTANCESENSOR ) { + + RelativeLayout.LayoutParams _lp = new RelativeLayout.LayoutParams( + getResources().getDimensionPixelSize(R.dimen.channel_distanceimg_width), getResources().getDimensionPixelSize(R.dimen.channel_distanceimg_height)); + + _lp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + _lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + + Img1.setLayoutParams(_lp); + Img1.setVisibility(View.VISIBLE); + + + _lp = new RelativeLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.channel_distanceimgtext_width), getResources().getDimensionPixelSize(R.dimen.channel_distanceimgtext_height)); + + _lp.addRule(RelativeLayout.ABOVE, Img1.getId()); + _lp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); + + Text1.setLayoutParams(_lp); + Text1.setVisibility(View.VISIBLE); + Text1.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); + + + } else if ( Func == SuplaConst.SUPLA_CHANNELFNC_DEPTHSENSOR ) { + + SetImgDimensions(Img1, false, 0); + SetTextDimensions(Text1, Img1, true, getResources().getDimensionPixelSize(R.dimen.channel_depthimgtext_width), getResources().getDimensionPixelSize(R.dimen.channel_depthimgtext_height)); + } else { + + SetImgDimensions(Img1, false, Func == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE ? getResources().getDimensionPixelSize(R.dimen.channel_img_left_margin) : 0); + SetTextDimensions(Text1, Img1, Func == SuplaConst.SUPLA_CHANNELFNC_THERMOMETER + || Func == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE); + + } + + + SetImgDimensions(Img2, true, 0); SetTextDimensions(Text2, Img2, Func == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE); } @@ -869,14 +927,15 @@ public void setChannelData(Channel channel) { caption_text.setText(channel.getNotEmptyCaption(getContext())); if ( channel.getFunc() == SuplaConst.SUPLA_CHANNELFNC_THERMOMETER ) { + if ( channel.getOnLine() && channel.getTemp() >= -273 ) imgl.setText1(String.format("%.1f", channel.getTemp())+ (char) 0x00B0); else imgl.setText1("---"); - } - if ( channel.getFunc() == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE ) { + } else if ( channel.getFunc() == SuplaConst.SUPLA_CHANNELFNC_HUMIDITYANDTEMPERATURE ) { + if ( channel.getOnLine() && channel.getTemp() >= -273 ) imgl.setText1(String.format("%.1f", channel.getTemp()) + (char) 0x00B0); @@ -888,6 +947,41 @@ public void setChannelData(Channel channel) { imgl.setText2(String.format("%.1f", channel.getHumidity())); else imgl.setText2("---"); + + } else if ( channel.getFunc() == SuplaConst.SUPLA_CHANNELFNC_DISTANCESENSOR + || channel.getFunc() == SuplaConst.SUPLA_CHANNELFNC_DEPTHSENSOR ) { + + if ( channel.getOnLine() + && channel.getDistance() > -1 ) { + + double distance = channel.getDistance(); + + if ( distance >= 1000 ) { + + imgl.setText1(String.format("%.2f km", distance/1000.00)); + + } else if ( distance >= 1 ) { + + imgl.setText1(String.format("%.2f m", distance)); + + } else { + distance *= 100; + + if ( distance >= 1 ) { + imgl.setText1(String.format("%.1f cm", distance)); + } else { + distance *= 10; + + imgl.setText1(String.format("%i mm", (int)distance)); + } + } + + + } else { + imgl.setText1("--- m"); + } + + } } diff --git a/app/src/main/java/org/supla/android/listview/DetailLayout.java b/app/src/main/java/org/supla/android/listview/DetailLayout.java index 0dd7a17d3..ca8c0fcdd 100644 --- a/app/src/main/java/org/supla/android/listview/DetailLayout.java +++ b/app/src/main/java/org/supla/android/listview/DetailLayout.java @@ -85,7 +85,7 @@ protected View inflateLayout(int id) { public abstract View getContentView(); public abstract void OnChannelDataChanged(); public void setData(Channel channel) { - mChannelId = channel.getChannelId(); + mChannelId = channel == null ? 0 : channel.getChannelId(); } @Override diff --git a/app/src/main/libs/armeabi-v7a/libsuplaclient.so b/app/src/main/libs/armeabi-v7a/libsuplaclient.so index 967e7588e..466ea9625 100755 Binary files a/app/src/main/libs/armeabi-v7a/libsuplaclient.so and b/app/src/main/libs/armeabi-v7a/libsuplaclient.so differ diff --git a/app/src/main/libs/armeabi/libsuplaclient.so b/app/src/main/libs/armeabi/libsuplaclient.so index c69ebe296..6d4eea754 100755 Binary files a/app/src/main/libs/armeabi/libsuplaclient.so and b/app/src/main/libs/armeabi/libsuplaclient.so differ diff --git a/app/src/main/libs/x86/libsuplaclient.so b/app/src/main/libs/x86/libsuplaclient.so index 7cc4bda03..b13673263 100755 Binary files a/app/src/main/libs/x86/libsuplaclient.so and b/app/src/main/libs/x86/libsuplaclient.so differ diff --git a/app/src/main/res/drawable/depthsensor.png b/app/src/main/res/drawable/depthsensor.png new file mode 100644 index 000000000..a6160ee30 Binary files /dev/null and b/app/src/main/res/drawable/depthsensor.png differ diff --git a/app/src/main/res/drawable/distancesensor.png b/app/src/main/res/drawable/distancesensor.png new file mode 100644 index 000000000..9503d65f0 Binary files /dev/null and b/app/src/main/res/drawable/distancesensor.png differ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 9b3d731fb..f258ec14b 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -16,6 +16,9 @@ Zugriff deaktiviert Nicht kompatible Server-Version + Host nicht gefunden + Kann nicht Host verbinden + Pforte Tor Garagentor @@ -35,6 +38,8 @@ Garagentor-Öffnungssensor Tür-Öffnungssensor Rolladen-Öffnungssensor + Tiefensensor + Abstandssensor Helligkeit Farbe @@ -70,4 +75,10 @@ Sie sollten eine Kopie der GNU General Public License zusammen mit diesem Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + + Wenn Ihnen diese App gefällt, bewerten Sie sie bitte. Vielen Dank dafür! + Bewerten + Später + Nein danke + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 66bc97bad..5c13a7a79 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -16,6 +16,9 @@ Dostęp wyłączony Niekompatybilna wersja serwera + Adres serwera nie został znaleziony + Nie można połączyć się z serwerem + Furtka Brama Brama garażowa @@ -35,6 +38,8 @@ Czujnik otwacia bramy garażowej Czujnik otwacia drzwi Czujnik otwacia rolet + Czujnik głębokości + Czujnik odległości Jasność Kolor @@ -77,4 +82,9 @@   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + Jeśli podoba Ci się ta aplikacja to poświęć moment aby ją ocenić. Dziękujemy za Twoje wsparcie!
 + Oceń teraz + 
Później + 
Nie, dziękuję + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bfb1c1ecb..2cd963317 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -16,6 +16,9 @@ Доступ ограничен Несовместимая версия сервера + Хост не найден + Не удается подключиться к хосту + Калитка Ворота Гаражные ворота @@ -35,7 +38,8 @@ Диммер Контроллер освещения RGB Диммер и контроллер освещения RGB - + датчик глубины + датчик расстояния Яркость Цвет @@ -79,5 +83,10 @@ Temple Place - Suite 330, Boston, MA 02111-1307, USA + If you enjoy using this app, please take a moment to rate it. Thanks for your support! + Rate Now + Later + No thanks + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index bd05cbaeb..2de6117d0 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -23,6 +23,12 @@ 50dp 60dp 50dp + 100dp + 50dp + 150dp + 50dp + 150dp + 15dp 35dp 30dp 150dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f8583b59f..ba95ee78b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,6 +23,9 @@ Access disabled Incompatible server version + Host not found + Can\'t connect to host + Gateway Gate Garage door @@ -42,6 +45,8 @@ Garage door opening sensor Door opening sensor Roller shutter opening sensor + Depth sensor + Distance sensor Brightness Color @@ -84,5 +89,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + If you enjoy using this app, please take a moment to rate it. Thanks for your support! + Rate Now + Later + No thanks diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ac5f090e0..b60e3c79d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -11,4 +11,5 @@ 28dp + diff --git a/build.gradle b/build.gradle index 03bced9f3..c20bca142 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e6abc5375..a421daae8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue May 10 09:20:19 CEST 2016 +#Fri Oct 07 13:58:57 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/projectFilesBackup/.idea/workspace.xml b/projectFilesBackup/.idea/workspace.xml new file mode 100644 index 000000000..2b812dedb --- /dev/null +++ b/projectFilesBackup/.idea/workspace.xml @@ -0,0 +1,3877 @@ + + + + + + + + + + + + + + + + + + + @style/AppTheme + + + + + @style/AppTheme + + + + + @android:style/Theme.Light.NoTitleBar + + + + + @android:style/Theme.Holo.Light.NoActionBar.Fullscreen + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + 1445089419191 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file