Skip to content

Commit

Permalink
Don't use external browser + keep screen on (#7)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Kevinrob authored Apr 9, 2024
1 parent 1006d25 commit b7b25ee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions library/src/main/java/com/queue_it/androidsdk/UriOverrider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 5 additions & 0 deletions library/src/main/res/drawable/ic_arrow_back_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

0 comments on commit b7b25ee

Please sign in to comment.