Compare commits
	
		
			22 Commits
		
	
	
		
			v124020451
			...
			0f0ded2b74
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 0f0ded2b74 | ||
|  | aad93ef722 | ||
|  | 9e83af0302 | ||
|  | 24b86e66b4 | ||
|  | 641c444061 | ||
| 0902c61544 | |||
|  | 6790152a0b | ||
|  | 46d1ba418e | ||
|  | 436373d0ad | ||
|  | 5b9b51c02d | ||
| b81abe384a | |||
|  | 851f862dbe | ||
|  | 8d7e302af8 | ||
| 236e1cca90 | |||
| 3a33cb4510 | |||
| 0bf9ca9a49 | |||
|  | 61e0087894 | ||
|  | 1ec05d9913 | ||
|  | 859bd91bbb | ||
|  | 204b736c53 | ||
|  | f24609c143 | ||
|  | b94d7dc537 | 
							
								
								
									
										170
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										170
									
								
								.drone.yml
									
									
									
									
									
								
							| @@ -1,170 +0,0 @@ | ||||
| kind: pipeline | ||||
| type: docker | ||||
| name: test | ||||
|  | ||||
| steps: | ||||
|   - name: Lint | ||||
|     failure: ignore | ||||
|     image: mingc/android-build-box:latest | ||||
|     commands: | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Install linters..." | ||||
|       - curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.0.0/ktlint && chmod a+x ktlint && mv ktlint /usr/local/bin/ | ||||
|       - curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.1/detekt-cli-1.23.1.zip && unzip detekt-cli-1.23.1.zip | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Linting..." | ||||
|       - ktlint 'shared/**/*.kt' 'androidApp/**/*.kt' '!shared/build' || true | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Detecting..." | ||||
|       - ./detekt-cli-1.23.1/bin/detekt-cli --all-rules --excludes '**/shared/build/**/*.kt' || true | ||||
|       - echo "---------------------------------------------------------" | ||||
|     command_timeout: 1m | ||||
|   - name: BuildAndTest | ||||
|     image: mingc/android-build-box:latest | ||||
|     commands: | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Configure gradle..." | ||||
|       - mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=true\nsystemProp.org.gradle.internal.http.connectionTimeout=180000\nsystemProp.org.gradle.internal.http.socketTimeout=180000" >> ~/.gradle/gradle.properties | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Configure java..." | ||||
|       - . ~/.bash_profile | ||||
|       - jenv global 17.0 | ||||
|       - java --version | ||||
|       - date | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Building and testing..." | ||||
|       - ./gradlew build | ||||
|       - echo "---------------------------------------------------------" | ||||
| trigger: | ||||
|   event: | ||||
|     - push | ||||
|     - pull_request | ||||
|  | ||||
| --- | ||||
| kind: pipeline | ||||
| type: docker | ||||
| name: Publish | ||||
|  | ||||
| steps: | ||||
|   - name: createTagAndChangelog | ||||
|     image: ubuntu:latest | ||||
|     commands: | ||||
|       - apt-get update && apt-get install -y git | ||||
|       - git fetch --tags -p | ||||
|       - PREV=$(git describe --tags --abbrev=0) | ||||
|       - ./build.sh --publish --from-ci | ||||
|       - VER=$(git describe --tags --abbrev=0) | ||||
|       - CHANGELOG=$(git log $PREV..HEAD --pretty="- %s") | ||||
|       - echo "**$VER**\n\n$CHANGELOG\n\n--------------------------------------------------------------------\n\n$(cat CHANGELOG.md)" > CHANGELOG.md | ||||
|       - git add CHANGELOG.md | ||||
|       - git commit -m "Changelog for $VER [CI SKIP]" | ||||
|     environment: | ||||
|       TZ: Europe/Paris | ||||
|  | ||||
|   - name: git-push | ||||
|     image: appleboy/drone-git-push | ||||
|     settings: | ||||
|       branch: master | ||||
|       remote: | ||||
|         from_secret: remoteUrl | ||||
|       followtags: true | ||||
|       ssh_key: | ||||
|         from_secret: privateKey | ||||
|       skip_verify: true | ||||
|  | ||||
|   - name: scpFiles | ||||
|     image: appleboy/drone-scp | ||||
|     settings: | ||||
|       host: amine-bouabdallaoui.fr | ||||
|       username: ubuntu | ||||
|       key: | ||||
|         from_secret: privateKey | ||||
|       port: 22 | ||||
|       target: /home/ubuntu/ | ||||
|       source: version.txt | ||||
|  | ||||
|   - name: deploy | ||||
|     image: appleboy/drone-ssh | ||||
|     settings: | ||||
|       host: amine-bouabdallaoui.fr | ||||
|       user: ubuntu | ||||
|       key: | ||||
|         from_secret: privateKey | ||||
|       command_timeout: 2m | ||||
|       script: | ||||
|         - cd /home/ubuntu && sudo rm -rf /var/www/amine/version.txt && sudo chown www-data:www-data ./version.txt && sudo mv version.txt /var/www/amine/ | ||||
|  | ||||
| trigger: | ||||
|   event: | ||||
|     - promote | ||||
|   target: | ||||
|     - production | ||||
|  | ||||
| --- | ||||
| kind: pipeline | ||||
| type: docker | ||||
| name: Release | ||||
|  | ||||
| steps: | ||||
|   - name: build | ||||
|     image: mingc/android-build-box:latest | ||||
|     commands: | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Fetch tags..." | ||||
|       - git fetch --tags | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Configure gradle..." | ||||
|       - mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=false\nsystemProp.org.gradle.internal.http.connectionTimeout=180000\nsystemProp.org.gradle.internal.http.socketTimeout=180000" >> ~/.gradle/gradle.properties | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Generate APK" | ||||
|       - ./gradlew :androidApp:assembleGithubConfigRelease | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Get Key" | ||||
|       - wget https://amine-bouabdallaoui.fr/key | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Zipalign" | ||||
|       - $ANDROID_HOME/build-tools/31.0.0/zipalign -f -v 4 androidApp/build/outputs/apk/githubConfig/release/androidApp-githubConfig-release-unsigned.apk androidApp/build/outputs/apk/githubConfig/release/android-prod-released-ziped.apk | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Sign" | ||||
|       - $ANDROID_HOME/build-tools/31.0.0/apksigner sign -v --out signed.apk --ks ./key --ks-key-alias $YOUR_KEY_ALIAS --ks-pass pass:$YOUR_KEYSTORE_PASSWORD --v1-signing-enabled true --v2-signing-enabled true androidApp/build/outputs/apk/githubConfig/release/android-prod-released-ziped.apk | ||||
|       - echo "---------------------------------------------------------" | ||||
|       - echo "Verify" | ||||
|       - $ANDROID_HOME/build-tools/31.0.0/apksigner verify signed.apk | ||||
|     environment: | ||||
|       TZ: Europe/Paris | ||||
|       YOUR_KEYSTORE_PASSWORD: | ||||
|         from_secret: keyPass | ||||
|       YOUR_KEY_ALIAS: | ||||
|         from_secret: keyAlias | ||||
|  | ||||
|   - name: gitea_release | ||||
|     image: plugins/gitea-release | ||||
|     settings: | ||||
|       api_key: | ||||
|         from_secret: giteaAPI | ||||
|       base_url: https://gitea.amine-bouabdallaoui.fr | ||||
|       files: signed.apk | ||||
|  | ||||
|   - name: notify | ||||
|     image: drillster/drone-email | ||||
|     failure: ignore | ||||
|     settings: | ||||
|       host: | ||||
|         from_secret: smtpHOST | ||||
|       port: | ||||
|         from_secret: smtpPORT | ||||
|       username: | ||||
|         from_secret: smtpUSERNAME | ||||
|       password: | ||||
|         from_secret: smtpPASSWORD | ||||
|       from: | ||||
|         from_secret: smtpFROM | ||||
|       subject: Mapping file | ||||
|       recipients: | ||||
|         from_secret: smtpTO | ||||
|       recipients_only: true | ||||
|       skip_verify: true | ||||
|       attachment: androidApp/build/outputs/mapping/githubConfigRelease/mapping.txt | ||||
| trigger: | ||||
|   event: | ||||
|     - tag | ||||
							
								
								
									
										9
									
								
								.gitea/workflows/assets/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.gitea/workflows/assets/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| version: '3' | ||||
