diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a8d74aa --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 5 + labels: + - "dependencies" + - "github-actions" + commit-message: + prefix: "ci" + include: "scope" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..23dbdc9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,81 @@ +name: Lint + +on: + push: + branches: + - main + - upstream-v7.0.0 + pull_request: + +jobs: + detekt: + name: Detekt (Kotlin) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Make gradlew executable + run: chmod +x gradlew + + - name: Run Detekt + continue-on-error: true + run: ./gradlew detekt --no-daemon --continue || true + + - name: Upload Detekt SARIF + if: always() + uses: github/codeql-action/upload-sarif@v3 + continue-on-error: true + with: + sarif_file: app/build/reports/detekt/detekt.sarif + category: detekt + + spotless: + name: Spotless (formatting) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Make gradlew executable + run: chmod +x gradlew + + - name: Check Spotless + continue-on-error: true + run: ./gradlew spotlessCheck --no-daemon || true + + android-lint: + name: Android Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Make gradlew executable + run: chmod +x gradlew + + - name: Run Android Lint + continue-on-error: true + run: ./gradlew :app:lintRelease --no-daemon || true + + - name: Upload Lint report + if: always() + uses: actions/upload-artifact@v4 + with: + name: android-lint-report + path: app/build/reports/lint-results-release.html diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6512713 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,100 @@ +name: Release APK + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name to attach the APK to (e.g. v7.1.0)' + required: true + type: string + +permissions: + contents: write + +jobs: + build-release: + name: Build and publish APK + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + develocity-injection-enabled: false + cache-read-only: true + + - name: Make gradlew executable + run: chmod +x gradlew + + - name: Build Release APK + env: + SKETCHUB_API_KEY: ${{ secrets.SKETCHUB_API_KEY }} + run: ./gradlew --no-build-cache --no-configuration-cache --no-daemon assembleRelease + + - name: Resolve tag name + id: tag + shell: bash + # Workflow-dispatch input is funneled through an env var so a + # malicious tag_name cannot break out of the bash context. + env: + INPUT_TAG_NAME: ${{ inputs.tag_name }} + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + TAG_NAME="$INPUT_TAG_NAME" + else + TAG_NAME="${GITHUB_REF#refs/tags/}" + fi + # Refuse anything but a sensible release tag to belt-and-braces + # the env-var defence above. + if ! [[ "$TAG_NAME" =~ ^[A-Za-z0-9._-]+$ ]]; then + echo "::error::Refusing unsafe tag name: $TAG_NAME" + exit 1 + fi + echo "name=$TAG_NAME" >> "$GITHUB_OUTPUT" + + - name: Rename APK with tag + shell: bash + env: + TAG_NAME: ${{ steps.tag.outputs.name }} + run: | + cd app/build/outputs/apk/release + if [[ -f app-release.apk ]]; then + mv app-release.apk "SketchwarePro-${TAG_NAME}.apk" + fi + ls -la + + - name: Compute checksums + # Runs AFTER the rename so SHA256SUMS.txt references the final + # filename users will actually download from the release. + working-directory: app/build/outputs/apk/release + run: | + sha256sum *.apk > SHA256SUMS.txt + cat SHA256SUMS.txt + + - name: Create or update GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.tag.outputs.name }} + name: Sketchware Pro ${{ steps.tag.outputs.name }} + generate_release_notes: true + fail_on_unmatched_files: false + files: | + app/build/outputs/apk/release/SketchwarePro-${{ steps.tag.outputs.name }}.apk + app/build/outputs/apk/release/SHA256SUMS.txt + + - name: Upload APK as workflow artifact + uses: actions/upload-artifact@v4 + with: + name: SketchwarePro-${{ steps.tag.outputs.name }} + path: app/build/outputs/apk/release/* + retention-days: 30 diff --git a/app/build.gradle b/app/build.gradle index 607d74c..169c6f9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,6 +3,54 @@ def analyticsEnabled = secrets != null apply plugin: "com.android.application" apply plugin: "kotlin-android" +apply plugin: "io.gitlab.arturbosch.detekt" +apply plugin: "com.diffplug.spotless" + +detekt { + config.from(files("$rootDir/config/detekt/detekt.yml")) + parallel = true + buildUponDefaultConfig = true + autoCorrect = false + source.setFrom(files("src/main/java")) +} + +tasks.named("detekt").configure { + reports { + sarif.required.set(true) + html.required.set(true) + txt.required.set(false) + xml.required.set(false) + md.required.set(false) + } + // Detekt is informational only for now; remove ignoreFailures once + // the existing legacy code base is gradually cleaned up. + ignoreFailures = true +} + +spotless { + kotlin { + target "src/main/java/**/*.kt", "src/test/java/**/*.kt" + targetExclude "src/main/java/a/**", "src/main/java/com/besome/**", "src/main/java/mod/agus/**", "src/main/java/kellinwood/**" + ktlint("1.3.1").editorConfigOverride([ + "ktlint_standard_function-naming": "disabled", + "ktlint_standard_property-naming": "disabled", + "ktlint_standard_no-wildcard-imports": "disabled", + "ktlint_standard_filename": "disabled", + ]) + endWithNewline() + trimTrailingWhitespace() + } + kotlinGradle { + target "*.gradle.kts", "*.gradle" + ktlint("1.3.1") + } + format "misc", { + target "**/*.md", "**/*.gitignore", "**/*.yml", "**/*.yaml" + targetExclude "**/build/**", "**/.gradle/**" + trimTrailingWhitespace() + endWithNewline() + } +} if (analyticsEnabled) { apply plugin: "com.google.gms.google-services" @@ -71,6 +119,16 @@ android { buildConfig = true } + testOptions { + unitTests { + // Lets unit tests call into Android classes that exist only as + // stubs in the SDK jar (e.g. android.util.Pair, android.text.TextUtils) + // by returning default values instead of throwing "Stub!" errors. + returnDefaultValues = true + includeAndroidResources = false + } + } + configurations.implementation { exclude group: 'javax.inject', module: 'javax.inject' exclude group: "org.jetbrains.kotlin", module: "kotlin-scripting-compiler-embeddable" @@ -167,4 +225,25 @@ dependencies { implementation "com.google.firebase:firebase-analytics" implementation "com.google.firebase:firebase-messaging" coreLibraryDesugaring "com.android.tools:desugar_jdk_libs_nio:2.1.5" + + // ----- Test scaffolding (JUnit 5 + MockK + Truth) ----- + testImplementation platform("org.junit:junit-bom:5.11.4") + testImplementation "org.junit.jupiter:junit-jupiter" + testRuntimeOnly "org.junit.platform:junit-platform-launcher" + testImplementation "org.junit.jupiter:junit-jupiter-params" + testImplementation "io.mockk:mockk:1.13.13" + testImplementation "com.google.truth:truth:1.4.4" + testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1" + testImplementation "androidx.arch.core:core-testing:2.2.0" + + androidTestImplementation "androidx.test.ext:junit:1.2.1" + androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1" +} + +tasks.withType(Test).configureEach { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + showStandardStreams = false + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e8c8043..7f35b0f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,10 +22,23 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:largeHeap="true" + android:localeConfig="@xml/locales_config" + android:supportsRtl="true" android:requestLegacyExternalStorage="true" android:theme="@style/Theme.SketchwarePro" android:usesCleartextTraffic="true" tools:targetApi="p"> + + + + + + isDynamicColorEnabled(activity)) + .build(); + DynamicColors.applyToActivitiesIfAvailable(application, options); + } + + public static boolean isDynamicColorEnabled(Context context) { + return getPreferences(context).getBoolean(DYNAMIC_COLOR_KEY, true); + } + + public static void setDynamicColorEnabled(Context context, boolean enabled) { + getPreferences(context).edit().putBoolean(DYNAMIC_COLOR_KEY, enabled).apply(); + } + public static int getCurrentTheme(Context context) { return getPreferences(context).getInt(THEME_KEY, THEME_SYSTEM); } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml new file mode 100644 index 0000000..198bb97 --- /dev/null +++ b/app/src/main/res/values-ar/strings.xml @@ -0,0 +1,121 @@ + + + + + سكتشوير برو + + + حفظ + شاشة + إضافة + موافق + الكل + بلوك + إلغاء + تغيير + اختيار + إغلاق + مجموعة + مكوّن + متابعة + مساهم + نسخ + إنشاء + عنصر مخصص + فك التشفير + حذف + تم الحذف! + تجاهل + *مهجور + الوصف + التفاصيل + تنزيل + نسخ مكرر + القائمة الجانبية + تعديل + انتهى + اشتراك + مشترك + خروج + تصدير + إنهاء + خط + انتقل للتوثيق + رجوع + صورة + استيراد الكل + استيراد + استيراد %s عنصر + معلومات + اللغة + تعديل + بلوك إضافي + التالي + لا + موافق + السابق + معاينة + خاص + جاري التنفيذ + معلومات المشروع + اسم التطبيق + حزمة الكود + المشروع + رقم الإصدار + اسم الإصدار + عام + شراء + إزالة + إعادة تعيين + استعادة + مراجعة + تشغيل + حفظ + تم الحفظ + حفظ كنسخة جديدة + عرض الكل + عرض المزيد + اختيار + اختر متغيراً + تغيير المتغير + إنشاء متغير جديد + استيراد من المتغير الافتراضي + الإعدادات + مشاركة + عرض + صوت + خطوة %d + إرسال + حاول مرة أخرى + تحديث + رفع + نعم + + + التوثيق + تصدير الروابط + إعدادات اللغة + معلومات البرنامج + قائمة المشتريات + إزالة الإعلانات + حفظ سكتشوير + شارك مع أصدقائك + اشترك + إعدادات النظام + + + مكوّنات + تحكم + ملفات + قوائم + رياضيات + بلوكات إضافية + عمليات + متغيرات + عناصر العرض + نقل لسلة المحذوفات + diff --git a/app/src/main/res/xml/locales_config.xml b/app/src/main/res/xml/locales_config.xml new file mode 100644 index 0000000..ef83d0d --- /dev/null +++ b/app/src/main/res/xml/locales_config.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/app/src/test/java/pro/sketchware/utility/CustomVariableUtilTest.kt b/app/src/test/java/pro/sketchware/utility/CustomVariableUtilTest.kt new file mode 100644 index 0000000..b3cda6b --- /dev/null +++ b/app/src/test/java/pro/sketchware/utility/CustomVariableUtilTest.kt @@ -0,0 +1,48 @@ +package pro.sketchware.utility + +import com.google.common.truth.Truth.assertThat +import org.junit.jupiter.api.Test + +/** + * Unit tests for [CustomVariableUtil]. The class powers the "custom variable" + * declaration parser used by Sketchware's Java exporter, so the regex needs + * to handle the most common Java field declaration shapes. + */ +class CustomVariableUtilTest { + + @Test + fun `parses simple typed declaration with initializer`() { + val input = "private String userName = \"alice\"" + assertThat(CustomVariableUtil.getVariableModifier(input)).isEqualTo("private") + assertThat(CustomVariableUtil.getVariableType(input)).isEqualTo("String") + assertThat(CustomVariableUtil.getVariableName(input)).isEqualTo("userName") + assertThat(CustomVariableUtil.getVariableInitializer(input)?.trim()) + .isEqualTo("\"alice\"") + } + + @Test + fun `parses generic type declaration without initializer`() { + val input = "public List tags" + assertThat(CustomVariableUtil.getVariableModifier(input)).isEqualTo("public") + assertThat(CustomVariableUtil.getVariableType(input)).isEqualTo("List") + assertThat(CustomVariableUtil.getVariableName(input)).isEqualTo("tags") + assertThat(CustomVariableUtil.getVariableInitializer(input)).isNull() + } + + @Test + fun `parses array declaration`() { + val input = "static int[] codes" + assertThat(CustomVariableUtil.getVariableType(input)).isEqualTo("int[]") + assertThat(CustomVariableUtil.getVariableName(input)).isEqualTo("codes") + } + + @Test + fun `parses package-private declaration with no modifier`() { + val input = "double total = 0.0" + assertThat(CustomVariableUtil.getVariableModifier(input)).isEmpty() + assertThat(CustomVariableUtil.getVariableType(input)).isEqualTo("double") + assertThat(CustomVariableUtil.getVariableName(input)).isEqualTo("total") + assertThat(CustomVariableUtil.getVariableInitializer(input)?.trim()) + .isEqualTo("0.0") + } +} diff --git a/app/src/test/java/pro/sketchware/utility/PropertiesUtilTest.kt b/app/src/test/java/pro/sketchware/utility/PropertiesUtilTest.kt new file mode 100644 index 0000000..1628b77 --- /dev/null +++ b/app/src/test/java/pro/sketchware/utility/PropertiesUtilTest.kt @@ -0,0 +1,61 @@ +package pro.sketchware.utility + +import com.google.common.truth.Truth.assertThat +import org.junit.jupiter.api.Test + +/** + * Pure-JVM unit tests for [PropertiesUtil]. We only exercise the helpers that + * don't reach into android.util.Pair / android.text.TextUtils — those are + * covered by instrumentation tests because the Android SDK stubs in the + * unit-test classpath throw "Stub!" RuntimeExceptions for them. + */ +class PropertiesUtilTest { + + @Test + fun `parseReferName extracts value after separator`() { + assertThat(PropertiesUtil.parseReferName("@string/app_name", "/")).isEqualTo("app_name") + } + + @Test + fun `parseReferName returns input when separator missing`() { + assertThat(PropertiesUtil.parseReferName("just_text", "/")).isEqualTo("just_text") + } + + @Test + fun `parseReferName returns null for null input`() { + assertThat(PropertiesUtil.parseReferName(null, "/")).isNull() + } + + @Test + fun `parseReferName returns input unchanged when separator is the last character`() { + // Separator at the very end means there is no value after it. + assertThat(PropertiesUtil.parseReferName("foo/", "/")).isEqualTo("foo/") + } + + @Test + fun `generateItems creates the requested number of labelled rows`() { + val items = PropertiesUtil.generateItems("Item", 3) + assertThat(items).containsExactly("Item 1", "Item 2", "Item 3").inOrder() + } + + @Test + fun `generateItems returns empty list when count is zero`() { + assertThat(PropertiesUtil.generateItems("X", 0)).isEmpty() + } + + @Test + fun `generateItems supports a different prefix`() { + assertThat(PropertiesUtil.generateItems("Tab", 2)) + .containsExactly("Tab 1", "Tab 2").inOrder() + } + + @Test + fun `regex constants are exposed and usable`() { + // Defensive: we don't want a refactor to silently break the regex API. + assertThat(PropertiesUtil.HEX_COLOR_PATTERN.pattern()) + .isEqualTo("^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$") + assertThat(PropertiesUtil.UNIT_PATTERN.matcher("16dp").find()).isTrue() + assertThat(PropertiesUtil.UNIT_PATTERN.matcher("12sp").find()).isTrue() + assertThat(PropertiesUtil.UNIT_PATTERN.matcher("plain").find()).isFalse() + } +} diff --git a/app/src/test/java/pro/sketchware/utility/locale/LocaleHelperTest.kt b/app/src/test/java/pro/sketchware/utility/locale/LocaleHelperTest.kt new file mode 100644 index 0000000..c735ea1 --- /dev/null +++ b/app/src/test/java/pro/sketchware/utility/locale/LocaleHelperTest.kt @@ -0,0 +1,40 @@ +package pro.sketchware.utility.locale + +import androidx.appcompat.app.AppCompatDelegate +import androidx.core.os.LocaleListCompat +import com.google.common.truth.Truth.assertThat +import io.mockk.every +import io.mockk.mockkStatic +import io.mockk.unmockkAll +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +/** + * Unit tests for [LocaleHelper]. We mock {@link AppCompatDelegate} (a static API + * surface) using MockK so the helper logic can be exercised in plain JVM tests. + */ +class LocaleHelperTest { + + @BeforeEach + fun setUp() { + mockkStatic(AppCompatDelegate::class) + } + + @AfterEach + fun tearDown() { + unmockkAll() + } + + @Test + fun `getCurrentTag returns empty string when no override is active`() { + every { AppCompatDelegate.getApplicationLocales() } returns LocaleListCompat.getEmptyLocaleList() + assertThat(LocaleHelper.getCurrentTag()).isEmpty() + } + + @Test + fun `getCurrentTag returns the active BCP47 tag`() { + every { AppCompatDelegate.getApplicationLocales() } returns LocaleListCompat.forLanguageTags("ar") + assertThat(LocaleHelper.getCurrentTag()).isEqualTo("ar") + } +} diff --git a/build.gradle b/build.gradle index 6a00507..03bc913 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,11 @@ buildscript { } } +plugins { + id "io.gitlab.arturbosch.detekt" version "1.23.7" apply false + id "com.diffplug.spotless" version "6.25.0" apply false +} + tasks.register("clean", Delete) { delete rootProject.layout.buildDirectory } diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml new file mode 100644 index 0000000..9348661 --- /dev/null +++ b/config/detekt/detekt.yml @@ -0,0 +1,95 @@ +build: + maxIssues: 0 + excludeCorrectable: false + weights: + complexity: 2 + formatting: 1 + comments: 1 + +config: + validation: true + warningsAsErrors: false + excludes: '' + +complexity: + active: true + LongMethod: + active: true + threshold: 200 + LongParameterList: + active: true + functionThreshold: 8 + constructorThreshold: 10 + TooManyFunctions: + active: false + CyclomaticComplexMethod: + active: true + threshold: 25 + NestedBlockDepth: + active: true + threshold: 6 + LargeClass: + active: true + threshold: 600 + +style: + active: true + MagicNumber: + active: false + MaxLineLength: + active: true + maxLineLength: 140 + excludePackageStatements: true + excludeImportStatements: true + NewLineAtEndOfFile: + active: true + UnnecessaryAbstractClass: + active: false + WildcardImport: + active: true + SerialVersionUIDInSerializableClass: + active: false + +performance: + active: true + +potential-bugs: + active: true + UnsafeCast: + active: true + +empty-blocks: + active: true + EmptyFunctionBlock: + active: true + +exceptions: + active: true + SwallowedException: + active: true + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException + +naming: + active: true + FunctionNaming: + active: true + functionPattern: '[a-z][a-zA-Z0-9]*' + ClassNaming: + active: true + classPattern: '[A-Z][a-zA-Z0-9]*' + VariableNaming: + active: true + variablePattern: '[a-z][A-Za-z0-9]*' + +formatting: + active: true + android: true + autoCorrect: true + Indentation: + active: true + autoCorrect: true + indentSize: 4 diff --git a/docs/CONTRIBUTING-i18n.md b/docs/CONTRIBUTING-i18n.md new file mode 100644 index 0000000..cac25a1 --- /dev/null +++ b/docs/CONTRIBUTING-i18n.md @@ -0,0 +1,60 @@ +# Translating Sketchware Pro + +Sketchware Pro ships an English UI with progressively-extended translations +for the largest user communities. This document explains how to contribute +translations. + +## Where strings live + +* Source-of-truth English strings: `app/src/main/res/values/strings.xml`. +* Per-locale overrides: `app/src/main/res/values-/strings.xml`. + When a key is missing in a locale file Android falls back to the base + English string, so partial translations are always safe to merge. + +## Supported locales + +Declared in `app/src/main/res/xml/locales_config.xml`. We only list a +locale here once at least a partial translation exists at +`app/src/main/res/values-/strings.xml` — otherwise the +Android 13+ system language picker would advertise a language that +silently falls back to English. + +### Currently shipping +| Tag | Language | Status | +|--------|-------------------|---------------| +| `en` | English (default) | 100% | +| `ar` | Arabic | Phase 1 seed | + +### Planned (will be added to `locales_config.xml` together with their `values-/`) +- `id` — Indonesian +- `pt-BR` — Portuguese (Brazil) +- `es` — Spanish +- `ru` — Russian +- `hi` — Hindi +- `fa` — Persian +- `tr` — Turkish +- `vi` — Vietnamese + +## How to translate + +1. Find your locale folder in `app/src/main/res/values-/`. If it + doesn't exist yet, create it and copy `strings.xml` from `values/`. +2. Translate strings in place. Keep the `name` attribute identical; only + change the value. Preserve any format placeholders (`%s`, `%d`, + `%1$d`, etc.) and HTML tags exactly as in the source. +3. Open a PR. Title format: `i18n(): translate `. + +## Per-app language at runtime + +The app uses AndroidX AppCompat 1.7's per-app language API +(`AppCompatDelegate.setApplicationLocales`). The user's choice is +persisted automatically via the `AppLocalesMetadataHolderService` +declared in `AndroidManifest.xml` with `autoStoreLocales=true`. There is +no need to wrap activities in a custom `LocaleHelper` for context. + +## RTL languages + +Arabic and Persian are right-to-left. The app already declares +`android:supportsRtl="true"` (default true on AppCompat themes) and most +layouts use `start`/`end` instead of `left`/`right`. If you spot a layout +that mirrors incorrectly, please open an issue with a screenshot. diff --git a/docs/adr/0001-record-architecture-decisions.md b/docs/adr/0001-record-architecture-decisions.md new file mode 100644 index 0000000..103272d --- /dev/null +++ b/docs/adr/0001-record-architecture-decisions.md @@ -0,0 +1,31 @@ +# 1. Record architecture decisions + +Date: 2026-04-25 + +## Status + +Accepted + +## Context + +Sketchware Pro started life as a community-maintained mod of the original +Sketchware app. The project has grown to ~200k LOC across Java + Kotlin with +many overlapping subsystems (legacy `a.a.a.*`, contributor `mod.*`, modern +`pro.sketchware.*`). Future contributors need a low-friction way to understand +why the codebase looks the way it does and to propose changes that affect +multiple modules. + +## Decision + +We will record significant architectural decisions in this directory using +the [ADR template](https://github.com/joelparkerhenderson/architecture-decision-record). +Each ADR is an immutable, numbered Markdown file describing the context, the +decision, and the consequences. Superseded ADRs are kept for history and link +to the ADR that replaces them. + +## Consequences + +* New contributors can answer "why is X done this way?" by reading ADRs. +* Architectural debates leave a paper trail instead of being scattered across + Discord/Telegram/PR comments. +* PRs that materially change architecture must add or update an ADR. diff --git a/docs/adr/0002-pin-r8-to-8-11-x.md b/docs/adr/0002-pin-r8-to-8-11-x.md new file mode 100644 index 0000000..82f07fc --- /dev/null +++ b/docs/adr/0002-pin-r8-to-8-11-x.md @@ -0,0 +1,30 @@ +# 2. Pin r8 to the 8.11.x line until DependencyResolver is migrated + +Date: 2026-04-25 + +## Status + +Accepted + +## Context + +Library updates in PR #1 brought the Android Gradle Plugin to 8.13.x and +the standalone `com.android.tools:r8` artifact to its current latest. r8 +8.13+ migrated several internal API signatures, notably +`D8Command.Builder.addClasspathFiles`, from `java.io.File` to +`java.nio.file.Path`. The on-device dependency resolver +(`mod/pranav/dependency/resolver/DependencyResolver.kt`) calls the older +signature directly and fails to compile against the newer API. + +## Decision + +We pin `com.android.tools:r8` to `8.11.18` in `app/build.gradle` and add +a Renovate package rule (`<8.12.0`) so automated bumps don't override the +pin. A follow-up task will port `DependencyResolver.kt` to the new Path- +based API and remove the pin. + +## Consequences + +* Builds remain green with current AGP and Kotlin versions. +* On-device dependency resolution continues to work unchanged. +* We carry technical debt until `DependencyResolver.kt` is migrated. diff --git a/docs/adr/0003-defer-modular-refactor.md b/docs/adr/0003-defer-modular-refactor.md new file mode 100644 index 0000000..1fa9c6c --- /dev/null +++ b/docs/adr/0003-defer-modular-refactor.md @@ -0,0 +1,38 @@ +# 3. Defer the modular Gradle refactor; introduce package boundaries first + +Date: 2026-04-25 + +## Status + +Accepted + +## Context + +The professional roadmap proposes a multi-module Gradle structure +(`core-*`, `feature-*`, `builder-*`, `blocks-*`, `components-*`, +`plugins-*`). Splitting the existing monolithic `:app` module is a +multi-month effort because legacy Java code in `a.a.a.*`, `com.besome.*` +and `mod.agus.*` has dense cyclic dependencies. Doing this in one PR +would block all other work and produce a giant unreviewable diff. + +## Decision + +In Phase 1 we leave the Gradle module structure as-is and instead: + +1. Establish package boundaries by isolating new code under + `pro.sketchware.`. +2. Add Detekt + Spotless to enforce style on the new code only + (legacy packages are excluded via `targetExclude` in `spotless`). +3. Author ADRs for any boundary-crossing change so the eventual + modularisation has a clear migration map. + +The actual `:core-common`, `:core-ui`, `:feature-projects` Gradle modules +will be introduced incrementally in Phase 2 once at least one feature has +a clean package boundary that can be lifted out. + +## Consequences + +* No "big bang" refactor PR. Reviewers can keep up. +* Modularisation slips into Phase 2 / Q2 2026. +* New code must follow the package convention or risk being absorbed back + into the monolith. diff --git a/releases/README.md b/releases/README.md new file mode 100644 index 0000000..6f5f7a9 --- /dev/null +++ b/releases/README.md @@ -0,0 +1,25 @@ +# Pre-built APKs + +GitHub blocks files larger than 100 MB on push, and the Sketchware Pro +release APK is ~124 MB, so the binaries themselves live exclusively on +[GitHub Releases](https://github.com/Dr-Code-EG/Sketchware-Pro/releases). +This directory holds checksums and pointers so that an offline clone can +still verify a downloaded APK. + +| Tag | APK download | SHA-256 | +|---|---|---| +| `v7.0.0-phase1-r1` | [SketchwarePro-v7.0.0-phase1-r1.apk](https://github.com/Dr-Code-EG/Sketchware-Pro/releases/download/v7.0.0-phase1-r1/SketchwarePro-v7.0.0-phase1-r1.apk) | see [`v7.0.0-phase1-r1.sha256`](./v7.0.0-phase1-r1.sha256) | + +## Verifying a downloaded APK + +```bash +# Once you've downloaded the APK from the Releases page: +sha256sum -c releases/v7.0.0-phase1-r1.sha256 +``` + +## Why not commit the APK? + +GitHub's pre-receive hook rejects pushes containing files > 100 MB. +Switching to git-LFS would solve that but adds friction for casual +contributors who clone the repo. Releases are the canonical +distribution channel and are versioned alongside git tags. diff --git a/releases/v7.0.0-phase1-r1.sha256 b/releases/v7.0.0-phase1-r1.sha256 new file mode 100644 index 0000000..6064a89 --- /dev/null +++ b/releases/v7.0.0-phase1-r1.sha256 @@ -0,0 +1 @@ +2185ad263d4007273faf4b29a644ae4d626b5f5ba0f2a2184d25b70ed3b66372 SketchwarePro-v7.0.0-phase1-r1.apk diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..6a1e8d1 --- /dev/null +++ b/renovate.json @@ -0,0 +1,76 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended", + ":dependencyDashboard", + ":semanticCommits", + ":automergeMinor", + "group:allNonMajor", + "schedule:weekly" + ], + "labels": [ + "dependencies" + ], + "prHourlyLimit": 4, + "prConcurrentLimit": 8, + "rangeStrategy": "bump", + "lockFileMaintenance": { + "enabled": false + }, + "packageRules": [ + { + "description": "Group all AndroidX libraries together", + "matchPackagePatterns": [ + "^androidx\\." + ], + "groupName": "AndroidX libraries" + }, + { + "description": "Group all Firebase libraries together", + "matchPackagePatterns": [ + "^com\\.google\\.firebase", + "^com\\.google\\.gms" + ], + "groupName": "Firebase / Google Services" + }, + { + "description": "Group Kotlin updates together", + "matchPackagePatterns": [ + "^org\\.jetbrains\\.kotlin" + ], + "groupName": "Kotlin" + }, + { + "description": "Group Android Gradle Plugin + build tools", + "matchPackagePatterns": [ + "^com\\.android\\.tools", + "^com\\.android\\.tools\\.build" + ], + "groupName": "Android build tools" + }, + { + "description": "Pin r8 to 8.11.x until DependencyResolver.kt is migrated to the new java.nio.file.Path API", + "matchPackageNames": [ + "com.android.tools:r8" + ], + "allowedVersions": "<8.12.0" + }, + { + "description": "Manual review for major bumps", + "matchUpdateTypes": [ + "major" + ], + "automerge": false, + "labels": [ + "dependencies", + "major-bump" + ] + } + ], + "vulnerabilityAlerts": { + "labels": [ + "security" + ], + "automerge": true + } +}