Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.8.22-5 #44

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 31
compileSdkVersion 33
defaultConfig {
applicationId "com.csl.cs108ademoapp"
minSdkVersion 19
targetSdkVersion 31
targetSdkVersion 33
versionCode 38
versionName "2.7.0"
versionName "2.8.22"
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':cs108library4a')
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.9.0'
}
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.csl.cs108ademoapp",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 38,
"versionName": "2.8.22",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.NFC" />

<application
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 59 additions & 53 deletions app/src/main/java/com/csl/cs108ademoapp/AccessTask.java

Large diffs are not rendered by default.

65 changes: 33 additions & 32 deletions app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.widget.Button;
import android.widget.Toast;

import com.csl.cs108library4a.Cs108Connector;
import com.csl.cs108library4a.Cs108Library4A;

public class AccessTask1 {
Button button;
Expand All @@ -14,25 +14,25 @@ public class AccessTask1 {
int selectBank, selectOffset;
String strPassword;
int powerLevel;
Cs108Connector.HostCommands hostCommand;
Cs108Library4A.HostCommands hostCommand;
Runnable updateRunnable = null;

AccessTask accessTask;
public AccessTask1(Button button, boolean invalidRequest,
int accBank, int accOffset, int accSize, int accBlockCount, String accWriteData,
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand, Runnable updateRunnable) {
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Library4A.HostCommands hostCommand, Runnable updateRunnable) {
this.button = button;
this.invalidRequest = invalidRequest;
MainActivity.mCs108Library4a.appendToLog("HelloK: invalidRequest=" + invalidRequest);
MainActivity.csLibrary4A.appendToLog("HelloK: invalidRequest=" + invalidRequest);
this.accBank = accBank;
this.accOffset = accOffset;
if (hostCommand == Cs108Connector.HostCommands.CMD_18K6CWRITE) { if (accBlockCount > 16) accBlockCount = 16; }
if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CWRITE) { if (accBlockCount > 16) accBlockCount = 16; }
else if (accBlockCount > 255) accBlockCount = 255;
this.accBlockCount = accBlockCount;
if (accWriteData == null) accWriteData = "";
if (hostCommand == Cs108Connector.HostCommands.CMD_18K6CWRITE) {
MainActivity.mCs108Library4a.appendToLog("strOut: accWriteData=" + accWriteData);
if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CWRITE) {
MainActivity.csLibrary4A.appendToLog("strOut: accWriteData=" + accWriteData);
accWriteData = deformatWriteAccessData(accWriteData);
if (accWriteData.length() < accSize * 4) {
accSize = accWriteData.length()/4;
Expand All @@ -52,7 +52,7 @@ public AccessTask1(Button button, boolean invalidRequest,
this.powerLevel = powerLevel;
this.hostCommand = hostCommand;
this.updateRunnable = updateRunnable;
MainActivity.mCs108Library4a.appendToLog("HelloA, AccessTask1");
MainActivity.csLibrary4A.appendToLog("HelloA, AccessTask1");
CustomMediaPlayer playerN = MainActivity.sharedObjects.playerN;
playerN.start();
setup();
Expand All @@ -73,30 +73,30 @@ public AsyncTask.Status getStatus() {
}

public String deformatWriteAccessData(String strIn) {
MainActivity.mCs108Library4a.appendToLog("strOut: strIn=" + strIn);
MainActivity.csLibrary4A.appendToLog("strOut: strIn=" + strIn);
String strOut = strIn.replaceAll("\\P{Print}", "");
MainActivity.mCs108Library4a.appendToLog("strOut=" + strOut);
MainActivity.csLibrary4A.appendToLog("strOut=" + strOut);
while (strOut.indexOf(":") > 0) {
int index = strOut.indexOf(":");
String writeDataTemp = "";
if (index > 4) writeDataTemp = strOut.substring(0, index - 3);
writeDataTemp += strOut.substring(index + 1);
strOut = writeDataTemp;
MainActivity.mCs108Library4a.appendToLog("strOut=" + strOut);
MainActivity.csLibrary4A.appendToLog("strOut=" + strOut);
}
MainActivity.mCs108Library4a.appendToLog("strOut=" + strOut);
MainActivity.csLibrary4A.appendToLog("strOut=" + strOut);
return strOut;
}

boolean isResultReady = false; int tryCount = 0, tryCountMax = 20;
boolean isResultReady = false; int tryCount = 0, tryCountMax = 3;
public boolean isResultReady() {
boolean bValue = false;
if (accessTask == null) { }
else if (accessTask.getStatus() != AsyncTask.Status.FINISHED) { }
else if (button.getText().toString().indexOf("ING") > 0) { }
else if (isResultReady == false) {
String strAccessResult = "";
if (hostCommand != Cs108Connector.HostCommands.CMD_18K6CREAD || accBank != 3) strAccessResult = accessTask.accessResult;
if (hostCommand != Cs108Library4A.HostCommands.CMD_18K6CREAD || accBank != 3) strAccessResult = accessTask.accessResult;
else {
int word4line = 7;
for (int i = 0; i < accSizeNow; i=i+word4line) {
Expand All @@ -112,13 +112,13 @@ else if (isResultReady == false) {
strAccessResult += accessTask.accessResult.substring(i * 4, (i + word4line) * 4);
}
strAccessResult += "\n";
MainActivity.mCs108Library4a.appendToLog("i=" + i + ", formatted accessTask.accessResult=" + strAccessResult);
MainActivity.csLibrary4A.appendToLog("i=" + i + ", formatted accessTask.accessResult=" + strAccessResult);
}
}
if (accessResult == null) accessResult = strAccessResult;
else accessResult += strAccessResult;

MainActivity.mCs108Library4a.appendToLog("HelloA: accessResult=" + accessTask.accessResult);
MainActivity.csLibrary4A.appendToLog("HelloA: accessResult=" + accessTask.accessResult);
if (accessTask.accessResult != null && accSizeNow >= accSize) {
bValue = true;
Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show();
Expand All @@ -129,21 +129,22 @@ else if (isResultReady == false) {
accSize -= accSizeNow;
if (accWriteData != null) { if (accWriteData.length() >= accSizeNow*4) accWriteData = accWriteData.substring(accSizeNow*4); }
tryCount = 0;
} else MainActivity.mCs108Library4a.appendToLog("HelloA: Going to retry with TryCount=" + tryCount);
}
MainActivity.csLibrary4A.appendToLog("HelloA: Going to retry with TryCount=" + tryCount + ", resultError = " + accessTask.resultError);
if (tryCount < tryCountMax) {
MainActivity.mCs108Library4a.appendToLog("HelloA: re-setup");
MainActivity.csLibrary4A.appendToLog("HelloA: re-setup");
setup();
execute();
} else bValue = true;
}
} else bValue = true;
MainActivity.mCs108Library4a.appendToLog("HelloA: bValue=" + bValue);
//MainActivity.csLibrary4A.appendToLog("HelloA: bValue=" + bValue);
isResultReady = bValue;
return bValue;
}
public String accessResult;
public String getResult() {
MainActivity.mCs108Library4a.appendToLog("HelloA: accessResult=" + accessResult);
MainActivity.csLibrary4A.appendToLog("HelloA: accessResult=" + accessResult);
if (accessTask == null) return null;
if (accessTask.getStatus() != AsyncTask.Status.FINISHED) return null;
if (button.getText().toString().indexOf("ING") > 0) return null;
Expand All @@ -153,39 +154,39 @@ public String getResult() {
void setup() {
tryCount++;
if (invalidRequest == false) {
if (MainActivity.mCs108Library4a.setAccessBank(accBank) == false) {
MainActivity.mCs108Library4a.appendToLog("HelloK: accBank, invalidRequest=" + invalidRequest);
if (MainActivity.csLibrary4A.setAccessBank(accBank) == false) {
MainActivity.csLibrary4A.appendToLog("HelloK: accBank, invalidRequest=" + invalidRequest);
invalidRequest = true;
}
}
if (invalidRequest == false) {
if (MainActivity.mCs108Library4a.setAccessOffset(accOffset) == false) {
MainActivity.mCs108Library4a.appendToLog("HelloK: accOffset, invalidRequest=" + invalidRequest);
if (MainActivity.csLibrary4A.setAccessOffset(accOffset) == false) {
MainActivity.csLibrary4A.appendToLog("HelloK: accOffset, invalidRequest=" + invalidRequest);
invalidRequest = true;
}
}
if (invalidRequest == false) {
if (accSize == 0) {
MainActivity.mCs108Library4a.appendToLog("HelloK: accSize0, invalidRequest=" + invalidRequest);
MainActivity.csLibrary4A.appendToLog("HelloK: accSize0, invalidRequest=" + invalidRequest);
invalidRequest = true;
} else {
if (accSize > accBlockCount) accSizeNow = accBlockCount;
else accSizeNow = accSize;
MainActivity.mCs108Library4a.appendToLog("HelloA: accSize=" + accSize + ", accSizeNow=" + accSizeNow);
if (MainActivity.mCs108Library4a.setAccessCount(accSizeNow) == false) {
MainActivity.csLibrary4A.appendToLog("HelloA: accSize=" + accSize + ", accSizeNow=" + accSizeNow);
if (MainActivity.csLibrary4A.setAccessCount(accSizeNow) == false) {
invalidRequest = true;
}
}
}
if (invalidRequest == false && hostCommand == Cs108Connector.HostCommands.CMD_18K6CWRITE) {
if (invalidRequest == false && hostCommand == Cs108Library4A.HostCommands.CMD_18K6CWRITE) {
if (accWriteData.length() > accSizeNow * 4) accWriteDataNow = accWriteData.substring(0, accSizeNow*4);
else accWriteDataNow = accWriteData;
if (MainActivity.mCs108Library4a.setAccessWriteData(accWriteDataNow) == false) {
if (MainActivity.csLibrary4A.setAccessWriteData(accWriteDataNow) == false) {
invalidRequest = true;
}
}
MainActivity.mCs108Library4a.appendToLog("HelloA: accOffset=" + accOffset + ", accSizeNow=" + accSizeNow + ", accSize=" + accSize);
MainActivity.mCs108Library4a.appendToLog("HelloK: invalidRequest=" + invalidRequest);
MainActivity.csLibrary4A.appendToLog("HelloA: accOffset=" + accOffset + ", accSizeNow=" + accSizeNow + ", accSize=" + accSize);
MainActivity.csLibrary4A.appendToLog("HelloK: invalidRequest=" + invalidRequest);
accessTask = new AccessTask(button, invalidRequest,
selectMask, selectBank, selectOffset,
strPassword, powerLevel, hostCommand, tryCount==tryCountMax, updateRunnable);
Expand Down
51 changes: 38 additions & 13 deletions app/src/main/java/com/csl/cs108ademoapp/CustomIME.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.csl.cs108ademoapp;

import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.os.AsyncTask;
import android.os.Handler;
import android.provider.Settings;
Expand All @@ -14,9 +16,8 @@

import static android.content.ContentValues.TAG;

public class CustomIME extends InputMethodService {
public class CustomIME extends InputMethodService { //implements KeyboardView.OnKeyboardActionListener {
Handler mHandler = new Handler();
boolean activittyActive = false;

@Override
public void onCreate() {
Expand All @@ -25,10 +26,16 @@ public void onCreate() {
}
@Override
public View onCreateInputView() {
super.onCreateInputView();
appendToLog("CustomIME.onCreateInputView()");
super.onCreateInputView();;
mHandler.post(serviceRunnable);
return null;
KeyboardView keyboardView = null;
if (false) {
keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard_view, null);
Keyboard keyboard = new Keyboard(this, R.xml.number_pad);
keyboardView.setKeyboard(keyboard);
//keyboardView.setOnKeyboardActionListener(this);
}
return keyboardView;
}
@Override
public void onDestroy() {
Expand All @@ -49,19 +56,19 @@ public void run() {

mHandler.postDelayed(serviceRunnable, 1000);
if (MainActivity.sharedObjects == null) return;
if (MainActivity.mCs108Library4a == null) return;
if (MainActivity.csLibrary4A == null) return;

if (inventoring == false) { MainActivity.sharedObjects.serviceArrayList.clear(); epcArrayList.clear(); }
if (MainActivity.mContext == null) return;
appendToLog("CustomIME Debug 1");
if (MainActivity.activityActive == false && MainActivity.wedged && MainActivity.mCs108Library4a.isBleConnected()) {
if (MainActivity.mCs108Library4a.getTriggerButtonStatus() == false) {
appendToLog("CustomIME Debug 1 with activityActive = " + MainActivity.activityActive + ", wedged = " + MainActivity.wedged + ", isBleConnected = " + MainActivity.csLibrary4A.isBleConnected());
if (MainActivity.activityActive == false /*&& MainActivity.wedged*/ && MainActivity.csLibrary4A.isBleConnected()) {
if (MainActivity.csLibrary4A.getTriggerButtonStatus() == false) {
appendToLog("CustomIME Debug 2");
startStopHandler();
inventoring = false;
} else if (inventoring == false) {
appendToLog("CustomIME Debug 3");
if (MainActivity.sharedObjects.runningInventoryRfidTask == false && MainActivity.sharedObjects.runningInventoryBarcodeTask == false && MainActivity.mCs108Library4a.mrfidToWriteSize() == 0) {
if (MainActivity.sharedObjects.runningInventoryRfidTask == false && MainActivity.sharedObjects.runningInventoryBarcodeTask == false && MainActivity.csLibrary4A.mrfidToWriteSize() == 0) {
startStopHandler();
inventoring = true;
}
Expand All @@ -79,7 +86,25 @@ public void run() {
if (matched == false && strEpc != null) {
epcArrayList.add(strEpc);
InputConnection ic = getCurrentInputConnection();
ic.commitText(strEpc + "\n", 1);
strEpc = (MainActivity.wedgePrefix != null ? MainActivity.wedgePrefix : "") + strEpc
+ (MainActivity.wedgeSuffix != null ? MainActivity.wedgeSuffix : "");
switch (MainActivity.wedgeDelimiter) {
default:
strEpc += "\n";
break;
case 0x09:
strEpc += "\t";
break;
case 0x2C:
strEpc += ",";
break;
case 0x20:
strEpc += " ";
break;
case -1:
break;
}
ic.commitText(strEpc, 1);
}
}
}
Expand All @@ -96,10 +121,10 @@ void startStopHandler() {
if (inventoryRfidTask.getStatus() == AsyncTask.Status.RUNNING) started = true;
}
appendToLog("CustomIME Debug 10");
if ((started && MainActivity.mCs108Library4a.getTriggerButtonStatus()) || (started == false && MainActivity.mCs108Library4a.getTriggerButtonStatus() == false)) return;
if ((started && MainActivity.csLibrary4A.getTriggerButtonStatus()) || (started == false && MainActivity.csLibrary4A.getTriggerButtonStatus() == false)) return;
if (started == false) {
appendToLog("CustomIME Debug 11");
MainActivity.mCs108Library4a.startOperation(Cs108Library4A.OperationTypes.TAG_INVENTORY);
MainActivity.csLibrary4A.startOperation(Cs108Library4A.OperationTypes.TAG_INVENTORY);
inventoryRfidTask = new InventoryRfidTask();
inventoryRfidTask.execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public CustomMediaPlayer(Context context, String file) {
@Override
public void onCompletion(MediaPlayer mp) {
starting = false;
if (DEBUG) MainActivity.mCs108Library4a.appendToLog("MediaPlayer is completed.");
if (DEBUG) MainActivity.csLibrary4A.appendToLog("MediaPlayer is completed.");
}
});
} catch (IOException e) {
MainActivity.mCs108Library4a.appendToLog("mp3 setup FAIL");
MainActivity.csLibrary4A.appendToLog("mp3 setup FAIL");
}
}

Expand All @@ -48,7 +48,7 @@ void setVolume(int volume1, int volume2) {
AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
int iVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
MainActivity.mCs108Library4a.appendToLog("Hello8: currentVolume = " + currentVolume);
MainActivity.csLibrary4A.appendToLog("Hello8: currentVolume = " + currentVolume);
if (currentVolume > 0) {
int volume12 = volume1 + volume2;
volume12 = ( volume12 * iVolumeMax ) / 600;
Expand Down
Loading