| services: | ||||
|   selfoss: | ||||
|     container_name: selfoss | ||||
|     image: rsprta/selfoss | ||||
|     restart: unless-stopped | ||||
|     ports: | ||||
|       - "8888:8888" | ||||
|  | ||||
							
								
								
									
										24
									
								
								.gitea/workflows/common_build.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.gitea/workflows/common_build.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| name: Build | ||||
| on: | ||||
|   workflow_call: | ||||
|  | ||||
| jobs: | ||||
|   BuildAndTest: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Check out repository code | ||||
|         uses: actions/checkout@v4 | ||||
|         with: | ||||
|           fetch-depth: 0 | ||||
|       - name: Fetch tags | ||||
|         run: git fetch --tags -p | ||||
|       - uses: actions/setup-java@v4 | ||||
|         with: | ||||
|           distribution: 'temurin' | ||||
|           java-version: '17' | ||||
|       - name: Setup Android SDK | ||||
|         uses: android-actions/setup-android@v3 | ||||
|       - name: Configure gradle... | ||||
|         run: mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=true\nsystemProp.org.gradle.internal.http.connectionTimeout=180000\nsystemProp.org.gradle.internal.http.socketTimeout=180000" >> ~/.gradle/gradle.properties | ||||
|       - name: Build and test | ||||
|         run: ./gradlew build --stacktrace | ||||
							
								
								
									
										126
									
								
								.gitea/workflows/on_merge_on_release.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								.gitea/workflows/on_merge_on_release.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,126 @@ | ||||
