Skip to content

Commit

Permalink
v.1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawzygmunt committed Nov 4, 2016
1 parent 497a633 commit 738c494
Show file tree
Hide file tree
Showing 32 changed files with 4,388 additions and 80 deletions.
12 changes: 8 additions & 4 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
Expand Down Expand Up @@ -81,7 +83,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/jars" />
Expand All @@ -92,10 +94,12 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
Expand All @@ -107,11 +111,11 @@
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.0" level="project" />
</component>
</module>
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -31,7 +31,7 @@ android {
abi {
enable true
reset()
include 'x86', 'armeabi', 'armeabi-v7a'
include 'armeabi-v7a', 'x86', 'armeabi'
universalApk true
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE"/>

<supports-screens
android:resizeable="true"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/supla/android/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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.SuplaEvent;
import org.supla.android.lib.SuplaRegisterError;
import org.supla.android.lib.SuplaVersionError;
Expand Down Expand Up @@ -158,6 +159,9 @@ public void handleMessage(Message msg) {
case SuplaClientMsg.onEvent:
OnEventMsg(_msg.getEvent());
break;
case SuplaClientMsg.onConnError:
OnConnErrorMsg(_msg.getConnError());
break;
}

}
Expand All @@ -184,4 +188,5 @@ protected void onDestroy() {
protected void OnConnectedMsg() {};
protected void OnVersionErrorMsg(SuplaVersionError error) {};
protected void OnEventMsg(SuplaEvent event) {};
protected void OnConnErrorMsg(SuplaConnError error) {};
}
31 changes: 12 additions & 19 deletions app/src/main/java/org/supla/android/ChannelDetailRGB.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ChannelDetailRGB extends DetailLayout implements View.OnClickListen
int lastBrightness;

final static private long MIN_REMOTE_UPDATE_PERIOD = 250;
final static private long MIN_UPDATE_DELAY = 500;
final static private long MIN_UPDATE_DELAY = 2000;

public ChannelDetailRGB(Context context, ChannelListView cLV) {
super(context, cLV);
Expand Down Expand Up @@ -156,23 +156,21 @@ private void showRGB() {
rgbPicker.setColorBrightnessWheelVisible(true);
setColorVisibility(View.VISIBLE);

channelDataToViews(null);
channelDataToViews();
}

private void showDimmer() {

rgbPicker.setBWBrightnessWheelVisible(true);
setColorVisibility(View.GONE);

channelDataToViews(null);
channelDataToViews();
}

public void setData(Channel channel) {

super.setData(channel);

Trace.d("F", "Func:"+Integer.toString(channel.getFunc()));

switch(channel.getFunc()) {

case SuplaConst.SUPLA_CHANNELFNC_DIMMER:
Expand All @@ -196,26 +194,21 @@ public void setData(Channel channel) {
}


channelDataToViews(channel);
channelDataToViews();
}

private void channelDataToViews(Channel channel) {

if ( channel == null ) {

channel = getChannelFromDatabase();

if ( channel == null )
return;
}
private void channelDataToViews() {

Channel channel = getChannelFromDatabase();

tvTitle.setText(channel.getNotEmptyCaption(getContext()));

if ( rgbPicker.getColorBrightnessWheelVisible() )
if ( rgbPicker.getColorBrightnessWheelVisible()
&& (int)rgbPicker.getBrightnessValue() != (int)channel.getColorBrightness() )
rgbPicker.setBrightnessValue(channel.getColorBrightness());

if ( rgbPicker.getBWBrightnessWheelVisible() )
if ( rgbPicker.getBWBrightnessWheelVisible()
&& (int)rgbPicker.getBrightnessValue() != (int)channel.getBrightness() )
rgbPicker.setBrightnessValue(channel.getBrightness());

if ( rgbPicker.getColorWheelVisible() )
Expand Down Expand Up @@ -337,7 +330,7 @@ public void onClick(View v) {
}

if ( v == tabDimmer || v == tabRGB ) {
channelDataToViews(null);
channelDataToViews();
}

}
Expand Down Expand Up @@ -367,7 +360,7 @@ private void updateDelayed() {

if ( System.currentTimeMillis()-changeFinishedTime >= MIN_UPDATE_DELAY ) {

channelDataToViews(null);
channelDataToViews();

} else {

Expand Down
23 changes: 22 additions & 1 deletion app/src/main/java/org/supla/android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,6 +131,10 @@ protected void onResume() {


cLV.hideDetail(false);

RateApp ra = new RateApp(this);
ra.showDialog(1000);

}

@Override
Expand All @@ -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();

Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -347,4 +366,6 @@ public void onChannelDetailShow() {
public void onChannelDetailHide() {
showMenuButton();
}

}

144 changes: 144 additions & 0 deletions app/src/main/java/org/supla/android/RateApp.java
Original file line number Diff line number Diff line change
@@ -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 [email protected]
*/

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;


}


}


Loading

0 comments on commit 738c494

Please sign in to comment.