NFC tag fix
This commit is contained in:
@@ -2,10 +2,13 @@ package com.jens.automation2;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.view.View;
|
||||
@@ -22,6 +25,7 @@ public class ActivityManageActionVibrate extends Activity
|
||||
{
|
||||
TextView etVibratePattern;
|
||||
Button bTestVibratePattern, bSaveVibratePattern;
|
||||
ProgressDialog pdPleaseWait = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
@@ -60,7 +64,20 @@ public class ActivityManageActionVibrate extends Activity
|
||||
if (ActivityPermissions.havePermission(Manifest.permission.VIBRATE, ActivityManageActionVibrate.this))
|
||||
{
|
||||
String pattern = etVibratePattern.getText().toString();
|
||||
Actions.vibrate(false, pattern);
|
||||
|
||||
String[] patternArray = pattern.split(",");
|
||||
long sum = 0;
|
||||
for(String element : patternArray)
|
||||
sum += Long.parseLong(element);
|
||||
|
||||
if(sum <= 2000)
|
||||
Actions.vibrate(false, pattern);
|
||||
else
|
||||
{
|
||||
pdPleaseWait = ProgressDialog.show(ActivityManageActionVibrate.this, null, getResources().getString(R.string.pleaseWait));
|
||||
VibrateTask vt = new VibrateTask();
|
||||
vt.execute(pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,4 +101,22 @@ public class ActivityManageActionVibrate extends Activity
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class VibrateTask extends AsyncTask<String, Void, Void>
|
||||
{
|
||||
@Override
|
||||
protected Void doInBackground(String... strings)
|
||||
{
|
||||
String pattern = (String)strings[0];
|
||||
Actions.vibrate(false, pattern);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused)
|
||||
{
|
||||
pdPleaseWait.dismiss();
|
||||
super.onPostExecute(unused);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class Miscellaneous extends Service
|
||||
else if(method.equals(ActivityManageActionTriggerUrl.methodPost))
|
||||
connection.setRequestMethod("POST");
|
||||
|
||||
if(httpParams.size() > 0)
|
||||
if(httpParams.size() > 0)
|
||||
{
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setDoInput(true);
|
||||
|
||||
@@ -1240,6 +1240,12 @@ public class Trigger
|
||||
|
||||
public boolean hasStateNotAppliedSinceLastRuleExecution()
|
||||
{
|
||||
/*
|
||||
There is no easy event to tell when a tag has been disconnected again.
|
||||
*/
|
||||
if(getTriggerType().equals(Trigger_Enum.nfcTag))
|
||||
return true;
|
||||
|
||||
if(getParentRule().getLastExecution() == null)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Trigger", "Trigger " + this.toString() + " of rule " + getParentRule().getName() + " has NOT applied since the parent rule\'s last activation.", 4);
|
||||
|
||||
@@ -8,10 +8,10 @@ import android.nfc.NdefMessage;
|
||||
import android.nfc.NdefRecord;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.nfc.Tag;
|
||||
import android.nfc.tech.IsoDep;
|
||||
import android.nfc.tech.Ndef;
|
||||
import android.nfc.tech.NdefFormatable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -56,9 +56,9 @@ public class NfcReceiver
|
||||
if(action == null)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "NFC", "action=null", 5);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(action.equals(NfcAdapter.ACTION_NDEF_DISCOVERED))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "NFC", "ACTION_NDEF_DISCOVERED", 4);
|
||||
@@ -275,7 +275,7 @@ public class NfcReceiver
|
||||
{
|
||||
format.connect();
|
||||
format.format(completeMessageToWrite);
|
||||
Miscellaneous.logEvent("i", "NFC", "Done writing tag.", 2);
|
||||
Miscellaneous.logEvent("i", "NFC", "Done writing tag.", 2);
|
||||
return true;
|
||||
}
|
||||
catch(IOException e)
|
||||
|
||||
@@ -969,4 +969,5 @@
|
||||
<string name="close">close</string>
|
||||
<string name="far">far</string>
|
||||
<string name="proximityText">proximity is between \"%1$s\" and \"%2$s\"</string>
|
||||
<string name="pleaseWait">Please wait.</string>
|
||||
</resources>
|
||||
@@ -8,5 +8,7 @@
|
||||
* Fixed: Variable trigger didn't always compare correctly.
|
||||
* Fixed: Permission check for ability to schedule exact timers
|
||||
* Fixed: Crash in Google Play version
|
||||
* Fixed: Added waiting period for vibrations
|
||||
* Fixed: Added waiting period for vibrations and separate thread for trying a sequence.
|
||||
* Fixed: Buttons in NFC screen weren't enabled.
|
||||
* Fixed: NFC tag triggers didn't cause a second execution if a tag was removed and presented again.
|
||||
* Added Possibility to select UI theme, hence enabling modern UI designs
|
||||
Reference in New Issue
Block a user