| name: Create tag | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - release | ||||
|   workflow_dispatch: | ||||
|  | ||||
| jobs: | ||||
|   build: | ||||
|     uses: ./.gitea/workflows/common_build.yml | ||||
|   createTagAndChangelog: | ||||
|     runs-on: ubuntu-latest | ||||
|     needs: build | ||||
|     steps: | ||||
|       - name: Check out repository code | ||||
|         uses: actions/checkout@v4 | ||||
|         with: | ||||
|           fetch-depth: 0 | ||||
|       - name: Config git | ||||
|         run: | | ||||
|           git config --global user.email aminecmi+giteadrone@pm.me | ||||
|           git config --global user.name giteadrone | ||||
|       - name: Creating the tag and generate changelog | ||||
|         run: | | ||||
|           git fetch --tags -p | ||||
|           PREV=$(git describe --tags --abbrev=0) | ||||
|           ./build.sh --publish --from-ci | ||||
|           VER=$(git describe --tags --abbrev=0) | ||||
|           CHANGELOG=$(git log $PREV..HEAD --pretty="- %s") | ||||
|           echo "**$VER | ||||
|            | ||||
|           $CHANGELOG | ||||
|            | ||||
|           -------------------------------------------------------------------- | ||||
|            | ||||
|           $(cat CHANGELOG.md)" > CHANGELOG.md | ||||
|           git add CHANGELOG.md | ||||
|           touch ./fastlane/metadata/android/en\-US/changelogs/$VER.txt | ||||
|           echo "**$VER** | ||||
|            | ||||
|           $CHANGELOG" > ./fastlane/metadata/android/en\-US/changelogs/$VER.txt | ||||
|           git add ./fastlane/metadata/android/en\-US/changelogs/$VER.txt | ||||
|           git commit -m "Changelog for $VER" | ||||
|       - name: Push changes | ||||
|         uses: appleboy/git-push-action@v1.0.0 | ||||
|         with: | ||||
|           author_name: giteadrone | ||||
|           author_email: aminecmi+giteadrone@pm.me | ||||
|           remote: ${{ secrets.REMOTE_URL }} | ||||
|           followtags: true | ||||
|           ssh_key: ${{ secrets.PRIVATE_KEY }} | ||||
|           tags: true | ||||
|           branch: release | ||||
|       - name: copy file via ssh password | ||||
|         uses: appleboy/scp-action@v0.1.7 | ||||
|         with: | ||||
|           host: amine-bouabdallaoui.fr | ||||
|           username: ubuntu | ||||
|           key: ${{ secrets.PRIVATE_KEY }} | ||||
|           source: "version.txt" | ||||
|           target: "/home/ubuntu/" | ||||
|       - name: deploy version file | ||||
|         uses: appleboy/ssh-action@v1.2.0 | ||||
|         with: | ||||
|           host: amine-bouabdallaoui.fr | ||||
|           username: ubuntu | ||||
|           key: ${{ secrets.PRIVATE_KEY }} | ||||
|           script: cd /home/ubuntu && sudo rm -rf /var/www/amine/version.txt && sudo chown www-data:www-data ./version.txt && sudo mv version.txt /var/www/amine/ | ||||
|   release: | ||||
|     runs-on: ubuntu-latest | ||||
|     needs: createTagAndChangelog | ||||
|     steps: | ||||
|       - name: Check out repository code | ||||
|         uses: actions/checkout@v4 | ||||
|         with: | ||||
|           fetch-depth: 0 | ||||
|       - name: Fetch tags | ||||
|         id: version | ||||
|         run: | | ||||
|           git fetch --tags -p | ||||
|           PREV=$(git describe --tags --abbrev=0) | ||||
|           echo $PREV | ||||
|           echo "VERSION=$PREV" >> $GITHUB_OUTPUT | ||||
|       - uses: actions/setup-java@v4 | ||||
|         with: | ||||
|           distribution: 'temurin' | ||||
|           java-version: '17' | ||||
|       - name: Setup Android SDK | ||||
|         uses: android-actions/setup-android@v3 | ||||
|       - name: Configure gradle... | ||||
|         run: mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=false\nsystemProp.org.gradle.internal.http.connectionTimeout=180000\nsystemProp.org.gradle.internal.http.socketTimeout=180000" >> ~/.gradle/gradle.properties | ||||
|       - name: setup go | ||||
|         uses: https://github.com/actions/setup-go@v4 | ||||
|         with: | ||||
|           go-version: '>=1.20.1' | ||||
|       - name: Generate APK | ||||
|         run: ./gradlew :androidApp:assembleGithubConfigRelease | ||||
|       - name: Get Key | ||||
|         run: wget ${{ secrets.KEY_URL }} | ||||
|       - name: Zippalign | ||||
|         run: | | ||||
|           sdkmanager "build-tools;31.0.0" | ||||
|           ls $ANDROID_HOME/build-tools  | ||||
|           $ANDROID_HOME/build-tools/31.0.0/zipalign -f -v 4 androidApp/build/outputs/apk/githubConfig/release/androidApp-githubConfig-release-unsigned.apk androidApp/build/outputs/apk/githubConfig/release/android-prod-released-ziped.apk | ||||
|       - name: Sigh | ||||
|         run: $ANDROID_HOME/build-tools/31.0.0/apksigner sign -v --out signed.apk --ks ./key --ks-key-alias ${{ secrets.KEY_ALIAS }} --ks-pass pass:${{ secrets.KEYSTORE_PASSWORD }} --v1-signing-enabled true --v2-signing-enabled true androidApp/build/outputs/apk/githubConfig/release/android-prod-released-ziped.apk | ||||
|       - name: Verify | ||||
|         run: $ANDROID_HOME/build-tools/31.0.0/apksigner verify signed.apk | ||||
|       - name: Release | ||||
|         uses: https://gitea.com/actions/gitea-release-action@main | ||||
|         with: | ||||
|           files: signed.apk | ||||
|           token: ${{ secrets.API_KEY }} | ||||
|           tag_name: ${{ steps.version.outputs.VERSION }} | ||||
|           name: ${{ steps.version.outputs.VERSION }} | ||||
|       - name: Send mail | ||||
|         uses: https://github.com/dawidd6/action-send-mail@v4 | ||||
|         with: | ||||
|           connection_url: ${{ secrets.MAIL_CONNECTION }} | ||||
|           to: ${{ secrets.MAIL_TO }} | ||||
|           from: ${{ secrets.MAIL_FROM }} | ||||
|           subject: Mapping file | ||||
|           priority: high | ||||
|           convert_markdown: true | ||||
|           body: Nouveau fichier de mapping pour la version ${{ steps.version.outputs.VERSION }} | ||||
|           attachments: androidApp/build/outputs/mapping/githubConfigRelease/mapping.txt | ||||
							
								
								
									
										26
									
								
								.gitea/workflows/on_pr.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								.gitea/workflows/on_pr.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| name: Check PR code | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|  | ||||
| jobs: | ||||
|   Lint: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Check out repository code | ||||
|         uses: actions/checkout@v4 | ||||
|       - uses: actions/setup-java@v4 | ||||
|         with: | ||||
|           distribution: 'temurin' # See 'Supported distributions' for available options | ||||
|           java-version: '17' | ||||
|       - name: Install klint | ||||
|         run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.0.0/ktlint && chmod a+x ktlint && mv ktlint /usr/local/bin/ | ||||
|       - name: Install detekt | ||||
|         run: curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.1/detekt-cli-1.23.1.zip && unzip detekt-cli-1.23.1.zip | ||||
|       - name: Linting... | ||||
|         run: ktlint 'shared/**/*.kt' 'androidApp/**/*.kt' '!shared/build' || true | ||||
|       - name: Detecting... | ||||
|         run: ./detekt-cli-1.23.1/bin/detekt-cli --all-rules --excludes '**/shared/build/**/*.kt' || true | ||||
|   build: | ||||
|     uses: ./.gitea/workflows/common_build.yml | ||||
							
								
								
									
										9
									
								
								.gitea/workflows/on_push.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.gitea/workflows/on_push.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| name: Check master code | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|  | ||||
| jobs: | ||||
|   build: | ||||
|     uses: ./.gitea/workflows/common_build.yml | ||||
							
								
								
									
										36
									
								
								.gitea/workflows/on_push_testing.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								.gitea/workflows/on_push_testing.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| name: Check master code | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - testing | ||||
