forked from upstream-mirrors/quik
Merge branch 'master' into upgrade-smsmms-group-individual-send-no-wait-appear-delayed-mms-mms-receive-to-worker-send-ack-mmsc
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
version: 2
|
||||
|
||||
jobs:
|
||||
build:
|
||||
working_directory: ~/code
|
||||
docker:
|
||||
- image: cimg/android:2022.12.1
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
|
||||
- run:
|
||||
name: Download dependencies
|
||||
command: ./gradlew androidDependencies
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/.gradle
|
||||
key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
|
||||
- run:
|
||||
name: Decrypt and unzip secrets
|
||||
command: |
|
||||
openssl aes-256-cbc -d -in secrets.tar.enc -md sha1 -k ${SECRETS_KEY} -iv ${SECRETS_IV} >> secrets.tar
|
||||
tar xvf secrets.tar
|
||||
- run:
|
||||
name: Gradle build
|
||||
command: ./gradlew :presentation:assembleWithAnalyticsRelease :presentation:bundleWithAnalyticsRelease
|
||||
- run:
|
||||
name: Flatten outputs
|
||||
command: find presentation/build/outputs -mindepth 2 -type f -exec mv -i '{}' presentation/build/outputs/ ';'
|
||||
- store_artifacts:
|
||||
path: presentation/build/outputs
|
||||
- persist_to_workspace:
|
||||
root: presentation/build/outputs
|
||||
paths: .
|
||||
|
||||
test:
|
||||
working_directory: ~/code
|
||||
docker:
|
||||
- image: cimg/android:2022.12.1
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
|
||||
- run:
|
||||
name: Download dependencies
|
||||
command: ./gradlew androidDependencies
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/.gradle
|
||||
key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
|
||||
- store_test_results:
|
||||
path: presentation/build/test-results
|
||||
|
||||
deploy:
|
||||
docker:
|
||||
- image: cibuilds/github:0.10
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: presentation/build/outputs
|
||||
- run:
|
||||
name: "Publish Release on GitHub"
|
||||
command: ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} presentation/build/outputs/
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
main:
|
||||
jobs:
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
- test:
|
||||
requires:
|
||||
- build
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
- deploy:
|
||||
requires:
|
||||
- test
|
||||
filters:
|
||||
branches:
|
||||
ignore: /.*/
|
||||
tags:
|
||||
only: /^v.*/
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
|
||||
- name: Build APK
|
||||
run: |
|
||||
./gradlew assembleNoAnalyticsRelease \
|
||||
./gradlew assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
@@ -38,13 +38,13 @@ jobs:
|
||||
--stacktrace
|
||||
|
||||
- name: Rename APK
|
||||
run: mv presentation/build/outputs/apk/noAnalytics/release/QUIK-v*-noAnalytics-release.apk presentation/build/outputs/apk/noAnalytics/release/QUIK-noAnalytics-release.apk
|
||||
run: mv presentation/build/outputs/apk/release/QUIK-v*-release.apk presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apk
|
||||
path: presentation/build/outputs/apk/noAnalytics/release/QUIK-noAnalytics-release.apk
|
||||
path: presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
release:
|
||||
name: validate fdroid APK
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
name: Android CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
@@ -8,8 +8,6 @@ on:
|
||||
jobs:
|
||||
vvm:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DEFAULT_BRANCH: auto-update-mms-configs
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -35,6 +33,9 @@ jobs:
|
||||
- name: Download Messaging APK
|
||||
run: apkeep -a com.google.android.apps.messaging -o device=walleye /home/runner/work/quik/quik
|
||||
|
||||
- name: List files in directory
|
||||
run: ls /home/runner/work/quik/quik
|
||||
|
||||
- name: Unzip the Messaging APK from XAPK
|
||||
run: |
|
||||
unzip /home/runner/work/quik/quik/com.google.android.apps.messaging.xapk -d /home/runner/work/quik/quik
|
||||
@@ -78,4 +79,5 @@ jobs:
|
||||
- Updated by [Auto-Update MMS configs] [Auto-Update MMS configs](./.github%2Fworkflows%2Fauto-update-mms-configs.yml)
|
||||
add-paths: android-smsmms/src/main/res/xml-mcc*
|
||||
branch: ${{ env.NEW_BRANCH }}
|
||||
base: ${{ env.DEFAULT_BRANCH }}
|
||||
base: master
|
||||
labels: automated
|
||||
|
||||
@@ -29,9 +29,41 @@ jobs:
|
||||
- name: List files in the APK directory
|
||||
run: ls -Rla ./
|
||||
|
||||
- name: Bump MINOR version in build.gradle (features update)
|
||||
working-directory: presentation
|
||||
run: |
|
||||
# Extract current versionName and versionCode
|
||||
VERSION_LINE=$(grep "versionName" build.gradle)
|
||||
VERSION_NAME=$(echo "$VERSION_LINE" | sed -n "s/.*versionName[ ]*['\"]\([^'\"]*\)['\"].*/\1/p")
|
||||
VERSION_CODE=$(grep "versionCode" build.gradle | awk '{print $2}')
|
||||
|
||||
# Error handling for version parsing
|
||||
if [[ ! "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Error: versionName is not in MAJOR.MINOR.PATCH format: $VERSION_NAME"
|
||||
exit 1
|
||||
fi
|
||||
if ! [[ "$VERSION_CODE" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: versionCode is not an integer: $VERSION_CODE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Split versionName into major, minor, patch
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NAME"
|
||||
# Bump minor version, reset patch to 0
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
NEW_VERSION_NAME="$MAJOR.$MINOR.$PATCH"
|
||||
NEW_VERSION_CODE=$((VERSION_CODE + 1))
|
||||
|
||||
# Update build.gradle in-place
|
||||
sed -i "s/versionName.*/versionName '$NEW_VERSION_NAME'/" build.gradle
|
||||
sed -i "s/versionCode.*/versionCode $NEW_VERSION_CODE/" build.gradle
|
||||
|
||||
echo "Bumped version to $NEW_VERSION_NAME ($NEW_VERSION_CODE)"
|
||||
|
||||
- name: Build APK
|
||||
run: |
|
||||
./gradlew assembleNoAnalyticsRelease \
|
||||
./gradlew assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
@@ -39,13 +71,13 @@ jobs:
|
||||
--stacktrace
|
||||
|
||||
- name: Rename APK
|
||||
run: mv presentation/build/outputs/apk/noAnalytics/release/QUIK-v*-noAnalytics-release.apk presentation/build/outputs/apk/noAnalytics/release/QUIK-noAnalytics-release.apk
|
||||
run: mv presentation/build/outputs/apk/release/QUIK-v*-release.apk presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apk
|
||||
path: presentation/build/outputs/apk/noAnalytics/release/QUIK-noAnalytics-release.apk
|
||||
path: presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
release:
|
||||
name: Release APK
|
||||
@@ -78,7 +110,7 @@ jobs:
|
||||
with:
|
||||
prerelease: true
|
||||
tag_name: "v${{ env.DATETIME }}"
|
||||
files: QUIK-noAnalytics-release.apk
|
||||
files: QUIK-release.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
@@ -25,20 +25,20 @@ jobs:
|
||||
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
./gradlew assembleNoAnalyticsDebug \
|
||||
./gradlew assembleDebug \
|
||||
-Dandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore
|
||||
|
||||
- name: Run Tests
|
||||
run: ./gradlew test
|
||||
|
||||
- name: List APK Output Directory
|
||||
run: ls -R presentation/build/outputs/apk/noAnalytics/debug
|
||||
run: ls -R presentation/build/outputs/apk/debug
|
||||
|
||||
- name: Rename APK
|
||||
run: mv presentation/build/outputs/apk/noAnalytics/debug/QUIK-v*-noAnalytics-debug.apk presentation/build/outputs/apk/noAnalytics/debug/QUIK-noAnalytics-debug.apk
|
||||
run: mv presentation/build/outputs/apk/debug/QUIK-v*-debug.apk presentation/build/outputs/apk/debug/QUIK-debug.apk
|
||||
|
||||
- name: Upload App
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apk-debug
|
||||
path: presentation/build/outputs/apk/noAnalytics/debug/QUIK-noAnalytics-debug.apk
|
||||
path: presentation/build/outputs/apk/debug/QUIK-debug.apk
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
name: Bump Version & Prepare F-Droid Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
META_YML: fdroid/metadata/dev.octoshrimpy.quik.yml
|
||||
GRADLE_FILE: presentation/build.gradle
|
||||
CHANGELOG: data/src/main/assets/changelog.json
|
||||
|
||||
steps:
|
||||
- name: Checkout full history
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
- name: Decode Android keystore
|
||||
run: |
|
||||
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > keystore.p12
|
||||
|
||||
- name: Install repo icon
|
||||
run: |
|
||||
mkdir -p repo/icons/metadata/en-US/images
|
||||
cp metadata/en-US/images/icon.png \
|
||||
repo/icons/metadata/en-US/images/icon.png
|
||||
|
||||
- name: Write F-Droid config.yml
|
||||
run: |
|
||||
cat > config.yml <<EOF
|
||||
repo_keystore: keystore.p12
|
||||
keystorepass: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
repo_keyalias: ${{ secrets.KEY_ALIAS }}
|
||||
keypass: ${{ secrets.KEY_PASSWORD }}
|
||||
repo_icon: metadata/en-US/images/icon.png
|
||||
EOF
|
||||
|
||||
- name: Bump F-Droid metadata
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- run: |
|
||||
pip3 install fdroidserver
|
||||
fdroid update
|
||||
|
||||
- name: Commit F-Droid metadata bump
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add "$META_YML"
|
||||
git diff --quiet --cached || git commit -m "chore: bump F-Droid metadata"
|
||||
|
||||
- name: Set up Java & jq
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
- run: sudo apt-get update && sudo apt-get install -y jq
|
||||
|
||||
- name: Bump Android version & changelog
|
||||
id: bump
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# extract current values
|
||||
current_code=$(grep -E '^[[:space:]]*versionCode ' "$GRADLE_FILE" | awk '{print $2}')
|
||||
current_name=$(grep -E 'versionName' "$GRADLE_FILE" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
# bump
|
||||
new_code=$((current_code + 1))
|
||||
IFS='.' read -r major minor patch <<< "$current_name"
|
||||
new_name="${major}.$((minor + 1)).0"
|
||||
# apply to build.gradle
|
||||
sed -i \
|
||||
-e "s|^[[:space:]]*versionCode[[:space:]]\+$current_code|versionCode $new_code|" \
|
||||
-e "s|versionName[[:space:]]\+'$current_name'|versionName '$new_name'|" \
|
||||
"$GRADLE_FILE"
|
||||
echo "NEW_CODE=$new_code" >> "$GITHUB_ENV"
|
||||
echo "NEW_NAME=$new_name" >> "$GITHUB_ENV"
|
||||
# prepend to changelog.json
|
||||
prev_tag="v${new_name}"
|
||||
if git rev-parse --verify --quiet "$prev_tag" >/dev/null; then
|
||||
base="$prev_tag"
|
||||
else
|
||||
base=$(git describe --tags --match "v[0-9]*" --abbrev=0 2>/dev/null || echo "")
|
||||
fi
|
||||
[[ -n "$base" ]] && range="$base..HEAD" || range="HEAD"
|
||||
mapfile -t commits < <(
|
||||
git log --no-merges --reverse --pretty=format:"%s by %an" $range \
|
||||
| sed -E 's/[[:space:]]*\.*[[:space:]]+by/ by/' \
|
||||
| sed -E 's/^[[:space:]]+//;s/[[:space:]]+$//' \
|
||||
| awk '!seen[$0]++'
|
||||
)
|
||||
changes_json=$(printf '%s\n' "${commits[@]:-}" | jq -R . | jq -s .)
|
||||
jq --argjson changes "$changes_json" \
|
||||
--arg vc "$new_code" \
|
||||
--arg vn "$new_name" \
|
||||
'
|
||||
def capfirst: sub("^(.)"; "\(ascii_upcase(.1))");
|
||||
$all := ($changes | map(capfirst));
|
||||
$fixes := $all | map(select(test("^(Fix|fix)")));
|
||||
$others := $all | map(select(test("^(Fix|fix)") | not));
|
||||
. = [{
|
||||
versionCode: ($vc|tonumber),
|
||||
versionName: $vn,
|
||||
fixes: $fixes,
|
||||
changes: $others
|
||||
}] + .
|
||||
' "$CHANGELOG" > tmp && mv tmp "$CHANGELOG"
|
||||
# write F-Droid .txt summary
|
||||
mkdir -p fdroid/metadata
|
||||
{
|
||||
echo "Changes in $new_name ($new_code):"
|
||||
echo
|
||||
for c in "${commits[@]}"; do echo "- $c"; done
|
||||
} > fdroid/metadata/"${new_code}".txt
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add "$GRADLE_FILE" "$CHANGELOG" "fdroid/metadata/${new_code}.txt"
|
||||
git commit -m "chore: bump to $new_name ($new_code)"
|
||||
|
||||
- name: Push bump branch
|
||||
run: |
|
||||
branch="bump/${{ env.NEW_NAME }}-${{ env.NEW_CODE }}"
|
||||
# Create or switch to the branch locally
|
||||
if git rev-parse --verify "$branch" >/dev/null 2>&1; then
|
||||
git checkout "$branch"
|
||||
else
|
||||
git checkout -b "$branch"
|
||||
fi
|
||||
# Force-push safely: only if the remote hasn't moved since last fetched
|
||||
git push --force-with-lease origin HEAD:"$branch"
|
||||
|
||||
- name: Open PR (no auto-merge)
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "chore: bump to ${{ env.NEW_NAME }} (${{ env.NEW_CODE }})"
|
||||
title: "chore: bump to ${{ env.NEW_NAME }} (${{ env.NEW_CODE }})"
|
||||
body: |
|
||||
This PR bumps:
|
||||
- versionCode → ${{ env.NEW_CODE }}
|
||||
- versionName → ${{ env.NEW_NAME }}
|
||||
branch: bump/${{ env.NEW_NAME }}-${{ env.NEW_CODE }}
|
||||
base: master
|
||||
labels: automated
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Deploy APK from master
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GRADLE_FILE: presentation/build.gradle
|
||||
|
||||
steps:
|
||||
- name: Checkout master
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Java 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
|
||||
- name: Decode Android keystore
|
||||
run: |
|
||||
echo "${{ secrets.KEYSTORE_FILE }}" \
|
||||
| base64 --decode > keystore.p12
|
||||
|
||||
- name: Build release APK
|
||||
run: |
|
||||
chmod +x ./gradlew
|
||||
./gradlew clean :presentation:assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=keystore.p12 \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
-Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }}
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────
|
||||
# 1) Extract versionName into an environment variable
|
||||
- name: Extract versionName
|
||||
id: extract
|
||||
run: |
|
||||
version=$(grep versionName $GRADLE_FILE \
|
||||
| grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
|
||||
# 2) Publish using that VERSION
|
||||
- name: Publish GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: v${{ env.VERSION }}
|
||||
files: presentation/build/outputs/apk/release/*-release.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
sudo: false
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: change
|
||||
|
||||
env:
|
||||
global:
|
||||
- COMPILE_API_LEVEL=29
|
||||
- EMULATOR_API_LEVEL=24 # It seems emulator levels 25,26,27 from main repos have google_apis by default, and do not support armeabi-v7a. Check commit comment.
|
||||
- EMULATOR_TAG=default # Possible values are default, google_apis, android-tv, android-wear, android-wear-cn
|
||||
- EMULATOR_ABI=armeabi-v7a # Default is armeabi-v7a, possible options are: x86, x86_64, mips, arm64-v8a, armeabi-v7a. Note: check commit comment
|
||||
- EMULATOR_NAME=quik4
|
||||
- ANDROID_BUILD_TOOLS_VERSION=29.0.2 # Match build-tools version used in build.gradle
|
||||
- EMULATOR="system-images;android-${EMULATOR_API_LEVEL};${EMULATOR_TAG};${EMULATOR_ABI}" # Used to install/create emulator
|
||||
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- tools
|
||||
- extra
|
||||
|
||||
# The build tools used in the project
|
||||
- build-tools-${ANDROID_BUILD_TOOLS_VERSION}
|
||||
|
||||
# The SDK used in the project
|
||||
- android-${COMPILE_API_LEVEL}
|
||||
|
||||
# For running the emulator in Travis
|
||||
- android-${EMULATOR_API_LEVEL}
|
||||
- sys-img-${EMULATOR_ABI}-android-${EMULATOR_API_LEVEL}
|
||||
|
||||
# Set up Android-sdk and the emulator
|
||||
before_install:
|
||||
# Decrypt keystore and google-services.json
|
||||
- openssl aes-256-cbc -K $encrypted_4d1d940e2c65_key -iv $encrypted_4d1d940e2c65_iv -in secrets.tar.enc -out secrets.tar -d
|
||||
- tar xvf secrets.tar
|
||||
|
||||
- echo 'count=0' > /home/travis/.android/repositories.cfg # Avoid warning
|
||||
- ls -lar $HOME/**/*
|
||||
|
||||
# List and delete unnecessary components to free space
|
||||
- sdkmanager --list || true # Print out package list for debug purposes
|
||||
- sdkmanager --uninstall "extras;google;google_play_services"
|
||||
- yes | sdkmanager "tools" # Update tools
|
||||
- yes | sdkmanager "platforms;android-${EMULATOR_API_LEVEL}" # Android platform required by emulator
|
||||
- yes | sdkmanager "platforms;android-${COMPILE_API_LEVEL}" # Android platform required by compiler
|
||||
- yes | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" # Android build tools
|
||||
- yes | sdkmanager "${EMULATOR}" # Install emulator system image
|
||||
- sdkmanager --list || true # Print out package list for debug purposes
|
||||
|
||||
# Run the emulator
|
||||
install:
|
||||
# emulator instance
|
||||
- echo no | android create avd --force -n ${EMULATOR_NAME} -k "${EMULATOR}"
|
||||
# Run emulator in a subshell, this seems to solve the travis QT issue
|
||||
- ( cd "$(dirname "$(which emulator)")" && ./emulator -avd ${EMULATOR_NAME} -verbose -show-kernel -selinux permissive -no-audio -no-window -no-boot-anim -wipe-data & )
|
||||
- android-wait-for-emulator
|
||||
- adb shell settings put global window_animation_scale 0 &
|
||||
- adb shell settings put global transition_animation_scale 0 &
|
||||
- adb shell settings put global animator_duration_scale 0 &
|
||||
- sleep 30
|
||||
- adb shell input keyevent 82 &
|
||||
- adb devices
|
||||
|
||||
# Gradle setup
|
||||
before_script:
|
||||
- cd ${TRAVIS_BUILD_DIR}
|
||||
- ./gradlew --version
|
||||
- ./gradlew clean
|
||||
|
||||
# Build APK
|
||||
script:
|
||||
- |
|
||||
./gradlew :presentation:assembleWithAnalyticsRelease :presentation:bundleWithAnalyticsRelease assembleAndroidTest -PtestCoverageEnabled='true'
|
||||
retval=$?
|
||||
if [$retval -ne 0]; then
|
||||
echo "error on assembling, exit code: "$retval
|
||||
exit $retval
|
||||
fi
|
||||
|
||||
# Deploy APK
|
||||
deploy:
|
||||
provider: releases
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
api_key:
|
||||
secure: XF7V/I02gpyOzCAFXEFyrThXVUUnKjSaWQ8lppO50mVtdugimjWIPtHrcYASaJQf9INhqo0lamk+khPxtKxc1BSCp8o+c22UKcpczyjD4kK27a3zKfuNQWteBRjCH34vIGnrRFSHSWYLIgeuoIK3q5Lq4IBK/Od3mfpRaDt1ER+IqMzR3L205x1H8dW3MVuxXgdnq3jHlRpq86oOe293+dnblVCtWUvAzwhZPnnbBc4JUaNomMI7dLJ/pAigByCoHHmG9pc2Cky1yyWVAnTZFAlf2PbzPDLRRnXmHuYKfHxiZgd/l8JTiZdhky9cXgFoSxvJyDABRqqLxVNfXt2ZwgdtiulZml8RB1FB0L37qL72mxWgi6y9IbQgt/FG20K2QpSBglk0bCGLS+h5Yz3kV4fhsBY7llpWGw14BvlAx9sUfl3Ej+IUsWoJgA00TFNGDG8sMyOFoCQVz/sB4Dv4h+JfynJZcmm8okcfYrWBHOoHY7cH3chBWp/2A736f2A/aqnBd6z8a03toe2ILC9eSOiIhrVxPyqLmEKBD1rCduVFNteqGwm9G9YwKpvFibTqu0gqEtfF7cmuMH6M5PYExI5EzoewZTYmgp02+lBuFAEMvycVvXcu8VfeeT6cgeLlmz2hsbo93UfoSQyP+gSojMOOkVUsl6mIp1STLiJ5IRY=
|
||||
file:
|
||||
- /home/travis/build/octoshrimpy/quik/presentation/build/outputs/bundle/withAnalyticsRelease/presentation.aab
|
||||
- /home/travis/build/octoshrimpy/quik/presentation/build/outputs/apk/withAnalytics/release/presentation-withAnalytics-release.apk
|
||||
on:
|
||||
repo: octoshrimpy/quik
|
||||
tags: true
|
||||
+6
-43
@@ -16,12 +16,13 @@ When reporting a bug, please make sure to provide the following information:
|
||||
To do this, navigate to the release tab in this repository and click on releases. There are two types of releases in Quik. The first is the `Latest Release`. This is the version that is distributed over the app stores. The other type is `Pre-Release`, which contains the latest features and may have bugs. To install this, download the apk from the release tab and install it on your phone. (Instructions can be found in the wiki for a more detailed explanation).
|
||||
Once you have done this, simply use the app as normal, and report any bugs you come across.
|
||||
## Translate
|
||||
To translate this app navigate to `presentation/src/main/res` and find or make a values file with the language you wish to edit. Then copy over the `strings.xml` file from `presentation/src/main/res/values` and translate it. Please do not translate any string with the `translatable=false` attribute. Also, remember to make sure to insert a backslash `\` before any apostrophe `'` or quotes `"`.
|
||||
<!--
|
||||
## Translations
|
||||
To translate this app join our [Weblate project](https://hosted.weblate.org/engage/quik/). From here you can begin editing strings on the web. We have a few guidelines for translations:
|
||||
* Insert a backslash `\` before any apostrophe `'` or quotes `"`.
|
||||
* Use `` ` `` instead of single quotes.
|
||||
* Follow the punctuation in the English strings as much as possible. For example don't add a `.` when there is none in the original strings.
|
||||
* If you are unsure of a translation, consider using a suggestion rather than translating the string. That way other translators can review it.
|
||||
|
||||
If you'd like to add translations to QUIK, please join the project on [Crowdin](https://crowdin.com/project/qksms). Translations that are committed directly to source files will not be accepted.
|
||||
-->
|
||||
We recommend checking out the [Weblate documentation](https://docs.weblate.org/en/latest/index.html), and if you need any help please open an issue.
|
||||
## Update the Wiki
|
||||
To update the wiki, simply navigate to the [wiki tab](https://github.com/octoshrimpy/quik/wiki) in this repository, find the file that you need to edit, and then click `Edit Page`. Then you can edit and commit your change. For more sizeable changes, and for feedback and questions please comment in [this discussion](https://github.com/octoshrimpy/quik/discussions/174).
|
||||
## Fix Bugs
|
||||
@@ -41,43 +42,5 @@ To update the wiki, simply navigate to the [wiki tab](https://github.com/octoshr
|
||||
6. Submit a pull request with your change.
|
||||
**We have a build action on each pull request, if this build fails, please edit the pull request in order to make the build succeed.**
|
||||
## Helpful Tips
|
||||
### [build.gradle](https://github.com/octoshrimpy/quik/blob/master/presentation/build.gradle) configuration for building locally
|
||||
```
|
||||
|
||||
/*
|
||||
signingConfigs {
|
||||
release {
|
||||
def keystoreProps = new Properties()
|
||||
def keystorePropsFile = rootProject.file('./.gradle/.gradlerc')
|
||||
storeFile file('./my-release-key.keystore')
|
||||
keyAlias 'quik_release'
|
||||
if (keystorePropsFile.exists()) {
|
||||
keystoreProps.load(new FileInputStream(keystorePropsFile))
|
||||
} else if (System.getenv("CI") == "true") {
|
||||
// do nothing
|
||||
} else {
|
||||
throw new GradleException("Keystore properties file not found.")
|
||||
}
|
||||
storePassword keystoreProps['storePassword']
|
||||
keyPassword keystoreProps['keyPassword']
|
||||
}
|
||||
}
|
||||
*/
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
// signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
withAnalytics { dimension "analytics" }
|
||||
noAnalytics {
|
||||
// signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
```
|
||||
### Set Java Version
|
||||
When building QUIK, make sure to download JDK 17 and specify an installation path for it. In Android Studio, you can do that in Settings > Build, Execution, Deployment > Build Tools > Gradle.
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
# QUIK
|
||||
|
||||
[](https://github.com/octoshrimpy/quik/actions/workflows/build-and-release.yml)
|
||||
<a href="https://hosted.weblate.org/engage/quik/">
|
||||
<img src="https://hosted.weblate.org/widget/quik/svg-badge.svg" alt="Translation status" />
|
||||
</a>
|
||||
|
||||
QUIK is an open source replacement to the [stock messaging app](https://github.com/android/platform_packages_apps_mms) on Android. It is a continuation of [QKSMS](https://github.com/moezbhatti/qksms).
|
||||
|
||||
@@ -46,6 +49,13 @@ When reporting a bug, please make sure to provide the following information:
|
||||
## Contributing
|
||||
Contributions welcome! Please see the [contributing guidelines](/CONTRIBUTING.md) for details.
|
||||
|
||||
## Translations
|
||||
If you'd like to add translations to QUIK, please join the project on [Weblate](https://hosted.weblate.org/engage/quik/)! Translations that are committed directly to source files will not be accepted. For more information see the [translation guidelines](/CONTRIBUTING.md#translate).
|
||||
|
||||
<a href="https://hosted.weblate.org/engage/quik/">
|
||||
<img src="https://hosted.weblate.org/widget/quik/multi-auto.svg" alt="Translation status" />
|
||||
</a>
|
||||
|
||||
## Thank you
|
||||
|
||||
A special thank you to Jake ([@klinker41](https://github.com/klinker41)) and Luke Klinker ([@klinker24](https://github.com/klinker24)) for their work on [android-smsmms](https://github.com/klinker41/android-smsmms), which has been an unspeakably large help in implementing MMS into QUIK.
|
||||
|
||||
+3
-4
@@ -18,7 +18,7 @@ buildscript {
|
||||
ext.exoplayer_version = "r2.9.0"
|
||||
ext.glide_version = "4.16.0"
|
||||
ext.junit_version = '4.12'
|
||||
ext.kotlin_version = '1.7.20'
|
||||
ext.kotlin_version = '1.7.21'
|
||||
ext.lifecycle_version = '2.1.0'
|
||||
ext.material_version = '1.0.0'
|
||||
ext.mockito_version = '2.18.3'
|
||||
@@ -32,7 +32,7 @@ buildscript {
|
||||
ext.rxjava_version = '2.1.4'
|
||||
ext.rxkotlin_version = '2.1.0'
|
||||
ext.rx_preferences_version = '2.0.0-RC3'
|
||||
ext.timber_version = '4.5.1'
|
||||
ext.timber_version = '5.0.1'
|
||||
ext.androidx_work_version = "2.8.0"
|
||||
|
||||
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2]
|
||||
@@ -46,7 +46,6 @@ buildscript {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
}
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -72,7 +71,7 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register('clean', Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
|
||||
@@ -48,5 +48,4 @@ repositories {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
}
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
@@ -4,15 +4,17 @@ package com.bumptech.glide.gifencoder;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class AnimatedGifEncoder {
|
||||
|
||||
// The minimum % of an images pixels that must be transparent for us to set a transparent index
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
repo_keystore: keystore.p12
|
||||
keystorepass: ekaterina
|
||||
repo_keyalias: quik_release
|
||||
keypass: ekaterina
|
||||
repo_icon: metadata/en-US/images/icon.png
|
||||
+1
-13
@@ -22,8 +22,6 @@ apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
compileSdk 34
|
||||
publishNonDefault true
|
||||
flavorDimensions "analytics"
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility 1.8
|
||||
@@ -34,14 +32,8 @@ android {
|
||||
minSdk 23
|
||||
targetSdkVersion 33
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
buildConfigField "String", "AMPLITUDE_API_KEY", "\"${System.getenv("AMPLITUDE_API_KEY")}\""
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
withAnalytics { dimension "analytics" }
|
||||
noAnalytics { dimension "analytics" }
|
||||
}
|
||||
namespace 'dev.octoshrimpy.quik.data'
|
||||
}
|
||||
|
||||
@@ -64,8 +56,6 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
//Resolve jdk8+ Generation Annotations - javax annotation does not exist
|
||||
implementation 'com.github.pengrad:jdk9-deps:1ffe84c468'
|
||||
|
||||
// look into jakarta.annotation-api when switching to java 9
|
||||
implementation 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
|
||||
// rxjava
|
||||
@@ -91,6 +81,7 @@ dependencies {
|
||||
implementation "com.f2prateek.rx.preferences2:rx-preferences:$rx_preferences_version"
|
||||
implementation "com.jakewharton.timber:timber:$timber_version"
|
||||
implementation "com.squareup.moshi:moshi:$moshi_version"
|
||||
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
|
||||
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
|
||||
implementation 'io.michaelrocks:libphonenumber-android:8.13.47'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
@@ -103,8 +94,6 @@ dependencies {
|
||||
implementation project(':common')
|
||||
implementation project(':domain')
|
||||
|
||||
withAnalyticsImplementation 'com.android.installreferrer:installreferrer:1.1'
|
||||
withAnalyticsImplementation "com.amplitude:android-sdk:2.16.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -116,5 +105,4 @@ repositories {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
}
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class PhoneNumberUtilsTest {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"emoji_reaction_ios_generic_added": "^(?s)Reacted (.+?) to “(.+?)”$",
|
||||
"emoji_reaction_ios_generic_removed": "^(?s)Removed (.+?) from “(.+?)”$",
|
||||
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Loved “(.+?)”$",
|
||||
"emoji_reaction_ios_heart_removed": "^(?s)Removed a heart from “(.+?)”$",
|
||||
|
||||
"emoji_reaction_ios_like_added": "^(?s)Liked “(.+?)”$",
|
||||
"emoji_reaction_ios_like_removed": "^(?s)Removed a like from “(.+?)”$",
|
||||
|
||||
"emoji_reaction_ios_dislike_added": "^(?s)Disliked “(.+?)”$",
|
||||
"emoji_reaction_ios_dislike_removed": "^(?s)Removed a dislike from “(.+?)”$",
|
||||
|
||||
"emoji_reaction_ios_laugh_added": "^(?s)Laughed at “(.+?)”$",
|
||||
"emoji_reaction_ios_laugh_removed": "^(?s)Removed a laugh from “(.+?)”$",
|
||||
|
||||
"emoji_reaction_ios_exclamation_added": "^(?s)Emphasized “(.+?)”$",
|
||||
"emoji_reaction_ios_exclamation_removed": "^(?s)Removed an exclamation from “(.+?)”$",
|
||||
|
||||
"emoji_reaction_ios_question_mark_added": "^(?s)Questioned “(.+?)”$",
|
||||
"emoji_reaction_ios_question_mark_removed": "^(?s)Removed a question mark from “(.+?)”$"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Очень понравилось «(.+?)»$",
|
||||
|
||||
"emoji_reaction_ios_like_added": "^(?s)Понравилось «(.+?)»$",
|
||||
|
||||
"emoji_reaction_ios_dislike_added": "^(?s)Не понравилось «(.+?)»$",
|
||||
|
||||
"emoji_reaction_ios_laugh_added": "^(?s)Посмеялись над «(.+?)»$",
|
||||
|
||||
"emoji_reaction_ios_exclamation_added": "^(?s)Отмечено «(.+?)»$",
|
||||
|
||||
"emoji_reaction_ios_question_mark_added": "^(?s)Поставлен вопрос на «(.+?)»$"
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import dev.octoshrimpy.quik.extensions.map
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Single
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class CallBlockerBlockingClient @Inject constructor(
|
||||
|
||||
@@ -20,12 +20,12 @@ package dev.octoshrimpy.quik.manager
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import dev.octoshrimpy.quik.common.util.extensions.versionCode
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.Types
|
||||
import dev.octoshrimpy.quik.common.util.extensions.versionCode
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.octoshrimpy.quik.manager
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
class ReferralManagerImpl @Inject constructor() : ReferralManager {
|
||||
|
||||
override suspend fun trackReferrer() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,9 @@ package dev.octoshrimpy.quik.mapper
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.provider.Telephony.*
|
||||
import android.provider.Telephony.Mms
|
||||
import android.provider.Telephony.MmsSms
|
||||
import android.provider.Telephony.Sms
|
||||
import com.google.android.mms.pdu_alt.EncodedStringValue
|
||||
import com.google.android.mms.pdu_alt.PduHeaders
|
||||
import com.google.android.mms.pdu_alt.PduPersister
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
package dev.octoshrimpy.quik.mapper
|
||||
|
||||
import com.f2prateek.rx.preferences2.RxSharedPreferences
|
||||
import dev.octoshrimpy.quik.manager.AnalyticsManager
|
||||
import dev.octoshrimpy.quik.manager.RatingManager
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import javax.inject.Inject
|
||||
|
||||
class RatingManagerImpl @Inject constructor(
|
||||
rxPrefs: RxSharedPreferences,
|
||||
private val analyticsManager: AnalyticsManager
|
||||
) : RatingManager {
|
||||
|
||||
companion object {
|
||||
@@ -50,12 +48,10 @@ class RatingManagerImpl @Inject constructor(
|
||||
}
|
||||
|
||||
override fun rate() {
|
||||
// analyticsManager.track("Clicked Rate")
|
||||
rated.set(true)
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
// analyticsManager.track("Clicked Rate (Dismiss)")
|
||||
dismissed.set(true)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class QkRealmMigration @Inject constructor(
|
||||
) : RealmMigration {
|
||||
|
||||
companion object {
|
||||
const val SCHEMA_VERSION: Long = 12
|
||||
const val SCHEMA_VERSION: Long = 14
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@@ -234,8 +234,19 @@ class QkRealmMigration @Inject constructor(
|
||||
|
||||
version++
|
||||
}
|
||||
|
||||
if (version == 11L) {
|
||||
realm.schema.get("ScheduledMessage")
|
||||
?.addField("conversationId", Long::class.java, FieldAttribute.REQUIRED)
|
||||
// Because there was never any property associated with which conversation/recipients a scheduled message was for,
|
||||
// we can't update this field on a realm migration. It will be set to a default of 0
|
||||
|
||||
realm.schema.create("MessageContentFilter")
|
||||
.addField("id", Long::class.java, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
|
||||
.addField("value", String::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("caseSensitive", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("isRegex", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("includeContacts", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
|
||||
realm.schema.get("Conversation")
|
||||
?.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
?.transform { conversation ->
|
||||
@@ -248,6 +259,38 @@ class QkRealmMigration @Inject constructor(
|
||||
realm.schema.get("Message")
|
||||
?.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
|
||||
|
||||
version++
|
||||
}
|
||||
|
||||
if (version == 12L) {
|
||||
realm.schema.get("Conversation")
|
||||
?.addField("draftDate", Long::class.java, FieldAttribute.REQUIRED)
|
||||
|
||||
version++
|
||||
}
|
||||
|
||||
if (version == 13L) {
|
||||
val emojiReactionTable = realm.schema.create("EmojiReaction")
|
||||
.addField("id", Long::class.java, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
|
||||
.addField("reactionMessageId", Long::class.java, FieldAttribute.INDEXED, FieldAttribute.REQUIRED)
|
||||
.addField("senderAddress", String::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("emoji", String::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("originalMessageText", String::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("threadId", Long::class.java, FieldAttribute.INDEXED, FieldAttribute.REQUIRED)
|
||||
|
||||
realm.schema.get("Message")
|
||||
?.addField("isEmojiReaction", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
?.addRealmListField("emojiReactions", emojiReactionTable)
|
||||
?.transform { msg ->
|
||||
msg.setBoolean("isEmojiReaction", false)
|
||||
}
|
||||
|
||||
realm.schema.create("EmojiSyncNeeded")
|
||||
.addField("createdAt", Long::class.java, FieldAttribute.REQUIRED)
|
||||
|
||||
realm.createObject("EmojiSyncNeeded")
|
||||
|
||||
version++
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.receiver
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.blocking.BlockingClient
|
||||
import dev.octoshrimpy.quik.interactor.MarkBlocked
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
@@ -37,6 +38,7 @@ class BlockThreadReceiver : BroadcastReceiver() {
|
||||
@Inject lateinit var markBlocked: MarkBlocked
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
AndroidInjection.inject(this, context)
|
||||
|
||||
@@ -57,8 +59,14 @@ class BlockThreadReceiver : BroadcastReceiver() {
|
||||
MarkBlocked.Params(listOf(threadId), prefs.blockingManager.get(), null)
|
||||
)
|
||||
)
|
||||
.subscribe { goAsync().finish() }
|
||||
.dispose()
|
||||
.subscribe(
|
||||
{
|
||||
goAsync().finish()
|
||||
},
|
||||
{ error ->
|
||||
Timber.e("BlockThreadReceiver", "blocking failed")
|
||||
goAsync().finish()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.octoshrimpy.quik.receiver
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dev.octoshrimpy.quik.interactor.UpdateScheduledMessageAlarms
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.UpdateScheduledMessageAlarms
|
||||
import javax.inject.Inject
|
||||
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
|
||||
@@ -24,9 +24,9 @@ import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Telephony
|
||||
import androidx.annotation.RequiresApi
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.SyncMessages
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class DefaultSmsChangedReceiver : BroadcastReceiver() {
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.octoshrimpy.quik.receiver
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dev.octoshrimpy.quik.interactor.DeleteMessages
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.DeleteMessages
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ import android.app.Activity
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.MarkDelivered
|
||||
import dev.octoshrimpy.quik.interactor.MarkDeliveryFailed
|
||||
import dagger.android.AndroidInjection
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.octoshrimpy.quik.receiver
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dev.octoshrimpy.quik.util.NightModeManager
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.util.NightModeManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class NightModeReceiver : BroadcastReceiver() {
|
||||
|
||||
@@ -22,12 +22,12 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.app.RemoteInput
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.compat.SubscriptionManagerCompat
|
||||
import dev.octoshrimpy.quik.interactor.MarkRead
|
||||
import dev.octoshrimpy.quik.interactor.SendNewMessage
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class RemoteMessagingReceiver : BroadcastReceiver() {
|
||||
|
||||
@@ -21,9 +21,9 @@ package dev.octoshrimpy.quik.receiver
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.SendScheduledMessage
|
||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||
import dagger.android.AndroidInjection
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.octoshrimpy.quik.receiver
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dev.octoshrimpy.quik.interactor.SyncMessage
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.SyncMessage
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.octoshrimpy.quik.receiver
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dev.octoshrimpy.quik.interactor.SpeakThreads
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.SpeakThreads
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ import android.provider.Telephony
|
||||
import androidx.core.content.contentValuesOf
|
||||
import androidx.core.net.toUri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.squareup.moshi.Moshi
|
||||
import dev.octoshrimpy.quik.common.util.extensions.now
|
||||
import dev.octoshrimpy.quik.model.BackupFile
|
||||
import dev.octoshrimpy.quik.model.Message
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import com.squareup.moshi.Moshi
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
@@ -40,7 +40,8 @@ import okio.buffer
|
||||
import okio.source
|
||||
import timber.log.Timber
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import java.util.Timer
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.concurrent.schedule
|
||||
|
||||
@@ -171,4 +171,14 @@ class ContactRepositoryImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun isContact(address: String): Boolean {
|
||||
val uri : Uri
|
||||
if (address.contains('@')) {
|
||||
uri = Uri.withAppendedPath(Email.CONTENT_FILTER_URI, Uri.encode(address))
|
||||
} else {
|
||||
uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(address))
|
||||
}
|
||||
return context.contentResolver.query(uri, arrayOf(BaseColumns._ID), null, null, null)?.count!! > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -355,6 +355,7 @@ class ConversationRepositoryImpl @Inject constructor(
|
||||
|
||||
realm.executeTransaction {
|
||||
conversation?.takeIf { it.isValid }?.draft = draft
|
||||
conversation?.takeIf { it.isValid }?.draftDate = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* Copyright (C) 2025
|
||||
*
|
||||
* This file is part of QUIK.
|
||||
*
|
||||
* QUIK is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QUIK is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QUIK. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.repository
|
||||
|
||||
import android.content.Context
|
||||
import com.squareup.moshi.Moshi
|
||||
import dev.octoshrimpy.quik.extensions.insertOrUpdate
|
||||
import dev.octoshrimpy.quik.manager.KeyManager
|
||||
import dev.octoshrimpy.quik.model.EmojiReaction
|
||||
import dev.octoshrimpy.quik.model.Message
|
||||
import dev.octoshrimpy.quik.util.EmojiPatternStrings
|
||||
import io.realm.Realm
|
||||
import io.realm.Sort
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
private val context: Context,
|
||||
private val keyManager: KeyManager,
|
||||
private val moshi: Moshi,
|
||||
) : EmojiReactionRepository {
|
||||
// We use an ordered map to make sure we can test tapback regexes before generic ones
|
||||
private val reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf(
|
||||
Regex( // Google Messages
|
||||
"(?s)^\u200a[^\u200b\u200a]*\u200b([^\u200b]*)\u200b[^\u200b\u200a]*\u200a(.*)\u200a[^\u200b\u200a]*\u200a\\Z"
|
||||
) to { match -> ParsedEmojiReaction(match.groupValues[1], match.groupValues[2]) }
|
||||
)
|
||||
private val removalPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf(
|
||||
Regex( // Google Messages
|
||||
"(?s)^\u200a[^\u200c\u200a]*\u200c([^\u200c]*)\u200c[^\u200c\u200a]*\u200a(.*)\u200a[^\u200c\u200a]*\u200a\\Z"
|
||||
) to { match -> ParsedEmojiReaction(match.groupValues[1], match.groupValues[2], isRemoval = true) }
|
||||
)
|
||||
|
||||
init {
|
||||
val assetEntries = loadEmojiPatternEntriesFromAssets()
|
||||
assetEntries.forEach { (localeTag, strings) ->
|
||||
try {
|
||||
addPatternsForLocaleStrings(localeTag, strings, reactionPatterns, removalPatterns)
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Failed to load asset patterns for locale: $localeTag")
|
||||
}
|
||||
}
|
||||
Timber.i("Loaded emoji reaction patterns for locales: ${assetEntries.map { it.first }}")
|
||||
}
|
||||
|
||||
private fun addPatternsForLocaleStrings(
|
||||
localeTag: String,
|
||||
strings: EmojiPatternStrings,
|
||||
reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?>,
|
||||
removalPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?>
|
||||
) {
|
||||
// iOS tapbacks (important to add these before generic emoji patterns as the regexes may overlap)
|
||||
listOf(
|
||||
Triple("❤️", strings.iosHeartAdded, strings.iosHeartRemoved),
|
||||
Triple("👍", strings.iosLikeAdded, strings.iosLikeRemoved),
|
||||
Triple("👎", strings.iosDislikeAdded, strings.iosDislikeRemoved),
|
||||
Triple("😂", strings.iosLaughAdded, strings.iosLaughRemoved),
|
||||
Triple("‼️", strings.iosExclamationAdded, strings.iosExclamationRemoved),
|
||||
Triple("❓", strings.iosQuestionMarkAdded, strings.iosQuestionMarkRemoved)
|
||||
).forEach { (emoji, added, removed) ->
|
||||
added?.let {
|
||||
reactionPatterns[Regex(it)] =
|
||||
{ match -> ParsedEmojiReaction(emoji, match.groupValues[1]) }
|
||||
}
|
||||
removed?.let {
|
||||
removalPatterns[Regex(it)] =
|
||||
{ match -> ParsedEmojiReaction(emoji, match.groupValues[1], isRemoval = true) }
|
||||
}
|
||||
}
|
||||
|
||||
// Generic iOS emoji patterns
|
||||
strings.iosGenericAdded?.let { pattern ->
|
||||
reactionPatterns[Regex(pattern)] = { match ->
|
||||
if (match.groupValues.getOrNull(1) == "with a sticker") null // TODO: localize "with a sticker"
|
||||
else ParsedEmojiReaction(match.groupValues[1], match.groupValues[2])
|
||||
}
|
||||
}
|
||||
strings.iosGenericRemoved?.let { pattern ->
|
||||
removalPatterns[Regex(pattern)] = { match ->
|
||||
ParsedEmojiReaction(match.groupValues[1], match.groupValues[2], isRemoval = true)
|
||||
}
|
||||
}
|
||||
|
||||
Timber.d("Loaded emoji regex patterns for $localeTag from assets")
|
||||
}
|
||||
|
||||
private fun loadEmojiPatternEntriesFromAssets(): List<Pair<String, EmojiPatternStrings>> {
|
||||
val dir = "emojis"
|
||||
val files = context.assets.list(dir) ?: emptyArray()
|
||||
return files.filter { it.endsWith(".json", ignoreCase = true) }
|
||||
.mapNotNull { filename ->
|
||||
val localeTag = filename.removeSuffix(".json")
|
||||
try {
|
||||
val json = context.assets.open("$dir/$filename").bufferedReader().use { it.readText() }
|
||||
val data = parseEmojiPatternsJson(json)
|
||||
localeTag to data
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Failed parsing emoji patterns asset: $filename")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseEmojiPatternsJson(json: String): EmojiPatternStrings {
|
||||
val adapter = moshi.adapter(EmojiPatternStrings::class.java)
|
||||
return requireNotNull(adapter.fromJson(json)) { "Invalid emoji patterns JSON" }
|
||||
}
|
||||
|
||||
override fun parseEmojiReaction(body: String): ParsedEmojiReaction? {
|
||||
val removal = parseRemoval(body)
|
||||
if (removal != null) return removal
|
||||
|
||||
for ((pattern, parser) in reactionPatterns) {
|
||||
val match = pattern.find(body)
|
||||
if (match == null) continue;
|
||||
|
||||
val result = parser(match)
|
||||
if (result == null) continue
|
||||
|
||||
Timber.d("Reaction found with ${result.emoji}")
|
||||
return result
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun parseRemoval(body: String): ParsedEmojiReaction? {
|
||||
for ((pattern, parser) in removalPatterns) {
|
||||
val match = pattern.find(body)
|
||||
if (match == null) continue;
|
||||
|
||||
val result = parser(match)
|
||||
if (result == null) continue
|
||||
|
||||
Timber.d("Removal found with ${result.emoji}")
|
||||
return result
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for messages in the same thread with matching text content
|
||||
* We'll search recent messages first
|
||||
*/
|
||||
override fun findTargetMessage(
|
||||
threadId: Long,
|
||||
originalMessageText: String,
|
||||
realm: Realm
|
||||
): Message? {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val messages = realm.where(Message::class.java)
|
||||
.equalTo("threadId", threadId)
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.findAll()
|
||||
val endTime = System.currentTimeMillis()
|
||||
Timber.d("Found ${messages.size} messages as potential emoji targets in ${endTime - startTime}ms")
|
||||
|
||||
val match = messages.find { message ->
|
||||
message.getText(false).trim() == originalMessageText.trim()
|
||||
}
|
||||
if (match != null) {
|
||||
Timber.d("Found match for reaction target: message ID ${match.id}")
|
||||
return match
|
||||
}
|
||||
|
||||
Timber.w("No target message found for reaction text: '$originalMessageText'")
|
||||
return null
|
||||
}
|
||||
|
||||
private fun removeEmojiReaction(
|
||||
reactionMessage: Message,
|
||||
reaction: ParsedEmojiReaction,
|
||||
targetMessage: Message?,
|
||||
realm: Realm,
|
||||
) {
|
||||
if (targetMessage == null) {
|
||||
Timber.w("Cannot remove emoji reaction '${reaction.emoji}': no target message found")
|
||||
return
|
||||
}
|
||||
|
||||
val existingReaction = targetMessage.emojiReactions.find { candidate ->
|
||||
candidate.senderAddress == reactionMessage.address && candidate.emoji == reaction.emoji
|
||||
}
|
||||
|
||||
if (existingReaction != null) {
|
||||
existingReaction.deleteFromRealm()
|
||||
Timber.d("Removed emoji reaction: ${reaction.emoji} to message ${targetMessage.id}")
|
||||
} else {
|
||||
Timber.w("No existing emoji reaction found to remove: ${reaction.emoji} to message ${targetMessage.id}")
|
||||
}
|
||||
|
||||
reactionMessage.isEmojiReaction = true
|
||||
realm.insertOrUpdate(reactionMessage)
|
||||
}
|
||||
|
||||
override fun saveEmojiReaction(
|
||||
reactionMessage: Message,
|
||||
parsedReaction: ParsedEmojiReaction,
|
||||
targetMessage: Message?,
|
||||
realm: Realm,
|
||||
) {
|
||||
if (parsedReaction.isRemoval) {
|
||||
removeEmojiReaction(reactionMessage, parsedReaction, targetMessage, realm)
|
||||
return
|
||||
}
|
||||
|
||||
val reaction = EmojiReaction().apply {
|
||||
id = keyManager.newId()
|
||||
reactionMessageId = reactionMessage.id
|
||||
senderAddress = reactionMessage.address
|
||||
emoji = parsedReaction.emoji
|
||||
originalMessageText = parsedReaction.originalMessage
|
||||
threadId = reactionMessage.threadId
|
||||
}
|
||||
realm.insertOrUpdate(reaction)
|
||||
|
||||
if (targetMessage != null) {
|
||||
reactionMessage.isEmojiReaction = true
|
||||
realm.insertOrUpdate(reactionMessage)
|
||||
|
||||
// Overwrite any previous reaction from this sender for this target
|
||||
val priorFromSender = targetMessage.emojiReactions.filter { it.senderAddress == reaction.senderAddress }
|
||||
priorFromSender.forEach { it.deleteFromRealm() }
|
||||
|
||||
targetMessage.emojiReactions.add(reaction)
|
||||
|
||||
Timber.i("Saved emoji reaction: ${reaction.emoji} to message ${targetMessage.id}")
|
||||
} else {
|
||||
Timber.w("No target message, cannot save emoji reaction: ${reaction.emoji}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteAndReparseAllEmojiReactions(realm: Realm) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
|
||||
realm.delete(EmojiReaction::class.java)
|
||||
realm.where(Message::class.java).findAll().map {
|
||||
it.isEmojiReaction = false
|
||||
}
|
||||
|
||||
val allMessages = realm.where(Message::class.java)
|
||||
.beginGroup()
|
||||
.beginGroup()
|
||||
.equalTo("type", "sms")
|
||||
.isNotEmpty("body")
|
||||
.endGroup()
|
||||
.or()
|
||||
.beginGroup()
|
||||
.equalTo("type", "mms")
|
||||
.notEqualTo("messageType", 130.toLong())
|
||||
.isNotEmpty("parts.text")
|
||||
.endGroup()
|
||||
.endGroup()
|
||||
.sort("date", Sort.ASCENDING) // parse oldest to newest to handle reactions & removals properly
|
||||
.findAll()
|
||||
|
||||
allMessages.forEach { message ->
|
||||
val text = message.getText(false)
|
||||
val parsedReaction = parseEmojiReaction(text)
|
||||
if (parsedReaction != null) {
|
||||
val targetMessage = findTargetMessage(
|
||||
message.threadId,
|
||||
parsedReaction.originalMessage,
|
||||
realm
|
||||
)
|
||||
saveEmojiReaction(
|
||||
message,
|
||||
parsedReaction,
|
||||
targetMessage,
|
||||
realm,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val endTime = System.currentTimeMillis()
|
||||
Timber.d("Deleted and reparsed all emoji reactions in ${endTime - startTime}ms")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.repository
|
||||
|
||||
import dev.octoshrimpy.quik.model.MessageContentFilter
|
||||
import dev.octoshrimpy.quik.model.MessageContentFilterData
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmResults
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageContentFilterRepositoryImpl @Inject constructor() : MessageContentFilterRepository {
|
||||
override fun createFilter(data: MessageContentFilterData) {
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
realm.refresh()
|
||||
val maxId = realm.where(MessageContentFilter::class.java)
|
||||
.max("id")?.toLong() ?: -1
|
||||
|
||||
realm.executeTransaction {
|
||||
realm.insert(MessageContentFilter(maxId + 1, data.value, data.caseSensitive, data.isRegex, data.includeContacts))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMessageContentFilters(): RealmResults<MessageContentFilter> {
|
||||
return Realm.getDefaultInstance()
|
||||
.where(MessageContentFilter::class.java)
|
||||
.findAllAsync()
|
||||
}
|
||||
|
||||
override fun getMessageContentFilter(id: Long): MessageContentFilter? {
|
||||
return Realm.getDefaultInstance()
|
||||
.where(MessageContentFilter::class.java)
|
||||
.equalTo("id", id)
|
||||
.findFirst()
|
||||
}
|
||||
|
||||
override fun isBlocked(messageBody: String, address: String, contactsRepo: ContactRepository): Boolean {
|
||||
val isContact = contactsRepo.isContact(address)
|
||||
|
||||
return Realm.getDefaultInstance().use { realm ->
|
||||
realm.where(MessageContentFilter::class.java)
|
||||
.findAll()
|
||||
.any { filter ->
|
||||
if (isContact && !filter.includeContacts) {
|
||||
false
|
||||
} else if (filter.isRegex) {
|
||||
Regex(filter.value).matches(messageBody)
|
||||
} else if (filter.caseSensitive) {
|
||||
val regexp = ".*\\b" + Regex.escape(filter.value) + "\\b.*"
|
||||
Regex(regexp).matches(messageBody)
|
||||
} else {
|
||||
val regexp = ".*\\b" + Regex.escape(filter.value.lowercase()) + "\\b.*"
|
||||
Regex(regexp).matches(messageBody.lowercase())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeFilter(id: Long) {
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
realm.executeTransaction {
|
||||
realm.where(MessageContentFilter::class.java)
|
||||
.equalTo("id", id)
|
||||
.findAll()
|
||||
.deleteAllFromRealm()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,6 +81,8 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
private val messageIds: KeyManager,
|
||||
private val phoneNumberUtils: PhoneNumberUtils,
|
||||
private val prefs: Preferences,
|
||||
private val syncRepository: SyncRepository,
|
||||
private val reactions: EmojiReactionRepository,
|
||||
private val cursorToMessage: CursorToMessage,
|
||||
private val cursorToPart: CursorToPart,
|
||||
) : MessageRepository {
|
||||
@@ -93,6 +95,7 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
Realm.getDefaultInstance()
|
||||
.where(Message::class.java)
|
||||
.equalTo("threadId", threadId)
|
||||
.equalTo("isEmojiReaction", false)
|
||||
.let {
|
||||
when (query.isEmpty()) {
|
||||
true -> it
|
||||
@@ -188,9 +191,10 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
|
||||
val extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(part.type)
|
||||
?: return null
|
||||
val date = part.messages?.first()?.date
|
||||
val fileName = part.name?.takeIf { name -> name.endsWith(extension) }
|
||||
?: "${part.type.split("/").last()}_$date.$extension"
|
||||
// fileDateAndTime is divided by 1000 in order to remove the extra 0's after date and time
|
||||
// This way the file name isn't so long.
|
||||
val fileDateAndTime = (part.messages?.first()?.date)?.div(1000)
|
||||
val fileName = "QUIK_${part.type.split("/").last()}_$fileDateAndTime.$extension"
|
||||
|
||||
val values = contentValuesOf(
|
||||
MediaStore.MediaColumns.DISPLAY_NAME to fileName,
|
||||
@@ -731,7 +735,33 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
}
|
||||
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
realm.executeTransaction { realm.copyToRealmOrUpdate(message) }
|
||||
var managedMessage: Message? = null
|
||||
realm.executeTransaction { managedMessage = realm.copyToRealmOrUpdate(message) }
|
||||
|
||||
context.contentResolver.insert(Sms.Inbox.CONTENT_URI, values)
|
||||
?.lastPathSegment?.toLong()?.let { id ->
|
||||
// Update contentId after the message has been inserted to the content provider
|
||||
realm.executeTransaction { managedMessage?.contentId = id }
|
||||
}
|
||||
|
||||
managedMessage?.let { savedMessage ->
|
||||
val parsedReaction = reactions.parseEmojiReaction(body)
|
||||
if (parsedReaction != null) {
|
||||
val targetMessage = reactions.findTargetMessage(
|
||||
savedMessage.threadId,
|
||||
parsedReaction.originalMessage,
|
||||
realm
|
||||
)
|
||||
realm.executeTransaction {
|
||||
reactions.saveEmojiReaction(
|
||||
savedMessage,
|
||||
parsedReaction,
|
||||
targetMessage,
|
||||
realm,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return message
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.reactivex.schedulers.Schedulers
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmResults
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRepository {
|
||||
@@ -20,7 +21,8 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
|
||||
recipients: List<String>,
|
||||
sendAsGroup: Boolean,
|
||||
body: String,
|
||||
attachments: List<String>
|
||||
attachments: List<String>,
|
||||
conversationId: Long
|
||||
): ScheduledMessage {
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
val id = (realm
|
||||
@@ -33,7 +35,7 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
|
||||
val attachmentsRealmList = RealmList(*attachments.toTypedArray())
|
||||
|
||||
val message = ScheduledMessage(id, date, subId, recipientsRealmList, sendAsGroup, body,
|
||||
attachmentsRealmList)
|
||||
attachmentsRealmList, conversationId)
|
||||
|
||||
realm.executeTransaction { realm.insertOrUpdate(message) }
|
||||
|
||||
@@ -62,6 +64,13 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
|
||||
.findFirst()
|
||||
}
|
||||
|
||||
override fun getScheduledMessagesForConversation(conversationId: Long): RealmResults<ScheduledMessage> {
|
||||
return Realm.getDefaultInstance()
|
||||
.where(ScheduledMessage::class.java)
|
||||
.equalTo("conversationId", conversationId)
|
||||
.findAllAsync()
|
||||
}
|
||||
|
||||
override fun deleteScheduledMessage(id: Long) {
|
||||
val subscription = Completable.fromAction {
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
@@ -71,12 +80,12 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
|
||||
|
||||
realm.executeTransaction { message?.deleteFromRealm() }
|
||||
}
|
||||
}.subscribeOn(Schedulers.io()) // Perform the operation in a background thread
|
||||
.observeOn(AndroidSchedulers.mainThread()) // Switch back to the main thread if needed
|
||||
}.subscribeOn(Schedulers.io()) // Run on a background thread and switch to main if needed
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
// Handle completion, e.g., log success or update UI
|
||||
Timber.v("Successfully deleted scheduled messages.")
|
||||
}, {
|
||||
// Handle error, e.g., log or show error message
|
||||
Timber.e("Deleting scheduled messages failed.")
|
||||
})
|
||||
|
||||
disposables.add(subscription)
|
||||
@@ -96,5 +105,4 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
|
||||
.map { it.id }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ package dev.octoshrimpy.quik.repository
|
||||
import android.content.ContentResolver
|
||||
import android.content.ContentUris
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.provider.Telephony
|
||||
import com.f2prateek.rx.preferences2.RxSharedPreferences
|
||||
import dev.octoshrimpy.quik.extensions.forEach
|
||||
@@ -37,6 +39,7 @@ import dev.octoshrimpy.quik.mapper.CursorToRecipient
|
||||
import dev.octoshrimpy.quik.model.Contact
|
||||
import dev.octoshrimpy.quik.model.ContactGroup
|
||||
import dev.octoshrimpy.quik.model.Conversation
|
||||
import dev.octoshrimpy.quik.model.EmojiReaction
|
||||
import dev.octoshrimpy.quik.model.Message
|
||||
import dev.octoshrimpy.quik.model.MmsPart
|
||||
import dev.octoshrimpy.quik.model.PhoneNumber
|
||||
@@ -49,6 +52,7 @@ import io.reactivex.subjects.Subject
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmList
|
||||
import io.realm.Sort
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -65,7 +69,8 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
private val cursorToContactGroupMember: CursorToContactGroupMember,
|
||||
private val keys: KeyManager,
|
||||
private val phoneNumberUtils: PhoneNumberUtils,
|
||||
private val rxPrefs: RxSharedPreferences
|
||||
private val rxPrefs: RxSharedPreferences,
|
||||
private val reactions: EmojiReactionRepository,
|
||||
) : SyncRepository {
|
||||
|
||||
override val syncProgress: Subject<SyncRepository.SyncProgress> =
|
||||
@@ -73,144 +78,173 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
|
||||
override fun syncMessages() {
|
||||
|
||||
val oldBlockedSenders = rxPrefs.getStringSet("pref_key_blocked_senders")
|
||||
|
||||
// If the sync is already running, don't try to do another one
|
||||
if (syncProgress.blockingFirst() is SyncRepository.SyncProgress.Running) return
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(0, 0, true))
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
val handlerThread = HandlerThread("RealmSyncThread")
|
||||
handlerThread.start()
|
||||
Handler(handlerThread.looper).post {
|
||||
Realm.getDefaultInstance().executeTransactionAsync(
|
||||
{ realm ->
|
||||
// Prepare existing conversation data
|
||||
val persistedData = realm.copyFromRealm(
|
||||
realm.where(Conversation::class.java)
|
||||
.beginGroup()
|
||||
.equalTo("archived", true)
|
||||
.or()
|
||||
.equalTo("blocked", true)
|
||||
.or()
|
||||
.equalTo("pinned", true)
|
||||
.or()
|
||||
.isNotEmpty("name")
|
||||
.or()
|
||||
.isNotNull("blockingClient")
|
||||
.or()
|
||||
.isNotEmpty("blockReason")
|
||||
.endGroup()
|
||||
.findAll()
|
||||
).associateBy { conversation -> conversation.id }.toMutableMap()
|
||||
|
||||
val persistedData = realm.copyFromRealm(realm.where(Conversation::class.java)
|
||||
.beginGroup()
|
||||
.equalTo("archived", true)
|
||||
.or()
|
||||
.equalTo("blocked", true)
|
||||
.or()
|
||||
.equalTo("pinned", true)
|
||||
.or()
|
||||
.isNotEmpty("name")
|
||||
.or()
|
||||
.isNotNull("blockingClient")
|
||||
.or()
|
||||
.isNotEmpty("blockReason")
|
||||
.endGroup()
|
||||
.findAll())
|
||||
.associateBy { conversation -> conversation.id }
|
||||
.toMutableMap()
|
||||
removeOldMessages(realm)
|
||||
|
||||
realm.delete(Contact::class.java)
|
||||
realm.delete(ContactGroup::class.java)
|
||||
realm.delete(Conversation::class.java)
|
||||
realm.delete(Message::class.java)
|
||||
realm.delete(MmsPart::class.java)
|
||||
realm.delete(Recipient::class.java)
|
||||
keys.reset()
|
||||
|
||||
keys.reset()
|
||||
val partsCursor = cursorToPart.getPartsCursor()
|
||||
val messageCursor = cursorToMessage.getMessagesCursor()
|
||||
val conversationCursor = cursorToConversation.getConversationsCursor()
|
||||
val recipientCursor = cursorToRecipient.getRecipientCursor()
|
||||
|
||||
val partsCursor = cursorToPart.getPartsCursor()
|
||||
val messageCursor = cursorToMessage.getMessagesCursor()
|
||||
val conversationCursor = cursorToConversation.getConversationsCursor()
|
||||
val recipientCursor = cursorToRecipient.getRecipientCursor()
|
||||
val max = (partsCursor?.count ?: 0) +
|
||||
(messageCursor?.count ?: 0) +
|
||||
(conversationCursor?.count ?: 0) +
|
||||
(recipientCursor?.count ?: 0)
|
||||
|
||||
val max = (partsCursor?.count ?: 0) +
|
||||
(messageCursor?.count ?: 0) +
|
||||
(conversationCursor?.count ?: 0) +
|
||||
(recipientCursor?.count ?: 0)
|
||||
var progress = 0
|
||||
|
||||
var progress = 0
|
||||
|
||||
// Sync message parts
|
||||
partsCursor?.use {
|
||||
partsCursor.forEach {
|
||||
tryOrNull {
|
||||
progress++
|
||||
val part = cursorToPart.map(partsCursor)
|
||||
realm.insertOrUpdate(part)
|
||||
// Sync message parts
|
||||
partsCursor?.use {
|
||||
partsCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
val part = cursorToPart.map(partsCursor)
|
||||
realm.insertOrUpdate(part)
|
||||
progress++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sync messages
|
||||
messageCursor?.use {
|
||||
val messageColumns = CursorToMessage.MessageColumns(messageCursor)
|
||||
messageCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
progress++
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(max, progress, false))
|
||||
val message = cursorToMessage.map(Pair(cursor, messageColumns)).apply {
|
||||
if (isMms()) {
|
||||
parts = RealmList<MmsPart>().apply {
|
||||
addAll(realm.where(MmsPart::class.java)
|
||||
.equalTo("messageId", contentId)
|
||||
.findAll())
|
||||
// Sync messages
|
||||
messageCursor?.use {
|
||||
val messageColumns = CursorToMessage.MessageColumns(messageCursor)
|
||||
messageCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
syncProgress.onNext(
|
||||
SyncRepository.SyncProgress.Running(
|
||||
max,
|
||||
++progress,
|
||||
false
|
||||
)
|
||||
)
|
||||
val message = cursorToMessage.map(Pair(cursor, messageColumns)).apply {
|
||||
if (isMms()) {
|
||||
parts = RealmList<MmsPart>().apply {
|
||||
addAll(
|
||||
realm.where(MmsPart::class.java)
|
||||
.equalTo("messageId", contentId)
|
||||
.findAll()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
realm.insertOrUpdate(message)
|
||||
}
|
||||
}
|
||||
realm.insertOrUpdate(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate blocked conversations from 2.7.3
|
||||
val oldBlockedSenders = rxPrefs.getStringSet("pref_key_blocked_senders")
|
||||
oldBlockedSenders.get()
|
||||
.map { threadIdString -> threadIdString.toLong() }
|
||||
.filter { threadId -> !persistedData.contains(threadId) }
|
||||
.forEach { threadId -> persistedData[threadId] = Conversation(id = threadId, blocked = true) }
|
||||
|
||||
// Sync conversations
|
||||
conversationCursor?.use {
|
||||
conversationCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
progress++
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(max, progress, false))
|
||||
val conversation = cursorToConversation.map(cursor).apply {
|
||||
persistedData[id]?.let { persistedConversation ->
|
||||
archived = persistedConversation.archived
|
||||
blocked = persistedConversation.blocked
|
||||
pinned = persistedConversation.pinned
|
||||
name = persistedConversation.name
|
||||
blockingClient = persistedConversation.blockingClient
|
||||
blockReason = persistedConversation.blockReason
|
||||
}
|
||||
lastMessage = realm.where(Message::class.java)
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.equalTo("threadId", id)
|
||||
.findFirst()
|
||||
// Migrate blocked conversations from 2.7.3
|
||||
oldBlockedSenders.get()
|
||||
.map { threadIdString -> threadIdString.toLong() }
|
||||
.filter { threadId -> !persistedData.contains(threadId) }
|
||||
.forEach { threadId ->
|
||||
persistedData[threadId] = Conversation(id = threadId, blocked = true)
|
||||
}
|
||||
realm.insertOrUpdate(conversation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sync recipients
|
||||
recipientCursor?.use {
|
||||
val contacts = realm.copyToRealmOrUpdate(getContacts())
|
||||
recipientCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
progress++
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(max, progress, false))
|
||||
val recipient = cursorToRecipient.map(cursor).apply {
|
||||
contact = contacts.firstOrNull { contact ->
|
||||
contact.numbers.any { phoneNumberUtils.compare(address, it.address) }
|
||||
// Sync conversations
|
||||
conversationCursor?.use {
|
||||
conversationCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
syncProgress.onNext(
|
||||
SyncRepository.SyncProgress.Running(
|
||||
max,
|
||||
++progress,
|
||||
false
|
||||
)
|
||||
)
|
||||
val conversation = cursorToConversation.map(cursor).apply {
|
||||
persistedData[id]?.let { persistedConversation ->
|
||||
archived = persistedConversation.archived
|
||||
blocked = persistedConversation.blocked
|
||||
pinned = persistedConversation.pinned
|
||||
name = persistedConversation.name
|
||||
blockingClient = persistedConversation.blockingClient
|
||||
blockReason = persistedConversation.blockReason
|
||||
}
|
||||
lastMessage = realm.where(Message::class.java)
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.equalTo("threadId", id)
|
||||
.findFirst()
|
||||
}
|
||||
realm.insertOrUpdate(conversation)
|
||||
}
|
||||
}
|
||||
realm.insertOrUpdate(recipient)
|
||||
}
|
||||
}
|
||||
|
||||
// Sync recipients
|
||||
val contacts = realm.copyToRealmOrUpdate(getContacts())
|
||||
recipientCursor?.use {
|
||||
recipientCursor.forEach { cursor ->
|
||||
tryOrNull {
|
||||
syncProgress.onNext(
|
||||
SyncRepository.SyncProgress.Running(
|
||||
max,
|
||||
++progress,
|
||||
false
|
||||
)
|
||||
)
|
||||
val rec = cursorToRecipient.map(cursor).apply {
|
||||
contact = contacts.firstOrNull { c ->
|
||||
c.numbers.any { num ->
|
||||
phoneNumberUtils.compare(
|
||||
address,
|
||||
num.address
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
realm.insertOrUpdate(rec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(0, 0, true))
|
||||
|
||||
// Now that we have all the messages, we can scan for emoji reactions
|
||||
reactions.deleteAndReparseAllEmojiReactions(realm)
|
||||
|
||||
realm.insert(SyncLog())
|
||||
}, {
|
||||
handlerThread.quitSafely()
|
||||
oldBlockedSenders.delete()
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Idle)
|
||||
},
|
||||
{ error ->
|
||||
handlerThread.quitSafely()
|
||||
Timber.e(error, "syncMessages Failed")
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Idle)
|
||||
})
|
||||
}
|
||||
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(0, 0, true))
|
||||
|
||||
|
||||
realm.insert(SyncLog())
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
|
||||
// Only delete this after the sync has successfully completed
|
||||
oldBlockedSenders.delete()
|
||||
|
||||
syncProgress.onNext(SyncRepository.SyncProgress.Idle)
|
||||
}
|
||||
|
||||
override fun syncMessage(uri: Uri, messageId: Long): Message? {
|
||||
@@ -265,6 +299,26 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
|
||||
conversationRepo.getOrCreateConversation(threadId)
|
||||
insertOrUpdate()
|
||||
|
||||
val text = getText(false)
|
||||
val parsedReaction = reactions.parseEmojiReaction(text)
|
||||
if (parsedReaction != null) {
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
val targetMessage = reactions.findTargetMessage(
|
||||
threadId,
|
||||
parsedReaction.originalMessage,
|
||||
realm
|
||||
)
|
||||
realm.executeTransaction {
|
||||
reactions.saveEmojiReaction(
|
||||
this,
|
||||
parsedReaction,
|
||||
targetMessage,
|
||||
realm,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,4 +405,13 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
return groups
|
||||
}
|
||||
|
||||
private fun removeOldMessages(realm: Realm) {
|
||||
realm.delete(Contact::class.java)
|
||||
realm.delete(ContactGroup::class.java)
|
||||
realm.delete(Conversation::class.java)
|
||||
realm.delete(Message::class.java)
|
||||
realm.delete(MmsPart::class.java)
|
||||
realm.delete(Recipient::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import android.app.job.JobParameters
|
||||
import android.app.job.JobService
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.common.util.extensions.jobScheduler
|
||||
import dev.octoshrimpy.quik.interactor.DeleteOldMessages
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import timber.log.Timber
|
||||
|
||||
@@ -22,9 +22,9 @@ import android.app.IntentService
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.telephony.TelephonyManager
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.interactor.SendNewMessage
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class HeadlessSmsSendService : IntentService("HeadlessSmsSendService") {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.octoshrimpy.quik.util
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = false)
|
||||
data class EmojiPatternStrings(
|
||||
@Json(name = "emoji_reaction_ios_generic_added") val iosGenericAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_generic_removed") val iosGenericRemoved: String? = null,
|
||||
|
||||
@Json(name = "emoji_reaction_ios_heart_added") val iosHeartAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_heart_removed") val iosHeartRemoved: String? = null,
|
||||
|
||||
@Json(name = "emoji_reaction_ios_like_added") val iosLikeAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_like_removed") val iosLikeRemoved: String? = null,
|
||||
|
||||
@Json(name = "emoji_reaction_ios_dislike_added") val iosDislikeAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_dislike_removed") val iosDislikeRemoved: String? = null,
|
||||
|
||||
@Json(name = "emoji_reaction_ios_laugh_added") val iosLaughAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_laugh_removed") val iosLaughRemoved: String? = null,
|
||||
|
||||
@Json(name = "emoji_reaction_ios_exclamation_added") val iosExclamationAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_exclamation_removed") val iosExclamationRemoved: String? = null,
|
||||
|
||||
@Json(name = "emoji_reaction_ios_question_mark_added") val iosQuestionMarkAdded: String? = null,
|
||||
@Json(name = "emoji_reaction_ios_question_mark_removed") val iosQuestionMarkRemoved: String? = null,
|
||||
)
|
||||
@@ -26,7 +26,8 @@ import androidx.appcompat.app.AppCompatDelegate
|
||||
import dev.octoshrimpy.quik.manager.WidgetManager
|
||||
import dev.octoshrimpy.quik.receiver.NightModeReceiver
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -22,7 +22,7 @@ import android.content.Context
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil
|
||||
import io.michaelrocks.libphonenumber.android.Phonenumber
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -39,12 +39,14 @@ class PhoneNumberUtils @Inject constructor(context: Context) {
|
||||
* This method will run successfully stricter checks without compromising much speed
|
||||
*/
|
||||
fun compare(first: String, second: String): Boolean {
|
||||
if (first.equals(second, true)) {
|
||||
val normalizedFirst = normalizeNumber(first)
|
||||
val normalizedSecond = normalizeNumber(second)
|
||||
if (normalizedFirst.equals(normalizedSecond, true)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (PhoneNumberUtils.compare(first, second)) {
|
||||
val matchType = phoneNumberUtil.isNumberMatch(first, second)
|
||||
val matchType = phoneNumberUtil.isNumberMatch(normalizedFirst, normalizedSecond)
|
||||
if (matchType >= PhoneNumberUtil.MatchType.SHORT_NSN_MATCH) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package dev.octoshrimpy.quik.manager
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
class ReferralManagerImpl @Inject constructor() : ReferralManager {
|
||||
|
||||
override suspend fun trackReferrer() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.manager
|
||||
|
||||
import android.content.Context
|
||||
import com.amplitude.api.Amplitude
|
||||
import com.amplitude.api.AmplitudeClient
|
||||
import com.amplitude.api.Identify
|
||||
import dev.octoshrimpy.quik.data.BuildConfig
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class AnalyticsManagerImpl @Inject constructor(context: Context) : AnalyticsManager {
|
||||
|
||||
private val amplitude: AmplitudeClient = Amplitude.getInstance().initialize(context, BuildConfig.AMPLITUDE_API_KEY)
|
||||
|
||||
init {
|
||||
amplitude.trackSessionEvents(true)
|
||||
}
|
||||
|
||||
override fun track(event: String, vararg properties: Pair<String, Any>) {
|
||||
val propertiesJson = JSONObject(properties
|
||||
.associateBy { pair -> pair.first }
|
||||
.mapValues { pair -> pair.value.second })
|
||||
.also { Timber.v("$event: $it") }
|
||||
|
||||
amplitude.logEvent(event, propertiesJson)
|
||||
}
|
||||
|
||||
override fun setUserProperty(key: String, value: Any) {
|
||||
Timber.v("$key: $value")
|
||||
|
||||
// Set the value in Amplitude
|
||||
val identify = Identify()
|
||||
when (value) {
|
||||
is Boolean -> identify.set(key, value)
|
||||
is BooleanArray -> identify.set(key, value)
|
||||
is Double -> identify.set(key, value)
|
||||
is DoubleArray -> identify.set(key, value)
|
||||
is Float -> identify.set(key, value)
|
||||
is FloatArray -> identify.set(key, value)
|
||||
is Int -> identify.set(key, value)
|
||||
is IntArray -> identify.set(key, value)
|
||||
is Long -> identify.set(key, value)
|
||||
is LongArray -> identify.set(key, value)
|
||||
is String -> identify.set(key, value)
|
||||
is JSONArray -> identify.set(key, value)
|
||||
is JSONObject -> identify.set(key, value)
|
||||
else -> Timber.e("Value of type ${value::class.java} not supported")
|
||||
}
|
||||
amplitude.identify(identify)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package dev.octoshrimpy.quik.manager
|
||||
|
||||
import android.content.Context
|
||||
import com.android.installreferrer.api.InstallReferrerClient
|
||||
import com.android.installreferrer.api.InstallReferrerStateListener
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
class ReferralManagerImpl @Inject constructor(
|
||||
private val analytics: AnalyticsManager,
|
||||
private val context: Context,
|
||||
private val prefs: Preferences
|
||||
) : ReferralManager {
|
||||
|
||||
override suspend fun trackReferrer() {
|
||||
if (prefs.didSetReferrer.get()) {
|
||||
return
|
||||
}
|
||||
|
||||
context.packageManager.getInstallerPackageName(context.packageName)?.let { installer ->
|
||||
analytics.setUserProperty("Installer", installer)
|
||||
}
|
||||
|
||||
val referrerClient = InstallReferrerClient.newBuilder(context).build()
|
||||
val responseCode = suspendCancellableCoroutine<Int> { cont ->
|
||||
referrerClient.startConnection(object : InstallReferrerStateListener {
|
||||
override fun onInstallReferrerSetupFinished(responseCode: Int) {
|
||||
cont.resume(responseCode)
|
||||
}
|
||||
|
||||
override fun onInstallReferrerServiceDisconnected() {
|
||||
cont.resume(InstallReferrerClient.InstallReferrerResponse.SERVICE_DISCONNECTED)
|
||||
}
|
||||
})
|
||||
|
||||
cont.invokeOnCancellation {
|
||||
referrerClient.endConnection()
|
||||
}
|
||||
}
|
||||
|
||||
when (responseCode) {
|
||||
InstallReferrerClient.InstallReferrerResponse.OK -> {
|
||||
analytics.setUserProperty("Referrer", referrerClient.installReferrer.installReferrer)
|
||||
prefs.didSetReferrer.set(true)
|
||||
}
|
||||
|
||||
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
|
||||
prefs.didSetReferrer.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
referrerClient.endConnection()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,8 +46,6 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
//Resolve jdk8+ Generation Annotations - javax annotation does not exist
|
||||
implementation 'com.github.pengrad:jdk9-deps:1ffe84c468'
|
||||
|
||||
// look into jakarta.annotation-api when switching to java 9
|
||||
implementation 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
|
||||
// realm
|
||||
@@ -70,8 +68,6 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation project(":common")
|
||||
|
||||
// implementation 'com.github.pengrad:jdk9-deps:1ffe84c'
|
||||
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -83,5 +79,4 @@ repositories {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
}
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ package dev.octoshrimpy.quik.experiment
|
||||
|
||||
import android.content.Context
|
||||
import android.preference.PreferenceManager
|
||||
import dev.octoshrimpy.quik.manager.AnalyticsManager
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import java.util.Random
|
||||
|
||||
abstract class Experiment<T>(val context: Context, val analytics: AnalyticsManager) {
|
||||
abstract class Experiment<T>(val context: Context) {
|
||||
|
||||
private val prefs by lazy { PreferenceManager.getDefaultSharedPreferences(context) }
|
||||
private val prefKey: String
|
||||
@@ -48,7 +48,6 @@ abstract class Experiment<T>(val context: Context, val analytics: AnalyticsManag
|
||||
|
||||
else -> { // Variant hasn't been set yet
|
||||
variants[Random().nextInt(variants.size)].also { variant ->
|
||||
analytics.setUserProperty("Experiment: $key", variant.key)
|
||||
prefs.edit().putString(prefKey, variant.key).apply()
|
||||
}.value
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.interactor
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.core.net.toUri
|
||||
import dev.octoshrimpy.quik.extensions.getName
|
||||
import dev.octoshrimpy.quik.extensions.getResourceBytes
|
||||
import dev.octoshrimpy.quik.repository.ScheduledMessageRepository
|
||||
@@ -42,7 +43,8 @@ class AddScheduledMessage @Inject constructor(
|
||||
val recipients: List<String>,
|
||||
val sendAsGroup: Boolean,
|
||||
val body: String,
|
||||
val attachments: List<Uri>
|
||||
val attachments: List<Uri>,
|
||||
val conversationId: Long
|
||||
)
|
||||
|
||||
@SuppressLint("Range")
|
||||
@@ -52,7 +54,13 @@ class AddScheduledMessage @Inject constructor(
|
||||
.map { // step 1 - save, without attachments, to db to get primary key id which is
|
||||
// needed for building the save file location dir name in step 2
|
||||
scheduledMessageRepo.saveScheduledMessage(
|
||||
it.date, it.subId, it.recipients, it.sendAsGroup, it.body, listOf()
|
||||
it.date,
|
||||
it.subId,
|
||||
it.recipients,
|
||||
it.sendAsGroup,
|
||||
it.body,
|
||||
listOf(),
|
||||
it.conversationId
|
||||
)
|
||||
}
|
||||
.map { scheduledMessage ->
|
||||
@@ -86,5 +94,4 @@ class AddScheduledMessage @Inject constructor(
|
||||
}
|
||||
.flatMap { updateScheduledMessageAlarms.buildObservable(Unit) }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.interactor
|
||||
import android.content.Context
|
||||
import dev.octoshrimpy.quik.repository.ScheduledMessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -39,11 +40,12 @@ class DeleteScheduledMessages @Inject constructor(
|
||||
val topDir = File(context.filesDir, "scheduled-${scheduledMessageId}")
|
||||
topDir.exists() && topDir.deleteRecursively()
|
||||
}
|
||||
} catch (e: Exception) { /* nothing */ }
|
||||
} catch (e: Exception) {
|
||||
Timber.e("Unable to delete scheduled messages.")
|
||||
}
|
||||
|
||||
// delete the db entries
|
||||
scheduledMessageRepo.deleteScheduledMessages(params)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,22 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.interactor
|
||||
|
||||
import dev.octoshrimpy.quik.manager.NotificationManager
|
||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class SendExistingMessage @Inject constructor(
|
||||
private val messageRepo: MessageRepository
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager
|
||||
) : Interactor<Long>() {
|
||||
override fun buildObservable(params: Long): Flowable<Long> =
|
||||
Flowable.just(params)
|
||||
.doOnNext { messageId -> messageRepo.sendMessage(messageId) }
|
||||
.doOnNext { messageId ->
|
||||
val message = messageRepo.getMessage(messageId)
|
||||
messageRepo.sendMessage(messageId)
|
||||
|
||||
val threadId = message!!.threadId
|
||||
notificationManager.cancel(threadId.toInt() + 100000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,6 @@ interface NotificationManager {
|
||||
|
||||
fun getNotificationForBackup(): NotificationCompat.Builder
|
||||
|
||||
fun cancel(i: Int)
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.manager
|
||||
|
||||
import android.content.pm.ShortcutInfo
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
|
||||
interface ShortcutManager {
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
package dev.octoshrimpy.quik.mapper
|
||||
|
||||
import android.database.Cursor
|
||||
import android.provider.Telephony.*
|
||||
import android.provider.Telephony.Mms
|
||||
import android.provider.Telephony.MmsSms
|
||||
import android.provider.Telephony.Sms
|
||||
import dev.octoshrimpy.quik.model.Message
|
||||
import timber.log.Timber
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ open class Conversation(
|
||||
var recipients: RealmList<Recipient> = RealmList(),
|
||||
var lastMessage: Message? = null,
|
||||
var draft: String = "",
|
||||
var draftDate: Long = 0,
|
||||
|
||||
var blockingClient: Int? = null,
|
||||
var blockReason: String? = null,
|
||||
@@ -40,7 +41,7 @@ open class Conversation(
|
||||
var sendAsGroup: Boolean = false,
|
||||
) : RealmObject() {
|
||||
|
||||
val date: Long get() = lastMessage?.date ?: 0
|
||||
val date: Long get() = lastMessage?.date ?: if (draft.isNotEmpty()) draftDate else 0
|
||||
val snippet: String? get() = lastMessage?.getSummary()
|
||||
val unread: Boolean get() = lastMessage?.read == false
|
||||
val me: Boolean get() = lastMessage?.isMe() == true
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2025
|
||||
*
|
||||
* This file is part of QUIK.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class EmojiReaction : RealmObject() {
|
||||
@PrimaryKey var id: Long = 0
|
||||
|
||||
/** The reaction message ID itself */
|
||||
@Index var reactionMessageId: Long = 0
|
||||
|
||||
/** The sender's address (phone number) */
|
||||
var senderAddress: String = ""
|
||||
|
||||
/** The emoji used in the reaction */
|
||||
var emoji: String = ""
|
||||
|
||||
/** The original message text that was reacted to */
|
||||
var originalMessageText: String = ""
|
||||
|
||||
/** Thread ID for easier querying */
|
||||
@Index var threadId: Long = 0
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2025
|
||||
*
|
||||
* This file is part of QUIK.
|
||||
*
|
||||
* QUIK is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QUIK is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QUIK. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
|
||||
open class EmojiSyncNeeded : RealmObject() {
|
||||
var createdAt: Long = System.currentTimeMillis()
|
||||
}
|
||||
@@ -20,7 +20,9 @@ package dev.octoshrimpy.quik.model
|
||||
|
||||
import android.content.ContentUris
|
||||
import android.net.Uri
|
||||
import android.provider.Telephony.*
|
||||
import android.provider.Telephony.Mms
|
||||
import android.provider.Telephony.MmsSms
|
||||
import android.provider.Telephony.Sms
|
||||
import dev.octoshrimpy.quik.extensions.joinTo
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
@@ -76,6 +78,8 @@ open class Message : RealmObject() {
|
||||
var subject: String = ""
|
||||
var textContentType: String = ""
|
||||
var parts: RealmList<MmsPart> = RealmList()
|
||||
var isEmojiReaction: Boolean = false
|
||||
val emojiReactions: RealmList<EmojiReaction> = RealmList()
|
||||
|
||||
var sendAsGroup: Boolean = false
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.octoshrimpy.quik.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class MessageContentFilter(
|
||||
@PrimaryKey var id: Long = 0,
|
||||
|
||||
var value: String = "",
|
||||
var caseSensitive: Boolean = false,
|
||||
var isRegex: Boolean = false,
|
||||
var includeContacts: Boolean = false
|
||||
) : RealmObject()
|
||||
|
||||
data class MessageContentFilterData(
|
||||
var value: String = "",
|
||||
var caseSensitive: Boolean = false,
|
||||
var isRegex: Boolean = false,
|
||||
var includeContacts: Boolean = false
|
||||
)
|
||||
@@ -21,7 +21,7 @@ package dev.octoshrimpy.quik.model
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
open class Recipient(
|
||||
@PrimaryKey var id: Long = 0,
|
||||
|
||||
@@ -29,7 +29,8 @@ open class ScheduledMessage(
|
||||
var recipients: RealmList<String> = RealmList(),
|
||||
var sendAsGroup: Boolean = true,
|
||||
var body: String = "",
|
||||
var attachments: RealmList<String> = RealmList()
|
||||
var attachments: RealmList<String> = RealmList(),
|
||||
var conversationId: Long = 0
|
||||
) : RealmObject() {
|
||||
|
||||
fun copy(
|
||||
@@ -39,10 +40,11 @@ open class ScheduledMessage(
|
||||
recipients: RealmList<String> = this.recipients,
|
||||
sendAsGroup: Boolean = this.sendAsGroup,
|
||||
body: String = this.body,
|
||||
attachments: RealmList<String> = this.attachments
|
||||
attachments: RealmList<String> = this.attachments,
|
||||
conversationId: Long = this.conversationId
|
||||
): ScheduledMessage {
|
||||
|
||||
return ScheduledMessage(id, date, subId, recipients, sendAsGroup, body, attachments)
|
||||
return ScheduledMessage(id, date, subId, recipients, sendAsGroup, body, attachments, conversationId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,4 +41,6 @@ interface ContactRepository {
|
||||
|
||||
fun setDefaultPhoneNumber(lookupKey: String, phoneNumberId: Long)
|
||||
|
||||
fun isContact(address: String): Boolean
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2025
|
||||
*
|
||||
* This file is part of QUIK.
|
||||
*
|
||||
* QUIK is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QUIK is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QUIK. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.repository
|
||||
|
||||
import dev.octoshrimpy.quik.model.Message
|
||||
import io.realm.Realm
|
||||
|
||||
data class ParsedEmojiReaction(val emoji: String, val originalMessage: String, val isRemoval: Boolean = false)
|
||||
|
||||
interface EmojiReactionRepository {
|
||||
fun parseEmojiReaction(body: String): ParsedEmojiReaction?
|
||||
|
||||
fun findTargetMessage(threadId: Long, originalMessageText: String, realm: Realm): Message?
|
||||
|
||||
fun saveEmojiReaction(
|
||||
reactionMessage: Message,
|
||||
parsedReaction: ParsedEmojiReaction,
|
||||
targetMessage: Message?,
|
||||
realm: Realm,
|
||||
)
|
||||
|
||||
fun deleteAndReparseAllEmojiReactions(realm: Realm)
|
||||
}
|
||||
+12
-17
@@ -16,27 +16,22 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.octoshrimpy.quik.manager
|
||||
package dev.octoshrimpy.quik.repository
|
||||
|
||||
import org.json.JSONObject
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import dev.octoshrimpy.quik.model.MessageContentFilter
|
||||
import dev.octoshrimpy.quik.model.MessageContentFilterData
|
||||
import io.realm.RealmResults
|
||||
|
||||
@Singleton
|
||||
class AnalyticsManagerImpl @Inject constructor() : AnalyticsManager {
|
||||
interface MessageContentFilterRepository {
|
||||
|
||||
override fun track(event: String, vararg properties: Pair<String, Any>) {
|
||||
fun createFilter(data: MessageContentFilterData)
|
||||
|
||||
// Log the event, but don't do anything else
|
||||
JSONObject(properties
|
||||
.associateBy { pair -> pair.first }
|
||||
.mapValues { pair -> pair.value.second })
|
||||
.also { Timber.v("$event: $it") }
|
||||
}
|
||||
fun getMessageContentFilters(): RealmResults<MessageContentFilter>
|
||||
|
||||
override fun setUserProperty(key: String, value: Any) {
|
||||
Timber.v("$key: $value")
|
||||
}
|
||||
fun getMessageContentFilter(id: Long): MessageContentFilter?
|
||||
|
||||
fun isBlocked(messageBody: String, address: String, contactsRepo: ContactRepository): Boolean
|
||||
|
||||
fun removeFilter(id: Long)
|
||||
|
||||
}
|
||||
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.repository
|
||||
|
||||
import dev.octoshrimpy.quik.model.Recipient
|
||||
import dev.octoshrimpy.quik.model.ScheduledMessage
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmResults
|
||||
|
||||
interface ScheduledMessageRepository {
|
||||
@@ -32,9 +34,13 @@ interface ScheduledMessageRepository {
|
||||
recipients: List<String>,
|
||||
sendAsGroup: Boolean,
|
||||
body: String,
|
||||
attachments: List<String>
|
||||
attachments: List<String>,
|
||||
conversationId: Long
|
||||
): ScheduledMessage
|
||||
|
||||
/**
|
||||
* Updates scheduled messages with new uris
|
||||
*/
|
||||
fun updateScheduledMessage(scheduledMessage: ScheduledMessage)
|
||||
|
||||
/**
|
||||
@@ -47,15 +53,24 @@ interface ScheduledMessageRepository {
|
||||
*/
|
||||
fun getScheduledMessage(id: Long): ScheduledMessage?
|
||||
|
||||
/**
|
||||
* Returns all scheduled messages with the given [conversationId]
|
||||
*/
|
||||
fun getScheduledMessagesForConversation(conversationId: Long): RealmResults<ScheduledMessage>
|
||||
|
||||
/**
|
||||
* Deletes the scheduled message with the given [id]
|
||||
*/
|
||||
fun deleteScheduledMessage(id: Long)
|
||||
|
||||
// delete multiple scheduled messages by id list
|
||||
/**
|
||||
* Delete multiple scheduled messages by id list
|
||||
*/
|
||||
fun deleteScheduledMessages(ids: List<Long>)
|
||||
|
||||
// get a list of all scheduled message ids (in scheduled date order)
|
||||
/**
|
||||
* Get a list of all scheduled message ids (in scheduled date order)
|
||||
*/
|
||||
fun getAllScheduledMessageIdsSnapshot(): List<Long>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
PackageName: dev.octoshrimpy.quik
|
||||
Name: QUIK
|
||||
Summary: The most beautiful SMS messenger for Android
|
||||
License: GPL-3.0
|
||||
AuthorName: Marcos Jones
|
||||
SourceCode: https://github.com/octoshrimpy/quik
|
||||
IssueTracker: https://github.com/octoshrimpy/quik/issues
|
||||
WebSite: ""
|
||||
Categories:
|
||||
- Communication
|
||||
- Internet
|
||||
AntiFeatures: NonFreeNet
|
||||
CurrentVersion: "4.1.1"
|
||||
CurrentVersionCode: 2229
|
||||
Description: |
|
||||
QUIK is an open source replacement for the stock messaging app on Android.
|
||||
It displays SMS/MMS conversations, supports scheduled sends, backups, voice
|
||||
messages, speech-to-text and text-to-speech, and more.
|
||||
QUIK connects to public APIs (e.g. Space Devs) for news and may fetch
|
||||
thumbnails from third-party hosts, so it’s marked as NonFreeNet.
|
||||
@@ -15,7 +15,6 @@ org.gradle.jvmargs=-Xmx1536m
|
||||
org.gradle.caching=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
|
||||
|
||||
Binary file not shown.
+18
-34
@@ -24,7 +24,6 @@ apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
compileSdk 34
|
||||
flavorDimensions "analytics"
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'dev.octoshrimpy.quik'
|
||||
@@ -34,12 +33,10 @@ android {
|
||||
versionName '4.1.1'
|
||||
setProperty("archivesBaseName", "QUIK-v${versionName}")
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
setProperty("archivesBaseName", "QUIK-v${versionName}")
|
||||
// versionNameSuffix '-beta'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
debug // Uses the default debug keystore.
|
||||
release {
|
||||
def keystoreProps = new Properties()
|
||||
def keystorePropsFile = rootProject.file('./.gradle/.gradlerc')
|
||||
@@ -47,16 +44,14 @@ android {
|
||||
keyAlias 'quik_release'
|
||||
if (keystorePropsFile.exists()) {
|
||||
keystoreProps.load(new FileInputStream(keystorePropsFile))
|
||||
} else if (System.getenv("CI") == "true") {
|
||||
// do nothing
|
||||
} else {
|
||||
throw new GradleException("Keystore properties file not found.")
|
||||
// do nothing
|
||||
}
|
||||
storePassword keystoreProps['storePassword']
|
||||
keyPassword keystoreProps['keyPassword']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependenciesInfo {
|
||||
// Disables dependency metadata when building APKs.
|
||||
includeInApk = false
|
||||
@@ -76,6 +71,7 @@ android {
|
||||
versionNameSuffix "-debug"
|
||||
resValue("string", "app_name", "QUIK-Debug")
|
||||
resValue("string", "application_id", defaultConfig.applicationId)
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,17 +84,14 @@ android {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
|
||||
productFlavors {
|
||||
withAnalytics { dimension "analytics" }
|
||||
noAnalytics {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
lint {
|
||||
abortOnError false
|
||||
}
|
||||
namespace 'dev.octoshrimpy.quik'
|
||||
buildFeatures {
|
||||
buildConfig true
|
||||
viewBinding true
|
||||
}
|
||||
if (System.getenv("CI") == "true") {
|
||||
signingConfigs.release.storePassword = System.getenv("keystore_password")
|
||||
signingConfigs.release.keyAlias = System.getenv("key_alias")
|
||||
@@ -111,10 +104,8 @@ androidExtensions {
|
||||
}
|
||||
|
||||
configurations {
|
||||
noAnalyticsDebug
|
||||
noAnalyticsRelease
|
||||
withAnalyticsDebug
|
||||
withAnalyticsRelease
|
||||
debug
|
||||
release
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -161,11 +152,8 @@ dependencies {
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||
// compileOnly "javax.annotation:jsr250-api:1.0"
|
||||
//Resolve jdk8+ Generation Annotations - javax annotation does not exist
|
||||
implementation 'com.github.pengrad:jdk9-deps:1ffe84c468'
|
||||
|
||||
// look into jakarta.annotation-api when switching to java 9
|
||||
implementation 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
|
||||
// ezvcard
|
||||
@@ -177,7 +165,6 @@ dependencies {
|
||||
|
||||
// realm
|
||||
implementation "com.github.realm:realm-android-adapters:$realm_adapters_version"
|
||||
// implementation("io.realm:android-adapters:$realm_adapters_version") { transitive = false }
|
||||
kapt "io.realm:realm-annotations:$realm_version"
|
||||
kapt "io.realm:realm-annotations-processor:$realm_version"
|
||||
|
||||
@@ -221,16 +208,13 @@ dependencies {
|
||||
implementation project(':data')
|
||||
implementation project(':domain')
|
||||
|
||||
withAnalyticsImplementation 'com.google.firebase:firebase-crashlytics:17.3.0'
|
||||
withAnalyticsImplementation "com.android.billingclient:billing:$billing_version"
|
||||
withAnalyticsImplementation "com.android.billingclient:billing-ktx:$billing_version"
|
||||
noAnalyticsDebug project(path: ':data', configuration: 'noAnalyticsDebug')
|
||||
noAnalyticsRelease project(path: ':data', configuration: 'noAnalyticsRelease')
|
||||
withAnalyticsDebug project(path: ':data', configuration: 'withAnalyticsDebug')
|
||||
withAnalyticsRelease project(path: ':data', configuration: 'withAnalyticsRelease')
|
||||
}
|
||||
|
||||
if (getGradle().getStartParameter().getTaskRequests().toString().contains("WithAnalytics")) {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
// Check to make sure that the keystore file is present when building a release
|
||||
gradle.taskGraph.whenReady { taskGraph ->
|
||||
if ((taskGraph.hasTask(':assembleRelease') ||
|
||||
taskGraph.allTasks.any { it.name == 'assembleRelease' }) &&
|
||||
!file('./.gradle/.gradlerc').exists() &&
|
||||
System.getenv("CI") != "true") {
|
||||
throw new GradleException("Keystore properties file not found")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".feature.widget.WidgetProvider"
|
||||
android:label="@string/all_conversations_widget_title"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
|
||||
@@ -24,22 +24,20 @@ import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.ArrayRes
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.base.QkAdapter
|
||||
import dev.octoshrimpy.quik.common.base.QkViewHolder
|
||||
import dev.octoshrimpy.quik.common.base.QkBindingViewHolder
|
||||
import dev.octoshrimpy.quik.common.util.Colors
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeColor
|
||||
import dev.octoshrimpy.quik.common.util.extensions.setVisible
|
||||
import dev.octoshrimpy.quik.databinding.MenuListItemBinding
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.menu_list_item.*
|
||||
import kotlinx.android.synthetic.main.menu_list_item.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
data class MenuItem(val title: String, val actionId: Int)
|
||||
|
||||
class MenuItemAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<MenuItem, QkViewHolder>() {
|
||||
class MenuItemAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<MenuItem, QkBindingViewHolder<MenuListItemBinding>>() {
|
||||
|
||||
val menuItemClicks: Subject<Int> = PublishSubject.create()
|
||||
|
||||
@@ -63,31 +61,30 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
||||
.mapIndexed { index, title -> MenuItem(title, valueInts?.getOrNull(index) ?: index) }
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.menu_list_item, parent, false)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkBindingViewHolder<MenuListItemBinding> {
|
||||
val binding = MenuListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_activated),
|
||||
intArrayOf(-android.R.attr.state_activated))
|
||||
|
||||
val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||
view.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
|
||||
binding.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
|
||||
|
||||
return QkViewHolder(view).apply {
|
||||
view.setOnClickListener {
|
||||
return QkBindingViewHolder(binding).apply {
|
||||
binding.root.setOnClickListener {
|
||||
val menuItem = getItem(adapterPosition)
|
||||
menuItemClicks.onNext(menuItem.actionId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||
override fun onBindViewHolder(holder: QkBindingViewHolder<MenuListItemBinding>, position: Int) {
|
||||
val menuItem = getItem(position)
|
||||
|
||||
holder.title.text = menuItem.title
|
||||
holder.check.isActivated = (menuItem.actionId == selectedItem)
|
||||
holder.check.setVisible(selectedItem != null)
|
||||
holder.binding.title.text = menuItem.title
|
||||
holder.binding.check.isActivated = (menuItem.actionId == selectedItem)
|
||||
holder.binding.check.setVisible(selectedItem != null)
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
|
||||
@@ -36,11 +36,11 @@ import dev.octoshrimpy.quik.feature.blocking.BlockingActivity
|
||||
import dev.octoshrimpy.quik.feature.compose.ComposeActivity
|
||||
import dev.octoshrimpy.quik.feature.conversationinfo.ConversationInfoActivity
|
||||
import dev.octoshrimpy.quik.feature.gallery.GalleryActivity
|
||||
import dev.octoshrimpy.quik.feature.main.MainActivity
|
||||
import dev.octoshrimpy.quik.feature.notificationprefs.NotificationPrefsActivity
|
||||
import dev.octoshrimpy.quik.feature.plus.PlusActivity
|
||||
import dev.octoshrimpy.quik.feature.scheduled.ScheduledActivity
|
||||
import dev.octoshrimpy.quik.feature.settings.SettingsActivity
|
||||
import dev.octoshrimpy.quik.manager.AnalyticsManager
|
||||
import dev.octoshrimpy.quik.manager.BillingManager
|
||||
import dev.octoshrimpy.quik.manager.NotificationManager
|
||||
import dev.octoshrimpy.quik.manager.PermissionManager
|
||||
@@ -51,7 +51,6 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class Navigator @Inject constructor(
|
||||
private val context: Context,
|
||||
private val analyticsManager: AnalyticsManager,
|
||||
private val billingManager: BillingManager,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val permissions: PermissionManager
|
||||
@@ -75,7 +74,6 @@ class Navigator @Inject constructor(
|
||||
* one of [main_menu, compose_schedule, settings_night, settings_theme]
|
||||
*/
|
||||
fun showQksmsPlusActivity(source: String) {
|
||||
// analyticsManager.track("Viewed QKSMS+", Pair("source", source))
|
||||
val intent = Intent(context, PlusActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
@@ -95,6 +93,11 @@ class Navigator @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun showMainActivity() {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
fun showCompose(body: String? = null, attachments: List<Uri>? = null, mode: String? = null) {
|
||||
val intent = Intent(context, ComposeActivity::class.java)
|
||||
intent.putExtra(Intent.EXTRA_TEXT, body)
|
||||
@@ -160,13 +163,12 @@ class Navigator @Inject constructor(
|
||||
}
|
||||
|
||||
fun showBackup() {
|
||||
// analyticsManager.track("Viewed Backup")
|
||||
startActivity(Intent(context, BackupActivity::class.java))
|
||||
}
|
||||
|
||||
fun showScheduled() {
|
||||
// analyticsManager.track("Viewed Scheduled")
|
||||
fun showScheduled(conversationId: Long?) {
|
||||
val intent = Intent(context, ScheduledActivity::class.java)
|
||||
conversationId?.let { intent.putExtra("conversationId", it) }
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
@@ -264,14 +266,12 @@ class Navigator @Inject constructor(
|
||||
.append("Device: ${Build.BRAND} ${Build.MODEL}\n")
|
||||
.append("SDK: ${Build.VERSION.SDK_INT}\n")
|
||||
.append("Upgraded"
|
||||
.takeIf { BuildConfig.FLAVOR != "noAnalytics" }
|
||||
.takeIf { billingManager.upgradeStatus.blockingFirst() } ?: "")
|
||||
.toString())
|
||||
startActivityExternal(intent)
|
||||
}
|
||||
|
||||
fun showInvite() {
|
||||
// analyticsManager.track("Clicked Invite")
|
||||
Intent(Intent.ACTION_SEND)
|
||||
.setType("text/plain")
|
||||
.putExtra(Intent.EXTRA_TEXT, "https://github.com/octoshrimpy/quik/releases/latest")
|
||||
|
||||
@@ -27,17 +27,6 @@ import androidx.emoji2.text.EmojiCompat
|
||||
import androidx.work.Configuration
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkerFactory
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.CrashlyticsTree
|
||||
import dev.octoshrimpy.quik.common.util.FileLoggingTree
|
||||
import dev.octoshrimpy.quik.injection.AppComponentManager
|
||||
import dev.octoshrimpy.quik.injection.appComponent
|
||||
import dev.octoshrimpy.quik.manager.AnalyticsManager
|
||||
import dev.octoshrimpy.quik.manager.BillingManager
|
||||
import dev.octoshrimpy.quik.manager.ReferralManager
|
||||
import dev.octoshrimpy.quik.migration.QkMigration
|
||||
import dev.octoshrimpy.quik.migration.QkRealmMigration
|
||||
import dev.octoshrimpy.quik.util.NightModeManager
|
||||
import com.uber.rxdogtag.RxDogTag
|
||||
import com.uber.rxdogtag.autodispose.AutoDisposeConfigurer
|
||||
import dagger.android.AndroidInjector
|
||||
@@ -45,7 +34,16 @@ import dagger.android.DispatchingAndroidInjector
|
||||
import dagger.android.HasActivityInjector
|
||||
import dagger.android.HasBroadcastReceiverInjector
|
||||
import dagger.android.HasServiceInjector
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.FileLoggingTree
|
||||
import dev.octoshrimpy.quik.injection.AppComponentManager
|
||||
import dev.octoshrimpy.quik.injection.appComponent
|
||||
import dev.octoshrimpy.quik.interactor.SpeakThreads
|
||||
import dev.octoshrimpy.quik.manager.BillingManager
|
||||
import dev.octoshrimpy.quik.manager.ReferralManager
|
||||
import dev.octoshrimpy.quik.migration.QkMigration
|
||||
import dev.octoshrimpy.quik.migration.QkRealmMigration
|
||||
import dev.octoshrimpy.quik.util.NightModeManager
|
||||
import dev.octoshrimpy.quik.worker.HousekeepingWorker
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
@@ -61,8 +59,6 @@ class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverIn
|
||||
* Inject these so that they are forced to initialize
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@Inject lateinit var analyticsManager: AnalyticsManager
|
||||
@Suppress("unused")
|
||||
@Inject lateinit var qkMigration: QkMigration
|
||||
|
||||
@Inject lateinit var billingManager: BillingManager
|
||||
@@ -102,7 +98,7 @@ class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverIn
|
||||
nightModeManager.updateCurrentTheme()
|
||||
|
||||
// configure timber logging
|
||||
Timber.plant(Timber.DebugTree(), CrashlyticsTree(), fileLoggingTree)
|
||||
Timber.plant(Timber.DebugTree(), fileLoggingTree)
|
||||
|
||||
// configure emoji compatibility with bundled package
|
||||
// (bundled library works with no play-services/gsm os versions)
|
||||
|
||||
+5
-2
@@ -18,14 +18,17 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.common.androidxcompat;
|
||||
|
||||
import static com.jakewharton.rxbinding2.internal.Preconditions.checkMainThread;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import com.jakewharton.rxbinding2.InitialValueObservable;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.MainThreadDisposable;
|
||||
|
||||
import static com.jakewharton.rxbinding2.internal.Preconditions.checkMainThread;
|
||||
|
||||
final class DrawerLayoutDrawerOpenedObservable extends InitialValueObservable<Boolean> {
|
||||
private final DrawerLayout view;
|
||||
private final int gravity;
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import dev.octoshrimpy.quik.util.Preferences
|
||||
@@ -63,6 +64,12 @@ abstract class QkActivity : AppCompatActivity() {
|
||||
title = title // The title may have been set before layout inflation
|
||||
}
|
||||
|
||||
override fun setContentView(view: View?) {
|
||||
super.setContentView(view)
|
||||
setSupportActionBar(toolbar)
|
||||
title = title // The title may have been set before layout inflation
|
||||
}
|
||||
|
||||
override fun setTitle(titleId: Int) {
|
||||
title = getString(titleId)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import io.realm.RealmRecyclerViewAdapter
|
||||
import io.realm.RealmResults
|
||||
import timber.log.Timber
|
||||
|
||||
abstract class QkRealmAdapter<T : RealmModel> : RealmRecyclerViewAdapter<T, QkViewHolder>(null, true) {
|
||||
abstract class QkRealmAdapter<T : RealmModel, VH : QkViewHolder> : RealmRecyclerViewAdapter<T, VH>(null, true) {
|
||||
|
||||
/**
|
||||
* This view can be set, and the adapter will automatically control the visibility of this view
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.view.iterator
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.Colors
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeBoolean
|
||||
@@ -36,8 +38,6 @@ import dev.octoshrimpy.quik.extensions.mapNotNull
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||
import dev.octoshrimpy.quik.util.PhoneNumberUtils
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
|
||||
@@ -20,8 +20,11 @@ package dev.octoshrimpy.quik.common.base
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
|
||||
open class QkViewHolder(view: View) : RecyclerView.ViewHolder(view), LayoutContainer {
|
||||
override val containerView: View = view
|
||||
}
|
||||
|
||||
open class QkBindingViewHolder<T : ViewBinding>(val binding: T) : QkViewHolder(binding.root)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.octoshrimpy.quik.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import dev.octoshrimpy.quik.manager.BillingManager
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class BillingManagerImpl @Inject constructor(
|
||||
): BillingManager {
|
||||
|
||||
override val products: Observable<List<BillingManager.Product>> = BehaviorSubject.createDefault(listOf())
|
||||
override val upgradeStatus: Observable<Boolean> = BehaviorSubject.createDefault(true)
|
||||
|
||||
override suspend fun checkForPurchases() = Unit
|
||||
override suspend fun queryProducts() = Unit
|
||||
override suspend fun initiatePurchaseFlow(activity: Activity, sku: String) = Unit
|
||||
|
||||
}
|
||||
@@ -24,7 +24,8 @@ import dev.octoshrimpy.quik.common.util.extensions.isSameDay
|
||||
import dev.octoshrimpy.quik.common.util.extensions.isSameWeek
|
||||
import dev.octoshrimpy.quik.common.util.extensions.isSameYear
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.reactivex.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import java.io.FileNotFoundException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -45,7 +45,7 @@ class FileLoggingTree @Inject constructor(
|
||||
|
||||
private var logFileUri: Uri? = null
|
||||
|
||||
override fun log(priority: Int, tag: String, message: String, t: Throwable?) {
|
||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||
if (!prefs.logging.get()) return
|
||||
|
||||
Schedulers.io().scheduleDirect {
|
||||
|
||||
@@ -51,6 +51,7 @@ import dev.octoshrimpy.quik.receiver.DeleteMessagesReceiver
|
||||
import dev.octoshrimpy.quik.receiver.MessageMarkReceiver
|
||||
import dev.octoshrimpy.quik.receiver.RemoteMessagingReceiver
|
||||
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
|
||||
import dev.octoshrimpy.quik.receiver.SendSmsReceiver
|
||||
import dev.octoshrimpy.quik.repository.ContactRepository
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||
@@ -388,9 +389,29 @@ class NotificationManagerImpl @Inject constructor(
|
||||
.addNextIntent(contentIntent)
|
||||
val contentPI = taskStackBuilder.getPendingIntent(threadId.toInt(), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
|
||||
//Action for resending a failed message
|
||||
val resendIntent = Intent(context, SendSmsReceiver::class.java).apply {
|
||||
putExtra("id", message.id)
|
||||
}
|
||||
val resendPendingIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
message.id.toInt(),
|
||||
resendIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
val resendAction = NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_send_black_24dp,
|
||||
context.getString(R.string.notification_message_failed_action),
|
||||
resendPendingIntent
|
||||
)
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_NONE)
|
||||
.build()
|
||||
|
||||
val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId))
|
||||
.setContentTitle(context.getString(R.string.notification_message_failed_title))
|
||||
.setContentText(context.getString(R.string.notification_message_failed_text, conversation.getTitle()))
|
||||
.addAction(resendAction)
|
||||
.setColor(colors.theme(lastRecipient).theme)
|
||||
.setPriority(NotificationManagerCompat.IMPORTANCE_MAX)
|
||||
.setSmallIcon(R.drawable.ic_notification_failed)
|
||||
@@ -523,4 +544,8 @@ class NotificationManagerImpl @Inject constructor(
|
||||
.setOngoing(true)
|
||||
}
|
||||
|
||||
override fun cancel(i: Int) {
|
||||
notificationManager.cancel(i)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package dev.octoshrimpy.quik.common.util
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.content.pm.ShortcutManager
|
||||
import android.os.Build
|
||||
import androidx.core.app.Person
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
@@ -101,7 +101,7 @@ class ShortcutManagerImpl @Inject constructor(
|
||||
|
||||
@TargetApi(29)
|
||||
private fun createShortcutForConversation(conversation: Conversation): ShortcutInfoCompat {
|
||||
Timber.v("creating shortcut for conversation ${conversation.id} : ${conversation.getTitle()}")
|
||||
Timber.v("creating shortcut for conversation ${conversation.id}")
|
||||
val icon = when {
|
||||
conversation.recipients.size == 1 -> {
|
||||
val recipient = conversation.recipients.first()!!
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.common.util.extensions
|
||||
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
|
||||
fun Calendar.isSameDay(other: Calendar): Boolean {
|
||||
return get(Calendar.YEAR) == other.get(Calendar.YEAR) && get(Calendar.DAY_OF_YEAR) == other.get(Calendar.DAY_OF_YEAR)
|
||||
|
||||
+3
-1
@@ -8,7 +8,9 @@ import android.provider.ContactsContract
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View.*
|
||||
import android.view.View.GONE
|
||||
import android.view.View.MeasureSpec
|
||||
import android.view.View.VISIBLE
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.core.app.Person
|
||||
|
||||
@@ -20,17 +20,17 @@ package dev.octoshrimpy.quik.common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.Navigator
|
||||
import dev.octoshrimpy.quik.common.util.Colors
|
||||
import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint
|
||||
import dev.octoshrimpy.quik.common.util.extensions.setTint
|
||||
import dev.octoshrimpy.quik.databinding.AvatarViewBinding
|
||||
import dev.octoshrimpy.quik.injection.appComponent
|
||||
import dev.octoshrimpy.quik.model.Recipient
|
||||
import dev.octoshrimpy.quik.util.GlideApp
|
||||
import kotlinx.android.synthetic.main.avatar_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AvatarView @JvmOverloads constructor(
|
||||
@@ -45,6 +45,7 @@ class AvatarView @JvmOverloads constructor(
|
||||
private var photoUri: String? = null
|
||||
private var lastUpdated: Long? = null
|
||||
private var theme: Colors.Theme
|
||||
private var layout: AvatarViewBinding
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
@@ -53,7 +54,7 @@ class AvatarView @JvmOverloads constructor(
|
||||
|
||||
theme = colors.theme()
|
||||
|
||||
View.inflate(context, R.layout.avatar_view, this)
|
||||
layout = AvatarViewBinding.inflate(LayoutInflater.from(context), this)
|
||||
setBackgroundResource(R.drawable.circle)
|
||||
clipToOutline = true
|
||||
}
|
||||
@@ -81,8 +82,8 @@ class AvatarView @JvmOverloads constructor(
|
||||
private fun updateView() {
|
||||
// Apply theme
|
||||
setBackgroundTint(theme.theme)
|
||||
initial.setTextColor(theme.textPrimary)
|
||||
icon.setTint(theme.textPrimary)
|
||||
layout.initial.setTextColor(theme.textPrimary)
|
||||
layout.icon.setTint(theme.textPrimary)
|
||||
|
||||
val initials = fullName
|
||||
?.substringBefore(',')
|
||||
@@ -93,18 +94,18 @@ class AvatarView @JvmOverloads constructor(
|
||||
.map { initial -> initial.toString() }
|
||||
|
||||
if (initials.isNotEmpty()) {
|
||||
initial.text = if (initials.size > 1) initials.first() + initials.last() else initials.first()
|
||||
icon.visibility = GONE
|
||||
layout.initial.text = if (initials.size > 1) initials.first() + initials.last() else initials.first()
|
||||
layout.icon.visibility = GONE
|
||||
} else {
|
||||
initial.text = null
|
||||
icon.visibility = VISIBLE
|
||||
layout.initial.text = null
|
||||
layout.icon.visibility = VISIBLE
|
||||
}
|
||||
|
||||
photo.setImageDrawable(null)
|
||||
layout.photo.setImageDrawable(null)
|
||||
photoUri?.let { photoUri ->
|
||||
GlideApp.with(photo)
|
||||
GlideApp.with(layout.photo)
|
||||
.load(photoUri)
|
||||
.into(photo)
|
||||
.into(layout.photo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,31 +20,29 @@ package dev.octoshrimpy.quik.common.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.extensions.getColorCompat
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeColor
|
||||
import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint
|
||||
import dev.octoshrimpy.quik.databinding.GroupAvatarViewBinding
|
||||
import dev.octoshrimpy.quik.model.Recipient
|
||||
import kotlinx.android.synthetic.main.group_avatar_view.view.*
|
||||
|
||||
class GroupAvatarView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : ConstraintLayout(context, attrs) {
|
||||
|
||||
private var layout: GroupAvatarViewBinding =
|
||||
GroupAvatarViewBinding.inflate(LayoutInflater.from(context), this)
|
||||
|
||||
var recipients: List<Recipient> = ArrayList()
|
||||
set(value) {
|
||||
field = value.sortedWith(compareByDescending { contact -> contact.contact?.lookupKey })
|
||||
updateView()
|
||||
}
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.group_avatar_view, this)
|
||||
}
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
|
||||
@@ -54,18 +52,18 @@ class GroupAvatarView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
avatar1Frame.setBackgroundTint(when (recipients.size > 1) {
|
||||
layout.avatar1Frame.setBackgroundTint(when (recipients.size > 1) {
|
||||
true -> context.resolveThemeColor(android.R.attr.windowBackground)
|
||||
false -> context.getColorCompat(android.R.color.transparent)
|
||||
})
|
||||
avatar1Frame.updateLayoutParams<LayoutParams> {
|
||||
layout.avatar1Frame.updateLayoutParams<LayoutParams> {
|
||||
matchConstraintPercentWidth = if (recipients.size > 1) 0.75f else 1.0f
|
||||
}
|
||||
avatar2.isVisible = recipients.size > 1
|
||||
layout.avatar2.isVisible = recipients.size > 1
|
||||
|
||||
|
||||
recipients.getOrNull(0).run(avatar1::setRecipient)
|
||||
recipients.getOrNull(1).run(avatar2::setRecipient)
|
||||
recipients.getOrNull(0).run(layout.avatar1::setRecipient)
|
||||
recipients.getOrNull(1).run(layout.avatar2::setRecipient)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,18 +25,17 @@ import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import dev.octoshrimpy.quik.R
|
||||
import com.uber.autodispose.android.ViewScopeProvider
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import dev.octoshrimpy.quik.common.util.Colors
|
||||
import dev.octoshrimpy.quik.common.util.extensions.forEach
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeColor
|
||||
import dev.octoshrimpy.quik.databinding.TabViewBinding
|
||||
import dev.octoshrimpy.quik.extensions.Optional
|
||||
import dev.octoshrimpy.quik.injection.appComponent
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import com.uber.autodispose.android.ViewScopeProvider
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.tab_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class PagerTitleView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) {
|
||||
@@ -66,11 +65,11 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
removeAllViews()
|
||||
|
||||
pager?.adapter?.count?.forEach { position ->
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.tab_view, this, false)
|
||||
val view = TabViewBinding.inflate(LayoutInflater.from(context), this, false)
|
||||
view.label.text = pager?.adapter?.getPageTitle(position)
|
||||
view.setOnClickListener { pager?.currentItem = position }
|
||||
view.root.setOnClickListener { pager?.currentItem = position }
|
||||
|
||||
addView(view)
|
||||
addView(view.root)
|
||||
}
|
||||
|
||||
childCount.forEach { index ->
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.common.widget
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
@@ -28,13 +29,17 @@ import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeAttribute
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeColorStateList
|
||||
import dev.octoshrimpy.quik.common.util.extensions.setVisible
|
||||
import dev.octoshrimpy.quik.databinding.PreferenceViewBinding
|
||||
import dev.octoshrimpy.quik.injection.appComponent
|
||||
import kotlinx.android.synthetic.main.preference_view.view.*
|
||||
|
||||
class PreferenceView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : LinearLayoutCompat(context, attrs) {
|
||||
|
||||
private var layout: PreferenceViewBinding
|
||||
|
||||
val titleTextView: TextView get() = layout.titleView
|
||||
|
||||
var title: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -42,7 +47,7 @@ class PreferenceView @JvmOverloads constructor(
|
||||
if (isInEditMode) {
|
||||
findViewById<TextView>(R.id.titleView).text = value
|
||||
} else {
|
||||
titleView.text = value
|
||||
layout.titleView.text = value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +62,8 @@ class PreferenceView @JvmOverloads constructor(
|
||||
setVisible(value?.isNotEmpty() == true)
|
||||
}
|
||||
} else {
|
||||
summaryView.text = value
|
||||
summaryView.setVisible(value?.isNotEmpty() == true)
|
||||
layout.summaryView.text = value
|
||||
layout.summaryView.setVisible(value?.isNotEmpty() == true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +72,12 @@ class PreferenceView @JvmOverloads constructor(
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
View.inflate(context, R.layout.preference_view, this)
|
||||
layout = PreferenceViewBinding.inflate(LayoutInflater.from(context), this)
|
||||
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
||||
orientation = HORIZONTAL
|
||||
gravity = Gravity.CENTER_VERTICAL
|
||||
|
||||
icon.imageTintList = context.resolveThemeColorStateList(android.R.attr.textColorSecondary)
|
||||
layout.icon.imageTintList = context.resolveThemeColorStateList(android.R.attr.textColorSecondary)
|
||||
|
||||
context.obtainStyledAttributes(attrs, R.styleable.PreferenceView).run {
|
||||
title = getString(R.styleable.PreferenceView_title)
|
||||
@@ -80,17 +85,17 @@ class PreferenceView @JvmOverloads constructor(
|
||||
|
||||
// If there's a custom view used for the preference's widget, inflate it
|
||||
getResourceId(R.styleable.PreferenceView_widget, -1).takeIf { it != -1 }?.let { id ->
|
||||
View.inflate(context, id, widgetFrame)
|
||||
View.inflate(context, id, layout.widgetFrame)
|
||||
}
|
||||
|
||||
// If an icon is being used, set up the icon view
|
||||
getResourceId(R.styleable.PreferenceView_icon, -1).takeIf { it != -1 }?.let { id ->
|
||||
icon.setVisible(true)
|
||||
icon.setImageResource(id)
|
||||
layout.icon.setVisible(true)
|
||||
layout.icon.setImageResource(id)
|
||||
}
|
||||
|
||||
recycle()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,12 @@ import android.view.LayoutInflater
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.isVisible
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.base.QkAdapter
|
||||
import kotlinx.android.synthetic.main.qk_dialog.view.*
|
||||
import dev.octoshrimpy.quik.databinding.QkDialogBinding
|
||||
|
||||
class QkDialog(private val context: Activity) : AlertDialog(context) {
|
||||
|
||||
private val view = LayoutInflater.from(context).inflate(R.layout.qk_dialog, null)
|
||||
private val view = QkDialogBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
@StringRes
|
||||
var titleRes: Int? = null
|
||||
@@ -99,7 +98,7 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
||||
}
|
||||
|
||||
init {
|
||||
setView(view)
|
||||
setView(view.root)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.common.widget
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -30,8 +31,8 @@ import dev.octoshrimpy.quik.common.util.extensions.forwardTouches
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeAttribute
|
||||
import dev.octoshrimpy.quik.common.util.extensions.resolveThemeColor
|
||||
import dev.octoshrimpy.quik.common.util.extensions.setVisible
|
||||
import dev.octoshrimpy.quik.databinding.RadioPreferenceViewBinding
|
||||
import dev.octoshrimpy.quik.injection.appComponent
|
||||
import kotlinx.android.synthetic.main.radio_preference_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class RadioPreferenceView @JvmOverloads constructor(
|
||||
@@ -39,6 +40,7 @@ class RadioPreferenceView @JvmOverloads constructor(
|
||||
) : ConstraintLayout(context, attrs) {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
private var layout: RadioPreferenceViewBinding
|
||||
|
||||
var title: String? = null
|
||||
set(value) {
|
||||
@@ -47,7 +49,7 @@ class RadioPreferenceView @JvmOverloads constructor(
|
||||
if (isInEditMode) {
|
||||
findViewById<TextView>(R.id.titleView).text = value
|
||||
} else {
|
||||
titleView.text = value
|
||||
layout.titleView.text = value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +64,8 @@ class RadioPreferenceView @JvmOverloads constructor(
|
||||
setVisible(value?.isNotEmpty() == true)
|
||||
}
|
||||
} else {
|
||||
summaryView.text = value
|
||||
summaryView.setVisible(value?.isNotEmpty() == true)
|
||||
layout.summaryView.text = value
|
||||
layout.summaryView.setVisible(value?.isNotEmpty() == true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +74,7 @@ class RadioPreferenceView @JvmOverloads constructor(
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
View.inflate(context, R.layout.radio_preference_view, this)
|
||||
layout = RadioPreferenceViewBinding.inflate(LayoutInflater.from(context), this)
|
||||
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
||||
|
||||
val states = arrayOf(
|
||||
@@ -84,8 +86,8 @@ class RadioPreferenceView @JvmOverloads constructor(
|
||||
false -> colors.theme().theme
|
||||
}
|
||||
val textSecondary = context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||
radioButton.buttonTintList = ColorStateList(states, intArrayOf(themeColor, textSecondary))
|
||||
radioButton.forwardTouches(this)
|
||||
layout.radioButton.buttonTintList = ColorStateList(states, intArrayOf(themeColor, textSecondary))
|
||||
layout.radioButton.forwardTouches(this)
|
||||
|
||||
context.obtainStyledAttributes(attrs, R.styleable.RadioPreferenceView).run {
|
||||
title = getString(R.styleable.RadioPreferenceView_title)
|
||||
@@ -93,7 +95,7 @@ class RadioPreferenceView @JvmOverloads constructor(
|
||||
|
||||
// If there's a custom view used for the preference's widget, inflate it
|
||||
getResourceId(R.styleable.RadioPreferenceView_widget, -1).takeIf { it != -1 }?.let { id ->
|
||||
View.inflate(context, id, widgetFrame)
|
||||
View.inflate(context, id, layout.widgetFrame)
|
||||
}
|
||||
|
||||
recycle()
|
||||
|
||||
@@ -23,16 +23,16 @@ import android.content.DialogInterface
|
||||
import android.view.LayoutInflater
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import dev.octoshrimpy.quik.R
|
||||
import kotlinx.android.synthetic.main.text_input_dialog.view.*
|
||||
import dev.octoshrimpy.quik.databinding.TextInputDialogBinding
|
||||
|
||||
class TextInputDialog(context: Activity, hint: String, listener: (String) -> Unit) : AlertDialog(context) {
|
||||
|
||||
private val layout = LayoutInflater.from(context).inflate(R.layout.text_input_dialog, null)
|
||||
private val layout = TextInputDialogBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
init {
|
||||
layout.field.hint = hint
|
||||
|
||||
setView(layout)
|
||||
setView(layout.root)
|
||||
setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.button_cancel)) { _, _ -> }
|
||||
setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.button_delete)) { _, _ -> listener("") }
|
||||
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.button_save)) { _, _ ->
|
||||
|
||||
@@ -22,22 +22,24 @@ import android.os.Bundle
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.base.QkThemedActivity
|
||||
import dagger.android.AndroidInjection
|
||||
import kotlinx.android.synthetic.main.container_activity.*
|
||||
import dev.octoshrimpy.quik.databinding.ContainerActivityBinding
|
||||
|
||||
|
||||
class BackupActivity : QkThemedActivity() {
|
||||
|
||||
private lateinit var router: Router
|
||||
private lateinit var binding: ContainerActivityBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.container_activity)
|
||||
binding = ContainerActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
router = Conductor.attachRouter(this, container, savedInstanceState)
|
||||
router = Conductor.attachRouter(this, binding.container, savedInstanceState)
|
||||
if (!router.hasRootController()) {
|
||||
router.setRoot(RouterTransaction.with(BackupController()))
|
||||
}
|
||||
@@ -49,4 +51,4 @@ class BackupActivity : QkThemedActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package dev.octoshrimpy.quik.feature.backup
|
||||
|
||||
import android.content.Context
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.Navigator
|
||||
import dev.octoshrimpy.quik.common.base.QkPresenter
|
||||
@@ -27,11 +29,8 @@ import dev.octoshrimpy.quik.common.util.extensions.makeToast
|
||||
import dev.octoshrimpy.quik.interactor.PerformBackup
|
||||
import dev.octoshrimpy.quik.manager.BillingManager
|
||||
import dev.octoshrimpy.quik.repository.BackupRepository
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -26,10 +26,10 @@ import android.net.Uri
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import dagger.android.AndroidInjection
|
||||
import dev.octoshrimpy.quik.common.util.extensions.getLabel
|
||||
import dev.octoshrimpy.quik.manager.NotificationManager
|
||||
import dev.octoshrimpy.quik.repository.BackupRepository
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user