Repository navigation
feat: Phase 1 — quality tooling, Material You, per-app language, Arabic seed, JUnit5 tests, release workflow #2
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
Open
devin-ai-integration
wants to merge
8
commits into
chore/update-dependencies
Choose a base branch
from
feat/phase1-quality-i18n-ux
base: chore/update-dependencies
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9d24033
tooling: add Detekt, Spotless, Renovate, Dependabot, lint CI, ADRs
Dr-Code-EG 7fd0f2a
feat(ui): Material You dynamic color, per-app language API, Arabic seed
Dr-Code-EG 397c9e9
test+release: JUnit 5 / MockK / Truth scaffold + release workflow
Dr-Code-EG 9d41b30
test: stabilise PropertiesUtil tests for the JVM unit-test runtime
Dr-Code-EG 341c1b9
release: add releases/ pointer + checksum for v7.0.0-phase1-r1
Dr-Code-EG a399c3b
fix(ci): address Devin Review findings on release.yml
Dr-Code-EG 25b7634
fix(i18n): explicitly declare android:supportsRtl=true
Dr-Code-EG 028942f
fix(i18n): only advertise locales that actually have translations
Dr-Code-EG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
app/src/main/java/pro/sketchware/utility/locale/LocaleHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package pro.sketchware.utility.locale; | ||
|
|
||
| import android.content.Context; | ||
| import android.os.LocaleList; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
| import androidx.appcompat.app.AppCompatDelegate; | ||
| import androidx.core.os.LocaleListCompat; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| /** | ||
| * Thin wrapper around {@link AppCompatDelegate} per-app language APIs introduced in | ||
| * AppCompat 1.6+. Together with the {@code AppLocalesMetadataHolderService} declared | ||
| * in the manifest with {@code autoStoreLocales=true}, the user's choice is persisted | ||
| * across app launches without us managing SharedPreferences manually. | ||
| */ | ||
| public final class LocaleHelper { | ||
|
|
||
| private LocaleHelper() { | ||
| } | ||
|
|
||
| /** | ||
| * Sets the application locale. Pass {@code null} or an empty tag to reset to the | ||
| * system default ("Use system language"). | ||
| */ | ||
| public static void setAppLocale(@Nullable String bcp47Tag) { | ||
| if (bcp47Tag == null || bcp47Tag.isEmpty()) { | ||
| AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList()); | ||
| return; | ||
| } | ||
| AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(bcp47Tag)); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the BCP-47 tag of the currently selected app locale, or empty string | ||
| * if the user follows the system default. | ||
| */ | ||
| @NonNull | ||
| public static String getCurrentTag() { | ||
| LocaleListCompat locales = AppCompatDelegate.getApplicationLocales(); | ||
| if (locales.isEmpty()) { | ||
| return ""; | ||
| } | ||
| Locale first = locales.get(0); | ||
| return first != null ? first.toLanguageTag() : ""; | ||
| } | ||
|
|
||
| /** | ||
| * Convenience: returns the {@link Locale} actually being applied to UI (falls | ||
| * back to system default if no per-app override). | ||
| */ | ||
| @NonNull | ||
| public static Locale getEffectiveLocale(@NonNull Context context) { | ||
| LocaleListCompat locales = AppCompatDelegate.getApplicationLocales(); | ||
| if (!locales.isEmpty() && locales.get(0) != null) { | ||
| return locales.get(0); | ||
| } | ||
| LocaleList sys = context.getResources().getConfiguration().getLocales(); | ||
| return sys.isEmpty() ? Locale.getDefault() : sys.get(0); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.