|  | ||||
| jobs: | ||||
|   checkout: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Check out repository code | ||||
|         uses: actions/checkout@v4 | ||||
|         with: | ||||
|           fetch-depth: 0 | ||||
| #      - name: Fetch tags | ||||
| #        run: git fetch --tags -p | ||||
| #      - uses: actions/setup-java@v4 | ||||
| #        with: | ||||
| #          distribution: 'temurin' | ||||
| #          java-version: '17' | ||||
| #      - name: Setup Android SDK | ||||
| #        uses: android-actions/setup-android@v3 | ||||
| #      - name: Configure gradle... | ||||
| #        run: mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=true\nsystemProp.org.gradle.internal.http.connectionTimeout=180000\nsystemProp.org.gradle.internal.http.socketTimeout=180000" >> ~/.gradle/gradle.properties | ||||
|       - name: Init compose | ||||
|         uses: KengoTODA/actions-setup-docker-compose@v1 | ||||
|         with: | ||||
|           version: "2.23.3" | ||||
|       - name: run selfoss | ||||
|         run: |  | ||||
|           pwd | ||||
|           docker-compose up -d -f .gitea/workflows/assets/docker-compose.yml | ||||
|           sleep 2m | ||||
|           wget -O- http://localhost:8888 | ||||
| #      - name: Build and test | ||||
| #        run: ./gradlew build --stacktrace | ||||
							
								
								
									
										47
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -1,3 +1,50 @@ | ||||
| **v124123421 | ||||
|  | ||||
| - fix: Trying to fix the serialization issue. | ||||
| - Changelog for v124113311 | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v124113311 | ||||
|  | ||||
| - chore: update versions. (#165) | ||||
| - chore: fastlane changelog. | ||||
| - chore: fastlane fixes. | ||||
| - Changelog for v124113301 | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v124113301** | ||||
|  | ||||
| - chore: Gitea Action | ||||
| - Merge pull request 'chore: Gitea Action' (#164) from runner into master | ||||
| - chore: Gitea Action | ||||
| - chore: Readme update. | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v124041081** | ||||
|  | ||||
| - chore: comment. | ||||
| - fix: Last time fixing the parsing date hack before moving it to os version. | ||||
| - Changelog for v124030731 [CI SKIP] | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v124030731** | ||||
|  | ||||
| - fix: Basic auth and password can have non whitspace characters. Fixes 142. | ||||
| - Changelog for v124020451 [CI SKIP] | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v124020451** | ||||
|  | ||||
| - fix: Fixed handling of position in card adapter. | ||||
| - Changelog for v124010301 [CI SKIP] | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v124010301** | ||||
|  | ||||
| - fix: This may fix the oom errors. | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| # ReaderForSelfoss-multiplatform [](https://build.amine-bouabdallaoui.fr/Louvorg/ReaderForSelfoss-multiplatform) | ||||
| # ReaderForSelfoss-multiplatform [](https://gitea.amine-bouabdallaoui.fr/Louvorg/ReaderForSelfoss-multiplatform/actions?workflow=on_push.yml&actor=0&status=0) | ||||
|  | ||||
| [](https://crowdin.com/project/readerforselfoss) | ||||
|  | ||||
| @@ -10,10 +10,6 @@ If you are a user, you can still create new issues. I'll fix them when I can. | ||||
|  | ||||
| <a href="https://f-droid.org/packages/bou.amine.apps.readerforselfossv2.android"><img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="100"></a> | ||||
|  | ||||
| ## Screen captures | ||||
|  | ||||
| <img src="res//fr-card.png?raw=true" alt="card view" width="400"/> <img src="res//fr-list.png?raw=true" alt="list view" width="400"/> | ||||
|  | ||||
| ## Like my app ? | ||||
|  | ||||
| <a href="https://www.buymeacoffee.com/aminecmi" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/lato-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a> | ||||
|   | ||||
| @@ -13,7 +13,11 @@ import androidx.appcompat.app.AppCompatActivity | ||||
| import androidx.appcompat.widget.SearchView | ||||
| import androidx.core.view.doOnNextLayout | ||||
| import androidx.lifecycle.lifecycleScope | ||||
| import androidx.recyclerview.widget.* | ||||
| import androidx.recyclerview.widget.DividerItemDecoration | ||||
| import androidx.recyclerview.widget.GridLayoutManager | ||||
| import androidx.recyclerview.widget.ItemTouchHelper | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import androidx.recyclerview.widget.StaggeredGridLayoutManager | ||||
| import androidx.work.Constraints | ||||
| import androidx.work.ExistingPeriodicWorkPolicy | ||||
| import androidx.work.PeriodicWorkRequestBuilder | ||||
| @@ -58,7 +62,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar | ||||
|     private lateinit var recyclerViewScrollListener: RecyclerView.OnScrollListener | ||||
|     private lateinit var binding: ActivityHomeBinding | ||||
|  | ||||
|     private var recyclerAdapter: RecyclerView.Adapter<*>? = null | ||||
|     private var recyclerAdapter: ItemsAdapter<out RecyclerView.ViewHolder>? = null | ||||
|  | ||||
|     private var fromTabShortcut: Boolean = false | ||||
|  | ||||
| @@ -498,7 +502,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar | ||||
|             } | ||||
|             binding.recyclerView.adapter = recyclerAdapter | ||||
|         } else { | ||||
|             (recyclerAdapter as ItemsAdapter<*>).updateAllItems(items) | ||||
|             recyclerAdapter!!.updateAllItems(items) | ||||
|         } | ||||
|  | ||||
|         reloadBadges() | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package bou.amine.apps.readerforselfossv2.android.adapters | ||||
|  | ||||
| import android.app.Activity | ||||
| import android.content.Context | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| @@ -9,11 +8,11 @@ import android.widget.ImageView.ScaleType | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import bou.amine.apps.readerforselfossv2.android.R | ||||
| import bou.amine.apps.readerforselfossv2.android.databinding.CardItemBinding | ||||
| import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.openInBrowserAsNewTask | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.shareLink | ||||
| import bou.amine.apps.readerforselfossv2.model.SelfossModel | ||||
| import bou.amine.apps.readerforselfossv2.repository.Repository | ||||
| @@ -31,11 +30,10 @@ import org.kodein.di.instance | ||||
|  | ||||
| class ItemCardAdapter( | ||||
|     override val app: Activity, | ||||
|     override var items: ArrayList<SelfossModel.Item>, | ||||
|     override val updateItems: (ArrayList<SelfossModel.Item>) -> Unit, | ||||
|     override val items: ArrayList<SelfossModel.Item>, | ||||
|     override val updateHomeItems: (ArrayList<SelfossModel.Item>) -> Unit, | ||||
| ) : ItemsAdapter<ItemCardAdapter.ViewHolder>() { | ||||
|     private lateinit var binding: CardItemBinding | ||||
|     private val c: Context = app.baseContext | ||||
|     override lateinit var binding: CardItemBinding | ||||
|     private val imageMaxHeight: Int = | ||||
|         c.resources.getDimension(R.dimen.card_image_max_height).toInt() | ||||
|  | ||||
| @@ -51,8 +49,8 @@ class ItemCardAdapter( | ||||
|         return ViewHolder(binding) | ||||
|     } | ||||
|  | ||||
|     private fun handleClickListeners(position: Int) { | ||||
|         binding.favButton.setOnClickListener { | ||||
|     private fun handleClickListeners(holderBinding: CardItemBinding, position: Int) { | ||||
|         holderBinding.favButton.setOnClickListener { | ||||
|             val item = items[position] | ||||
|             if (item.starred) { | ||||
|                 CoroutineScope(Dispatchers.IO).launch { | ||||
| @@ -77,27 +75,15 @@ class ItemCardAdapter( | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun handleLinkOpening(position: Int) { | ||||
|         binding.root.setOnClickListener { | ||||
|             repository.setReaderItems(items) | ||||
|             c.openItemUrl( | ||||
|                 position, | ||||
|                 items[position].getLinkDecoded(), | ||||
|                 appSettingsService.isArticleViewerEnabled(), | ||||
|                 app, | ||||
|             ) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun onBindViewHolder( | ||||
|         holder: ViewHolder, | ||||
|         position: Int, | ||||
|     ) { | ||||
|         with(holder) { | ||||
|             val itm = items[holder.bindingAdapterPosition] | ||||
|             val itm = items[position] | ||||
|  | ||||
|             handleClickListeners(holder.bindingAdapterPosition) | ||||
|             handleLinkOpening(holder.bindingAdapterPosition) | ||||
|             handleClickListeners(binding, position) | ||||
|             handleLinkOpening(binding, position) | ||||
|  | ||||
|             binding.favButton.isSelected = itm.starred | ||||
|             if (appSettingsService.getPublicAccess()) { | ||||
| @@ -110,7 +96,12 @@ class ItemCardAdapter( | ||||
|  | ||||
|             binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent)) | ||||
|  | ||||
|             binding.sourceTitleAndDate.text = itm.sourceAuthorAndDate() | ||||
|             binding.sourceTitleAndDate.text = try { | ||||
|                 itm.sourceAuthorAndDate() | ||||
|             } catch (e: Exception) { | ||||
|                 e.sendSilentlyWithAcraWithName("ItemCardAdapter parse date") | ||||
|                 itm.sourceAuthorOnly() | ||||
|             } | ||||
|  | ||||
|             if (!appSettingsService.isFullHeightCardsEnabled()) { | ||||
|                 binding.itemImage.maxHeight = imageMaxHeight | ||||
| @@ -134,9 +125,5 @@ class ItemCardAdapter( | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun getItemCount(): Int { | ||||
|         return items.size | ||||
|     } | ||||
|  | ||||
|     inner class ViewHolder(val binding: CardItemBinding) : RecyclerView.ViewHolder(binding.root) | ||||
| } | ||||
|   | ||||
| @@ -1,15 +1,14 @@ | ||||
| package bou.amine.apps.readerforselfossv2.android.adapters | ||||
|  | ||||
| import android.app.Activity | ||||
| import android.content.Context | ||||
| import android.view.LayoutInflater | ||||
| import android.view.ViewGroup | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import bou.amine.apps.readerforselfossv2.android.R | ||||
| import bou.amine.apps.readerforselfossv2.android.databinding.ListItemBinding | ||||
| import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl | ||||
| import bou.amine.apps.readerforselfossv2.model.SelfossModel | ||||
| import bou.amine.apps.readerforselfossv2.repository.Repository | ||||
| import bou.amine.apps.readerforselfossv2.service.AppSettingsService | ||||
| @@ -22,11 +21,10 @@ import org.kodein.di.instance | ||||
|  | ||||
| class ItemListAdapter( | ||||
|     override val app: Activity, | ||||
|     override var items: ArrayList<SelfossModel.Item>, | ||||
|     override val updateItems: (ArrayList<SelfossModel.Item>) -> Unit, | ||||
|     override val items: ArrayList<SelfossModel.Item>, | ||||
|     override val updateHomeItems: (ArrayList<SelfossModel.Item>) -> Unit, | ||||
| ) : ItemsAdapter<ItemListAdapter.ViewHolder>() { | ||||
|     private lateinit var binding: ListItemBinding | ||||
|     private val c: Context = app.baseContext | ||||
|     override lateinit var binding: ListItemBinding | ||||
|  | ||||
|     override val di: DI by closestDI(app) | ||||
|     override val repository: Repository by instance() | ||||
| @@ -45,17 +43,9 @@ class ItemListAdapter( | ||||
|         position: Int, | ||||
|     ) { | ||||
|         with(holder) { | ||||
|             val itm = items[holder.bindingAdapterPosition] | ||||
|             val itm = items[position] | ||||
|  | ||||
|             binding.root.setOnClickListener { | ||||
|                 repository.setReaderItems(items) | ||||
|                 c.openItemUrl( | ||||
|                     holder.bindingAdapterPosition, | ||||
|                     items[holder.bindingAdapterPosition].getLinkDecoded(), | ||||
|                     appSettingsService.isArticleViewerEnabled(), | ||||
|                     app, | ||||
|                 ) | ||||
|             } | ||||
|             handleLinkOpening(binding, position) | ||||
|  | ||||
|             binding.title.text = itm.title.getHtmlDecoded() | ||||
|  | ||||
| @@ -63,7 +53,12 @@ class ItemListAdapter( | ||||
|  | ||||
|             binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent)) | ||||
|  | ||||
|             binding.sourceTitleAndDate.text = itm.sourceAuthorAndDate() | ||||
|             binding.sourceTitleAndDate.text = try { | ||||
|                 itm.sourceAuthorAndDate() | ||||
|             } catch (e: Exception) { | ||||
|                 e.sendSilentlyWithAcraWithName("ItemListAdapter parse date") | ||||
|                 itm.sourceAuthorOnly() | ||||
|             } | ||||
|  | ||||
|             if (itm.getThumbnail(repository.baseUrl).isEmpty()) { | ||||
|                 if (itm.getIcon(repository.baseUrl).isEmpty()) { | ||||
| @@ -77,7 +72,5 @@ class ItemListAdapter( | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun getItemCount(): Int = items.size | ||||
|  | ||||
|     inner class ViewHolder(val binding: ListItemBinding) : RecyclerView.ViewHolder(binding.root) | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| package bou.amine.apps.readerforselfossv2.android.adapters | ||||
|  | ||||
| import android.app.Activity | ||||
| import android.content.Context | ||||
| import android.graphics.Color | ||||
| import android.widget.TextView | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import androidx.viewbinding.ViewBinding | ||||
| import bou.amine.apps.readerforselfossv2.android.R | ||||
| import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl | ||||
| import bou.amine.apps.readerforselfossv2.model.SelfossModel | ||||
| import bou.amine.apps.readerforselfossv2.repository.Repository | ||||
| import bou.amine.apps.readerforselfossv2.service.AppSettingsService | ||||
| @@ -16,16 +19,20 @@ import kotlinx.coroutines.launch | ||||
| import org.kodein.di.DIAware | ||||
|  | ||||
| abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapter<VH>(), DIAware { | ||||
|     abstract var items: ArrayList<SelfossModel.Item> | ||||
|     abstract val items: ArrayList<SelfossModel.Item> | ||||
|     abstract val repository: Repository | ||||
|     abstract val binding: ViewBinding | ||||
|     abstract val appSettingsService: AppSettingsService | ||||
|     abstract val app: Activity | ||||
|     abstract val updateItems: (ArrayList<SelfossModel.Item>) -> Unit | ||||
|     abstract val updateHomeItems: (ArrayList<SelfossModel.Item>) -> Unit | ||||
|  | ||||
|     protected val c: Context get() = app.baseContext | ||||
|  | ||||
|     fun updateAllItems(items: ArrayList<SelfossModel.Item>) { | ||||
|         this.items = items | ||||
|         this.items.clear() | ||||
|         this.items.addAll(items) | ||||
|         updateHomeItems(items) | ||||
|         notifyDataSetChanged() | ||||
|         updateItems(this.items) | ||||
|     } | ||||
|  | ||||
|     private fun unmarkSnackbar( | ||||
| @@ -70,6 +77,18 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte | ||||
|         s.show() | ||||
|     } | ||||
|  | ||||
|     protected fun handleLinkOpening(holderBinding: ViewBinding, position: Int) { | ||||
|         holderBinding.root.setOnClickListener { | ||||
|             repository.setReaderItems(items) | ||||
|             c.openItemUrl( | ||||
|                 position, | ||||
|                 items[position].getLinkDecoded(), | ||||
|                 appSettingsService.isArticleViewerEnabled(), | ||||
|                 app, | ||||
|             ) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun handleItemAtIndex(position: Int) { | ||||
|         if (items[position].unread) { | ||||
|             readItemAtIndex(items[position], position) | ||||
| @@ -90,7 +109,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte | ||||
|             items.remove(item) | ||||
|             notifyItemRemoved(position) | ||||
|             notifyItemRangeChanged(position, itemCount) | ||||
|             updateItems(items) | ||||
|             updateHomeItems(items) | ||||
|         } else { | ||||
|             notifyItemChanged(position) | ||||
|         } | ||||
| @@ -119,13 +138,15 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte | ||||
|     ) { | ||||
|         items.add(position, item) | ||||
|         notifyItemInserted(position) | ||||
|         updateItems(items) | ||||
|         updateHomeItems(items) | ||||
|     } | ||||
|  | ||||
|     fun addItemsAtEnd(newItems: List<SelfossModel.Item>) { | ||||
|         val oldSize = items.size | ||||
|         items.addAll(newItems) | ||||
|         notifyItemRangeInserted(oldSize, newItems.size) | ||||
|         updateItems(items) | ||||
|         updateHomeItems(items) | ||||
|     } | ||||
|  | ||||
|     override fun getItemCount(): Int = items.size | ||||
| } | ||||
|   | ||||
| @@ -102,7 +102,12 @@ class ArticleFragment : Fragment(), DIAware { | ||||
|             contentText = item.content | ||||
|             contentTitle = item.title.getHtmlDecoded() | ||||
|             contentImage = item.getThumbnail(repository.baseUrl) | ||||
|             contentSource = item.sourceAuthorAndDate() | ||||
|             contentSource = try { | ||||
|                 item.sourceAuthorAndDate() | ||||
|             } catch (e: Exception) { | ||||
|                 e.sendSilentlyWithAcraWithName("Article Fragment parse date") | ||||
|                 item.sourceAuthorOnly() | ||||
|             } | ||||
|             allImages = item.getImages() | ||||
|  | ||||
|             fontSize = appSettingsService.getFontSize() | ||||
|   | ||||
| @@ -8,12 +8,12 @@ import kotlinx.datetime.toInstant | ||||
| import org.junit.Test | ||||
|  | ||||
| class DatesTest { | ||||
|     private val newVersionDateVariant = "2022-12-24T17:00:08+00" | ||||
|     private val newVersionDate = "2013-04-07T13:43:00+01:00" | ||||
|     private val oldVersionDate = "2013-05-07 13:46:00" | ||||
|     private val oldVersionDateVariant = "2021-03-21 10:32:00.000000" | ||||
|     private val newVersionDateVariant =     "2022-12-24T17:00:08+00" | ||||
|     private val newVersionDate =            "2013-04-07T13:43:00+01:00" | ||||
|     private val newVersionDate2 =            "2013-04-07T13:43:00-01:00" | ||||
|     private val oldVersionDate =            "2013-05-07 13:46:00" | ||||
|     private val oldVersionDateVariant =     "2021-03-21 10:32:00.000000" | ||||
|  | ||||
|     private val bugVersionDate = "2023-12-19T10:30:53-05:00" | ||||
|  | ||||
|     @Test | ||||
|     fun new_version_date_should_be_parsed() { | ||||
| @@ -24,6 +24,15 @@ class DatesTest { | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|     @Test | ||||
|     fun new_version_date2_should_be_parsed() { | ||||
|         val date = DateUtils.parseDate(newVersionDate2) | ||||
|         val expected = | ||||
|             LocalDateTime(2013, 4, 7, 13, 43, 0, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun old_version_date_should_be_parsed() { | ||||
| @@ -54,14 +63,4 @@ class DatesTest { | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun bug_version_variant_date_should_be_parsed() { | ||||
|         val date = DateUtils.parseDate(bugVersionDate) | ||||
|         val expected = | ||||
|             LocalDateTime(1991, 3, 18, 3, 0, 0, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,10 +7,10 @@ buildscript { | ||||
|  | ||||
| plugins { | ||||
|     //trick: for the same plugin versions in all sub-modules | ||||
|     id("com.android.application").version("8.1.2").apply(false) | ||||
|     id("com.android.library").version("8.1.2").apply(false) | ||||
|     id("org.jetbrains.kotlin.android").version("1.9.10").apply(false) | ||||
|     kotlin("multiplatform").version("1.9.10").apply(false) | ||||
|     id("com.android.application").version("8.7.3").apply(false) | ||||
|     id("com.android.library").version("8.7.3").apply(false) | ||||
|     id("org.jetbrains.kotlin.android").version("2.1.0").apply(false) | ||||
|     kotlin("multiplatform").version("2.1.0").apply(false) | ||||
|     id("com.mikepenz.aboutlibraries.plugin").version("10.5.1").apply(false) | ||||
|     id("org.jetbrains.kotlinx.kover").version("0.6.1").apply(true) | ||||
| } | ||||
| @@ -25,7 +25,7 @@ allprojects { | ||||
|  | ||||
|  | ||||
| tasks.register("clean", Delete::class) { | ||||
|     delete(rootProject.buildDir) | ||||
|     delete(layout.buildDirectory) | ||||
| } | ||||
|  | ||||
| koverMerged { | ||||
|   | ||||
							
								
								
									
										0
									
								
								fastlane/metadata/android/en-US/changelogs/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								fastlane/metadata/android/en-US/changelogs/.gitkeep
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| **v124113311** | ||||
|  | ||||
| - chore: update versions. (#165) | ||||
| - chore: fastlane changelog. | ||||
| - chore: fastlane fixes. | ||||
| - Changelog for v124113301 | ||||
| @@ -0,0 +1,4 @@ | ||||
| **v124123421** | ||||
|  | ||||
| - fix: Trying to fix the serialization issue. | ||||
| - Changelog for v124113311 | ||||
							
								
								
									
										
											BIN
										
									
								
								fastlane/metadata/android/en-US/images/icon.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fastlane/metadata/android/en-US/images/icon.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 294 KiB | 
| @@ -1 +1 @@ | ||||
| A new RSS reader for <a href="http://selfoss.aditu.de/">selfoss</a>. | ||||
| A new RSS reader for selfoss (http://selfoss.aditu.de/) | ||||
|   | ||||
| @@ -18,7 +18,6 @@ kotlin.code.style=official | ||||
| #Android | ||||
| android.useAndroidX=true | ||||
| #android.nonTransitiveRClass=true | ||||
| android.enableJetifier=true | ||||
| android.nonTransitiveRClass=false | ||||
| #MPP | ||||
| kotlin.mpp.enableCInteropCommonization=true | ||||
|   | ||||
							
								
								
									
										4
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| #Thu Jul 13 11:41:19 CEST 2023 | ||||
| #Mon Nov 25 22:48:24 CET 2024 | ||||
| distributionBase=GRADLE_USER_HOME | ||||
| distributionPath=wrapper/dists | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip | ||||
| zipStoreBase=GRADLE_USER_HOME | ||||
| zipStorePath=wrapper/dists | ||||
|   | ||||
| @@ -173,7 +173,7 @@ | ||||
| 			); | ||||
| 			runOnlyForDeploymentPostprocessing = 0; | ||||
| 			shellPath = /bin/sh; | ||||
| 			shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n"; | ||||
| 			shellScript = "export JAVA_HOME=/Users/amine/.sdkman/candidates/java/17.0.8.1-jbr\ncd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode --stacktrace\n"; | ||||
| 		}; | ||||
| /* End PBXShellScriptBuildPhase section */ | ||||
|  | ||||
|   | ||||
| @@ -52,6 +52,9 @@ kotlin { | ||||
|  | ||||
|                 // Sql | ||||
|                 implementation(SqlDelight.runtime) | ||||
|  | ||||
|                 // Sql | ||||
|                 implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") | ||||
|             } | ||||
|         } | ||||
|         val commonTest by getting { | ||||
| @@ -80,10 +83,6 @@ kotlin { | ||||
|         val iosArm64Main by getting | ||||
|         // val iosSimulatorArm64Main by getting | ||||
|         val iosMain by creating { | ||||
|             dependsOn(commonMain) | ||||
|             iosX64Main.dependsOn(this) | ||||
|             iosArm64Main.dependsOn(this) | ||||
|             // iosSimulatorArm64Main.dependsOn(this) | ||||
|  | ||||
|             dependencies { | ||||
|                 implementation(SqlDelight.native) | ||||
| @@ -94,10 +93,6 @@ kotlin { | ||||
|         val iosArm64Test by getting | ||||
|         // val iosSimulatorArm64Test by getting | ||||
|         val iosTest by creating { | ||||
|             dependsOn(commonTest) | ||||
|             iosX64Test.dependsOn(this) | ||||
|             iosArm64Test.dependsOn(this) | ||||
|             // iosSimulatorArm64Test.dependsOn(this) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,35 +6,8 @@ import kotlinx.datetime.* | ||||
|  | ||||
| actual class DateUtils { | ||||
|     actual companion object { | ||||
|         // Possible formats are | ||||
|         // yyyy-mm-dd hh:mm:ss format | ||||
|         private val oldVersionFormat = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(.()\\d*)?".toRegex() | ||||
|  | ||||
|         // yyyy-MM-dd'T'HH:mm:ss[.SSS]XXX (RFC3339) | ||||
|         private val newVersionFormat = "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}(:\\d{2})?".toRegex() | ||||
|  | ||||
|         // We may need to consider moving the formatting to platform specific code, even if the tests are doubled | ||||
|         // For now, we handle this in a hacky way, because kotlin only accepts iso formats | ||||
|         actual fun parseDate(dateString: String): Long { | ||||
|             var isoDateString: String = | ||||
|                 try { | ||||
|                     if (dateString.matches(oldVersionFormat)) { | ||||
|                         dateString.replace(" ", "T") | ||||
|                     } else if (dateString.matches(newVersionFormat)) { | ||||
|                         dateString.split("+")[0] | ||||
|                     } else { | ||||
|                         throw Exception("Unrecognized format for $dateString") | ||||
|                     } | ||||
|                 } catch (e: Exception) { | ||||
|                     Napier.e("parseDate failed", e, tag = "DateUtils.parseDate") | ||||
|                     "1991-03-18T03:00:00" | ||||
|                 } | ||||
|  | ||||
|             return LocalDateTime.parse(isoDateString).toInstant(TimeZone.currentSystemDefault()).toEpochMilliseconds() | ||||
|         } | ||||
|  | ||||
|         actual fun parseRelativeDate(dateString: String): String { | ||||
|             val date = parseDate(dateString) | ||||
|             val date = dateString.toParsedDate() | ||||
|  | ||||
|             return " " + | ||||
|                 DateUtils.getRelativeTimeSpanString( | ||||
|   | ||||
| @@ -146,6 +146,14 @@ class SelfossModel { | ||||
|             return txt | ||||
|         } | ||||
|  | ||||
|         fun sourceAuthorOnly(): String { | ||||
|             var txt = this.sourcetitle.getHtmlDecoded() | ||||
|             if (!this.author.isNullOrBlank()) { | ||||
|                 txt += " (by ${this.author}) " | ||||
|             } | ||||
|             return txt | ||||
|         } | ||||
|  | ||||
|         fun toggleStar(): Item { | ||||
|             this.starred = !this.starred | ||||
|             return this | ||||
| @@ -183,7 +191,7 @@ class SelfossModel { | ||||
|         } | ||||
|  | ||||
|         override val descriptor: SerialDescriptor | ||||
|             get() = PrimitiveSerialDescriptor("b", PrimitiveKind.BOOLEAN) | ||||
|             get() = PrimitiveSerialDescriptor("BooleanOrIntForSomeSelfossVersions", PrimitiveKind.BOOLEAN) | ||||
|  | ||||
|         override fun serialize( | ||||
|             encoder: Encoder, | ||||
|   | ||||
| @@ -74,7 +74,7 @@ class Repository( | ||||
|                 dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value!!.title } | ||||
|             } | ||||
|             val itemsList = ArrayList(dbItems.map { it.toView() }) | ||||
|             itemsList.sortByDescending { DateUtils.parseDate(it.datetime) } | ||||
|             itemsList.sortByDescending { it.datetime.toParsedDate() } | ||||
|             fetchedItems = | ||||
|                 StatusAndData.succes( | ||||
|                     itemsList, | ||||
|   | ||||
| @@ -441,7 +441,7 @@ class AppSettingsService(acraSenderServiceProcess: Boolean = false) { | ||||
|         login: String, | ||||
|         password: String, | ||||
|     ) { | ||||
|         val regex = """\/\/(\D+):(\D+)@""".toRegex() | ||||
|         val regex = """\/\/(\S+):(\S+)@""".toRegex() | ||||
|         val matchResult = regex.find(url) | ||||
|         if (matchResult != null) { | ||||
|             val (basicLogin, basicPassword) = matchResult.destructured | ||||
|   | ||||
| @@ -1,9 +1,35 @@ | ||||
| package bou.amine.apps.readerforselfossv2.utils | ||||
|  | ||||
| import kotlinx.datetime.LocalDateTime | ||||
| import kotlinx.datetime.TimeZone | ||||
| import kotlinx.datetime.toInstant | ||||
|  | ||||
| fun String.toParsedDate(): Long { | ||||
|     // Possible formats are | ||||
|     // yyyy-mm-dd hh:mm:ss format | ||||
|     val oldVersionFormat = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(.()\\d*)?".toRegex() | ||||
|  | ||||
|     // yyyy-MM-dd'T'HH:mm:ss[.SSS]XXX (RFC3339) | ||||
|     val newVersionFormat = "(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})[+-](\\d{2}(:\\d{2})?)?".toRegex() | ||||
|  | ||||
|     val isoDateString: String = | ||||
|         try { | ||||
|             if (this.matches(oldVersionFormat)) { | ||||
|                 this.replace(" ", "T") | ||||
|             } else if (this.matches(newVersionFormat)) { | ||||
|                 newVersionFormat.find(this)?.groups?.get(1)?.value ?: throw Exception("Couldn't parse $this") | ||||
|             } else { | ||||
|                 throw Exception("Unrecognized format for $this") | ||||
|             } | ||||
|         } catch (e: Exception) { | ||||
|             throw Exception("parseDate failed for $this", e) | ||||
|         } | ||||
|  | ||||
|     return LocalDateTime.parse(isoDateString).toInstant(TimeZone.currentSystemDefault()).toEpochMilliseconds() | ||||
| } | ||||
|  | ||||
| expect class DateUtils() { | ||||
|     companion object { | ||||
|         fun parseDate(dateString: String): Long | ||||
|  | ||||
|         fun parseRelativeDate(dateString: String): String | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										66
									
								
								shared/src/commonTest/kotlin/DatesTest.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								shared/src/commonTest/kotlin/DatesTest.kt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| package bou.amine.apps.readerforselfossv2.repository | ||||
|  | ||||
| import bou.amine.apps.readerforselfossv2.utils.toParsedDate | ||||
| import kotlinx.datetime.LocalDateTime | ||||
| import kotlinx.datetime.TimeZone | ||||
| import kotlinx.datetime.toInstant | ||||
| import kotlin.test.Test | ||||
| import kotlin.test.assertEquals | ||||
|  | ||||
| class DatesTest { | ||||
|     private val newVersionDateVariant =     "2022-12-24T17:00:08+00" | ||||
|     private val newVersionDate =            "2013-04-07T13:43:00+01:00" | ||||
|     private val newVersionDate2 =            "2013-04-07T13:43:00-01:00" | ||||
|     private val oldVersionDate =            "2013-05-07 13:46:00" | ||||
|     private val oldVersionDateVariant =     "2021-03-21 10:32:00.000000" | ||||
|  | ||||
|  | ||||
|     @Test | ||||
|     fun new_version_date_should_be_parsed() { | ||||
|         val date = newVersionDate.toParsedDate() | ||||
|         val expected = | ||||
|             LocalDateTime(2013, 4, 7, 13, 43, 0, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|     @Test | ||||
|     fun new_version_date2_should_be_parsed() { | ||||
|         val date = newVersionDate2.toParsedDate() | ||||
|         val expected = | ||||
|             LocalDateTime(2013, 4, 7, 13, 43, 0, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun old_version_date_should_be_parsed() { | ||||
|         val date = oldVersionDate.toParsedDate() | ||||
|         val expected = | ||||
|             LocalDateTime(2013, 5, 7, 13, 46, 0, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun old_version_variant_date_should_be_parsed() { | ||||
|         val date = oldVersionDateVariant.toParsedDate() | ||||
|         val expected = | ||||
|             LocalDateTime(2021, 3, 21, 10, 32, 0, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun new_version_variant_date_should_be_parsed() { | ||||
|         val date = newVersionDateVariant.toParsedDate() | ||||
|         val expected = | ||||
|             LocalDateTime(2022, 12, 24, 17, 0, 8, 0).toInstant(TimeZone.currentSystemDefault()) | ||||
|                 .toEpochMilliseconds() | ||||
|  | ||||
|         assertEquals(expected, date) | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,9 @@ | ||||
| package bou.amine.apps.readerforselfossv2.utils | ||||
|  | ||||
| actual class DateUtils actual constructor() { | ||||
|     actual companion object { | ||||
|         actual fun parseRelativeDate(dateString: String): String { | ||||
|             TODO("Not yet implemented") | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,5 +0,0 @@ | ||||
| sonar.projectKey=RFS2 | ||||
| sonar.coverage.jacoco.xmlReportPaths=build/reports/kover/merged/xml/report.xml | ||||
| sonar.sourceEncoding=UTF-8 | ||||
| sonar.sources=. | ||||
| sonar.exclusions=shared/src/iosArm64Main/**, shared/src/iosX64Main/**, docs/**  | ||||
		Reference in New Issue
	
	Block a user