Skip to content

Commit

Permalink
Merge pull request #15 from sp0x/master
Browse files Browse the repository at this point in the history
Allows the handling of the user exiting the line.
  • Loading branch information
sarooghi authored Jul 23, 2020
2 parents 1b9c5f2 + b4731fb commit 5c77870
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 12 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/bintray-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to bintray on closed PR
on:
# Trigger the workflow on push to master branch
push:
branches: [master]

jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check Commit Type
uses: gsactions/commit-message-checker@v1
#Commit should be like "^Merge pull request #"
with:
pattern: '^Merge pull request #\d'
flags: 'gm'
error: 'This action runs only on PR merges. Check your commit message.'
- uses: actions/checkout@v2
# Export properties
- name: Setup bintray credentials
env:
BINTRAY_APIKEY: ${{ secrets.BINTRAY_APIKEY }}
run: |
echo "bintray.user=queueitdevs" > ./local.properties
echo "bintray.apiKey=${BINTRAY_APIKEY}" >> ./local.properties
- uses: actions/setup-java@v1
with:
java-version: 11
- uses: eskatos/gradle-command-action@v1
with:
arguments: bintrayUpload
18 changes: 18 additions & 0 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run Gradle Build on Push
on: push
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Create local.properties
run: echo "" >> ./local.properties
- uses: actions/setup-java@v1
with:
java-version: 11
- uses: eskatos/gradle-command-action@v1
with:
arguments: build
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Expand Down
14 changes: 7 additions & 7 deletions demoapp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
compileSdkVersion 26
buildToolsVersion "28.0.3"

defaultConfig {
applicationId "com.queue_it.shopdemo"
minSdkVersion 15
targetSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
Expand All @@ -20,9 +20,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile project(':library')
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation project(':library')
}
6 changes: 6 additions & 0 deletions demoapp/src/main/java/com/queue_it/shopdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public void onQueueViewWillOpen() {
queue_button.setEnabled(true);
}

@Override
public void onUserExited() {
Toast.makeText(getApplicationContext(), "onUserExited", Toast.LENGTH_SHORT).show();
}

@Override
public void onQueueDisabled() {
showResultActivity("The queue is disabled.", false);
Expand All @@ -106,6 +111,7 @@ public void onError(Error error, String errorMessage) {
showResultActivity("Critical error: " + errorMessage, false);
queue_button.setEnabled(true);
}

});
try {
queueITEngine.run(MainActivity.this, !enableCacheRadioButton.isChecked());
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'
def org = "queueit"
android {
compileSdkVersion 23
compileSdkVersion 26
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 15
targetSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "2.0.22"
}
Expand All @@ -22,7 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
}

Expand Down Expand Up @@ -108,7 +108,7 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream(

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
key = properties.getProperty("bintray.apiKey")

configurations = ['archives']
pkg {
Expand Down
1 change: 1 addition & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.queue_it.androidsdk">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:label="@string/app_name"
Expand Down
19 changes: 19 additions & 0 deletions library/src/main/java/com/queue_it/androidsdk/QueueActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public boolean shouldOverrideUrlLoading(WebView view, String urlString) {
urlString = QueueUrlHelper.updateUrl(urlString, userId);
Log.v("QueueITEngine", "URL intercepting: " + urlString);
}
if(isExitLineUrl(urlString)){
broadcastUserExited();
}
broadcastChangedQueueUrl(urlString);
if(needsRewrite){
webview.loadUrl(urlString);
Expand All @@ -111,6 +114,17 @@ public boolean shouldOverrideUrlLoading(WebView view, String urlString) {
}
};

private boolean isExitLineUrl(String urlString) {
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
e.printStackTrace();
return false;
}
return url.getPath().equals("/exitline.aspx");
}

private static void cleanupWebView(){
if(previousWebView==null) return;
previousWebView.destroy();
Expand Down Expand Up @@ -206,6 +220,11 @@ private void broadcastQueueActivityClosed() {
LocalBroadcastManager.getInstance(QueueActivity.this).sendBroadcast(intent);
}

public void broadcastUserExited(){
Intent intent = new Intent("queue-user-exited");
LocalBroadcastManager.getInstance(QueueActivity.this).sendBroadcast(intent);
}

private void broadcastQueueError(String errorMessage) {
Intent intent = new Intent("on-queue-error");
intent.putExtra("error-message", errorMessage);
Expand Down
13 changes: 13 additions & 0 deletions library/src/main/java/com/queue_it/androidsdk/QueueITEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private void registerReceivers() {
localBroadcastManager.registerReceiver(_queuePassedBroadcastReceiver, new IntentFilter("on-queue-passed"));
localBroadcastManager.registerReceiver(_queueUrlChangedBroadcastReceiver, new IntentFilter("on-changed-queue-url"));
localBroadcastManager.registerReceiver(_queueActivityClosedBroadcastReceiver, new IntentFilter("queue-activity-closed"));
localBroadcastManager.registerReceiver(_queueUserExitedBroadcastReceiver, new IntentFilter("queue-user-exited"));
localBroadcastManager.registerReceiver(_queueErrorBroadcastReceiver, new IntentFilter("on-queue-error"));
}

Expand All @@ -137,6 +138,7 @@ private void unregisterReceivers() {
localBroadcastManager.unregisterReceiver(_queuePassedBroadcastReceiver);
localBroadcastManager.unregisterReceiver(_queueUrlChangedBroadcastReceiver);
localBroadcastManager.unregisterReceiver(_queueActivityClosedBroadcastReceiver);
localBroadcastManager.unregisterReceiver(_queueUserExitedBroadcastReceiver);
localBroadcastManager.unregisterReceiver(_queueErrorBroadcastReceiver);
}

Expand All @@ -162,6 +164,13 @@ public void onReceive(Context context, Intent intent) {
}
};

private BroadcastReceiver _queueUserExitedBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
raiseUserExited();
}
};

private BroadcastReceiver _queueActivityClosedBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Expand Down Expand Up @@ -214,6 +223,10 @@ private void raiseQueueViewWillOpen() {
_isInQueue = true;
}

private void raiseUserExited(){
_queueListener.onUserExited();
}

private void raiseQueuePassed(String queueItToken) {
_queueCache.clear();
_queueListener.onQueuePassed(new QueuePassedInfo(queueItToken));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public interface QueueListener {
void onQueueDisabled();
void onQueueItUnavailable();
void onError(Error error, String errorMessage);
void onUserExited();
}

0 comments on commit 5c77870

Please sign in to comment.