Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
htr-tech authored Feb 18, 2025
1 parent 38577e5 commit d804233
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
run: chmod +x gradlew

- name: Build
run: ./gradlew assembleDebug
run: ./gradlew assembleRelease

- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: app.apk
path: ./app/build/outputs/apk/debug/app-debug.apk
name: release.apk
path: ./app/build/outputs/apk/release/app-release.apk
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 31
compileSdkVersion 35

defaultConfig {
applicationId "com.example.app"
applicationId "com.example.webapp"
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 35
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand Down
11 changes: 11 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}


-keep class com.example.webapp.** { *; }
-keep class android.webkit.** { *; }
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class **.R$* { *; }
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.example.app"
package="com.example.webapp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -12,7 +12,7 @@
tools:ignore="GoogleAppIndexingWarning">
<activity
android:configChanges="orientation|screenSize"
android:name="com.example.app.MainActivity"
android:name="com.example.webapp.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Binary file modified app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.app;
package com.example.webapp;

import android.annotation.SuppressLint;
import android.app.Activity;
Expand Down Expand Up @@ -77,10 +77,10 @@ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathC
});

// REMOTE RESOURCE
mWebView.loadUrl("https://example.com");
mWebView.loadUrl("https://github.com/htr-tech");

// LOCAL RESOURCE
mWebView.loadUrl("file:///android_asset/index.html");
// mWebView.loadUrl("file:///android_asset/index.html");
}

@Override
Expand Down Expand Up @@ -112,26 +112,26 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
// Mostrar um diálogo de confirmação antes de iniciar o download
new AlertDialog.Builder(MainActivity.this)
.setTitle("Download")
.setMessage("Deseja baixar o arquivo?")
.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
.setMessage("Do you want to download the file?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
String cookies = CookieManager.getInstance().getCookie(url);
String fileName = URLUtil.guessFileName(url, null, null);
request.addRequestHeader("cookie", cookies);
request.addRequestHeader("User-Agent", view.getSettings().getUserAgentString());
request.setDescription("Baixando arquivo...");
request.setDescription("Downloading file...");
request.setTitle(fileName);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);

DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(getApplicationContext(), "Baixando arquivo...", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Downloading file...", Toast.LENGTH_LONG).show();
}
})
.setNegativeButton("Não", new DialogInterface.OnClickListener() {
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.app;
package com.example.webapp;

import android.content.Intent;
import android.net.Uri;
Expand All @@ -12,7 +12,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
String hostname;

// YOUR HOSTNAME
hostname = "example.com";
hostname = "github.com";

Uri uri = Uri.parse(url);
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) {
Expand Down
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d804233

Please sign in to comment.