Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various updates #124

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
/build
/captures
.externalNativeBuild
/.kotlin
.cxx
.idea
29 changes: 15 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
defaultConfig {
applicationId "com.example.deeplviewer"
minSdkVersion 21
targetSdkVersion 33
compileSdk 33
targetSdkVersion 35
compileSdk 35
versionCode 38
versionName "8.5"

Expand All @@ -19,6 +18,7 @@ android {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
applicationIdSuffix '.debug'
}
release {
shrinkResources true
Expand All @@ -34,6 +34,7 @@ android {

buildFeatures {
buildConfig true
viewBinding true
}
}

Expand All @@ -55,17 +56,17 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation "androidx.webkit:webkit:1.5.0"
implementation "androidx.preference:preference-ktx:1.2.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'com.google.errorprone:error_prone_annotations:2.10.0'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.webkit:webkit:1.12.1"
implementation "androidx.preference:preference-ktx:1.2.1"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7'
implementation 'com.google.errorprone:error_prone_annotations:2.26.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.facebook.shimmer:shimmer:0.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test:runner:1.6.2'
androidTestImplementation 'androidx.test:rules:1.6.1'
}
1 change: 1 addition & 0 deletions app/src/main/assets/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $('head').append(`<style>
div[data-testid="chrome-extension-toast"],
div[data-testid="firefox-extension-toast"],
div[id="cookieBanner"],
div[aria-labelledby="app-stores-banner-description"], /* Download app from Play Store banner */
aside {
display: none !important;
visibility: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
createWebView(intent, savedInstanceState)

val settingButton: ImageButton = findViewById(R.id.settingButton)

settingButton.setOnClickListener {
findViewById<ImageButton>(R.id.settingButton).setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
Expand Down Expand Up @@ -64,6 +62,7 @@ class MainActivity : AppCompatActivity() {
}

CookieManagerHelper().migrateCookie(this)
CookieManagerHelper().addPrivacyCookie()

webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
Expand All @@ -90,7 +89,7 @@ class MainActivity : AppCompatActivity() {
val originUrlParam = startUrl.substringAfter("translator")
val isTextChanged = urlParam != originUrlParam

if (isTextChanged) {
if (isTextChanged && urlParam.isNotEmpty()) {
val urlText = urlParam.substring(originUrlParam.length)
val inputText = Uri.decode(urlText).replace("\\/", "/")
outState.putString("SavedText", inputText)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.util.Log
import android.webkit.CookieManager
import android.webkit.WebView
import com.example.deeplviewer.R
import java.net.URLEncoder

class CookieManagerHelper {
companion object {
Expand All @@ -13,6 +14,15 @@ class CookieManagerHelper {
}
}

fun addPrivacyCookie() {
val privacyValue = "{\"v\":2,\"t\":${System.currentTimeMillis().div(1000)},\"m\":\"STRICT\",\"consent\":[\"NECESSARY\"]}"

getCookieManager().setCookie(
".deepl.com",
"privacySettings=${URLEncoder.encode(privacyValue, Charsets.UTF_8.name())}"
)
}

fun saveCookies(context: Context, webView: WebView) {
val cookieManager = getCookieManager()
val isCookieAutoDeleted = context.getSharedPreferences("config", Context.MODE_PRIVATE)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:fitsSystemWindows="true">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/settings_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:fitsSystemWindows="true">

<androidx.appcompat.widget.Toolbar
android:id="@+id/settingsToolbar"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '2.0.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.4.2'
classpath 'com.android.tools.build:gradle:8.7.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# org.gradle.parallel=true
#Mon Oct 18 15:35:31 JST 2021
kotlin.code.style=official
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M"
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options=-Xmx2048M
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=false
android.enableR8.fullMode=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
54 changes: 36 additions & 18 deletions gradlew
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright ? 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand All @@ -32,10 +34,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions á$varâ, á${var}â, á${var:-default}â, á${var+SET}â,
# á${var#prefix}â, á${var%suffix}â, and á$( cmd )â;
# * compound commands having a testable exit status, especially ácaseâ;
# * various built-in commands including ácommandâ, ásetâ, and áulimitâ.
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand All @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +82,12 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +134,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +201,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Loading
Loading