From 7fc306cd09924e7224d804536caa14c010df643d Mon Sep 17 00:00:00 2001 From: Vasil Date: Thu, 4 Aug 2022 12:48:42 +0200 Subject: [PATCH] Syncronized repository --- .github/workflows/bintray-publish.yml | 50 +-- .github/workflows/gradle-build.yml | 34 +- .gitignore | 44 +- LICENSE | 42 +- README.md | 2 +- android-webui-sdk.iml | 36 +- build.gradle | 2 +- demoapp/.gitignore | 2 +- demoapp/demoapp.iml | 204 ++++----- demoapp/proguard-rules.pro | 34 +- .../com/queue_it/shopdemo/DeepActivity.java | 56 +-- .../com/queue_it/shopdemo/FirstFragment.java | 64 +-- .../com/queue_it/shopdemo/MainActivity.java | 392 +++++++++--------- .../com/queue_it/shopdemo/ResultActivity.java | 112 ++--- .../com/queue_it/shopdemo/SecondFragment.java | 62 +-- .../src/library/res/layout/activity_deep.xml | 64 +-- .../src/library/res/layout/activity_main.xml | 378 ++++++++--------- .../library/res/layout/activity_result.xml | 124 +++--- .../src/library/res/layout/content_deep.xml | 10 +- .../src/library/res/layout/fragment_first.xml | 54 +-- .../library/res/layout/fragment_second.xml | 52 +-- .../com/queue_it/shopdemo/DeepActivity.java | 54 +-- .../com/queue_it/shopdemo/FirstFragment.java | 68 +-- .../com/queue_it/shopdemo/ResultActivity.java | 110 ++--- .../com/queue_it/shopdemo/SecondFragment.java | 68 +-- .../res/layout/activity_deep.xml | 64 +-- .../res/layout/activity_result.xml | 124 +++--- .../res/layout/content_deep.xml | 10 +- .../res/layout/fragment_first.xml | 54 +-- .../res/layout/fragment_second.xml | 52 +-- demoapp/src/main/AndroidManifest.xml | 98 ++--- .../com/queue_it/shopdemo/TextValidator.java | 52 +-- .../main/res/drawable/ic_check_black_24dp.xml | 18 +- .../main/res/drawable/ic_error_black_24dp.xml | 18 +- .../res/drawable/ic_play_arrow_white_48px.xml | 8 +- .../res/drawable/ic_replay_white_48px.xml | 8 +- demoapp/src/main/res/navigation/nav_graph.xml | 54 +-- demoapp/src/main/res/values-w820dp/dimens.xml | 12 +- demoapp/src/main/res/values/colors.xml | 12 +- demoapp/src/main/res/values/dimens.xml | 12 +- demoapp/src/main/res/values/strings.xml | 24 +- demoapp/src/main/res/values/styles.xml | 40 +- demowithprotectedapi/build.gradle | 114 ++--- demowithprotectedapi/proguard-rules.pro | 40 +- .../ExampleInstrumentedTest.java | 50 +-- .../demowithprotectedapi/MainActivity.java | 162 ++++---- .../demowithprotectedapi/api/Product.java | 26 +- .../api/ProductFilter.java | 10 +- .../api/ProductsService.java | 28 +- .../exceptions/MustBeQueued.java | 32 +- .../http/AddCookiesInterceptor.java | 62 +-- .../http/CookieStorage.java | 46 +- .../http/QueueITInterceptor.java | 122 +++--- .../http/ReceivedCookiesInterceptor.java | 92 ++-- .../http/UserAgentInterceptor.java | 80 ++-- .../repos/IProductRepository.java | 24 +- .../repos/ProductRepository.java | 108 ++--- .../drawable-v24/ic_launcher_foreground.xml | 58 +-- .../res/drawable/ic_launcher_background.xml | 340 +++++++-------- .../src/main/res/layout/activity_main.xml | 64 +-- .../src/main/res/layout/content_main.xml | 36 +- .../src/main/res/layout/fragment_first.xml | 54 +-- .../src/main/res/menu/menu_main.xml | 18 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 8 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 8 +- .../src/main/res/navigation/nav_graph.xml | 26 +- .../src/main/res/values-night/themes.xml | 30 +- .../src/main/res/values/colors.xml | 18 +- .../src/main/res/values/dimens.xml | 4 +- .../src/main/res/values/strings.xml | 22 +- .../src/main/res/values/themes.xml | 48 +-- .../demowithprotectedapi/ExampleUnitTest.java | 32 +- documentation/protected_apis.md | 50 +-- gradle.properties | 38 +- gradlew | 290 ++++++++----- gradlew.bat | 53 ++- library/.gitignore | 2 +- library/build.gradle | 2 +- library/library.iml | 200 ++++----- library/proguard-rules.pro | 34 +- .../queue_it/androidsdk/QueueActivity.java | 70 ++-- library/src/main/AndroidManifest.xml | 26 +- .../src/main/res/layout/activity_queue.xml | 28 +- library/src/main/res/values/strings.xml | 8 +- publish.gradle | 224 +++++----- settings.gradle | 4 +- 86 files changed, 2820 insertions(+), 2749 deletions(-) diff --git a/.github/workflows/bintray-publish.yml b/.github/workflows/bintray-publish.yml index f4a40f2..a957b5f 100644 --- a/.github/workflows/bintray-publish.yml +++ b/.github/workflows/bintray-publish.yml @@ -1,26 +1,26 @@ -name: Publish to bintray on closed PR -on: - release: - types: [released] - -jobs: - gradle: - strategy: - matrix: - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - 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: +name: Publish to bintray on closed PR +on: + release: + types: [released] + +jobs: + gradle: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - 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: assembleLibrary_androidx :library:assembleLibrary bintrayUpload \ No newline at end of file diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 388a247..f296887 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -1,18 +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: +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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 28a428f..d27c0e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,23 @@ -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -/.idea/caches/build_file_checksums.ser -/.idea/caches/gradle_models.ser -/.idea/codeStyles/Project.xml -/.vs/android-webui-sdk/v16/.suo -/.vs/slnx.sqlite -/.vs/VSWorkspaceState.json -/private_key_sender.asc -/public_key_sender.asc -.idea -*.gpg -**/build -node_modules -.classpath -.project -*.prefs +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +/.idea/caches/build_file_checksums.ser +/.idea/caches/gradle_models.ser +/.idea/codeStyles/Project.xml +/.vs/android-webui-sdk/v16/.suo +/.vs/slnx.sqlite +/.vs/VSWorkspaceState.json +/private_key_sender.asc +/public_key_sender.asc +.idea +*.gpg +**/build +node_modules +.classpath +.project +*.prefs dist \ No newline at end of file diff --git a/LICENSE b/LICENSE index ddabc19..729e226 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2020 Queue-it - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2020 Queue-it + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index d5f2e71..52f2e47 100644 --- a/README.md +++ b/README.md @@ -157,4 +157,4 @@ If your application is using an API that's protected by a Queue-it connector (Kn ```xml -``` +``` \ No newline at end of file diff --git a/android-webui-sdk.iml b/android-webui-sdk.iml index 760fee4..6bb9038 100644 --- a/android-webui-sdk.iml +++ b/android-webui-sdk.iml @@ -1,19 +1,19 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 977b13b..314f467 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ allprojects { groupId = 'com.queue-it.androidsdk' libraryName = 'com.queue_it.androidsdk' libraryDescription = 'Android SDK to integrate with Queue-it' - libraryVersion = "2.1.1" + libraryVersion = "2.1.2" organization = "Queue-it" organizationUrl = "https://queue-it.com" diff --git a/demoapp/.gitignore b/demoapp/.gitignore index 796b96d..3543521 100644 --- a/demoapp/.gitignore +++ b/demoapp/.gitignore @@ -1 +1 @@ -/build +/build diff --git a/demoapp/demoapp.iml b/demoapp/demoapp.iml index 308dfd1..7455981 100644 --- a/demoapp/demoapp.iml +++ b/demoapp/demoapp.iml @@ -1,103 +1,103 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demoapp/proguard-rules.pro b/demoapp/proguard-rules.pro index 6f9ca39..9778714 100644 --- a/demoapp/proguard-rules.pro +++ b/demoapp/proguard-rules.pro @@ -1,17 +1,17 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in C:\Users\MortenBrixPedersen\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 *; -#} +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\MortenBrixPedersen\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 *; +#} diff --git a/demoapp/src/library/java/com/queue_it/shopdemo/DeepActivity.java b/demoapp/src/library/java/com/queue_it/shopdemo/DeepActivity.java index 339d760..54e5887 100644 --- a/demoapp/src/library/java/com/queue_it/shopdemo/DeepActivity.java +++ b/demoapp/src/library/java/com/queue_it/shopdemo/DeepActivity.java @@ -1,29 +1,29 @@ -package com.queue_it.shopdemo; - -import android.os.Bundle; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.android.material.snackbar.Snackbar; - -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.View; - -public class DeepActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_deep); - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - FloatingActionButton fab = findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show(); - } - }); - } +package com.queue_it.shopdemo; + +import android.os.Bundle; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; + +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; + +public class DeepActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_deep); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } } \ No newline at end of file diff --git a/demoapp/src/library/java/com/queue_it/shopdemo/FirstFragment.java b/demoapp/src/library/java/com/queue_it/shopdemo/FirstFragment.java index 54e7b63..829d8c8 100644 --- a/demoapp/src/library/java/com/queue_it/shopdemo/FirstFragment.java +++ b/demoapp/src/library/java/com/queue_it/shopdemo/FirstFragment.java @@ -1,33 +1,33 @@ -package com.queue_it.shopdemo; - -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - - -public class FirstFragment extends Fragment { - - @Override - public View onCreateView( - LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState - ) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_first, container, false); - } - - public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { -// NavHostFragment.findNavController(FirstFragment.this) -// .navigate(R.id.action_FirstFragment_to_SecondFragment); - } - }); - } +package com.queue_it.shopdemo; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +public class FirstFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_first, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { +// NavHostFragment.findNavController(FirstFragment.this) +// .navigate(R.id.action_FirstFragment_to_SecondFragment); + } + }); + } } \ No newline at end of file diff --git a/demoapp/src/library/java/com/queue_it/shopdemo/MainActivity.java b/demoapp/src/library/java/com/queue_it/shopdemo/MainActivity.java index d606fc6..f87aee1 100644 --- a/demoapp/src/library/java/com/queue_it/shopdemo/MainActivity.java +++ b/demoapp/src/library/java/com/queue_it/shopdemo/MainActivity.java @@ -1,196 +1,196 @@ -package com.queue_it.shopdemo; - -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.text.TextUtils; -import android.view.View; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.RadioButton; -import android.widget.TextView; -import android.widget.Toast; - -import com.queue_it.androidsdk.*; -import com.queue_it.androidsdk.Error; - -public class MainActivity extends AppCompatActivity { - RadioButton enableCacheRadioButton; - FloatingActionButton queue_button; - EditText customerIdEditText; - EditText eventIdEditText; - EditText layoutNameEditText; - EditText languageEditText; - EditText enqueueTokenEditText; - EditText enqueueKeyEditText; - RadioButton testRadioButton; - - private void runQueue(QueueITEngine queueITEngine) throws QueueITException { - String enqueueToken = enqueueTokenEditText.getText().toString(); - String enqueueKey = enqueueKeyEditText.getText().toString(); - if (enqueueToken.length() > 0) { - queueITEngine.runWithEnqueueToken(MainActivity.this, enqueueToken, !enableCacheRadioButton.isChecked()); - } else if (enqueueKey.length() > 0) { - queueITEngine.runWithEnqueueKey(MainActivity.this, enqueueKey, !enableCacheRadioButton.isChecked()); - } else { - queueITEngine.run(MainActivity.this, !enableCacheRadioButton.isChecked()); - } - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - queue_button = findViewById(R.id.queue_button); - customerIdEditText = findViewById(R.id.customerid_edittext); - eventIdEditText = findViewById(R.id.eventid_edittext); - layoutNameEditText = findViewById(R.id.layoutname_edittext); - languageEditText = findViewById(R.id.language_edittext); - testRadioButton = findViewById(R.id.radio_environment_test); - enableCacheRadioButton = findViewById(R.id.radio_cache_enabled); - customerIdEditText.addTextChangedListener(getRequiredTextValidator(customerIdEditText)); - eventIdEditText.addTextChangedListener(getRequiredTextValidator(eventIdEditText)); - enqueueTokenEditText = findViewById(R.id.enqueuetoken_edittext); - enqueueKeyEditText = findViewById(R.id.enqueuekey_edittext); - - final SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE); - String customerId = sharedPreferences.getString("customerId", ""); - String eventOrAliasId = sharedPreferences.getString("eventOrAliasId", ""); - String layoutName = sharedPreferences.getString("layoutName", ""); - String language = sharedPreferences.getString("language", ""); - String enqueueToken = sharedPreferences.getString("enqueueToken", ""); - String enqueueKey = sharedPreferences.getString("enqueueKey", ""); - - customerIdEditText.setText(customerId); - eventIdEditText.setText(eventOrAliasId); - layoutNameEditText.setText(layoutName); - languageEditText.setText(language); - enqueueTokenEditText.setText(enqueueToken); - enqueueKeyEditText.setText(enqueueKey); - - queue_button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!TextUtils.isEmpty(customerIdEditText.getError()) || !TextUtils.isEmpty(eventIdEditText.getError())) { - return; - } - - queue_button.setEnabled(false); - QueueService.IsTest = testRadioButton.isChecked(); - hideKeyboard(); - - String customerId = customerIdEditText.getText().toString(); - String eventOrAliasId = eventIdEditText.getText().toString(); - String layoutName = layoutNameEditText.getText().toString(); - String language = languageEditText.getText().toString(); - String enqueueToken = enqueueTokenEditText.getText().toString(); - String enqueueKey = enqueueKeyEditText.getText().toString(); - - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString("customerId", customerId); - editor.putString("eventOrAliasId", eventOrAliasId); - editor.putString("layoutName", layoutName); - editor.putString("language", language); - editor.putString("enqueueToken", enqueueToken); - editor.putString("enqueueKey", enqueueKey); - editor.commit(); - - Toast.makeText(getApplicationContext(), "Please wait for your turn.", Toast.LENGTH_SHORT).show(); - - QueueITEngine queueITEngine = new QueueITEngine(MainActivity.this, customerId, eventOrAliasId, layoutName, language, new QueueListener() { - - @Override - public void onSessionRestart(QueueITEngine queueITEngine) { - try { - runQueue(queueITEngine); - } catch (QueueITException e) { - Toast.makeText(getApplicationContext(), "Please try again.", Toast.LENGTH_LONG).show(); - queue_button.setEnabled(true); - } - } - - @Override - public void onQueuePassed(QueuePassedInfo queuePassedInfo) { - showResultActivity("You passed the queue! Your token: " + queuePassedInfo.getQueueItToken(), true); - queue_button.setEnabled(true); - } - - @Override - public void onQueueViewWillOpen() { - Toast.makeText(getApplicationContext(), "onQueueViewWillOpen", Toast.LENGTH_SHORT).show(); - 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); - queue_button.setEnabled(true); - } - - @Override - public void onQueueItUnavailable() { - showResultActivity("Queue-it is unavailable", false); - queue_button.setEnabled(true); - } - - @Override - public void onError(Error error, String errorMessage) { - showResultActivity("Critical error: " + errorMessage, false); - queue_button.setEnabled(true); - } - - }); - try { - runQueue(queueITEngine); - } catch (QueueITException e) { - Toast.makeText(getApplicationContext(), "Please try again.", Toast.LENGTH_LONG).show(); - queue_button.setEnabled(true); - } - } - }); - } - - private void showResultActivity(String result, boolean success) { - Intent intent = new Intent(this, ResultActivity.class); - intent.putExtra("success", success); - intent.putExtra("result", result); - startActivity(intent); - } - - private boolean isAlphaNumeric(String s) { - String pattern = "^[a-zA-Z0-9]*$"; - return s.matches(pattern); - } - - private void hideKeyboard() { - View view = this.getCurrentFocus(); - if (view != null) { - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); - } - } - - private TextValidator getRequiredTextValidator(TextView textView) { - return new TextValidator(textView) { - @Override - public void validate(TextView textView, String text) { - if (TextUtils.isEmpty(text)) { - textView.setError("Field required"); - } else if (!isAlphaNumeric(text)) { - textView.setError("Must be alphanumeric"); - } - } - }; - } -} +package com.queue_it.shopdemo; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; + +import com.google.android.material.floatingactionbutton.FloatingActionButton; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.TextView; +import android.widget.Toast; + +import com.queue_it.androidsdk.*; +import com.queue_it.androidsdk.Error; + +public class MainActivity extends AppCompatActivity { + RadioButton enableCacheRadioButton; + FloatingActionButton queue_button; + EditText customerIdEditText; + EditText eventIdEditText; + EditText layoutNameEditText; + EditText languageEditText; + EditText enqueueTokenEditText; + EditText enqueueKeyEditText; + RadioButton testRadioButton; + + private void runQueue(QueueITEngine queueITEngine) throws QueueITException { + String enqueueToken = enqueueTokenEditText.getText().toString(); + String enqueueKey = enqueueKeyEditText.getText().toString(); + if (enqueueToken.length() > 0) { + queueITEngine.runWithEnqueueToken(MainActivity.this, enqueueToken, !enableCacheRadioButton.isChecked()); + } else if (enqueueKey.length() > 0) { + queueITEngine.runWithEnqueueKey(MainActivity.this, enqueueKey, !enableCacheRadioButton.isChecked()); + } else { + queueITEngine.run(MainActivity.this, !enableCacheRadioButton.isChecked()); + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + queue_button = findViewById(R.id.queue_button); + customerIdEditText = findViewById(R.id.customerid_edittext); + eventIdEditText = findViewById(R.id.eventid_edittext); + layoutNameEditText = findViewById(R.id.layoutname_edittext); + languageEditText = findViewById(R.id.language_edittext); + testRadioButton = findViewById(R.id.radio_environment_test); + enableCacheRadioButton = findViewById(R.id.radio_cache_enabled); + customerIdEditText.addTextChangedListener(getRequiredTextValidator(customerIdEditText)); + eventIdEditText.addTextChangedListener(getRequiredTextValidator(eventIdEditText)); + enqueueTokenEditText = findViewById(R.id.enqueuetoken_edittext); + enqueueKeyEditText = findViewById(R.id.enqueuekey_edittext); + + final SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE); + String customerId = sharedPreferences.getString("customerId", ""); + String eventOrAliasId = sharedPreferences.getString("eventOrAliasId", ""); + String layoutName = sharedPreferences.getString("layoutName", ""); + String language = sharedPreferences.getString("language", ""); + String enqueueToken = sharedPreferences.getString("enqueueToken", ""); + String enqueueKey = sharedPreferences.getString("enqueueKey", ""); + + customerIdEditText.setText(customerId); + eventIdEditText.setText(eventOrAliasId); + layoutNameEditText.setText(layoutName); + languageEditText.setText(language); + enqueueTokenEditText.setText(enqueueToken); + enqueueKeyEditText.setText(enqueueKey); + + queue_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!TextUtils.isEmpty(customerIdEditText.getError()) || !TextUtils.isEmpty(eventIdEditText.getError())) { + return; + } + + queue_button.setEnabled(false); + QueueService.IsTest = testRadioButton.isChecked(); + hideKeyboard(); + + String customerId = customerIdEditText.getText().toString(); + String eventOrAliasId = eventIdEditText.getText().toString(); + String layoutName = layoutNameEditText.getText().toString(); + String language = languageEditText.getText().toString(); + String enqueueToken = enqueueTokenEditText.getText().toString(); + String enqueueKey = enqueueKeyEditText.getText().toString(); + + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("customerId", customerId); + editor.putString("eventOrAliasId", eventOrAliasId); + editor.putString("layoutName", layoutName); + editor.putString("language", language); + editor.putString("enqueueToken", enqueueToken); + editor.putString("enqueueKey", enqueueKey); + editor.commit(); + + Toast.makeText(getApplicationContext(), "Please wait for your turn.", Toast.LENGTH_SHORT).show(); + + QueueITEngine queueITEngine = new QueueITEngine(MainActivity.this, customerId, eventOrAliasId, layoutName, language, new QueueListener() { + + @Override + public void onSessionRestart(QueueITEngine queueITEngine) { + try { + runQueue(queueITEngine); + } catch (QueueITException e) { + Toast.makeText(getApplicationContext(), "Please try again.", Toast.LENGTH_LONG).show(); + queue_button.setEnabled(true); + } + } + + @Override + public void onQueuePassed(QueuePassedInfo queuePassedInfo) { + showResultActivity("You passed the queue! Your token: " + queuePassedInfo.getQueueItToken(), true); + queue_button.setEnabled(true); + } + + @Override + public void onQueueViewWillOpen() { + Toast.makeText(getApplicationContext(), "onQueueViewWillOpen", Toast.LENGTH_SHORT).show(); + 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); + queue_button.setEnabled(true); + } + + @Override + public void onQueueItUnavailable() { + showResultActivity("Queue-it is unavailable", false); + queue_button.setEnabled(true); + } + + @Override + public void onError(Error error, String errorMessage) { + showResultActivity("Critical error: " + errorMessage, false); + queue_button.setEnabled(true); + } + + }); + try { + runQueue(queueITEngine); + } catch (QueueITException e) { + Toast.makeText(getApplicationContext(), "Please try again.", Toast.LENGTH_LONG).show(); + queue_button.setEnabled(true); + } + } + }); + } + + private void showResultActivity(String result, boolean success) { + Intent intent = new Intent(this, ResultActivity.class); + intent.putExtra("success", success); + intent.putExtra("result", result); + startActivity(intent); + } + + private boolean isAlphaNumeric(String s) { + String pattern = "^[a-zA-Z0-9]*$"; + return s.matches(pattern); + } + + private void hideKeyboard() { + View view = this.getCurrentFocus(); + if (view != null) { + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + } + + private TextValidator getRequiredTextValidator(TextView textView) { + return new TextValidator(textView) { + @Override + public void validate(TextView textView, String text) { + if (TextUtils.isEmpty(text)) { + textView.setError("Field required"); + } else if (!isAlphaNumeric(text)) { + textView.setError("Must be alphanumeric"); + } + } + }; + } +} diff --git a/demoapp/src/library/java/com/queue_it/shopdemo/ResultActivity.java b/demoapp/src/library/java/com/queue_it/shopdemo/ResultActivity.java index bff5f51..ca00ede 100644 --- a/demoapp/src/library/java/com/queue_it/shopdemo/ResultActivity.java +++ b/demoapp/src/library/java/com/queue_it/shopdemo/ResultActivity.java @@ -1,56 +1,56 @@ -package com.queue_it.shopdemo; - -import android.content.Intent; -import android.os.Bundle; -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -import android.support.v4.content.res.ResourcesCompat; -import android.support.v7.app.AppCompatActivity; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; - - -public class ResultActivity extends AppCompatActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_result); - - String result; - boolean success; - if (savedInstanceState == null) { - Bundle extras = getIntent().getExtras(); - if (extras == null) { - result = null; - success = false; - } else { - result = extras.getString("result"); - success = extras.getBoolean("success"); - } - } else { - result = (String) savedInstanceState.getSerializable("result"); - success = (Boolean) savedInstanceState.getSerializable("success"); - } - - final TextView resultText = (TextView)findViewById(R.id.result_text); - final ImageView checkedImageView = (ImageView)findViewById(R.id.image_view_checked); - final FloatingActionButton retry_button = (FloatingActionButton)findViewById(R.id.retry_button); - - resultText.setText(result); - if (success){ - checkedImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_check_black_24dp, null)); - } else { - checkedImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_error_black_24dp, null)); - } - - retry_button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(ResultActivity.this, MainActivity.class); - startActivity(intent); - finish(); - } - }); - } -} +package com.queue_it.shopdemo; + +import android.content.Intent; +import android.os.Bundle; +import com.google.android.material.floatingactionbutton.FloatingActionButton; + +import android.support.v4.content.res.ResourcesCompat; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + + +public class ResultActivity extends AppCompatActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_result); + + String result; + boolean success; + if (savedInstanceState == null) { + Bundle extras = getIntent().getExtras(); + if (extras == null) { + result = null; + success = false; + } else { + result = extras.getString("result"); + success = extras.getBoolean("success"); + } + } else { + result = (String) savedInstanceState.getSerializable("result"); + success = (Boolean) savedInstanceState.getSerializable("success"); + } + + final TextView resultText = (TextView)findViewById(R.id.result_text); + final ImageView checkedImageView = (ImageView)findViewById(R.id.image_view_checked); + final FloatingActionButton retry_button = (FloatingActionButton)findViewById(R.id.retry_button); + + resultText.setText(result); + if (success){ + checkedImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_check_black_24dp, null)); + } else { + checkedImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_error_black_24dp, null)); + } + + retry_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(ResultActivity.this, MainActivity.class); + startActivity(intent); + finish(); + } + }); + } +} diff --git a/demoapp/src/library/java/com/queue_it/shopdemo/SecondFragment.java b/demoapp/src/library/java/com/queue_it/shopdemo/SecondFragment.java index 991ee41..44a234c 100644 --- a/demoapp/src/library/java/com/queue_it/shopdemo/SecondFragment.java +++ b/demoapp/src/library/java/com/queue_it/shopdemo/SecondFragment.java @@ -1,32 +1,32 @@ -package com.queue_it.shopdemo; - -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -public class SecondFragment extends Fragment { - - @Override - public View onCreateView( - LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState - ) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_second, container, false); - } - - public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { -// NavHostFragment.findNavController(SecondFragment.this) -// .navigate(R.id.action_SecondFragment_to_FirstFragment); - } - }); - } +package com.queue_it.shopdemo; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class SecondFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_second, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { +// NavHostFragment.findNavController(SecondFragment.this) +// .navigate(R.id.action_SecondFragment_to_FirstFragment); + } + }); + } } \ No newline at end of file diff --git a/demoapp/src/library/res/layout/activity_deep.xml b/demoapp/src/library/res/layout/activity_deep.xml index 08580ef..69876a0 100644 --- a/demoapp/src/library/res/layout/activity_deep.xml +++ b/demoapp/src/library/res/layout/activity_deep.xml @@ -1,33 +1,33 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/demoapp/src/library/res/layout/activity_main.xml b/demoapp/src/library/res/layout/activity_main.xml index ee7c443..2663300 100644 --- a/demoapp/src/library/res/layout/activity_main.xml +++ b/demoapp/src/library/res/layout/activity_main.xml @@ -1,189 +1,189 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demoapp/src/library/res/layout/activity_result.xml b/demoapp/src/library/res/layout/activity_result.xml index b898426..c427435 100644 --- a/demoapp/src/library/res/layout/activity_result.xml +++ b/demoapp/src/library/res/layout/activity_result.xml @@ -1,62 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/demoapp/src/library/res/layout/content_deep.xml b/demoapp/src/library/res/layout/content_deep.xml index 96f084d..bddaaf4 100644 --- a/demoapp/src/library/res/layout/content_deep.xml +++ b/demoapp/src/library/res/layout/content_deep.xml @@ -1,6 +1,6 @@ - - + \ No newline at end of file diff --git a/demoapp/src/library/res/layout/fragment_first.xml b/demoapp/src/library/res/layout/fragment_first.xml index 8cf9428..d9e300a 100644 --- a/demoapp/src/library/res/layout/fragment_first.xml +++ b/demoapp/src/library/res/layout/fragment_first.xml @@ -1,28 +1,28 @@ - - - - - -