From b7b25ee819018972102983197d8d5269cb4707a7 Mon Sep 17 00:00:00 2001 From: Kevin Robatel Date: Tue, 9 Apr 2024 15:25:36 +0200 Subject: [PATCH] Don't use external browser + keep screen on (#7) * Add Gradle wrapper files * Remove android.support flavor * Remove signature * Let define pomFile * Remove signing * Don't use external browser + keep screen on * Add toolbar with back button --- .../androidsdk/QueueActivityBase.java | 19 ++++++++++++++++++- .../com/queue_it/androidsdk/UriOverrider.java | 12 +++++++----- .../res/drawable/ic_arrow_back_black_24dp.xml | 5 +++++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 library/src/main/res/drawable/ic_arrow_back_black_24dp.xml diff --git a/library/src/main/java/com/queue_it/androidsdk/QueueActivityBase.java b/library/src/main/java/com/queue_it/androidsdk/QueueActivityBase.java index f75b5ff..dc1b003 100644 --- a/library/src/main/java/com/queue_it/androidsdk/QueueActivityBase.java +++ b/library/src/main/java/com/queue_it/androidsdk/QueueActivityBase.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.util.Log; import android.view.View; +import android.view.WindowManager; import android.webkit.CookieSyncManager; import android.webkit.SslErrorHandler; import android.webkit.WebChromeClient; @@ -17,8 +18,11 @@ import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.ProgressBar; +import androidx.appcompat.widget.Toolbar; + public class QueueActivityBase { private final Activity _context; private String queueUrl; @@ -119,11 +123,24 @@ private static void cleanupWebView() { public void initialize(Bundle savedInstanceState) { uriOverrider = new UriOverrider(); _context.setContentView(R.layout.activity_queue); + // QoQa: Keep screen on + _context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); readActivityExtras(savedInstanceState); cleanupWebView(); final ProgressBar progressBar = _context.findViewById(R.id.progressBar); - FrameLayout layout = _context.findViewById(R.id.relativeLayout); + // QoQa: Add toolbar with back button + FrameLayout rootLayout = _context.findViewById(R.id.relativeLayout); + + LinearLayout layout = new LinearLayout(_context); + layout.setOrientation(LinearLayout.VERTICAL); + rootLayout.addView(layout); + + Toolbar toolbar = new Toolbar(_context); + toolbar.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp); + toolbar.setNavigationOnClickListener(v -> _context.onBackPressed()); + layout.addView(toolbar); + webview = new WebView(_context); layout.addView(webview); previousWebView = webview; diff --git a/library/src/main/java/com/queue_it/androidsdk/UriOverrider.java b/library/src/main/java/com/queue_it/androidsdk/UriOverrider.java index b355d28..b09ad63 100644 --- a/library/src/main/java/com/queue_it/androidsdk/UriOverrider.java +++ b/library/src/main/java/com/queue_it/androidsdk/UriOverrider.java @@ -121,11 +121,13 @@ public boolean handleNavigationRequest(final String destinationUrlStr, WebView w uriOverride.onPassed(queueItToken); return true; } - if (!isQueueItUrl) { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, destinationUri); - webview.getContext().startActivity(browserIntent); - return true; - } + + // QoQa: Don't open link in external browser +// if (!isQueueItUrl) { +// Intent browserIntent = new Intent(Intent.ACTION_VIEW, destinationUri); +// webview.getContext().startActivity(browserIntent); +// return true; +// } return false; } } diff --git a/library/src/main/res/drawable/ic_arrow_back_black_24dp.xml b/library/src/main/res/drawable/ic_arrow_back_black_24dp.xml new file mode 100644 index 0000000..a5b378a --- /dev/null +++ b/library/src/main/res/drawable/ic_arrow_back_black_24dp.xml @@ -0,0 +1,5 @@ + + +