Skip to content
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
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.DS_Store

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# CS710S-and-CS108-Java-Simple-Wedge
# CS710S/CS108 Data Wedge for Android

This application serves as a keyboard wedge for writing RFID tag data to the cursor on your Android devices

<ol>
<li> For the first time launching the application, please grant device permission for location, connectivity and enabling [CSL Data Wedge].</li>
<li> Readers will be discovered by the app and please check the box on the right hand side to select the reader to be connected. </li>
<li> Once connected, put the application in background. </li>
<li> Open the target application where you would like data to be printed. </li>
<li> On the target applicatoin , put the cursor to the text field where data will be printed. Switch your keyboard to [CSL Data Wedge]. </li>
<li> Press and hold the trigger key of the reader to start reading tags. EPC values will be printed to the cursor on your target application. </li>
<li> Switch back to the CSL Data Wedge application. Now you can press the "Disconnect" button to disconnect from the reader. </li>
</ol>

**Configurations:** Press the button to modify parameters such as power, prefix, suffix and delimiter.

![csl-data-wedge-android](/images/csl-data-wedge-android.png)
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
19 changes: 19 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 33
defaultConfig {
applicationId "com.csl.cs710awedgeapp"
minSdkVersion 21
targetSdkVersion 33
versionCode 5
versionName "5.9.11"
}
namespace 'com.csl.cs710awedgeapp'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.9.0'
implementation project(path: ':cs710library4a')
}
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\wallace.sit\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Binary file not shown.
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.cs710awedgeapp",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "5.9.11",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
46 changes: 46 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_newname1"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme">

<service android:name="CustomIME"
android:label="@string/app_ime1"
android:exported="true"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method" />
</service>

<activity
android:name="MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.nfc.action.ACTION_TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
</manifest>
Binary file added app/src/main/assets/beep3s1khz.mp3
Binary file not shown.
Binary file added app/src/main/assets/beep3s1khz.wav
Binary file not shown.
Binary file added app/src/main/assets/beephigh.mp3
Binary file not shown.
Binary file added app/src/main/assets/beeplow.mp3
Binary file not shown.
Binary file added app/src/main/assets/cslrfidcloudserver.crt
Binary file not shown.
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.
137 changes: 137 additions & 0 deletions app/src/main/java/com/csl/cs710awedgeapp/CustomIME.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.csl.cs710awedgeapp;

import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.os.AsyncTask;
import android.os.Handler;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputConnection;

import com.csl.cs710library4a.CsLibrary4A;

import java.util.ArrayList;

import static android.content.ContentValues.TAG;

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

@Override
public void onCreate() {
super.onCreate();
appendToLog("CustomIME.onCreate()");
}
@Override
public View onCreateInputView() {
super.onCreateInputView();;
mHandler.post(serviceRunnable);
KeyboardView keyboardView = null;
if (true) {
keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard_view, null);
Keyboard keyboard = new Keyboard(this, R.xml.number_pad1);
keyboardView.setKeyboard(keyboard);
//keyboardView.setOnKeyboardActionListener(this);
}
return keyboardView;
}
@Override
public void onDestroy() {
appendToLog("CustomIME.onDestroy()");
mHandler.removeCallbacks(serviceRunnable);
super.onDestroy();
}

ArrayList<String> epcArrayList = new ArrayList<String>();
InventoryRfidTask inventoryRfidTask;
boolean inventoring = false;
private Runnable serviceRunnable = new Runnable() {
@Override
public void run() {
String strCurrentIME = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
String strCompare = getPackageName();
appendToLog("CustomIME Debug 0 with strCurrentIME = " + strCurrentIME + ", strCompare = " + strCompare);
if (strCurrentIME.contains(strCompare) == false) return;

mHandler.postDelayed(serviceRunnable, 1000);
if (MainActivity.sharedObjects == 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 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.csLibrary4A.mrfidToWriteSize() == 0) {
startStopHandler();
inventoring = true;
}
} else {
appendToLog("CustomIME Debug 4");
while (MainActivity.sharedObjects.serviceArrayList.size() != 0) {
String strEpc = MainActivity.sharedObjects.serviceArrayList.get(0); MainActivity.sharedObjects.serviceArrayList.remove(0);
boolean matched = false;
for (int i = 0; i < epcArrayList.size(); i++) {
if (epcArrayList.get(i).matches(strEpc)) {
matched = true;
break;
}
}
if (matched == false && strEpc != null) {
epcArrayList.add(strEpc);
InputConnection ic = getCurrentInputConnection();
if (MainActivity.wedgePrefix != null) strEpc = MainActivity.wedgePrefix + strEpc;
if (MainActivity.wedgeSuffix != null) strEpc += 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);
}
}
}
}
}
};

public void appendToLog(String s) {
Log.i(TAG + ".Hello", s);
}
void startStopHandler() {
boolean started = false;
if (inventoryRfidTask != null) {
if (inventoryRfidTask.getStatus() == AsyncTask.Status.RUNNING) started = true;
}
appendToLog("CustomIME Debug 10");
if ((started && MainActivity.csLibrary4A.getTriggerButtonStatus()) || (started == false && MainActivity.csLibrary4A.getTriggerButtonStatus() == false)) return;
if (started == false) {
appendToLog("CustomIME Debug 11");
MainActivity.csLibrary4A.startOperation(CsLibrary4A.OperationTypes.TAG_INVENTORY);
inventoryRfidTask = new InventoryRfidTask();
inventoryRfidTask.execute();
}
else {
appendToLog("CustomIME Debug 11");
inventoryRfidTask.taskCancelReason = InventoryRfidTask.TaskCancelRReason.BUTTON_RELEASE;
}
}
}
59 changes: 59 additions & 0 deletions app/src/main/java/com/csl/cs710awedgeapp/CustomMediaPlayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.csl.cs710awedgeapp;

import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.AudioManager;
import android.media.MediaPlayer;

import java.io.IOException;

public class CustomMediaPlayer {
final boolean DEBUG = false;
Context context;
MediaPlayer player; boolean starting = false;

public CustomMediaPlayer(Context context, String file) {
this.context = context;
player = null;
try {
AssetFileDescriptor afd = context.getAssets().openFd(file);
player = new MediaPlayer();
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
player.prepare();
player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
starting = false;
if (DEBUG) MainActivity.csLibrary4A.appendToLog("MediaPlayer is completed.");
}
});
} catch (IOException e) {
MainActivity.csLibrary4A.appendToLog("mp3 setup FAIL");
}
}

public void start() {
player.start();
if (false) starting = true;
}
public boolean isPlaying() {
return (player.isPlaying() | starting) ;
}
public void pause() {
player.pause();
}
void setVolume(int volume1, int volume2) {
if (false) player.setVolume(volume1, volume2);
else {
AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
int iVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
MainActivity.csLibrary4A.appendToLog("Hello8: currentVolume = " + currentVolume);
if (currentVolume > 0) {
int volume12 = volume1 + volume2;
volume12 = ( volume12 * iVolumeMax ) / 600;
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, iVolumeMax, 0);
}
}
}
}
Loading