Fix WebView uri handling, and fix top inset.

pull/90/head
Fox2Code 2 years ago
parent 52d22fe487
commit f8183bd2dc

@ -10,7 +10,7 @@ android {
applicationId "com.fox2code.mmm"
minSdk 21
targetSdk 32
versionCode 30
versionCode 31
versionName "0.3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

@ -244,7 +244,7 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O
swipeRefreshLayoutOrigStartOffset + combinedBarsHeight,
swipeRefreshLayoutOrigEndOffset + combinedBarsHeight);
this.moduleViewListBuilder.setHeaderPx(
actionBarHeight + CompatDisplay.dpToPixel(4));
actionBarHeight + CompatDisplay.dpToPixel(8));
this.moduleViewListBuilder.setFooterPx(
bottomInset + this.searchCard.getHeight());
this.searchCard.setRadius(this.searchCard.getHeight() / 2F);

@ -120,9 +120,9 @@ public class AndroidacyActivity extends CompatActivity {
public boolean shouldOverrideUrlLoading(
@NonNull WebView view, @NonNull WebResourceRequest request) {
// Don't open non Androidacy urls inside WebView
if (request.isForMainFrame() && !(request.getUrl().getScheme().equals("intent") ||
AndroidacyUtil.isAndroidacyLink(request.getUrl()))) {
IntentHelper.openUrl(view.getContext(), request.getUrl().toString());
if (request.isForMainFrame() &&
!AndroidacyUtil.isAndroidacyLink(request.getUrl())) {
IntentHelper.openUri(view.getContext(), request.getUrl().toString());
return true;
}
return false;

@ -30,8 +30,21 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
public class IntentHelper {
private static final String TAG = "IntentHelper";
public static void openUri(Context context, String uri) {
if (uri.startsWith("intent://")) {
try {
startActivity(context, Intent.parseUri(uri, Intent.URI_INTENT_SCHEME), false);
} catch (URISyntaxException | ActivityNotFoundException e) {
Log.e(TAG, "Failed launch of " + uri, e);
}
} else openUrl(context, uri);
}
public static void openUrl(Context context, String url) {
openUrl(context, url, false);
}
@ -227,7 +240,7 @@ public class IntentHelper {
callback.onReceived(destination, null, RESPONSE_ERROR);
return;
}
Log.d("IntentHelper", "FilePicker returned " + uri);
Log.d(TAG, "FilePicker returned " + uri);
if ("http".equals(uri.getScheme()) ||
"https".equals(uri.getScheme())) {
callback.onReceived(destination, uri, RESPONSE_URL);
@ -259,7 +272,7 @@ public class IntentHelper {
Files.copy(inputStream, outputStream);
success = true;
} catch (Exception e) {
Log.e("IntentHelper", "failed copy of " + uri, e);
Log.e(TAG, "failed copy of " + uri, e);
Toast.makeText(compatActivity,
R.string.file_picker_failure,
Toast.LENGTH_SHORT).show();
@ -267,7 +280,7 @@ public class IntentHelper {
Files.closeSilently(inputStream);
Files.closeSilently(outputStream);
if (!success && destination.exists() && !destination.delete())
Log.e("IntentHelper", "Failed to delete artefact!");
Log.e(TAG, "Failed to delete artefact!");
}
callback.onReceived(destination, uri, success ? RESPONSE_FILE : RESPONSE_ERROR);
});

Loading…
Cancel
Save