diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..c7f5bf3 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,76 @@ +name: "Lint" + +on: + workflow_dispatch: + push: + branches: [master] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: "Lint" + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Debug event.json" + if: ${{ !cancelled() }} + continue-on-error: true + run: | + cat "${GITHUB_EVENT_PATH}" + + - name: "Kotlin Lint" + if: ${{ !cancelled() }} + continue-on-error: true # TODO: Resolve KTLint Issues + env: + klint: ${RUNNER_TEMP}/ktlint + run: | + echo "Output File: ${{ env.klint }}" + wget -q https://github.com/pinterest/ktlint/releases/latest/download/ktlint -O ${{ env.klint }} + file ${{ env.klint }} + chmod +x ${{ env.klint }} + ${{ env.klint }} --version + ${{ env.klint }} --color 'app/src/main/java/**' + + - name: "Prettier" + if: ${{ !cancelled() }} + run: | + echo "::group::Install" + npm install prettier + echo "::endgroup::" + npx prettier --check . + + - name: "Yamllint" + if: ${{ !cancelled() }} + env: + CONFIG: "{extends: relaxed, ignore: [node_modules/,.github/disabled/], rules: {line-length: {max: 119}}}" + run: | + echo "::group::List Files" + yamllint -d '${{ env.CONFIG }}' --list-files . + echo "::endgroup::" + yamllint -d '${{ env.CONFIG }}' . + + - name: "Actionlint" + if: ${{ !cancelled() }} + run: | + echo "::group::Download" + loc=$(curl -sI https://github.com/rhysd/actionlint/releases/latest | grep -i '^location:') + echo "loc: ${loc}" + tag=$(echo "${loc}" | sed -E 's|.*/tag/v?(.*)|\1|' | tr -d '\t\r\n') + echo "tag: ${tag}" + url="https://github.com/rhysd/actionlint/releases/latest/download/actionlint_${tag}_linux_amd64.tar.gz" + echo "url: ${url}" + curl -sL "${url}" | tar xz -C "${RUNNER_TEMP}" actionlint + file "${RUNNER_TEMP}/actionlint" + "${RUNNER_TEMP}/actionlint" --version + echo "::endgroup::" + "${RUNNER_TEMP}/actionlint" -color -verbose -shellcheck= -pyflakes= diff --git a/.gitignore b/.gitignore index 6cb92aa..e59c676 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ app/release local.properties *.keystore +*.logcat diff --git a/README.md b/README.md index a8cdc7f..6487442 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![GitHub Downloads](https://img.shields.io/github/downloads/cssnr/zipline-android/total?logo=github)](https://github.com/cssnr/zipline-android/releases/latest/download/zipline.apk) [![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/zipline-android?logo=github)](https://github.com/cssnr/zipline-android/releases/latest) +[![Lint](https://img.shields.io/github/actions/workflow/status/cssnr/zipline-android/lint.yaml?logo=github&logoColor=white&label=lint)](https://github.com/cssnr/zipline-android/actions/workflows/lint.yaml) [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/zipline-android?logo=htmx)](https://github.com/cssnr/zipline-android) [![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/zipline-android?logo=github&label=updated)](https://github.com/cssnr/zipline-android/graphs/commit-activity) [![GitHub Repo Size](https://img.shields.io/github/repo-size/cssnr/zipline-android?logo=bookstack&logoColor=white&label=repo%20size)](https://github.com/cssnr/zipline-android) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4f1a602..d5d85d7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,15 +40,14 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(libs.material) implementation(libs.androidx.activity) + implementation(libs.okhttp) implementation(libs.retrofit) implementation(libs.retrofit.gson) - implementation(libs.okhttp) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) -} \ No newline at end of file +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 101c61d..51b896a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,13 +13,14 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Zipline" - tools:targetApi="35" android:enableOnBackInvokedCallback="true" - android:usesCleartextTraffic="true"> + android:usesCleartextTraffic="true" + tools:targetApi="35"> + android:windowSoftInputMode="adjustResize" + android:configChanges="orientation|smallestScreenSize|screenSize|screenLayout|keyboardHidden"> diff --git a/app/src/main/java/org/cssnr/zipline/MainActivity.kt b/app/src/main/java/org/cssnr/zipline/MainActivity.kt index 3808297..33cb914 100644 --- a/app/src/main/java/org/cssnr/zipline/MainActivity.kt +++ b/app/src/main/java/org/cssnr/zipline/MainActivity.kt @@ -25,8 +25,7 @@ class MainActivity : AppCompatActivity() { @SuppressLint("SetJavaScriptEnabled") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - Log.d("MainActivity", "onCreate") - + Log.d("onCreate", "savedInstanceState: $savedInstanceState") enableEdgeToEdge() binding = ActivityMainBinding.inflate(layoutInflater) @@ -51,6 +50,32 @@ class MainActivity : AppCompatActivity() { handleIntent(intent) } + override fun onSaveInstanceState(outState: Bundle) { + Log.d("onSaveInstanceState", "outState: $outState") + super.onSaveInstanceState(outState) + binding.webView.saveState(outState) + } + + override fun onRestoreInstanceState(savedInstanceState: Bundle) { + Log.d("onRestoreInstanceState", "savedInstanceState: $savedInstanceState") + super.onRestoreInstanceState(savedInstanceState) + binding.webView.restoreState(savedInstanceState) + } + + override fun onPause() { + Log.d("onPause", "ON PAUSE") + super.onPause() + binding.webView.onPause() + binding.webView.pauseTimers() + } + + override fun onResume() { + Log.d("onResume", "ON RESUME") + super.onResume() + binding.webView.onResume() + binding.webView.resumeTimers() + } + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) Log.d("onNewIntent", "intent: $intent") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d5d7213..b55da76 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,8 +8,8 @@ espressoCore = "3.6.1" appcompat = "1.7.0" material = "1.12.0" activity = "1.10.1" -retrofit = "2.9.0" okhttp = "4.12.0" +retrofit = "2.9.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -19,9 +19,9 @@ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-co androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } retrofit-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } -okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" }