Compare commits
No commits in common. "1.3.2" and "main" have entirely different histories.
|
|
@ -1,149 +1,117 @@
|
|||
name: Flutter Build (Signed APK)
|
||||
name: Kotlin Build (Signed APK)
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- ci-dev
|
||||
#branches:
|
||||
# - kotlin
|
||||
tags: ["*"]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
FLUTTER_PATH: "flutter" # Путь к подмодулю Flutter
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: codeberg.org/mi6e4ka/android-build-ct:latest
|
||||
env:
|
||||
TAR_OPTIONS: "--no-same-owner"
|
||||
# defaults:
|
||||
# run:
|
||||
# working-directory: /home/runner/openstore
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
# 1. Checkout репозиторий + подмодули
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
# - name: Pull flutter tags
|
||||
# run: |
|
||||
# cd flutter && git fetch --tags --depth=1 && cd ..
|
||||
|
||||
# - name: Set up JDK 21
|
||||
# uses: https://github.com/actions/setup-java@v3
|
||||
# with:
|
||||
# java-version: "21"
|
||||
# distribution: "temurin"
|
||||
|
||||
# - name: Cache Android SDK
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: |
|
||||
# ~/android-sdk
|
||||
# ~/.android
|
||||
# key: ${{ runner.os }}-android-${{ hashFiles('android/build.gradle.kts') }}
|
||||
|
||||
# - name: Setup Android SDK
|
||||
# uses: https://github.com/android-actions/setup-android@v3
|
||||
|
||||
# - name: Cache Flutter
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: |
|
||||
# ./flutter/bin/cache
|
||||
# key: ${{ runner.os }}-flutter-${{ hashFiles('.gitmodules') }}
|
||||
|
||||
- name: Flutter install and check
|
||||
run: ./flutter/bin/flutter doctor -v
|
||||
|
||||
# 3. Создаем key.properties и загружаем ключ (секреты Forgejo)
|
||||
#- name: Setup signing keys
|
||||
# run: |
|
||||
# # Создаем директорию для ключа
|
||||
# mkdir -p android/app
|
||||
#
|
||||
# # Создаем key.properties
|
||||
# echo "storePassword=${{ secrets.KEY_PASSWORD }}" > android/key.properties
|
||||
# echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
|
||||
# echo "keyAlias=upload" >> android/key.properties
|
||||
# echo "storeFile=key.jks" >> android/key.properties
|
||||
#
|
||||
# # Декодируем base64-ключ (хранится в secrets.KEYSTORE_BASE64)
|
||||
# echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/key.jks
|
||||
|
||||
# 4. Кэширование
|
||||
# - name: Cache dependencies
|
||||
# uses: actions/cache@v4
|
||||
# with:
|
||||
# path: |
|
||||
# flutter/bin/cache
|
||||
# .dart_tool
|
||||
# key: ${{ runner.os }}-flutter-${{ hashFiles('pubspec.lock') }}
|
||||
|
||||
# 6. Собираем подписанный APK
|
||||
|
||||
# - name: Cache Build
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: |
|
||||
# ./android/.gradle
|
||||
# ~/.gradle
|
||||
# key: ${{ runner.os }}-android-${{ hashFiles('android/') }}
|
||||
|
||||
- name: Build unsigned APK
|
||||
- name: Get Release Info
|
||||
id: get_release
|
||||
run: |
|
||||
./flutter/bin/flutter build apk --release --split-per-abi -v
|
||||
RESPONSE=$(curl -s $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/$GITHUB_REF_NAME)
|
||||
|
||||
- name: Sign apk
|
||||
echo $RESPONSE | jq
|
||||
|
||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
|
||||
PRERELEASE=$(echo "$RESPONSE" | jq -r '.prerelease // empty')
|
||||
TAG_NAME=$(echo "$RESPONSE" | jq -r '.tag_name // empty')
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
RELEASE_ID=null
|
||||
fi
|
||||
if [ -z "$PRERELEASE" ]; then
|
||||
PRERELEASE=null
|
||||
fi
|
||||
if [ -z "$TAG_NAME" ]; then
|
||||
TAG_NAME=null
|
||||
fi
|
||||
|
||||
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
||||
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
|
||||
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
|
||||
- name: debug
|
||||
run: |
|
||||
echo ${{ steps.get_release.outputs.prerelease }}
|
||||
echo ${{ steps.get_release.outputs.release_id }}
|
||||
|
||||
- name: Build unsigned nightly APK
|
||||
if: steps.get_release.outputs.prerelease == 'true'
|
||||
run: |
|
||||
./gradlew assembleNightly --stacktrace \
|
||||
-PversionCode=$(date +%s)
|
||||
# -PversionName=${{ steps.get_release.outputs.tag_name }}
|
||||
|
||||
- name: Build unsigned release APK
|
||||
if: steps.get_release.outputs.prerelease != 'true'
|
||||
run: |
|
||||
./gradlew assembleRelease --stacktrace \
|
||||
-PversionName=${{ steps.get_release.outputs.tag_name }} \
|
||||
-PversionCode=${{ steps.get_release.outputs.release_id }}
|
||||
|
||||
- name: Sign nightly apk
|
||||
if: steps.get_release.outputs.prerelease == 'true'
|
||||
uses: https://github.com/ilharp/sign-android-release@v2
|
||||
id: sign_app
|
||||
with:
|
||||
releaseDir: build/app/outputs/flutter-apk
|
||||
releaseDir: app/build/outputs/apk/nightly
|
||||
signingKey: ${{ secrets.KEYSTORE_BASE64 }}
|
||||
keyAlias: upload
|
||||
keyStorePassword: ${{ secrets.KEY_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
||||
|
||||
- name: Print build dir
|
||||
run: pwd
|
||||
- name: Sign release apk
|
||||
if: steps.get_release.outputs.prerelease != 'true'
|
||||
uses: https://github.com/ilharp/sign-android-release@v2
|
||||
id: sign_app
|
||||
with:
|
||||
releaseDir: app/build/outputs/apk/release
|
||||
signingKey: ${{ secrets.KEYSTORE_BASE64 }}
|
||||
keyAlias: upload
|
||||
keyStorePassword: ${{ secrets.KEY_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
||||
|
||||
- name: List release files
|
||||
run: ls build/app/outputs/flutter-apk
|
||||
- name: Upload nightly apk
|
||||
if: steps.get_release.outputs.prerelease == 'true'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: app-nightly
|
||||
path: app/build/outputs/apk/nightly/*-signed.apk
|
||||
|
||||
# 7. Сохраняем артефакты
|
||||
- name: Upload release apk
|
||||
if: steps.get_release.outputs.prerelease != 'true' && steps.get_release.outputs.release_id != 'null'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: app-release
|
||||
path: build/app/outputs/flutter-apk/*-signed.apk
|
||||
path: app/build/outputs/apk/release/*-signed.apk
|
||||
|
||||
- name: Get Release ID
|
||||
id: get_release
|
||||
run: |
|
||||
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/$GITHUB_REF_NAME)
|
||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -n1 | grep -o '[0-9]*')
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
RELEASE_ID=null
|
||||
fi
|
||||
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload Asset
|
||||
if: steps.get_release.outputs.release_id != 'null'
|
||||
- name: Upload nightly Asset
|
||||
if: steps.get_release.outputs.prerelease == 'true' && steps.get_release.outputs.release_id != 'null'
|
||||
run: |
|
||||
curl -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "attachment=@build/app/outputs/flutter-apk/app-arm64-v8a-release-signed.apk" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ env.GITHUB_REPOSITORY }}/releases/${{ steps.get_release.outputs.release_id }}/assets?name=app-arm64-v8a-release.apk"
|
||||
-F "attachment=@app/build/outputs/apk/nightly/app-nightly-signed.apk" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ env.GITHUB_REPOSITORY }}/releases/${{ steps.get_release.outputs.release_id }}/assets?name=app-nightly.apk"
|
||||
|
||||
- name: Upload release Asset
|
||||
if: steps.get_release.outputs.prerelease != 'true' && steps.get_release.outputs.release_id != 'null'
|
||||
run: |
|
||||
curl -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "attachment=@build/app/outputs/flutter-apk/app-armeabi-v7a-release-signed.apk" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ env.GITHUB_REPOSITORY }}/releases/${{ steps.get_release.outputs.release_id }}/assets?name=app-armeabi-v7a-release.apk"
|
||||
|
||||
curl -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "attachment=@build/app/outputs/flutter-apk/app-x86_64-release-signed.apk" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ env.GITHUB_REPOSITORY }}/releases/${{ steps.get_release.outputs.release_id }}/assets?name=app-x86_64-release.apk"
|
||||
-F "attachment=@app/build/outputs/apk/release/app-release-unsigned-signed.apk" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ env.GITHUB_REPOSITORY }}/releases/${{ steps.get_release.outputs.release_id }}/assets?name=app-release.apk"
|
||||
|
|
|
|||
54
.gitignore
vendored
|
|
@ -1,44 +1,12 @@
|
|||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
|
||||
# Android Studio will place build artifacts here
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
android/key.properties
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea
|
||||
/.kotlin
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
/app/release
|
||||
|
|
|
|||
3
.gitmodules
vendored
|
|
@ -1,3 +0,0 @@
|
|||
[submodule "flutter"]
|
||||
path = flutter
|
||||
url = https://github.com/flutter/flutter.git
|
||||
30
.metadata
|
|
@ -1,30 +0,0 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "c23637390482d4cf9598c3ce3f2be31aa7332daf"
|
||||
channel: "stable"
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
|
||||
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
|
||||
- platform: android
|
||||
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
|
||||
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
37
BUILDING.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
## Building the app
|
||||
|
||||
### Getting started
|
||||
Requirements/Dependencies:
|
||||
- tools: [listed here](https://codeberg.org/mi6e4ka/android-build-ct/src/branch/main/Dockerfile#L9-L26)
|
||||
- SDK: `OpenJDK 17`
|
||||
- [Android Studio](https://developer.android.com/studio) for app debugging
|
||||
|
||||
### Building debug release
|
||||
Open Android Studio, open project and Sync Gradle. After, in toolbar go to Run and run the app.
|
||||
Alternatively, run in terminal from project directory:
|
||||
```
|
||||
export ANDROID_HOME=/usr/lib/jvm/java-17-openjdk; # here the path to openjdk 17 \
|
||||
export ANDROID_SDK_ROOT=$ANDROID_HOME; \
|
||||
export JAVA_HOME=$ANDROID_HOME; \
|
||||
./gradlew assembleDebug
|
||||
```
|
||||
|
||||
### Building signed release
|
||||
Create file named `keystore.properties` in project directory with next values:
|
||||
```
|
||||
storeFile=<full path to your keystore.jks>
|
||||
keyAlias=<your key alias in keystore>
|
||||
storePassword=<password for keystore>
|
||||
keyPassword=<password for alias>
|
||||
```
|
||||
|
||||
After that, run in terminal from project directory:
|
||||
```
|
||||
export ANDROID_HOME=/usr/lib/jvm/java-17-openjdk; # here the path to openjdk 17 \
|
||||
export ANDROID_SDK_ROOT=$ANDROID_HOME; \
|
||||
export JAVA_HOME=$ANDROID_HOME; \
|
||||
./gradlew assembleRelease
|
||||
```
|
||||
|
||||
Release artifacts will be located in `app/build/outputs/apk/release/` directory.
|
||||
If you have no your keystore.jks, you can create it using `keytool` or just follow [this guide](https://developer.android.com/studio/publish/app-signing#generate-key) from Google for Android Studio.
|
||||
235
LICENSE
|
|
@ -1,235 +0,0 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
openstore
|
||||
Copyright (C) 2024 mi6e4ka
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
|
||||
675
LICENSE.md
Normal file
|
|
@ -0,0 +1,675 @@
|
|||
# GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
## Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
1
Maestro/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.maestro
|
||||
37
Maestro/flow.yaml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
appId: dev.mi6e4ka.openstore
|
||||
---
|
||||
- launchApp:
|
||||
clearState: true
|
||||
|
||||
- assertVisible: "OpenStore"
|
||||
- takeScreenshot: "01_main_screen"
|
||||
|
||||
- tapOn: "Search"
|
||||
- inputText: "Mir Pay"
|
||||
- pressKey: Enter
|
||||
- assertVisible: "Mir Pay"
|
||||
- takeScreenshot: "02_search_screen"
|
||||
|
||||
- tapOn: "Mir Pay"
|
||||
- assertVisible: "Mir Pay"
|
||||
- takeScreenshot: "03_details_screen"
|
||||
|
||||
- scrollUntilVisible:
|
||||
element: "Rating and reviews"
|
||||
direction: DOWN
|
||||
- tapOn: "Rating and reviews"
|
||||
- assertVisible: "Reviews"
|
||||
- takeScreenshot: "04_review_screen"
|
||||
|
||||
- back
|
||||
- back
|
||||
- back
|
||||
- assertVisible: "OpenStore"
|
||||
- tapOn: "updates|обновления"
|
||||
- assertVisible: "Updates"
|
||||
- takeScreenshot: "05_updates_screen"
|
||||
|
||||
- back
|
||||
- tapOn: "settings|настройки"
|
||||
- assertVisible: "Settings|Настройки"
|
||||
- takeScreenshot: "06_settings_screen"
|
||||
46
README.md
|
|
@ -1,5 +1,47 @@
|
|||
# OpenStore
|
||||
|
||||

|
||||
[](https://apilevels.com)
|
||||
[](https://apt.izzysoft.de/fdroid/index/apk/dev.mi6e4ka.openstore)
|
||||

|
||||
|
||||
Open client for RuStore (unofficial and violating ToS, haha)
|
||||
---
|
||||
|
||||
<img src="./logo.png" width=80 alt="logo"/>
|
||||
|
||||
Open client for popular russian app store (unofficial)
|
||||
|
||||
## Installation
|
||||
|
||||
<a href="https://apt.izzysoft.de/fdroid/index/apk/dev.mi6e4ka.openstore">
|
||||
<img src="https://gitlab.com/IzzyOnDroid/repo/-/raw/master/assets/IzzyOnDroid.png" alt="Get it on IzzyOnDroid" height="70"/>
|
||||
</a>
|
||||
<a href="https://codeberg.org/mi6e4ka/openstore/releases/latest">
|
||||
<img alt="Get it on Codeberg" src="https://codeberg.org/Codeberg/GetItOnCodeberg/raw/branch/main/get-it-on-white-on-black.png" height="60">
|
||||
</a>
|
||||
|
||||
Verification info:
|
||||
- Package ID: `dev.mi6e4ka.openstore`
|
||||
- SHA-256 hash of signing certificate: `57:F7:EA:8B:41:B7:2E:6E:CF:C5:08:46:AF:ED:12:01:47:1A:8D:37:8E:18:D7:6A:AD:AC:BD:9F:B2:19:DF:98`
|
||||
|
||||
## Features
|
||||
- [x] Search apps
|
||||
- [x] View apps descriptions, rating and reviews
|
||||
- [x] Native app installing
|
||||
- [x] Android 5.0+ support!
|
||||
- [x] Search and view TV apps
|
||||
- [x] Check all apps for updates
|
||||
|
||||
## Roadmap
|
||||
- [ ] Better TV navigation support
|
||||
- [ ] ...maybe more?
|
||||
|
||||
## Screenshots
|
||||
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/01_main_screen.png" width=250>
|
||||
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/02_search_screen.png" width=250>
|
||||
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/03_details_screen.png" width=250>
|
||||
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/04_review_screen.png" width=250>
|
||||
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/05_updates_screen.png" width=250>
|
||||
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/06_settings_screen.png" width=250>
|
||||
|
||||
## Building the app
|
||||
See [here](https://codeberg.org/mi6e4ka/openstore/src/branch/main/BUILDING.md)
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
# This file configures the analyzer, which statically analyzes Dart code to
|
||||
# check for errors, warnings, and lints.
|
||||
#
|
||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||
# invoked from the command line by running `flutter analyze`.
|
||||
|
||||
# The following line activates a set of recommended lints for Flutter apps,
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
# The lint rules applied to this project can be customized in the
|
||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||
# included above or to enable additional rules. A list of all available lints
|
||||
# and their documentation is published at https://dart.dev/lints.
|
||||
#
|
||||
# Instead of disabling a lint rule for the entire project in the
|
||||
# section below, it can also be suppressed for a single line of code
|
||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||
# producing the lint.
|
||||
rules:
|
||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
14
android/.gitignore
vendored
|
|
@ -1,14 +0,0 @@
|
|||
gradle-wrapper.jar
|
||||
/.gradle
|
||||
/captures/
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
/local.properties
|
||||
GeneratedPluginRegistrant.java
|
||||
.cxx/
|
||||
|
||||
# Remember to never publicly share your keystore.
|
||||
# See https://flutter.dev/to/reference-keystore
|
||||
key.properties
|
||||
**/*.keystore
|
||||
**/*.jks
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
val keystoreProperties = Properties()
|
||||
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "dev.mi6e4ka.openstore"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
// ndkVersion = flutter.ndkVersion
|
||||
ndkVersion = "27.2.12479018"
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId = "dev.mi6e4ka.openstore"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
minSdk = flutter.minSdkVersion
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = flutter.versionCode
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
storeFile = keystoreProperties["storeFile"]?.let { file(it) }
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig = null
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
}
|
||||
}
|
||||
dependenciesInfo {
|
||||
// Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid)
|
||||
includeInApk = false
|
||||
// Disables dependency metadata when building Android App Bundles (for Google Play)
|
||||
includeInBundle = false
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application
|
||||
android:label="OpenStore"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:enableOnBackInvokedCallback="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- openstore deeplink, haha -->
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="http" android:host="rustore.ru" />
|
||||
<data android:scheme="http" android:host="www.rustore.ru" />
|
||||
<data android:scheme="http" android:host="apps.rustore.ru" />
|
||||
<data android:scheme="https" />
|
||||
</intent-filter>
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
the Android process has started. This theme is visible to the user
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
to determine the Window background behind the Flutter UI. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
|
||||
|
||||
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
|
Before Width: | Height: | Size: 46 KiB |
|
|
@ -1,5 +0,0 @@
|
|||
package dev.mi6e4ka.openstore
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="?android:colorBackground" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="199"
|
||||
android:viewportHeight="199">
|
||||
<path
|
||||
android:pathData="M0,0h199v199h-199z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startX="40"
|
||||
android:startY="15.5"
|
||||
android:endX="156.5"
|
||||
android:endY="180"
|
||||
android:type="linear">
|
||||
<item android:offset="0" android:color="#FF009DFF"/>
|
||||
<item android:offset="1" android:color="#FF004DB1"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
</vector>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="127"
|
||||
android:viewportHeight="133">
|
||||
<group android:scaleX="0.42598578"
|
||||
android:scaleY="0.4461111"
|
||||
android:translateX="36.4499"
|
||||
android:translateY="36.83361">
|
||||
<path
|
||||
android:pathData="M126.59,82.78C126.64,77.58 122.45,73.06 116.98,73.06H105.29L111.37,48.64C111.56,47.88 111.66,47.12 111.67,46.37C111.72,41.17 107.53,36.65 102.05,36.65H90.41L96.45,12.45C97.96,6.37 93.37,0.47 87.13,0.47L22.23,0.47C16.71,0.47 11.92,4.22 10.58,9.58L0.95,48.25C-0.57,54.33 4.02,60.24 10.27,60.24L75.17,60.24C79.12,60.24 82.7,58.3 84.89,55.24C85.05,55.19 85.23,55.2 85.37,55.3C85.62,55.47 85.74,55.78 85.65,56.06C84.11,61.15 78.91,65.99 72.35,66.48L22.83,68.16C21.17,68.21 19.75,69.31 19.23,70.88L15.86,84.44C14.35,90.53 18.94,96.43 25.18,96.43C46.6,96.59 68.37,96.54 89.86,96.55C92.77,96.55 95.01,95.56 96.64,94.46C96.91,94.28 97.18,94.09 97.44,93.89C97.74,93.64 98.04,93.38 98.32,93.11C98.75,92.7 99.15,92.27 99.51,91.8L99.52,91.8C99.71,91.6 100.01,91.55 100.24,91.71C100.49,91.88 100.6,92.18 100.52,92.47C98.98,97.56 93.78,102.42 87.22,102.89L37.7,104.57C36.05,104.61 34.64,105.71 34.15,107.26L30.76,120.85C29.24,126.93 33.83,132.84 40.07,132.84H104.97C110.49,132.84 115.29,129.08 116.62,123.72L126.25,85.05C126.44,84.29 126.54,83.54 126.54,82.79L126.59,82.78Z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">?android:colorBackground</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#4AA4E9</color>
|
||||
</resources>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<item name="android:windowBackground">?android:colorBackground</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
|
||||
rootProject.layout.buildDirectory.value(newBuildDir)
|
||||
|
||||
subprojects {
|
||||
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
|
||||
project.layout.buildDirectory.value(newSubprojectBuildDir)
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(":app")
|
||||
}
|
||||
|
||||
tasks.register<Delete>("clean") {
|
||||
delete(rootProject.layout.buildDirectory)
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
pluginManagement {
|
||||
val flutterSdkPath = run {
|
||||
val properties = java.util.Properties()
|
||||
file("local.properties").inputStream().use { properties.load(it) }
|
||||
val flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
|
||||
flutterSdkPath
|
||||
}
|
||||
|
||||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||
id("com.android.application") version "8.7.0" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.8.22" apply false
|
||||
}
|
||||
|
||||
include(":app")
|
||||
1
app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
110
app/build.gradle.kts
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
import java.io.ByteArrayOutputStream
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
val keystoreProperties = Properties()
|
||||
val keystoreFileExists = rootProject.file("keystore.properties").exists();
|
||||
if (keystoreFileExists) {
|
||||
keystoreProperties.load(rootProject.file("keystore.properties").inputStream())
|
||||
}
|
||||
|
||||
val gitCommitShort: String = run {
|
||||
try {
|
||||
val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
val output = process.inputStream.bufferedReader().use { it.readText() }.trim()
|
||||
val exitCode = process.waitFor()
|
||||
if (exitCode == 0 && output.isNotEmpty()) output else "unknown"
|
||||
} catch (e: Exception) {
|
||||
"unknown"
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "dev.mi6e4ka.openstore"
|
||||
compileSdk = 36
|
||||
|
||||
androidResources {
|
||||
localeFilters.addAll(arrayOf("ru", "en"))
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "dev.mi6e4ka.openstore"
|
||||
minSdk = 21
|
||||
targetSdk = 36
|
||||
versionCode = (project.findProperty("versionCode") as String?)?.toInt() ?: 1
|
||||
versionName = project.findProperty("versionName") as String? ?: ("git-" + gitCommitShort)
|
||||
//testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (keystoreFileExists) {
|
||||
create("release") {
|
||||
storeFile = keystoreProperties["storeFile"]?.let { file(it as String) }
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
signingConfig = signingConfigs.findByName("release")?.takeIf { it.storeFile != null }
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
create("nightly") {
|
||||
initWith(getByName("release"))
|
||||
versionNameSuffix = "-nightly"
|
||||
applicationIdSuffix = ".nightly"
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
resValue("string", "app_name", "OpenStore Nightly")
|
||||
}
|
||||
debug {
|
||||
versionNameSuffix = "-debug"
|
||||
applicationIdSuffix = ".debug"
|
||||
resValue("string", "app_name", "OpenStore Debug")
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.material3)
|
||||
implementation(libs.androidx.paging.compose)
|
||||
implementation(libs.kotlinx.datetime)
|
||||
implementation(libs.navigation.compose)
|
||||
implementation(libs.retrofit)
|
||||
implementation(libs.converter.gson)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
implementation(libs.androidx.lifecycle.viewmodel.ktx)
|
||||
implementation(libs.coil.compose)
|
||||
implementation(libs.lz4.java)
|
||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
||||
}
|
||||
24
app/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
# Keep xxhash classes used by LZ4 library
|
||||
-keep class net.jpountz.xxhash.** { *; }
|
||||
79
app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
|
||||
tools:ignore="RequestInstallPackagesPolicy" />
|
||||
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
|
||||
<uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="PackageVisibilityPolicy,QueryAllPackagesPermission" />
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="28"/>
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:localeConfig="@xml/locale_config"
|
||||
tools:targetApi="36"
|
||||
android:memtagMode="async">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<!-- openstore deeplink, haha -->
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" android:host="www.rustore.ru" android:pathPrefix="/catalog/app/" />
|
||||
<data android:scheme="https" android:host="apps.rustore.ru" android:pathPrefix="/app/" />
|
||||
<data android:scheme="https" android:host="www.rustore.ru" android:pathPrefix="/instruction" />
|
||||
<data android:scheme="http" android:host="www.rustore.ru" android:pathPrefix="/catalog/app/" />
|
||||
<data android:scheme="http" android:host="apps.rustore.ru" android:pathPrefix="/app/" />
|
||||
<data android:scheme="http" android:host="www.rustore.ru" android:pathPrefix="/instruction" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data
|
||||
android:scheme="openstore"
|
||||
android:host="settings" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- "additional settings in the app" -->
|
||||
<activity
|
||||
android:name=".EditPreferencesActivity"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
<receiver
|
||||
android:name=".internal.installer.PackageInstallerStatusReceiver"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package dev.mi6e4ka.openstore
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.core.net.toUri
|
||||
|
||||
class EditPreferencesActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val intent = Intent(this, MainActivity::class.java).apply {
|
||||
data = "openstore://settings".toUri()
|
||||
}
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
141
app/src/main/java/dev/mi6e4ka/openstore/MainActivity.kt
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
package dev.mi6e4ka.openstore
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.animation.AnimatedContentTransitionScope
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navDeepLink
|
||||
import coil.Coil
|
||||
import coil.ImageLoader
|
||||
import coil.disk.DiskCache
|
||||
import coil.memory.MemoryCache
|
||||
import coil.request.CachePolicy
|
||||
import dev.mi6e4ka.openstore.ui.screen.details.DetailsScreen
|
||||
import dev.mi6e4ka.openstore.ui.screen.results.ResultsScreen
|
||||
import dev.mi6e4ka.openstore.ui.screen.reviews.ReviewsScreen
|
||||
import dev.mi6e4ka.openstore.ui.screen.search.SearchScreen
|
||||
import dev.mi6e4ka.openstore.ui.screen.settings.SettingsScreen
|
||||
import dev.mi6e4ka.openstore.ui.screen.updates.UpdatesScreen
|
||||
import dev.mi6e4ka.openstore.ui.theme.AppTheme
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
val cacheDir = externalCacheDir ?: cacheDir
|
||||
cacheDir.listFiles()?.forEach { file ->
|
||||
if (file.isFile && file.name.endsWith(".apk", ignoreCase = true)) {
|
||||
file.delete()
|
||||
println("CacheCleaner" + "Удален: ${file.name}")
|
||||
}
|
||||
}
|
||||
val imageLoader = ImageLoader.Builder(this)
|
||||
.diskCache {
|
||||
DiskCache.Builder()
|
||||
.directory(cacheDir.resolve("image_cache"))
|
||||
.maxSizeBytes(10L * 1024 * 1024)
|
||||
.build()
|
||||
}
|
||||
.memoryCache {
|
||||
MemoryCache.Builder(this)
|
||||
.maxSizeBytes(10 * 1024 * 1024)
|
||||
.build()
|
||||
}
|
||||
.networkCachePolicy(CachePolicy.ENABLED)
|
||||
.diskCachePolicy(CachePolicy.ENABLED)
|
||||
.memoryCachePolicy(CachePolicy.ENABLED)
|
||||
.build()
|
||||
Coil.setImageLoader(imageLoader)
|
||||
setContent {
|
||||
AppTheme {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
val navController = rememberNavController()
|
||||
val duration = 300
|
||||
val easing = FastOutSlowInEasing
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = "search",
|
||||
enterTransition = {
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { (it * 0.1f).toInt() },
|
||||
animationSpec = tween(duration, easing = easing)
|
||||
) + fadeIn(animationSpec = tween(duration))
|
||||
},
|
||||
exitTransition = {
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { -(it * 0.1f).toInt() },
|
||||
animationSpec = tween(duration, easing = easing)
|
||||
) + fadeOut(animationSpec = tween(duration))
|
||||
},
|
||||
popEnterTransition = {
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { -(it * 0.1f).toInt() },
|
||||
animationSpec = tween(duration, easing = easing)
|
||||
) + fadeIn(animationSpec = tween(duration))
|
||||
},
|
||||
popExitTransition = {
|
||||
slideOutHorizontally(
|
||||
targetOffsetX = { (it * 0.1f).toInt() },
|
||||
animationSpec = tween(duration, easing = easing)
|
||||
) + fadeOut(animationSpec = tween(duration))
|
||||
}
|
||||
) {
|
||||
composable("search") {
|
||||
SearchScreen(navController)
|
||||
}
|
||||
composable("search/{query}") {
|
||||
val query = it.arguments?.getString("query") ?: ""
|
||||
ResultsScreen(query = query, navController = navController)
|
||||
}
|
||||
composable("app/{appId}?platform={platform}", deepLinks = listOf(
|
||||
navDeepLink { uriPattern = "https://www.rustore.ru/catalog/app/{appId}" },
|
||||
navDeepLink { uriPattern = "https://apps.rustore.ru/app/{appId}" },
|
||||
navDeepLink { uriPattern = "https://www.rustore.ru/instruction?appName={appName}&utm_campaign={appId}" }
|
||||
)) { backStackEntry ->
|
||||
val itemId = backStackEntry.arguments?.getString("appId") ?: ""
|
||||
val platform = backStackEntry.arguments?.getString("platform") ?: "mobile"
|
||||
AnimatedVisibility(
|
||||
visible = true,
|
||||
enter = slideInHorizontally(initialOffsetX = { 1000 }) + fadeIn(),
|
||||
exit = slideOutHorizontally(targetOffsetX = { -1000 }) + fadeOut()
|
||||
) {
|
||||
DetailsScreen(itemId = itemId, appPlatform=platform, navController = navController)
|
||||
}
|
||||
}
|
||||
composable("app/{packageName}/reviews") {
|
||||
val packageName = it.arguments?.getString("packageName") ?: ""
|
||||
ReviewsScreen(packageName = packageName, navController = navController)
|
||||
}
|
||||
composable("updates") {
|
||||
UpdatesScreen(navController = navController)
|
||||
}
|
||||
composable("settings", deepLinks = listOf(
|
||||
navDeepLink { uriPattern = "openstore://settings" }
|
||||
)) {
|
||||
SettingsScreen(navController = navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package dev.mi6e4ka.openstore.data.api
|
||||
|
||||
import okhttp3.OkHttpClient
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
//import okhttp3.logging.HttpLoggingInterceptor
|
||||
|
||||
object ApiClient {
|
||||
private const val BASE_URL = "https://backapi.rustore.ru/"
|
||||
|
||||
// private val loggingInterceptor = HttpLoggingInterceptor().apply {
|
||||
// level = HttpLoggingInterceptor.Level.NONE
|
||||
// }
|
||||
|
||||
private val okHttpClient = OkHttpClient.Builder()
|
||||
// .addInterceptor(loggingInterceptor)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
private val retrofit = Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
|
||||
val service: ApiService = retrofit.create(ApiService::class.java)
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package dev.mi6e4ka.openstore.data.api
|
||||
|
||||
import dev.mi6e4ka.openstore.data.model.AppCommentsResponse
|
||||
import dev.mi6e4ka.openstore.data.model.AppRatingResponse
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateRequest
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateResponse
|
||||
import dev.mi6e4ka.openstore.data.model.BatchItemDetailsRequest
|
||||
import dev.mi6e4ka.openstore.data.model.DownloadLinkRequest
|
||||
import dev.mi6e4ka.openstore.data.model.DownloadLinkResponse
|
||||
import dev.mi6e4ka.openstore.data.model.ItemDetailsResponse
|
||||
import dev.mi6e4ka.openstore.data.model.SearchResponse
|
||||
import dev.mi6e4ka.openstore.data.model.ShortItemDetails
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface ApiService {
|
||||
@GET("applicationData/apps")
|
||||
suspend fun search(
|
||||
@Query("pageSize") pageSize: Int,
|
||||
@Query("pageNumber") pageNumber: Int,
|
||||
@Query("query") query: String,
|
||||
@Query("buyeruid") buyeruid : String,
|
||||
@Header("deviceType") deviceType : String
|
||||
): SearchResponse
|
||||
|
||||
@GET("applicationData/overallInfo/{packageName}")
|
||||
suspend fun getItemDetails(
|
||||
@Header("deviceType") deviceType : String,
|
||||
@Path("packageName") packageName: String
|
||||
): ItemDetailsResponse
|
||||
|
||||
@POST("applicationData/v2/download-link")
|
||||
suspend fun getAppDownloadLink(
|
||||
@Header("deviceType") deviceType : String,
|
||||
@Body request: DownloadLinkRequest
|
||||
) : DownloadLinkResponse
|
||||
|
||||
@GET("comment/findRating")
|
||||
suspend fun getAppRating(@Query("packageName") packageName: String) : AppRatingResponse
|
||||
|
||||
@GET("https://backapi.rustore.ru/comment/comment")
|
||||
suspend fun getAppComments(
|
||||
@Query("packageName") packageName: String,
|
||||
@Query("pageNumber") pageNumber: Int = 0,
|
||||
@Query("pageSize") pageSize: Int,
|
||||
@Query("sortBy") sortBy: String,
|
||||
) : AppCommentsResponse
|
||||
|
||||
@POST("applicationData/newApps")
|
||||
suspend fun getBatchUpdates(
|
||||
@Body request: AppUpdateRequest
|
||||
) : AppUpdateResponse
|
||||
|
||||
@POST("v2/showcase/store-app")
|
||||
suspend fun getBatchItemDetails(
|
||||
@Body request: BatchItemDetailsRequest
|
||||
) : List<ShortItemDetails>
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package dev.mi6e4ka.openstore.data.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class AppCommentsResponse(
|
||||
@SerializedName("body") val body: AppCommentsResponseBody,
|
||||
)
|
||||
|
||||
data class AppCommentsResponseBody(
|
||||
@SerializedName("content") val content: List<AppCommentsComments>,
|
||||
)
|
||||
|
||||
data class AppCommentsComments(
|
||||
@SerializedName("appRating") val appRating: Int,
|
||||
@SerializedName("firstName") val firstName: String,
|
||||
@SerializedName("commentDate") val commentDate: String,
|
||||
@SerializedName("commentText") val commentText: String,
|
||||
@SerializedName("likeCounter") val likeCounter: Int,
|
||||
@SerializedName("dislikeCounter") val dislikeCounter: Int,
|
||||
@SerializedName("updatedAt") val updatedAt: String,
|
||||
@SerializedName("devResponseDate") val devResponseDate: String,
|
||||
@SerializedName("devResponse") val devResponse: String
|
||||
)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package dev.mi6e4ka.openstore.data.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class AppRatingResponse(
|
||||
@SerializedName("body") val body: AppRatingResponseBody,
|
||||
)
|
||||
|
||||
data class AppRatingResponseBody(
|
||||
@SerializedName("ratings") val ratings: AppRatingCount,
|
||||
@SerializedName("averageUserRating") val averageUserRating: Float,
|
||||
@SerializedName("totalRatings") val totalRatings: Int,
|
||||
)
|
||||
|
||||
|
||||
data class AppRatingCount(
|
||||
@SerializedName("amountFive") val amountFive: Int,
|
||||
@SerializedName("amountFour") val amountFour: Int,
|
||||
@SerializedName("amountThree") val amountThree: Int,
|
||||
@SerializedName("amountTwo") val amountTwo: Int,
|
||||
@SerializedName("amountOne") val amountOne: Int,
|
||||
)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package dev.mi6e4ka.openstore.data.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class AppUpdateRequestEntry(
|
||||
@SerializedName("packageName") val packageName: String,
|
||||
@Transient val appName: String,
|
||||
@SerializedName("versionCode") val versionCode: Long,
|
||||
@Transient val versionName: String,
|
||||
@Transient val installSource: String
|
||||
)
|
||||
|
||||
data class AppUpdateRequest(
|
||||
@SerializedName("content") val content: List<AppUpdateRequestEntry>
|
||||
)
|
||||
|
||||
data class AppUpdateResponse(
|
||||
@SerializedName("body") val body: AppUpdateResponseBody
|
||||
)
|
||||
|
||||
data class AppUpdateResponseBody(
|
||||
@SerializedName("content") val content: List<AppUpdateResponseEntry>
|
||||
)
|
||||
|
||||
data class AppUpdateResponseEntry(
|
||||
@SerializedName("appId") val appId: Int,
|
||||
@SerializedName("packageName") val packageName: String,
|
||||
@SerializedName("appName") val appName: String,
|
||||
@SerializedName("updatedAt") val updatedAt: String,
|
||||
@SerializedName("versionCode") val versionCode: Long
|
||||
)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package dev.mi6e4ka.openstore.data.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class DownloadLinkRequest(
|
||||
@SerializedName("appId") val appId: Int,
|
||||
@SerializedName("firstInstall") val firstInstall: Boolean,
|
||||
@SerializedName("screenDensity") val screenDensity: Int,
|
||||
@SerializedName("sdkVersion") val sdkVersion: Int,
|
||||
@SerializedName("withoutSplits") val withoutSplits: Boolean,
|
||||
@SerializedName("supportedAbis") val supportedAbis: List<String>,
|
||||
)
|
||||
|
||||
data class DownloadLinkResponse(
|
||||
@SerializedName("body") val body: DownloadLinkResponseBody,
|
||||
)
|
||||
|
||||
data class DownloadLinkResponseBody(
|
||||
@SerializedName("downloadUrls") val downloadUrls: List<DownloadLinkResponseItem>,
|
||||
)
|
||||
|
||||
data class DownloadLinkResponseItem(
|
||||
@SerializedName("url") val url: String,
|
||||
@SerializedName("size") val size: Long,
|
||||
@SerializedName("hash") val hash: String,
|
||||
)
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package dev.mi6e4ka.openstore.data.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class ItemDetails(
|
||||
@SerializedName("appId") val appId: Int,
|
||||
@SerializedName("appName") val appName: String,
|
||||
@SerializedName("packageName") val packageName: String,
|
||||
@SerializedName("companyName") val companyName: String,
|
||||
@SerializedName("iconUrl") val iconUrl: String,
|
||||
@SerializedName("fullDescription") val fullDescription: String,
|
||||
@SerializedName("shortDescription") val shortDescription: String,
|
||||
@SerializedName("fileSize") val fileSize: Float,
|
||||
@SerializedName("minSdkVersion") val minSdkVersion: Int,
|
||||
@SerializedName("targetSdkVersion") val targetSdkVersion: Int,
|
||||
@SerializedName("versionName") val versionName: String,
|
||||
@SerializedName("versionCode") val versionCode: Long,
|
||||
@SerializedName("fileUrls") val fileUrls: List<Files>,
|
||||
@SerializedName("aggregatorInfo") val aggregatorInfo: AggregatorInfo?,
|
||||
@SerializedName("roundedDownloadsText") val roundedDownloadsText: String,
|
||||
@SerializedName("ageLegal") val ageLegal: String,
|
||||
@SerializedName("whatsNew") val whatsNew: String,
|
||||
@SerializedName("appVerUpdatedAt") val appVerUpdatedAt: String,
|
||||
)
|
||||
|
||||
data class ShortItemDetails(
|
||||
@SerializedName("appId") val appId: Int,
|
||||
@SerializedName("appName") val appName: String,
|
||||
@SerializedName("packageName") val packageName: String,
|
||||
@SerializedName("iconUrl") val iconUrl: String,
|
||||
@SerializedName("versionCode") val versionCode: Long,
|
||||
)
|
||||
|
||||
data class BatchItemDetailsRequest(
|
||||
@SerializedName("packageNames") val packageNames: List<String>,
|
||||
)
|
||||
|
||||
data class Files(
|
||||
@SerializedName("fileUrl") val fileUrl: String,
|
||||
@SerializedName("ordinal") val ordinal: Int,
|
||||
@SerializedName("type") val type: String,
|
||||
@SerializedName("orientation") val orientation: String,
|
||||
)
|
||||
|
||||
data class AggregatorInfo(
|
||||
@SerializedName("companyName") val companyName: String,
|
||||
@SerializedName("source") val source: String,
|
||||
)
|
||||
|
||||
data class ItemDetailsResponse(
|
||||
@SerializedName("code") val code: String,
|
||||
@SerializedName("message") val message: String?,
|
||||
@SerializedName("body") val body: ItemDetails,
|
||||
)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package dev.mi6e4ka.openstore.data.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class SearchResult(
|
||||
@SerializedName("appId") val appId: Int,
|
||||
@SerializedName("appName") val appName: String,
|
||||
@SerializedName("packageName") val packageName: String,
|
||||
@SerializedName("iconUrl") val iconUrl: String,
|
||||
)
|
||||
|
||||
data class SearchResponseBody(
|
||||
@SerializedName("content") val content: List<SearchResult>,
|
||||
@SerializedName("totalElements") val totalElements: Int,
|
||||
@SerializedName("totalPages") val totalPages: Int,
|
||||
)
|
||||
|
||||
data class SearchResponse(
|
||||
@SerializedName("code") val code: String,
|
||||
@SerializedName("message") val message: String?,
|
||||
@SerializedName("body") val body: SearchResponseBody
|
||||
)
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package dev.mi6e4ka.openstore.data.paging
|
||||
|
||||
import androidx.paging.PagingSource
|
||||
import androidx.paging.PagingState
|
||||
import dev.mi6e4ka.openstore.data.api.ApiService
|
||||
import dev.mi6e4ka.openstore.data.model.SearchResult
|
||||
|
||||
class SearchPagingSource(
|
||||
private val api: ApiService,
|
||||
private val query: String,
|
||||
private val deviceType : String
|
||||
) : PagingSource<Int, SearchResult>() {
|
||||
|
||||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, SearchResult> {
|
||||
return try {
|
||||
val page = params.key ?: 0
|
||||
val response = api.search(
|
||||
pageSize = params.loadSize,
|
||||
query = query,
|
||||
pageNumber = page,
|
||||
buyeruid = " ", // TODO: empty string for now. It should be zlib compressed string with many info about client. For now required at least the very presence
|
||||
deviceType = deviceType
|
||||
)
|
||||
LoadResult.Page(
|
||||
data = response.body.content,
|
||||
prevKey = if (page == 0) null else page - 1,
|
||||
nextKey = if (response.body.content.isEmpty()) null else page + 1
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
LoadResult.Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRefreshKey(state: PagingState<Int, SearchResult>): Int? {
|
||||
return state.anchorPosition?.let { anchor ->
|
||||
val page = state.closestPageToPosition(anchor)
|
||||
page?.prevKey?.plus(1) ?: page?.nextKey?.minus(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package dev.mi6e4ka.openstore.data.repository
|
||||
|
||||
import androidx.paging.Pager
|
||||
import androidx.paging.PagingConfig
|
||||
import dev.mi6e4ka.openstore.data.api.ApiClient
|
||||
import dev.mi6e4ka.openstore.data.model.AppCommentsComments
|
||||
import dev.mi6e4ka.openstore.data.model.AppRatingResponseBody
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateRequest
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateRequestEntry
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateResponse
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateResponseEntry
|
||||
import dev.mi6e4ka.openstore.data.model.BatchItemDetailsRequest
|
||||
import dev.mi6e4ka.openstore.data.model.DownloadLinkRequest
|
||||
import dev.mi6e4ka.openstore.data.model.DownloadLinkResponseItem
|
||||
import dev.mi6e4ka.openstore.data.model.ItemDetails
|
||||
import dev.mi6e4ka.openstore.data.model.SearchResult
|
||||
import dev.mi6e4ka.openstore.data.model.ShortItemDetails
|
||||
import dev.mi6e4ka.openstore.data.paging.SearchPagingSource
|
||||
|
||||
class SearchRepository {
|
||||
private val apiService = ApiClient.service
|
||||
|
||||
fun search(query: String, deviceType : String): Pager<Int, SearchResult> {
|
||||
return Pager(
|
||||
config = PagingConfig(
|
||||
pageSize = 20,
|
||||
initialLoadSize = 20,
|
||||
enablePlaceholders = false
|
||||
),
|
||||
pagingSourceFactory = { SearchPagingSource(apiService, query, deviceType) }
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getItemDetails(packageName: String, deviceType: String): ItemDetails {
|
||||
return apiService.getItemDetails(deviceType, packageName).body
|
||||
}
|
||||
|
||||
suspend fun getAppFiles(id: Int, firstInstall: Boolean, supportedAbis: List<String>, withoutSplits: Boolean, deviceType: String): List<DownloadLinkResponseItem> {
|
||||
val req = DownloadLinkRequest(
|
||||
appId = id,
|
||||
firstInstall = firstInstall,
|
||||
screenDensity = 420,
|
||||
sdkVersion = 36,
|
||||
withoutSplits = withoutSplits,
|
||||
supportedAbis = supportedAbis
|
||||
)
|
||||
return apiService.getAppDownloadLink(deviceType, req).body.downloadUrls
|
||||
}
|
||||
|
||||
suspend fun getAppRating(packageName: String): AppRatingResponseBody {
|
||||
return apiService.getAppRating(packageName).body
|
||||
}
|
||||
|
||||
suspend fun getAppComments(packageName: String, pageSize: Int, sortBy: String): List<AppCommentsComments> {
|
||||
return apiService.getAppComments(packageName, pageSize = pageSize, sortBy = sortBy).body.content
|
||||
}
|
||||
|
||||
suspend fun getBatchUpdates(apps: List<AppUpdateRequestEntry>): List<AppUpdateResponseEntry> {
|
||||
return apiService.getBatchUpdates(AppUpdateRequest(content = apps)).body.content
|
||||
}
|
||||
|
||||
suspend fun getBatchItemDetails(packageNames: List<String>) : List<ShortItemDetails> {
|
||||
return apiService.getBatchItemDetails(request = BatchItemDetailsRequest(packageNames = packageNames))
|
||||
}
|
||||
}
|
||||
14
app/src/main/java/dev/mi6e4ka/openstore/di/AppModule.kt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package dev.mi6e4ka.openstore.di
|
||||
|
||||
import dev.mi6e4ka.openstore.data.repository.SearchRepository
|
||||
import dev.mi6e4ka.openstore.internal.installer.UninstallerEventFlow
|
||||
|
||||
object AppModule {
|
||||
val searchRepository: SearchRepository by lazy {
|
||||
SearchRepository()
|
||||
}
|
||||
|
||||
val uninstallerEventFlow: UninstallerEventFlow by lazy {
|
||||
UninstallerEventFlow()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,381 @@
|
|||
package dev.mi6e4ka.openstore.internal.installer
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInstaller
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Base64
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.FileProvider
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.data.model.DownloadLinkResponseItem
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.IOException
|
||||
import net.jpountz.xxhash.XXHashFactory
|
||||
import java.util.Collections
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import kotlin.concurrent.atomics.AtomicLong
|
||||
import kotlin.concurrent.atomics.ExperimentalAtomicApi
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
class ApkInstaller(private val context: Context) {
|
||||
|
||||
companion object {
|
||||
private val okHttpClient = OkHttpClient.Builder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS)
|
||||
.readTimeout(120, TimeUnit.SECONDS)
|
||||
.writeTimeout(120, TimeUnit.SECONDS)
|
||||
.build()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAtomicApi::class)
|
||||
fun downloadFilesWithProgress(
|
||||
files: List<DownloadLinkResponseItem>,
|
||||
onProgress: (percent: Int, downloaded: Long, total: Long) -> Unit,
|
||||
onSuccess: (List<File>) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onCancel: () -> Unit,
|
||||
onInvalidHash: (List<File>, String?, String?) -> Unit = { _, _, _ -> }
|
||||
): () -> Unit {
|
||||
val downloadRunner = CoroutineScope(Dispatchers.IO).launch {
|
||||
val totalBytesToDownload = files.sumOf { it.size }
|
||||
val totalBytesDownloaded = AtomicLong(0)
|
||||
val downloadedFiles = Collections.synchronizedList(mutableListOf<File>())
|
||||
var lastUpdateMillis = 0L
|
||||
|
||||
try {
|
||||
val resultingFiles = coroutineScope {
|
||||
files.map { file ->
|
||||
async {
|
||||
val fileName = file.url.split("/").last()
|
||||
val apkFile = getApkFile(fileName)
|
||||
if (!downloadedFiles.contains(apkFile)) {
|
||||
downloadedFiles.add(apkFile)
|
||||
}
|
||||
|
||||
if (apkFile.exists() && apkFile.length() == file.size) {
|
||||
if (verifyFileHash(apkFile, file.hash)) {
|
||||
totalBytesDownloaded.addAndFetch(file.size)
|
||||
return@async apkFile
|
||||
}
|
||||
apkFile.delete()
|
||||
}
|
||||
|
||||
val request = Request.Builder().url(file.url).build()
|
||||
val call = okHttpClient.newCall(request)
|
||||
|
||||
// Связываем отмену корутины с OkHttp
|
||||
val job = coroutineContext[Job]!!
|
||||
val cancelHandler = job.invokeOnCompletion { call.cancel() }
|
||||
|
||||
try {
|
||||
call.execute().use { response ->
|
||||
if (!response.isSuccessful) throw IOException("Ошибка загрузки: ${response.code}")
|
||||
|
||||
val responseBody = response.body ?: throw IOException("Пустой ответ")
|
||||
|
||||
responseBody.byteStream().use { inputStream ->
|
||||
FileOutputStream(apkFile).use { outputStream ->
|
||||
val buffer = ByteArray(16384) // Увеличил буфер для скорости
|
||||
var bytesRead: Int
|
||||
|
||||
while (inputStream.read(buffer).also { bytesRead = it } != -1) {
|
||||
job.ensureActive()
|
||||
outputStream.write(buffer, 0, bytesRead)
|
||||
|
||||
val currentTotal = totalBytesDownloaded.addAndFetch(bytesRead.toLong())
|
||||
|
||||
// Троттлинг обновлений UI (не чаще 10 раз в секунду)
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastUpdateMillis > 100) {
|
||||
lastUpdateMillis = now
|
||||
val percent = if (totalBytesToDownload > 0) {
|
||||
(currentTotal * 100 / totalBytesToDownload).toInt()
|
||||
} else 0
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
onProgress(percent, currentTotal, totalBytesToDownload)
|
||||
}
|
||||
}
|
||||
}
|
||||
outputStream.flush()
|
||||
}
|
||||
}
|
||||
|
||||
if (!verifyFileHash(apkFile, file.hash)) {
|
||||
throw HashMismatchException(apkFile, file.hash)
|
||||
}
|
||||
apkFile
|
||||
}
|
||||
} finally {
|
||||
cancelHandler.dispose()
|
||||
}
|
||||
}
|
||||
}.awaitAll()
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
onSuccess(resultingFiles)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
withContext(NonCancellable) {
|
||||
if (e is HashMismatchException) {
|
||||
val expectedHash = formatHashForDisplay(e.expectedHash)
|
||||
val actualHash = computeExistingHash(e.file)
|
||||
val filesCopy = downloadedFiles.toList()
|
||||
withContext(Dispatchers.Main) {
|
||||
onInvalidHash(filesCopy, expectedHash, actualHash)
|
||||
}
|
||||
} else {
|
||||
// Удаляем недокачанные файлы при любой другой ошибке или отмене
|
||||
downloadedFiles.forEach { if (it.exists()) it.delete() }
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
if (e is CancellationException || (e is IOException && callIsCanceled(e))) {
|
||||
onCancel()
|
||||
} else {
|
||||
onError(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { downloadRunner.cancel() }
|
||||
}
|
||||
|
||||
private fun callIsCanceled(e: IOException): Boolean {
|
||||
return e.message?.contains("Canceled", ignoreCase = true) == true ||
|
||||
e.message?.contains("Socket closed", ignoreCase = true) == true
|
||||
}
|
||||
|
||||
private class HashMismatchException(val file: File, val expectedHash: String) : IOException("Hash mismatch")
|
||||
|
||||
fun getApkFile(fileName: String): File {
|
||||
return File(context.externalCacheDir ?: context.cacheDir, fileName)
|
||||
}
|
||||
|
||||
fun cleanApkFiles(files: List<String>) {
|
||||
files.forEach {
|
||||
val apkFile = getApkFile(it)
|
||||
if (apkFile.exists()) {
|
||||
apkFile.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
private val installer = context.packageManager.packageInstaller
|
||||
private val flags = PendingIntent.FLAG_MUTABLE
|
||||
private val intent = Intent(context, PackageInstallerStatusReceiver::class.java)
|
||||
|
||||
private fun verifyFileHash(file: File, expectedHash: String): Boolean {
|
||||
val normalizedHash = expectedHash.trim().ifEmpty { return true }
|
||||
val expectedBytes = decodeHashValue(normalizedHash) ?: return true
|
||||
if (expectedBytes.size != 8) return true
|
||||
|
||||
val actualBytes = digestFileXXH64(file) ?: return false
|
||||
return actualBytes.contentEquals(expectedBytes)
|
||||
}
|
||||
|
||||
private fun decodeHashValue(hash: String): ByteArray? {
|
||||
return try {
|
||||
if (hash.matches(Regex("^[0-9A-Fa-f]+$"))) {
|
||||
hash.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
|
||||
} else {
|
||||
Base64.decode(hash, Base64.DEFAULT)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatHashForDisplay(hash: String): String {
|
||||
return if (hash.matches(Regex("^[0-9A-Fa-f]+$"))) {
|
||||
hash.lowercase()
|
||||
} else {
|
||||
hash
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeExistingHash(file: File): String {
|
||||
val actualBytes = digestFileXXH64(file) ?: return ""
|
||||
return actualBytes.toHexString()
|
||||
}
|
||||
|
||||
private fun digestFileXXH64(file: File): ByteArray? {
|
||||
return try {
|
||||
val factory = XXHashFactory.fastestInstance()
|
||||
val hash64 = factory.newStreamingHash64(0L)
|
||||
FileInputStream(file).use { fis ->
|
||||
val buffer = ByteArray(8192)
|
||||
var bytesRead: Int
|
||||
while (fis.read(buffer).also { bytesRead = it } != -1) {
|
||||
hash64.update(buffer, 0, bytesRead)
|
||||
}
|
||||
}
|
||||
val hashValue = hash64.getValue()
|
||||
byteArrayOf(
|
||||
(hashValue shr 56).toByte(),
|
||||
(hashValue shr 48).toByte(),
|
||||
(hashValue shr 40).toByte(),
|
||||
(hashValue shr 32).toByte(),
|
||||
(hashValue shr 24).toByte(),
|
||||
(hashValue shr 16).toByte(),
|
||||
(hashValue shr 8).toByte(),
|
||||
hashValue.toByte()
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun ByteArray.toHexString(): String {
|
||||
val sb = StringBuilder(size * 2)
|
||||
for (b in this) {
|
||||
sb.append(String.format("%02x", b))
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
fun installApp(
|
||||
packageName: String,
|
||||
apkFiles: List<File>,
|
||||
onSessionFinished: (Boolean) -> Unit = {},
|
||||
onError: (Exception) -> Unit = {}
|
||||
) {
|
||||
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||
val installerType = prefs.getString("installer_type", "session")
|
||||
|
||||
when (installerType) {
|
||||
"session" -> {
|
||||
installViaSession(apkFiles, onSessionFinished, onError)
|
||||
}
|
||||
"intent" -> {
|
||||
installViaIntent(packageName, apkFiles, onError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun installViaSession(
|
||||
apkFiles: List<File>,
|
||||
onSessionFinished: (Boolean) -> Unit,
|
||||
onError: (Exception) -> Unit
|
||||
) {
|
||||
try {
|
||||
val sessionParams =
|
||||
PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL).apply {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
setRequestUpdateOwnership(true)
|
||||
}
|
||||
}
|
||||
val sessionId = installer.createSession(sessionParams)
|
||||
installer.registerSessionCallback(object : PackageInstaller.SessionCallback() {
|
||||
override fun onCreated(sessionId: Int) {}
|
||||
override fun onBadgingChanged(sessionId: Int) {}
|
||||
override fun onActiveChanged(sessionId: Int, active: Boolean) {}
|
||||
override fun onProgressChanged(sessionId: Int, progress: Float) {}
|
||||
override fun onFinished(id: Int, success: Boolean) {
|
||||
if (id == sessionId) {
|
||||
onSessionFinished(success)
|
||||
installer.unregisterSessionCallback(this)
|
||||
}
|
||||
}
|
||||
}, Handler(Looper.getMainLooper()))
|
||||
|
||||
val session = installer.openSession(sessionId)
|
||||
session.use { activeSession ->
|
||||
apkFiles.forEach { file ->
|
||||
val sizeBytes = file.length()
|
||||
file.inputStream().use { fileStream ->
|
||||
activeSession.openWrite(file.name, 0, sizeBytes).use { outputStream ->
|
||||
fileStream.copyTo(outputStream)
|
||||
activeSession.fsync(outputStream)
|
||||
}
|
||||
}
|
||||
}
|
||||
val pendingIntent = PendingIntent.getBroadcast(context, sessionId, intent, flags)
|
||||
activeSession.commit(pendingIntent.intentSender)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("ApkInstaller", "Error during session install", e)
|
||||
onError(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun installViaIntent(
|
||||
packageName: String,
|
||||
apkFiles: List<File>,
|
||||
onError: (Exception) -> Unit
|
||||
) {
|
||||
try {
|
||||
val apkUri: Uri
|
||||
if (apkFiles.size == 1) {
|
||||
apkUri = FileProvider.getUriForFile(
|
||||
context,
|
||||
"${context.packageName}.provider",
|
||||
apkFiles[0]
|
||||
)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.intent_installer_split_apk_build, Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
val apksFile = File(context.externalCacheDir ?: context.cacheDir, "$packageName.apks")
|
||||
buildSplitApk(apkFiles, apksFile)
|
||||
apkUri = FileProvider.getUriForFile(
|
||||
context,
|
||||
"${context.packageName}.provider",
|
||||
apksFile
|
||||
)
|
||||
}
|
||||
Toast.makeText(context, R.string.intent_installer_warning, Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
|
||||
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||
setDataAndType(apkUri, "application/vnd.android.package-archive")
|
||||
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Log.e("ApkInstaller", "Error during intent install", e)
|
||||
onError(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildSplitApk(apkFiles: List<File>, outputZip: File) {
|
||||
ZipOutputStream(BufferedOutputStream(FileOutputStream(outputZip))).use { zos ->
|
||||
apkFiles.forEach { file ->
|
||||
FileInputStream(file).use { fis ->
|
||||
val entry = ZipEntry(file.name)
|
||||
zos.putNextEntry(entry)
|
||||
fis.copyTo(zos)
|
||||
zos.closeEntry()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package dev.mi6e4ka.openstore.internal.installer
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInstaller
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.core.os.BundleCompat
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.di.AppModule
|
||||
|
||||
class PackageInstallerStatusReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1)
|
||||
val isUninstall = intent.getBooleanExtra(ACTION_UNINSTALL, false)
|
||||
|
||||
when (status) {
|
||||
PackageInstaller.STATUS_SUCCESS -> {
|
||||
Toast.makeText(context, if (isUninstall) R.string.app_uninstalled else R.string.app_installed, Toast.LENGTH_SHORT).show()
|
||||
if (isUninstall) {
|
||||
AppModule.uninstallerEventFlow.trigger()
|
||||
}
|
||||
}
|
||||
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
|
||||
val promptIntent = BundleCompat.getParcelable(intent.extras!!, Intent.EXTRA_INTENT, Intent::class.java)
|
||||
|
||||
promptIntent?.let {
|
||||
it.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||
it.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, "com.android.vending")
|
||||
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
val errorMessage = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
|
||||
|
||||
if (errorMessage?.contains("INSUFFICIENT_STORAGE", ignoreCase = true) == true) {
|
||||
Toast.makeText(context, R.string.insufficient_memory, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, if (isUninstall) R.string.failed_uninstall else R.string.failed_install, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
Log.e("app manager", errorMessage ?: "no error message")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ACTION_UNINSTALL = "action_uninstall"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package dev.mi6e4ka.openstore.internal.installer
|
||||
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
|
||||
class UninstallerEventFlow() {
|
||||
private val _events = Channel<Unit>(Channel.BUFFERED)
|
||||
val events = _events.receiveAsFlow()
|
||||
|
||||
fun trigger() {
|
||||
_events.trySend(Unit)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package dev.mi6e4ka.openstore.ui.components
|
||||
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.SubcomposeAsyncImage
|
||||
import dev.mi6e4ka.openstore.R
|
||||
|
||||
@Composable
|
||||
fun AppIcon(
|
||||
imageUrl: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
SubcomposeAsyncImage(
|
||||
model = imageUrl,
|
||||
contentDescription = "Icon",
|
||||
modifier = modifier,
|
||||
loading = {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
},
|
||||
error = {
|
||||
Icon(
|
||||
modifier = Modifier.size(24.dp),
|
||||
painter = painterResource(R.drawable.ic_broken_image_24px),
|
||||
contentDescription = "Error"
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
175
app/src/main/java/dev/mi6e4ka/openstore/ui/components/Gallery.kt
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
package dev.mi6e4ka.openstore.ui.components
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.hideFromAccessibility
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import coil.compose.AsyncImage
|
||||
import coil.compose.rememberAsyncImagePainter
|
||||
import dev.mi6e4ka.openstore.data.model.Files
|
||||
|
||||
@Composable
|
||||
fun GalleryWithPager(images: List<Files>) {
|
||||
var selectedImageIndex by remember { mutableStateOf<Int?>(null) }
|
||||
|
||||
if (selectedImageIndex != null) {
|
||||
Dialog(
|
||||
onDismissRequest = { selectedImageIndex = null },
|
||||
properties = DialogProperties(usePlatformDefaultWidth = false)
|
||||
) {
|
||||
FullScreenGallery(
|
||||
images = images,
|
||||
initialIndex = selectedImageIndex ?: 0,
|
||||
onDismiss = { selectedImageIndex = null }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Box(
|
||||
modifier = Modifier.height(250.dp)
|
||||
) {
|
||||
LazyRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.clearAndSetSemantics{}
|
||||
) {
|
||||
itemsIndexed(images) { i, file ->
|
||||
var isLoading by remember { mutableStateOf(true) }
|
||||
AsyncImage(
|
||||
model = file.fileUrl,
|
||||
contentDescription = null,
|
||||
onSuccess = { isLoading = false },
|
||||
onError = { isLoading = false },
|
||||
onLoading = { isLoading = true },
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.fillMaxHeight()
|
||||
.clickable(onClick = {
|
||||
selectedImageIndex = i
|
||||
}),
|
||||
contentScale = ContentScale.FillHeight
|
||||
)
|
||||
if (isLoading) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.fillMaxHeight()
|
||||
.aspectRatio(9f / 16f),
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun FullScreenGallery(
|
||||
images: List<Files>,
|
||||
initialIndex: Int,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
val pagerState = rememberPagerState(initialPage = initialIndex, pageCount = { images.size })
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
.clickable(onClick = onDismiss),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
//contentPadding = PaddingValues(horizontal = 16.dp),
|
||||
) { page ->
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
// .padding(horizontal = ((
|
||||
// (pagerState.currentPage - page) + pagerState
|
||||
// .currentPageOffsetFraction
|
||||
// ).absoluteValue * 0).dp)
|
||||
// .graphicsLayer {
|
||||
// val pageOffset = (
|
||||
// (pagerState.currentPage - page) + pagerState
|
||||
// .currentPageOffsetFraction
|
||||
// ).absoluteValue
|
||||
// alpha = lerp(
|
||||
// start = 0.5f,
|
||||
// stop = 1f,
|
||||
// fraction = 1f - pageOffset.coerceIn(0f, 1f)
|
||||
// )
|
||||
// }
|
||||
) {
|
||||
Image(
|
||||
painter = rememberAsyncImagePainter(images[page].fileUrl),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.clickable(onClick = onDismiss),
|
||||
contentScale = ContentScale.Fit
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
Modifier
|
||||
.wrapContentHeight()
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 16.dp),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
repeat(pagerState.pageCount) { iteration ->
|
||||
val color = if (pagerState.currentPage == iteration) MaterialTheme.colorScheme.onPrimaryContainer else MaterialTheme.colorScheme.primaryContainer
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.clip(CircleShape)
|
||||
.background(color)
|
||||
.size(8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,718 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.details
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.LinearOutSlowInEasing
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.systemBarsPadding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.AssistChip
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.FilledTonalIconButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.di.AppModule
|
||||
import dev.mi6e4ka.openstore.internal.installer.ApkInstaller
|
||||
import dev.mi6e4ka.openstore.ui.components.AppIcon
|
||||
import dev.mi6e4ka.openstore.ui.components.GalleryWithPager
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.datetime.LocalDateTime
|
||||
import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.format
|
||||
import kotlinx.datetime.format.FormatStringsInDatetimeFormats
|
||||
import kotlinx.datetime.format.byUnicodePattern
|
||||
import kotlinx.datetime.toLocalDateTime
|
||||
import android.Manifest
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.Instant
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class,
|
||||
FormatStringsInDatetimeFormats::class, ExperimentalTime::class
|
||||
)
|
||||
@Composable
|
||||
fun DetailsScreen(
|
||||
itemId: String,
|
||||
appPlatform: String,
|
||||
navController: NavController = rememberNavController()
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val apkInstaller = ApkInstaller(context)
|
||||
|
||||
//val viewModel = remember (itemId) { DetailsViewModel(itemId, apkInstaller) }
|
||||
val viewModel : DetailsViewModel = viewModel(
|
||||
factory = DetailsViewModelFactory(appPlatform, apkInstaller)
|
||||
)
|
||||
val state by viewModel.state.collectAsState()
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
var showAppDescriptionSheet by remember { mutableStateOf(false) }
|
||||
var showHashDetails by remember { mutableStateOf(false) }
|
||||
// val appDescriptionSheetState = rememberModalBottomSheetState(
|
||||
// skipPartiallyExpanded = true
|
||||
// )
|
||||
|
||||
val permissionLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.RequestPermission(),
|
||||
onResult = { isGranted ->
|
||||
if (isGranted) {
|
||||
viewModel.downloadFileToFolder(context)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
LaunchedEffect(itemId) {
|
||||
viewModel.loadDetails(context, itemId)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
AppModule.uninstallerEventFlow.events.collect {
|
||||
viewModel.updateInstallStatus(false)
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = { TopAppBar(
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back_button_desc)
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(
|
||||
{
|
||||
scope.launch {
|
||||
viewModel.copyTextToCB(context, state.plainApkUrl ?: "")
|
||||
}
|
||||
}
|
||||
){
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_link_24px),
|
||||
stringResource(R.string.copy_link_desc)
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
{
|
||||
scope.launch {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
viewModel.downloadFileToFolder(context)
|
||||
} else {
|
||||
val permissionStatus = ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
|
||||
viewModel.downloadFileToFolder(context)
|
||||
} else {
|
||||
permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
){
|
||||
Icon(
|
||||
painterResource(R.drawable.apk_install_24px),
|
||||
stringResource(R.string.download_apk_desc)
|
||||
)
|
||||
}
|
||||
IconButton(onClick = {
|
||||
val intent = Intent(Intent.ACTION_VIEW, "https://www.rustore.ru/catalog/app/${state.item?.packageName ?: ""}".toUri()).apply {
|
||||
addCategory(Intent.CATEGORY_BROWSABLE)
|
||||
setSelector(Intent(Intent.ACTION_VIEW, "http://".toUri()))
|
||||
}
|
||||
context.startActivity(intent)
|
||||
}, enabled = state.item != null) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_captive_portal_24px),
|
||||
stringResource(R.string.open_in_browser_desc)
|
||||
)
|
||||
}
|
||||
}
|
||||
) }
|
||||
) {
|
||||
innerPadding ->
|
||||
Column(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)) {
|
||||
if (showAppDescriptionSheet) {
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = {showAppDescriptionSheet = false},
|
||||
Modifier.systemBarsPadding()
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Text(stringResource(R.string.about_app), fontWeight = FontWeight.Bold, fontSize = 18.sp)
|
||||
Text(state.item?.fullDescription ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.invalidDownloadedApkFiles != null) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { viewModel.clearInvalidDownloadState() },
|
||||
title = { Text(stringResource(R.string.invalid_download_hash_title)) },
|
||||
text = {
|
||||
Column {
|
||||
Text(stringResource(R.string.invalid_download_hash_message))
|
||||
Spacer(modifier = Modifier.size(12.dp))
|
||||
TextButton(onClick = { showHashDetails = !showHashDetails }) {
|
||||
Text(stringResource(R.string.show_hashes))
|
||||
}
|
||||
if (showHashDetails) {
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
Text(stringResource(R.string.expected_hash, state.invalidExpectedHash ?: ""))
|
||||
Text(stringResource(R.string.actual_hash, state.invalidActualHash ?: ""))
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = { viewModel.retryDownloadAfterInvalid(context) }) {
|
||||
Text(stringResource(R.string.download_again))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { viewModel.installAsIsAfterInvalid(context) }) {
|
||||
Text(stringResource(R.string.install_as_is))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
if (state.isLoading) {
|
||||
LinearProgressIndicator(modifier = Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.fillMaxWidth())
|
||||
} else if (state.error != null) {
|
||||
Text(stringResource(R.string.error_message, state.error!!), modifier = Modifier.padding(16.dp))
|
||||
} else {
|
||||
val item = state.item
|
||||
if (item != null) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(horizontal = 16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = if (item.aggregatorInfo == null)
|
||||
Color(0, 255, 0, 35)
|
||||
else Color(255, 187, 0, 35)),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = {
|
||||
val intent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
"https://codeberg.org/mi6e4ka/openstore/src/branch/main/SAFETY.md".toUri()
|
||||
)
|
||||
context.startActivity(intent)
|
||||
})
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(15.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_security_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
if (item.aggregatorInfo != null) {
|
||||
Text(stringResource(R.string.provided_by_third_party, item.aggregatorInfo.source))
|
||||
} else {
|
||||
Text(stringResource(R.string.provided_by_developer))
|
||||
}
|
||||
}
|
||||
}
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(92.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
val animatedSize by animateDpAsState(
|
||||
targetValue = if (state.isDownloading) 80.dp else 92.dp,
|
||||
animationSpec = tween(durationMillis = 500, easing = FastOutSlowInEasing),
|
||||
label = "sizeAnimation"
|
||||
)
|
||||
val animatedCorner by animateDpAsState(
|
||||
targetValue = if (state.isDownloading) 80.dp / 2 else 12.dp,
|
||||
animationSpec = spring(dampingRatio = 0.6f),
|
||||
label = "cornerAnimation"
|
||||
)
|
||||
if (state.installStatus is InstallStatus.Pending || state.downloadTotalBytes.toInt() == 0) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier
|
||||
.size(128.dp)
|
||||
.alpha(if (state.isDownloading) 1f else 0f),
|
||||
strokeWidth = 3.dp
|
||||
)
|
||||
} else {
|
||||
CircularProgressIndicator(
|
||||
progress = { state.downloadProgress / 100f },
|
||||
modifier = Modifier
|
||||
.size(128.dp)
|
||||
.alpha(if (state.isDownloading) 1f else 0f),
|
||||
strokeWidth = 3.dp
|
||||
)
|
||||
}
|
||||
AppIcon(
|
||||
item.iconUrl, modifier = Modifier
|
||||
.size(animatedSize)
|
||||
.clip(RoundedCornerShape(animatedCorner))
|
||||
)
|
||||
}
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(item.appName, fontSize = 24.sp, fontWeight = FontWeight.Bold, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
Text(item.aggregatorInfo?.companyName ?: item.companyName, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.clearAndSetSemantics(){contentDescription = "Разработчик: ${item.aggregatorInfo?.companyName ?: item.companyName}"})
|
||||
}
|
||||
}
|
||||
if (!state.isSupported) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(painterResource(R.drawable.ic_warning_24px), null, tint = MaterialTheme.colorScheme.error, modifier = Modifier.size(22.dp))
|
||||
Text(stringResource(R.string.device_unsupported), color = MaterialTheme.colorScheme.error)
|
||||
}
|
||||
}
|
||||
if (state.isInstalled && state.isNeedUpgrade &&
|
||||
state.installerPackageName != context.packageName &&
|
||||
state.installerPackageName != "ru.vk.store") {
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Row(
|
||||
Modifier.padding(12.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(painterResource(R.drawable.ic_warning_24px), null, tint = MaterialTheme.colorScheme.onPrimaryContainer)
|
||||
Text(
|
||||
stringResource(R.string.signature_mismatch_warning),
|
||||
fontSize = 16.sp
|
||||
//color = MaterialTheme.colorScheme.onPrimaryContainer
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (!state.isInstalled || state.isDownloading) {
|
||||
Button(onClick = {
|
||||
viewModel.downloadAndInstallApp(context)
|
||||
}, modifier = Modifier.weight(1f), enabled = !state.isDownloading && state.isSupported) {
|
||||
if (state.installStatus is InstallStatus.Pending) {
|
||||
Text(stringResource(R.string.installing))
|
||||
} else if (state.isDownloading) {
|
||||
if (state.downloadTotalBytes.toInt() != 0) {
|
||||
Text(stringResource(R.string.downloading, " ${state.downloadCurrentBytes / 1024 / 1024}/${state.downloadTotalBytes / 1024 / 1024}МБ"))
|
||||
} else {
|
||||
Text(stringResource(R.string.downloading, ""))
|
||||
}
|
||||
} else {
|
||||
Text(stringResource(R.string.install_button))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FilledTonalButton(onClick = {
|
||||
viewModel.deleteApplication(context, itemId)
|
||||
}, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.uninstall)) }
|
||||
|
||||
if (state.isNeedUpgrade) {
|
||||
Button(onClick = {
|
||||
viewModel.downloadAndInstallApp(context)
|
||||
}, modifier = Modifier.weight(1f), enabled = state.isSupported) { Text(stringResource(R.string.update)) }
|
||||
|
||||
CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) {
|
||||
FilledTonalIconButton(onClick = {
|
||||
viewModel.runApplication(context, itemId)
|
||||
}, modifier = Modifier.size(40.dp)) {
|
||||
Icon(painterResource(R.drawable.ic_open_in_browser_24px), contentDescription = stringResource(R.string.open))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Button(onClick = {
|
||||
viewModel.runApplication(context, itemId)
|
||||
}, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.open)) }
|
||||
}
|
||||
}
|
||||
if (state.isDownloading) {
|
||||
CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) {
|
||||
FilledTonalIconButton(onClick = {
|
||||
viewModel.cancelDownload()
|
||||
}, enabled = state.installStatus != InstallStatus.Pending, modifier = Modifier.size(40.dp)) {
|
||||
Icon(painterResource(R.drawable.ic_close_24px), null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.horizontalScroll(rememberScrollState())
|
||||
.padding(bottom = 4.dp, top = 2.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
AssistChip(
|
||||
label = {
|
||||
Text("%.1f MB".format(
|
||||
(state.appFiles?.sumOf { it.size } ?: 0L) / 1024.0 / 1024.0)
|
||||
)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_upload_file_24px),
|
||||
stringResource(R.string.app_size_desc)
|
||||
)},
|
||||
onClick = {},
|
||||
)
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = {Text(item.versionName)},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_arrow_circle_up_24px),
|
||||
stringResource(R.string.latest_version_desc)
|
||||
)}
|
||||
)
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = {FormattedDateText(item.appVerUpdatedAt)},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_update_24px),
|
||||
stringResource(R.string.last_update_desc)
|
||||
)}
|
||||
)
|
||||
var detailedApiVersion by remember { mutableStateOf(false) }
|
||||
AssistChip(
|
||||
onClick = {
|
||||
detailedApiVersion = !detailedApiVersion
|
||||
},
|
||||
label = {
|
||||
if (!detailedApiVersion) {
|
||||
Text("Android ${getAndroidVersion(item.minSdkVersion)} +")
|
||||
} else {
|
||||
Text("API ${item.minSdkVersion} +")
|
||||
}
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_android_24px),
|
||||
stringResource(R.string.min_api_desc)
|
||||
)}
|
||||
)
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = {Text(if ((state.appFiles?.size ?: 1) > 1) "${state.appFiles?.size} Split APKs" else "APK")},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_adb_24px),
|
||||
stringResource(R.string.installer_type_desc)
|
||||
)}
|
||||
)
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = {Text(item.roundedDownloadsText)},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_download_24px),
|
||||
stringResource(R.string.downloads_desc)
|
||||
)}
|
||||
)
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = {Text(item.ageLegal)},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_supervised_user_circle_24px),
|
||||
stringResource(R.string.age_legal_desc)
|
||||
)}
|
||||
)
|
||||
}
|
||||
GalleryWithPager(item.fileUrls)
|
||||
}
|
||||
var isWhatsNewExpanded by remember { mutableStateOf(false) }
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.combinedClickable(
|
||||
onClick = {isWhatsNewExpanded = !isWhatsNewExpanded},
|
||||
onLongClick = {
|
||||
viewModel.copyTextToCB(context, item.whatsNew)
|
||||
}
|
||||
),
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.padding(16.dp)
|
||||
.animateContentSize(
|
||||
animationSpec = tween(
|
||||
durationMillis = 300,
|
||||
easing = LinearOutSlowInEasing
|
||||
)
|
||||
)
|
||||
) {
|
||||
Row {
|
||||
Text(stringResource(R.string.whats_new), fontWeight = FontWeight.Bold, fontSize = 18.sp)
|
||||
}
|
||||
|
||||
Text(item.whatsNew, maxLines = if (isWhatsNewExpanded) Int.MAX_VALUE else 4, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
Column(
|
||||
Modifier
|
||||
.padding(bottom = 8.dp)
|
||||
.clickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = null
|
||||
) {
|
||||
showAppDescriptionSheet = true
|
||||
}
|
||||
) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(stringResource(R.string.about_app), fontWeight = FontWeight.Bold, fontSize = 18.sp)
|
||||
IconButton(onClick = {showAppDescriptionSheet = true}) {
|
||||
Icon(painterResource(R.drawable.ic_arrow_forward_24px), contentDescription = null)
|
||||
}
|
||||
}
|
||||
Text(text = item.shortDescription)
|
||||
}
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = {
|
||||
navController.navigate("app/${item.packageName}/reviews") {
|
||||
restoreState = true
|
||||
}
|
||||
})
|
||||
.clearAndSetSemantics {
|
||||
contentDescription = context.getString(
|
||||
R.string.reviews_desc,
|
||||
state.rating?.averageUserRating ?: 0,
|
||||
state.rating?.totalRatings ?: 0
|
||||
)
|
||||
}
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 20.dp, end = 20.dp, top = 16.dp, bottom = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(stringResource(R.string.rating_and_reviews), fontWeight = FontWeight.Bold, fontSize = 18.sp)
|
||||
// FilledTonalIconButton(onClick = {}) {
|
||||
// Icon(imageVector = Icons.Rounded.ArrowForward, contentDescription = null)
|
||||
// }
|
||||
}
|
||||
Row(modifier = Modifier.padding(start = 20.dp, end = 20.dp, bottom = 16.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Column(
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("5", fontWeight = FontWeight.Bold)
|
||||
LinearProgressIndicator(progress = {
|
||||
((state.rating?.ratings?.amountFive ?: 0) / 100f)
|
||||
}, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("4", fontWeight = FontWeight.Bold)
|
||||
LinearProgressIndicator(progress = {
|
||||
((state.rating?.ratings?.amountFour ?: 0) / 100f)
|
||||
}, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("3", fontWeight = FontWeight.Bold)
|
||||
LinearProgressIndicator(progress = {
|
||||
((state.rating?.ratings?.amountThree ?: 0) / 100f)
|
||||
}, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("2", fontWeight = FontWeight.Bold)
|
||||
LinearProgressIndicator(progress = {
|
||||
((state.rating?.ratings?.amountTwo ?: 0) / 100f)
|
||||
}, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("1", fontWeight = FontWeight.Bold)
|
||||
LinearProgressIndicator(progress = {
|
||||
((state.rating?.ratings?.amountOne ?: 0) / 100f)
|
||||
}, modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.padding(start=24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("${state.rating?.averageUserRating ?: "?"}", fontWeight = FontWeight.Bold, fontSize = 24.sp)
|
||||
Text("${state.rating?.totalRatings ?: "?"}", fontSize = 16.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
Column(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(item.packageName, color = Color.Gray, fontSize = 14.sp)
|
||||
}
|
||||
//Spacer(Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalTime::class, FormatStringsInDatetimeFormats::class)
|
||||
@Composable
|
||||
fun FormattedDateText(dateString: String) {
|
||||
val formattedDate = remember(dateString) {
|
||||
try {
|
||||
Instant.parse(dateString)
|
||||
.toLocalDateTime(TimeZone.currentSystemDefault())
|
||||
.format(LocalDateTime.Format { byUnicodePattern("dd.MM.yyyy") })
|
||||
} catch (e: Exception) {
|
||||
"..."
|
||||
}
|
||||
}
|
||||
|
||||
Text(text = formattedDate)
|
||||
}
|
||||
|
||||
fun getAndroidVersion(apiLevel: Int): String {
|
||||
val versions = mapOf(
|
||||
1 to "1.0",
|
||||
2 to "1.1",
|
||||
3 to "1.5",
|
||||
4 to "1.6",
|
||||
5 to "2.0",
|
||||
6 to "2.0.1",
|
||||
7 to "2.1",
|
||||
8 to "2.2",
|
||||
9 to "2.3",
|
||||
10 to "2.3.3",
|
||||
11 to "3.0",
|
||||
12 to "3.1",
|
||||
13 to "3.2",
|
||||
14 to "4.0",
|
||||
15 to "4.0.3",
|
||||
16 to "4.1",
|
||||
17 to "4.2",
|
||||
18 to "4.3",
|
||||
19 to "4.4",
|
||||
20 to "4.4W", // Wear
|
||||
21 to "5.0",
|
||||
22 to "5.1",
|
||||
23 to "6.0",
|
||||
24 to "7.0",
|
||||
25 to "7.1",
|
||||
26 to "8.0",
|
||||
27 to "8.1",
|
||||
28 to "9.0",
|
||||
29 to "10",
|
||||
30 to "11",
|
||||
31 to "12",
|
||||
32 to "12L", // Android 12L
|
||||
33 to "13",
|
||||
34 to "14",
|
||||
35 to "15",
|
||||
36 to "16",
|
||||
37 to "17"
|
||||
)
|
||||
|
||||
return versions[apiLevel] ?: "? (API $apiLevel)"
|
||||
}
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.details
|
||||
|
||||
import android.app.DownloadManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.data.model.AppRatingResponseBody
|
||||
import dev.mi6e4ka.openstore.data.model.DownloadLinkResponseItem
|
||||
import dev.mi6e4ka.openstore.data.model.ItemDetails
|
||||
import dev.mi6e4ka.openstore.di.AppModule
|
||||
import dev.mi6e4ka.openstore.internal.installer.ApkInstaller
|
||||
import dev.mi6e4ka.openstore.internal.installer.PackageInstallerStatusReceiver
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import androidx.core.net.toUri
|
||||
|
||||
data class DetailsState(
|
||||
val isLoading: Boolean = true,
|
||||
val item: ItemDetails? = null,
|
||||
val rating: AppRatingResponseBody? = null,
|
||||
val error: String? = null,
|
||||
val appFiles: List<DownloadLinkResponseItem>? = null,
|
||||
val plainApkUrl: String? = null,
|
||||
val splitOnly: Boolean? = null,
|
||||
val installStatus: InstallStatus = InstallStatus.Idle,
|
||||
val isDownloading: Boolean = false,
|
||||
val downloadProgress: Int = 0,
|
||||
val downloadCurrentBytes: Long = 0,
|
||||
val downloadTotalBytes: Long = 0,
|
||||
val isInstalled: Boolean = false,
|
||||
val isNeedUpgrade: Boolean = false,
|
||||
val isSupported: Boolean = true,
|
||||
val installerPackageName: String? = null,
|
||||
val invalidDownloadedApkFiles: List<File>? = null,
|
||||
val invalidDownloadMessage: String? = null,
|
||||
val invalidExpectedHash: String? = null,
|
||||
val invalidActualHash: String? = null
|
||||
)
|
||||
|
||||
sealed class InstallStatus {
|
||||
object Idle : InstallStatus()
|
||||
object Pending : InstallStatus()
|
||||
object Success : InstallStatus()
|
||||
}
|
||||
|
||||
class DetailsViewModel(private val appPlatform: String, private val apkInstaller: ApkInstaller) : ViewModel() {
|
||||
private val _state = MutableStateFlow(DetailsState())
|
||||
val state: StateFlow<DetailsState> = _state.asStateFlow()
|
||||
private var cancelDownload: (() -> Unit)? = null
|
||||
|
||||
fun loadDetails(context: Context, itemId: String) {
|
||||
if (_state.value.item != null) {
|
||||
return
|
||||
}
|
||||
Log.d(null, "Initial loading")
|
||||
viewModelScope.launch {
|
||||
var item: ItemDetails? = null
|
||||
// основная информация о приложении
|
||||
try {
|
||||
item = AppModule.searchRepository.getItemDetails(itemId, appPlatform)
|
||||
//
|
||||
val packageInfo = getPackageInfo(context, itemId)
|
||||
val installer = if (packageInfo != null) getInstallSource(context.packageManager, itemId) else null
|
||||
|
||||
_state.value = DetailsState(
|
||||
isLoading = true,
|
||||
isInstalled = packageInfo != null,
|
||||
installerPackageName = installer
|
||||
)
|
||||
|
||||
if (packageInfo != null) {
|
||||
val installedVersionCode = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
packageInfo.longVersionCode
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
packageInfo.versionCode.toLong()
|
||||
})
|
||||
if (installedVersionCode < item.versionCode) {
|
||||
_state.update { it.copy(isNeedUpgrade = true) }
|
||||
}
|
||||
}
|
||||
//
|
||||
_state.update { it.copy(isSupported = Build.VERSION.SDK_INT >= item.minSdkVersion) }
|
||||
_state.update{ it.copy(item = item) }
|
||||
} catch (e: Exception) {
|
||||
_state.update { it.copy(error = e.message, isLoading = false) }
|
||||
}
|
||||
// пробуем получить все файлы приложения (включая split)
|
||||
try {
|
||||
if (item == null) return@launch
|
||||
val appFiles = AppModule.searchRepository.getAppFiles(item.appId, firstInstall = true, supportedAbis = Build.SUPPORTED_ABIS.toList(), withoutSplits = false, deviceType = appPlatform)
|
||||
_state.update{ it.copy(appFiles = appFiles) }
|
||||
} catch (e: Exception) {}
|
||||
// пробуем получить файлы приложения указав что нам не нужны split apk
|
||||
try {
|
||||
if (item == null) return@launch
|
||||
val singleApkUrl = AppModule.searchRepository.getAppFiles(item.appId, firstInstall = true, supportedAbis = Build.SUPPORTED_ABIS.toList(), withoutSplits = true, deviceType = appPlatform).firstOrNull()?.url
|
||||
_state.update{ it.copy(plainApkUrl = singleApkUrl, splitOnly = singleApkUrl == null) }
|
||||
} catch (e: Exception) {}
|
||||
// рейтинг
|
||||
try {
|
||||
val rating = AppModule.searchRepository.getAppRating(itemId)
|
||||
_state.update{ it.copy(rating = rating) }
|
||||
} catch (e: Exception) {}
|
||||
|
||||
_state.update { it.copy(isLoading = false) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstallSource(pm: PackageManager, packageName: String): String? {
|
||||
return try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
pm.getInstallSourceInfo(packageName).installingPackageName
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
pm.getInstallerPackageName(packageName)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadAndInstallApp(context: Context) {
|
||||
viewModelScope.launch {
|
||||
_state.update { it.copy(isDownloading = true, downloadProgress = 0, downloadTotalBytes = 0, downloadCurrentBytes = 0) }
|
||||
Log.d(null, "download apk " + state.value.appFiles)
|
||||
cancelDownload = apkInstaller.downloadFilesWithProgress(
|
||||
state.value.appFiles!!,
|
||||
onProgress = { percent, downloaded, total ->
|
||||
_state.update { it.copy(downloadProgress = percent, downloadCurrentBytes = downloaded, downloadTotalBytes = total) }
|
||||
},
|
||||
onSuccess = { apkFiles ->
|
||||
installApp(context, apkFiles)
|
||||
},
|
||||
onError = { error ->
|
||||
if (error.message?.contains("timeout") == true) {
|
||||
Toast.makeText(context, R.string.timeout, Toast.LENGTH_SHORT).show()
|
||||
} else if (error.message?.contains("Failed to allocate") == true) {
|
||||
Toast.makeText(context, R.string.insufficient_memory, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, R.string.loading_error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
_state.update { it.copy(isDownloading = false) }
|
||||
},
|
||||
onCancel = {
|
||||
_state.update { it.copy(isDownloading = false) }
|
||||
},
|
||||
onInvalidHash = { apkFiles, expectedHash, actualHash ->
|
||||
_state.update {
|
||||
it.copy(
|
||||
isDownloading = false,
|
||||
invalidDownloadedApkFiles = apkFiles,
|
||||
invalidDownloadMessage = "Файл скачан некорректно.",
|
||||
invalidExpectedHash = expectedHash,
|
||||
invalidActualHash = actualHash
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelDownload() {
|
||||
cancelDownload?.invoke()
|
||||
cancelDownload = null
|
||||
}
|
||||
|
||||
private fun installApp(context: Context, apkFiles: List<File>) {
|
||||
val packageName = state.value.item?.packageName ?: "tmp"
|
||||
_state.update { it.copy(installStatus = InstallStatus.Pending) }
|
||||
|
||||
apkInstaller.installApp(
|
||||
packageName = packageName,
|
||||
apkFiles = apkFiles,
|
||||
onSessionFinished = { success ->
|
||||
_state.update { it.copy(installStatus = InstallStatus.Success, isDownloading = false)}
|
||||
if (success) {
|
||||
_state.update { it.copy(isInstalled = true, isNeedUpgrade = false, installerPackageName = context.packageName) }
|
||||
apkInstaller.cleanApkFiles(apkFiles.map {it.name})
|
||||
}
|
||||
},
|
||||
onError = { error ->
|
||||
if (error.message?.contains("Failed to allocate") == true) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.insufficient_memory,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
println("apk installer $error")
|
||||
Toast.makeText(context, R.string.installing_error, Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
installStatus = InstallStatus.Idle,
|
||||
isDownloading = false
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun retryDownloadAfterInvalid(context: Context) {
|
||||
_state.update {
|
||||
it.copy(
|
||||
invalidDownloadedApkFiles = null,
|
||||
invalidDownloadMessage = null,
|
||||
invalidExpectedHash = null,
|
||||
invalidActualHash = null
|
||||
)
|
||||
}
|
||||
downloadAndInstallApp(context)
|
||||
}
|
||||
|
||||
fun installAsIsAfterInvalid(context: Context) {
|
||||
val apkFiles = state.value.invalidDownloadedApkFiles ?: return
|
||||
_state.update {
|
||||
it.copy(
|
||||
invalidDownloadedApkFiles = null,
|
||||
invalidDownloadMessage = null,
|
||||
invalidExpectedHash = null,
|
||||
invalidActualHash = null
|
||||
)
|
||||
}
|
||||
installApp(context, apkFiles)
|
||||
}
|
||||
|
||||
fun clearInvalidDownloadState() {
|
||||
_state.update {
|
||||
it.copy(
|
||||
invalidDownloadedApkFiles = null,
|
||||
invalidDownloadMessage = null,
|
||||
invalidExpectedHash = null,
|
||||
invalidActualHash = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPackageInfo(context: Context, packageName: String): PackageInfo? {
|
||||
Log.d(null, "try to check package $packageName")
|
||||
return try {
|
||||
val packageInfo : PackageInfo
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
packageInfo = context.packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0))
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
packageInfo = context.packageManager.getPackageInfo(packageName, 0)
|
||||
}
|
||||
Log.d(null, "try")
|
||||
packageInfo
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
Log.d(null, "false")
|
||||
null
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
fun runApplication(context: Context, packageName: String) {
|
||||
val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName)
|
||||
if (launchIntent != null) {
|
||||
context.startActivity(launchIntent)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.failed_to_open_app, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
fun deleteApplication(context: Context, packageName: String) {
|
||||
val intent = Intent(context, PackageInstallerStatusReceiver::class.java)
|
||||
intent.putExtra(PackageInstallerStatusReceiver.ACTION_UNINSTALL, true)
|
||||
val pendingIntent = PendingIntent.getBroadcast(context, -1, intent, PendingIntent.FLAG_MUTABLE)
|
||||
context.packageManager.packageInstaller.uninstall(packageName, pendingIntent.intentSender)
|
||||
}
|
||||
|
||||
fun updateInstallStatus(isInstalled: Boolean) {
|
||||
_state.update { it.copy(isInstalled = isInstalled, installerPackageName = if (isInstalled) it.installerPackageName else null) }
|
||||
}
|
||||
|
||||
fun downloadFileToFolder(context: Context) {
|
||||
val fileName = "${state.value.item?.packageName}-${state.value.item?.versionName}.apk"
|
||||
val request = DownloadManager.Request(state.value.plainApkUrl?.toUri())
|
||||
.setTitle(fileName)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setMimeType("application/vnd.android.package-archive")
|
||||
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
|
||||
|
||||
val downloadManager = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
context.getSystemService(DownloadManager::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||
}
|
||||
downloadManager.enqueue(request)
|
||||
Toast.makeText(context, R.string.download_has_started, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
fun copyTextToCB(context: Context, text: String) {
|
||||
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("", text)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
Toast.makeText(context, R.string.copied_to_buffer, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DetailsViewModelFactory(
|
||||
private val itemId: String,
|
||||
private val apkInstaller: ApkInstaller
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(DetailsViewModel::class.java)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return DetailsViewModel(itemId, apkInstaller) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.results
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.hideFromAccessibility
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.paging.LoadState
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import androidx.paging.compose.itemKey
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.ui.components.AppIcon
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ResultsScreen(
|
||||
query: String,
|
||||
navController: NavController = rememberNavController(),
|
||||
) {
|
||||
val viewModel : ResultsViewModel = viewModel(
|
||||
factory = ResultsViewModelFactory(query)
|
||||
)
|
||||
|
||||
val resultsLazyPaging = viewModel.searchFlow.collectAsLazyPagingItems()
|
||||
var platformSelectorExpanded by remember { mutableStateOf(false) }
|
||||
val state by viewModel.state.collectAsState()
|
||||
Scaffold(
|
||||
topBar = { TopAppBar(
|
||||
title = {Text(stringResource(R.string.search_title))},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back_button_desc)
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
val platforms = remember {
|
||||
listOf(
|
||||
Platform(R.string.mobile_label, "mobile", R.drawable.ic_mobile_24px),
|
||||
Platform(R.string.tv_label, "tv", R.drawable.ic_tv_gen_24px)
|
||||
)
|
||||
}
|
||||
|
||||
TextButton({platformSelectorExpanded = true}) {
|
||||
Icon(
|
||||
painterResource(state.selectedPlatform.icon),
|
||||
contentDescription = stringResource(R.string.tts_current_platform)
|
||||
)
|
||||
Spacer(Modifier.size(8.dp))
|
||||
Text(stringResource(state.selectedPlatform.label))
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = platformSelectorExpanded,
|
||||
onDismissRequest = {platformSelectorExpanded = false}
|
||||
) {
|
||||
platforms.forEach {
|
||||
DropdownMenuItem(
|
||||
leadingIcon = {Icon(painterResource(it.icon), null)},
|
||||
text = { Text(stringResource(it.label)) },
|
||||
onClick = { viewModel.selectPlatform(it); platformSelectorExpanded=false }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
) }
|
||||
) { innerPadding ->
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(horizontal = 16.dp).fillMaxSize().padding(innerPadding),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(
|
||||
resultsLazyPaging.itemCount,
|
||||
key = resultsLazyPaging.itemKey { it.appId }
|
||||
) { index ->
|
||||
val app = resultsLazyPaging[index]
|
||||
if (app != null) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = { navController.navigate("app/${app.packageName}?platform=${state.selectedPlatform.value}") })
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
AppIcon(app.iconUrl, modifier = Modifier.size(60.dp).clip(RoundedCornerShape(16.dp)))
|
||||
Column(
|
||||
modifier = Modifier.weight(1f).padding(start = 16.dp,end = 4.dp)
|
||||
) {
|
||||
Text(text = app.appName, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
text = app.packageName,
|
||||
fontSize = 14.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
modifier = Modifier.semantics{
|
||||
hideFromAccessibility()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text(stringResource(R.string.loading_error))
|
||||
}
|
||||
}
|
||||
resultsLazyPaging.apply {
|
||||
when {
|
||||
loadState.refresh is LoadState.Loading -> {
|
||||
item {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
}
|
||||
loadState.append is LoadState.Loading -> {
|
||||
item {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
}
|
||||
loadState.refresh is LoadState.Error -> {
|
||||
if (loadState.refresh is LoadState.Error) {
|
||||
item {
|
||||
Box(
|
||||
Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(20.dp)) {
|
||||
Text(stringResource(R.string.error), fontWeight = FontWeight.Bold, fontSize = 22.sp)
|
||||
Icon(painterResource(R.drawable.pest_control_24px), null, Modifier.size(62.dp))
|
||||
Text("${(loadState.refresh as LoadState.Error).error}", modifier = Modifier.padding(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resultsLazyPaging.itemCount == 0 && resultsLazyPaging.loadState.isIdle) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(bottom = 56.dp)
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(painterResource(R.drawable.ic_search_24px), "", modifier = Modifier.size(64.dp))
|
||||
Spacer(Modifier.size(4.dp))
|
||||
Text(stringResource(R.string.not_found_error))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.results
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.paging.PagingData
|
||||
import androidx.paging.cachedIn
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.data.model.SearchResult
|
||||
import dev.mi6e4ka.openstore.di.AppModule
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.update
|
||||
|
||||
data class Platform(
|
||||
val label: Int,
|
||||
val value: String,
|
||||
val icon: Int
|
||||
)
|
||||
data class ResultsState(
|
||||
val selectedPlatform: Platform = Platform(R.string.mobile_label, "mobile", R.drawable.ic_mobile_24px),
|
||||
)
|
||||
|
||||
class ResultsViewModel(private val query: String) : ViewModel() {
|
||||
private val _state = MutableStateFlow(ResultsState())
|
||||
val state: StateFlow<ResultsState> = _state.asStateFlow()
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
val searchFlow: Flow<PagingData<SearchResult>> = state.flatMapLatest {
|
||||
AppModule.searchRepository.search(query, it.selectedPlatform.value).flow
|
||||
}.cachedIn(viewModelScope)
|
||||
|
||||
fun selectPlatform(newPlatform: Platform) {
|
||||
_state.update { it.copy(selectedPlatform = newPlatform) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ResultsViewModelFactory(
|
||||
private val query: String
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(ResultsViewModel::class.java)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return ResultsViewModel(query) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.reviews
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.data.model.AppCommentsComments
|
||||
import dev.mi6e4ka.openstore.di.AppModule
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
enum class ReviewsFilters(val value: String, @param:StringRes val displayStringResource: Int) {
|
||||
NewFirst("NEW_FIRST", R.string.new_first),
|
||||
UsefulFirst("USEFUL_FIRST", R.string.useful_first),
|
||||
PositiveFirst("POSITIVE_FIRST", R.string.positive_first),
|
||||
NegativeFirst("NEGATIVE_FIRST", R.string.negative_first)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ReviewsScreen(packageName: String, navController: NavController = rememberNavController()) {
|
||||
var reviews: List<AppCommentsComments>? by remember { mutableStateOf(null) }
|
||||
var selectedFilter by remember { mutableStateOf(ReviewsFilters.NewFirst) }
|
||||
var isLoading by remember { mutableStateOf(false) }
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
LaunchedEffect(selectedFilter) {
|
||||
scope.launch {
|
||||
isLoading = true
|
||||
reviews = listOf()
|
||||
reviews = try {
|
||||
AppModule.searchRepository.getAppComments(packageName, 50, selectedFilter.value)
|
||||
} catch (e: Exception) {
|
||||
listOf(AppCommentsComments(
|
||||
appRating = 1,
|
||||
firstName = "Семен",
|
||||
commentDate = "2025-08-30 10:25:20.000",
|
||||
commentText = "Не работает этот ваш опенстор, удаляю",
|
||||
likeCounter = 100,
|
||||
dislikeCounter = 1,
|
||||
updatedAt = "2025-08-30 10:25:20.000",
|
||||
devResponse = "",
|
||||
devResponseDate = "",
|
||||
))
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
topBar = { TopAppBar(
|
||||
title = {Text(stringResource(R.string.reviews_title))},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back_button_desc)
|
||||
)
|
||||
}
|
||||
},
|
||||
) },
|
||||
) { innerPadding ->
|
||||
Column(
|
||||
Modifier.padding(innerPadding).padding(horizontal = 16.dp)
|
||||
) {
|
||||
LazyColumn(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
item {
|
||||
Row(
|
||||
Modifier.horizontalScroll(rememberScrollState()),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
ReviewsFilters.entries.forEach { filter ->
|
||||
FilterChip(
|
||||
selected = filter == selectedFilter,
|
||||
onClick = { selectedFilter = filter },
|
||||
label = {Text(stringResource(filter.displayStringResource))},
|
||||
leadingIcon = if (selectedFilter == filter) {
|
||||
{ Icon(painterResource(R.drawable.ic_check_24px), contentDescription = null) }
|
||||
} else null
|
||||
)
|
||||
}
|
||||
}
|
||||
if ((reviews?.size ?: 0) == 0 && !isLoading) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
||||
Text(stringResource(R.string.no_reviews))
|
||||
}
|
||||
}
|
||||
if (isLoading) {
|
||||
LinearProgressIndicator(Modifier.fillMaxWidth())
|
||||
}
|
||||
}
|
||||
items(reviews ?: listOf()) { review ->
|
||||
Card(
|
||||
Modifier.fillMaxWidth().semantics(mergeDescendants = true){}
|
||||
) {
|
||||
Column(
|
||||
Modifier.padding(16.dp)
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
Text(review.firstName, fontWeight = FontWeight.Bold)
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(formatTimestamp(review.commentDate), color = Color.Gray)
|
||||
}
|
||||
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.clearAndSetSemantics{
|
||||
contentDescription = context.getString(R.string.review_rating_desc, review.appRating)
|
||||
}
|
||||
) {
|
||||
repeat(review.appRating) {
|
||||
Icon(painterResource(R.drawable.ic_star_filled_24px), null, Modifier.size(16.dp), tint = MaterialTheme.colorScheme.primary)
|
||||
}
|
||||
repeat(5 - review.appRating) {
|
||||
Icon(painterResource(R.drawable.ic_star_24px), null, Modifier.size(16.dp), tint = MaterialTheme.colorScheme.secondary)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(review.commentText)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(painterResource(R.drawable.ic_thumb_up_24px), contentDescription = stringResource(R.string.likes_desc), Modifier.size(20.dp), tint = MaterialTheme.colorScheme.secondary)
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Text("${review.likeCounter}")
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(painterResource(R.drawable.ic_thumb_down_24px), contentDescription = stringResource(R.string.dislikes_desc), Modifier.size(20.dp), tint = MaterialTheme.colorScheme.secondary)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text("${review.dislikeCounter}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun formatTimestamp(timestamp: String): String {
|
||||
val inputFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())
|
||||
val outputFormat = SimpleDateFormat("d MMMM yyyy", Locale.getDefault())
|
||||
|
||||
val date = inputFormat.parse(timestamp)
|
||||
return outputFormat.format(date ?: "")
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.search
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.verify.domain.DomainVerificationManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import dev.mi6e4ka.openstore.BuildConfig
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.ui.screen.results.Platform
|
||||
import java.net.URLEncoder
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SearchScreen(navController: NavController = rememberNavController()) {
|
||||
var search by remember { mutableStateOf("") }
|
||||
var isDomainsVerified by remember { mutableStateOf(true) }
|
||||
val context = LocalContext.current
|
||||
|
||||
OnResumeEffect {
|
||||
isDomainsVerified = true
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val manager = context.getSystemService(DomainVerificationManager::class.java)
|
||||
val states = manager.getDomainVerificationUserState(context.packageName)
|
||||
states?.hostToStateMap?.forEach { state ->
|
||||
Log.d("state", "$state")
|
||||
if (state.value != 1) {
|
||||
isDomainsVerified = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
topBar = { TopAppBar(
|
||||
title = {Text(stringResource(R.string.app_name))},
|
||||
actions = {
|
||||
IconButton(onClick = { navController.navigate("updates") }) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_update_24px),
|
||||
contentDescription = stringResource(R.string.updates_title)
|
||||
)
|
||||
}
|
||||
IconButton({navController.navigate("settings")}) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_settings_24px),
|
||||
contentDescription = stringResource(R.string.settings_title)
|
||||
)
|
||||
}
|
||||
}
|
||||
) },
|
||||
) { innerPadding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(innerPadding)
|
||||
.padding(horizontal = 15.dp)
|
||||
.imePadding()
|
||||
.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.SpaceBetween,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Column {
|
||||
if (!isDomainsVerified) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(0.dp)
|
||||
.height(50.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val intent = Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS)
|
||||
.apply { data = Uri.fromParts("package", context.packageName, null) }
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}),
|
||||
colors = CardDefaults.cardColors(containerColor = Color(109, 255, 30, 40))
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.padding(horizontal = 10.dp)
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_add_link_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
)
|
||||
Text(stringResource(R.string.unconfirmed_domains), fontSize = 18.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = search,
|
||||
onValueChange = {s -> search=s},
|
||||
leadingIcon = { Icon(painterResource(R.drawable.ic_search_24px), contentDescription = null) },
|
||||
modifier = Modifier.fillMaxWidth().semantics{
|
||||
contentDescription = context.getString(R.string.search_title)
|
||||
},
|
||||
singleLine = true,
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Search
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onSearch = {
|
||||
if (search.isNotBlank()) {
|
||||
navController.navigate("search/${URLEncoder.encode(search, "UTF-8")}")
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("source code", textDecoration = TextDecoration.Underline, modifier = Modifier.clickable(onClick = {
|
||||
val intent = Intent(Intent.ACTION_VIEW, "https://codeberg.org/mi6e4ka/openstore".toUri())
|
||||
context.startActivity(intent)
|
||||
}))
|
||||
Text(BuildConfig.VERSION_NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun OnResumeEffect(onResume: () -> Unit) {
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
val currentOnResume by rememberUpdatedState(onResume)
|
||||
|
||||
DisposableEffect(lifecycleOwner) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
currentOnResume()
|
||||
}
|
||||
}
|
||||
lifecycleOwner.lifecycle.addObserver(observer)
|
||||
onDispose {
|
||||
lifecycleOwner.lifecycle.removeObserver(observer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,407 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import androidx.core.content.edit
|
||||
|
||||
data class SettingsSection(
|
||||
val id: String,
|
||||
val title: Int,
|
||||
val description: Int?,
|
||||
val icon: Int,
|
||||
val type: ParamType,
|
||||
val defaultVal: String,
|
||||
val select: List<SettingsSectionSelect>? = null
|
||||
)
|
||||
|
||||
@SuppressLint("ModifierParameter")
|
||||
data class SettingsSectionSelect(
|
||||
val title: String,
|
||||
val value: String,
|
||||
val isGroup: Boolean = false,
|
||||
val groupPackages: List<String> = emptyList()
|
||||
)
|
||||
|
||||
enum class ParamType {
|
||||
SWITCH,
|
||||
SELECT,
|
||||
MULTI_SELECT
|
||||
}
|
||||
|
||||
@SuppressLint("ContextCastToActivity")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScreen(
|
||||
navController: NavController
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val dynamicSources = remember {
|
||||
getDynamicInstallerSources(context)
|
||||
}
|
||||
|
||||
val sections = listOf(
|
||||
SettingsSection(
|
||||
id = "installer_type",
|
||||
title = R.string.settings_installer_title,
|
||||
description = R.string.settings_installer_description,
|
||||
icon = R.drawable.apk_install_24px,
|
||||
type = ParamType.SELECT,
|
||||
defaultVal = "session",
|
||||
select = listOf(
|
||||
SettingsSectionSelect(
|
||||
title = "Session",
|
||||
value = "session"
|
||||
),
|
||||
SettingsSectionSelect(
|
||||
title = "Intent",
|
||||
value = "intent"
|
||||
)
|
||||
)
|
||||
),
|
||||
SettingsSection(
|
||||
id = "updates_sources",
|
||||
title = R.string.settings_updates_sources_title,
|
||||
description = R.string.settings_updates_sources_description,
|
||||
icon = R.drawable.ic_checklist_24px,
|
||||
type = ParamType.MULTI_SELECT,
|
||||
defaultVal = "dev.mi6e4ka.openstore;dev.mi6e4ka.openstore.nightly;dev.mi6e4ka.openstore.debug;ru.vk.store",
|
||||
select = dynamicSources
|
||||
),
|
||||
SettingsSection(
|
||||
id = "updates_check_all",
|
||||
title = R.string.settings_updates_check_all_title,
|
||||
description = R.string.settings_updates_check_all_description,
|
||||
icon = R.drawable.ic_arrow_shape_up_stack_2_24px,
|
||||
type = ParamType.SWITCH,
|
||||
defaultVal = ""
|
||||
),
|
||||
SettingsSection(
|
||||
id = "app_theme",
|
||||
title = R.string.settings_app_theme_title,
|
||||
description = null,
|
||||
icon = R.drawable.ic_brightness_6_24px,
|
||||
type = ParamType.SELECT,
|
||||
defaultVal = "auto",
|
||||
select = listOf(
|
||||
SettingsSectionSelect(
|
||||
title = context.getString(R.string.theme_auto_label),
|
||||
value = "auto"
|
||||
),
|
||||
SettingsSectionSelect(
|
||||
title = context.getString(R.string.theme_dark_label),
|
||||
value = "dark"
|
||||
),
|
||||
SettingsSectionSelect(
|
||||
title = context.getString(R.string.theme_light_label),
|
||||
value = "light"
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val activity = context as? Activity
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.settings_title)) },
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
{
|
||||
val popped = navController.popBackStack()
|
||||
if (!popped) {
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_arrow_back_24px),
|
||||
stringResource(R.string.back_button_desc)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
innerPadding ->
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize().padding(innerPadding)
|
||||
) {
|
||||
items(sections) { item ->
|
||||
SettingsCard(
|
||||
item = item
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDynamicInstallerSources(context: Context): List<SettingsSectionSelect> {
|
||||
val pm = context.packageManager
|
||||
val installedPackages = pm.getInstalledPackages(0)
|
||||
|
||||
val foundInstallers = installedPackages.map { pkg ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
try {
|
||||
pm.getInstallSourceInfo(pkg.packageName).installingPackageName
|
||||
} catch (e: Exception) { null }
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
pm.getInstallerPackageName(pkg.packageName)
|
||||
}
|
||||
}.toSet()
|
||||
|
||||
val result = mutableListOf<SettingsSectionSelect>()
|
||||
|
||||
result.add(SettingsSectionSelect(
|
||||
title = "RuStore/OpenStore",
|
||||
value = "group_openstore",
|
||||
isGroup = true,
|
||||
groupPackages = listOf(
|
||||
"dev.mi6e4ka.openstore",
|
||||
"dev.mi6e4ka.openstore.nightly",
|
||||
"dev.mi6e4ka.openstore.debug",
|
||||
"ru.vk.store"
|
||||
)
|
||||
))
|
||||
|
||||
result.add(SettingsSectionSelect(
|
||||
title = context.getString(R.string.settings_source_manual),
|
||||
value = "group_installers",
|
||||
isGroup = true,
|
||||
groupPackages = listOf(
|
||||
"com.google.android.packageinstaller",
|
||||
"com.android.packageinstaller"
|
||||
)
|
||||
))
|
||||
|
||||
result.add(SettingsSectionSelect(
|
||||
title = context.getString(R.string.settings_source_unknown),
|
||||
value = "null"
|
||||
))
|
||||
|
||||
val handledPackages = mutableSetOf<String?>()
|
||||
handledPackages.add(null)
|
||||
handledPackages.add("null")
|
||||
handledPackages.add("com.google.android.packageinstaller")
|
||||
handledPackages.add("com.android.packageinstaller")
|
||||
handledPackages.add("ru.vk.store")
|
||||
handledPackages.add(context.packageName)
|
||||
handledPackages.addAll(listOf("dev.mi6e4ka.openstore", "dev.mi6e4ka.openstore.nightly", "dev.mi6e4ka.openstore.debug"))
|
||||
|
||||
foundInstallers.filter { it !in handledPackages && it != null }.forEach { pkg ->
|
||||
val label = try {
|
||||
val info = pm.getApplicationInfo(pkg!!, 0)
|
||||
pm.getApplicationLabel(info).toString()
|
||||
} catch (e: Exception) {
|
||||
pkg
|
||||
}
|
||||
result.add(SettingsSectionSelect(title = label ?: pkg!!, value = pkg!!))
|
||||
}
|
||||
Log.i("OS", "Found installers: $result")
|
||||
return result
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsCard(
|
||||
item: SettingsSection
|
||||
) {
|
||||
|
||||
val context = LocalContext.current
|
||||
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||
var showDialog by remember { mutableStateOf(false) }
|
||||
|
||||
var currentValue by remember {
|
||||
mutableStateOf<Any>(
|
||||
if (item.type == ParamType.SWITCH) prefs.getBoolean(item.id, false)
|
||||
else prefs.getString(item.id, item.defaultVal) ?: item.defaultVal
|
||||
)
|
||||
}
|
||||
|
||||
val description = if (item.description != null && item.description != 0) {
|
||||
stringResource(item.description)
|
||||
} else if (item.type != ParamType.SWITCH) {
|
||||
val strVal = currentValue as? String ?: ""
|
||||
val selectedValues = strVal.split(";").filter { it.isNotEmpty() }.toSet()
|
||||
item.select?.filter { entry ->
|
||||
if (entry.isGroup) {
|
||||
entry.groupPackages.any { it in selectedValues }
|
||||
} else {
|
||||
entry.value in selectedValues
|
||||
}
|
||||
}?.joinToString(", ") { it.title } ?: ""
|
||||
} else ""
|
||||
|
||||
Card (
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
.clickable{
|
||||
if (item.type == ParamType.SWITCH) {
|
||||
val newValue = !(currentValue as Boolean)
|
||||
prefs.edit { putBoolean(item.id, newValue) }
|
||||
currentValue = newValue
|
||||
} else {
|
||||
showDialog = true
|
||||
}
|
||||
}
|
||||
.padding(15.dp)
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(15.dp)
|
||||
) {
|
||||
Icon(
|
||||
painterResource(item.icon),
|
||||
"icon",
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
Text(stringResource(item.title), fontWeight = FontWeight.Medium)
|
||||
if (description.isNotEmpty()) {
|
||||
Text(description, color = Color.Gray, fontWeight = FontWeight.Normal)
|
||||
}
|
||||
}
|
||||
if (item.type == ParamType.SWITCH) {
|
||||
Switch(
|
||||
currentValue as Boolean,
|
||||
{ v ->
|
||||
prefs.edit { putBoolean(item.id, v) }
|
||||
currentValue = v
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (showDialog) {
|
||||
val selectedPackages = remember {
|
||||
mutableStateListOf<String>().apply {
|
||||
val currentStr = currentValue as? String ?: ""
|
||||
addAll(currentStr.split(";").filter { it.isNotEmpty() })
|
||||
}
|
||||
}
|
||||
|
||||
var selectedVal by remember { mutableStateOf(currentValue as? String) }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { showDialog = false },
|
||||
title = { Text(stringResource(item.title)) },
|
||||
text = {
|
||||
LazyColumn(modifier = Modifier.heightIn(max = 380.dp)) {
|
||||
items(item.select ?: listOf()) { entry ->
|
||||
val isChecked = if (entry.isGroup) {
|
||||
entry.groupPackages.all { it in selectedPackages }
|
||||
} else {
|
||||
entry.value in selectedPackages
|
||||
}
|
||||
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
if (item.type == ParamType.MULTI_SELECT) {
|
||||
if (entry.isGroup) {
|
||||
if (isChecked) {
|
||||
selectedPackages.removeAll(entry.groupPackages)
|
||||
} else {
|
||||
entry.groupPackages.forEach {
|
||||
if (it !in selectedPackages) selectedPackages.add(it)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isChecked) {
|
||||
selectedPackages.remove(entry.value)
|
||||
} else {
|
||||
selectedPackages.add(entry.value)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedVal = entry.value
|
||||
}
|
||||
}
|
||||
.padding(vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (item.type == ParamType.SELECT) {
|
||||
RadioButton(
|
||||
selected = selectedVal == entry.value,
|
||||
onClick = { selectedVal = entry.value }
|
||||
)
|
||||
} else {
|
||||
Checkbox(
|
||||
checked = isChecked,
|
||||
onCheckedChange = null // Click handled by Row
|
||||
)
|
||||
}
|
||||
|
||||
Text(
|
||||
entry.title,
|
||||
modifier = Modifier.padding(start = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
val newValue = if (item.type == ParamType.MULTI_SELECT) {
|
||||
selectedPackages.joinToString(";")
|
||||
} else {
|
||||
selectedVal ?: item.defaultVal
|
||||
}
|
||||
prefs.edit { putString(item.id, newValue) }
|
||||
currentValue = newValue
|
||||
showDialog = false
|
||||
}) {
|
||||
Text(stringResource(R.string.settings_save_button))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.settings
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
class DetailsViewModel() : ViewModel() {
|
||||
|
||||
}
|
||||
|
||||
class SettingsViewModelFactory() : ViewModelProvider.Factory {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(DetailsViewModel::class.java)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return DetailsViewModel() as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,346 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.updates
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.FilledTonalIconButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavController
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.internal.installer.ApkInstaller
|
||||
import dev.mi6e4ka.openstore.ui.components.AppIcon
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun UpdatesScreen(navController: NavController) {
|
||||
val context = LocalContext.current
|
||||
val apkInstaller = remember { ApkInstaller(context) }
|
||||
val viewModel: UpdatesViewModel = viewModel(
|
||||
factory = UpdatesViewModelFactory(apkInstaller)
|
||||
)
|
||||
val state by viewModel.state.collectAsState()
|
||||
var showHashDetails by remember { mutableStateOf(false) }
|
||||
|
||||
if (state.invalidDownloadedApkFiles != null && state.invalidDownloadedAppPackage != null) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { viewModel.clearInvalidDownloadState() },
|
||||
title = { Text(stringResource(R.string.invalid_download_hash_title)) },
|
||||
text = {
|
||||
Column {
|
||||
Text(stringResource(R.string.invalid_download_hash_message))
|
||||
Spacer(modifier = Modifier.size(12.dp))
|
||||
TextButton(onClick = { showHashDetails = !showHashDetails }) {
|
||||
Text(stringResource(R.string.show_hashes))
|
||||
}
|
||||
if (showHashDetails) {
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
Text(stringResource(R.string.expected_hash, state.invalidExpectedHash ?: ""))
|
||||
Text(stringResource(R.string.actual_hash, state.invalidActualHash ?: ""))
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = { viewModel.retryDownloadAfterInvalid(context) }) {
|
||||
Text(stringResource(R.string.download_again))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { viewModel.installAsIsAfterInvalid(context) }) {
|
||||
Text(stringResource(R.string.install_as_is))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.loadAndCheckUpdates(context)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.updates_title)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back_button_desc)
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(
|
||||
onClick = { viewModel.checkForUpdates(context) },
|
||||
enabled = !state.isCheckingUpdates && !state.isLoading
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_refresh_24px),
|
||||
contentDescription = stringResource(R.string.check_updates)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
) { innerPadding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
) {
|
||||
if (state.isLoading) {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
} else if (state.isCheckingUpdates) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
Text(stringResource(R.string.checking_updates))
|
||||
}
|
||||
} else if (state.appsWithUpdates.isEmpty()) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
UpdatesBanner(navController, state.installedApps.size)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_check_circle_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(80.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
Text(
|
||||
stringResource(R.string.all_apps_updated),
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 18.sp
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
} else {
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
item {
|
||||
UpdatesBanner(navController, state.installedApps.size)
|
||||
}
|
||||
|
||||
item {
|
||||
Text(
|
||||
stringResource(R.string.available_updates, state.appsWithUpdates.size),
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(vertical = 8.dp)
|
||||
)
|
||||
}
|
||||
|
||||
items(state.appsWithUpdates, key = { it.packageName }) { app ->
|
||||
UpdateAppCard(
|
||||
app = app,
|
||||
isDownloading = state.downloadingPackages.contains(app.packageName),
|
||||
downloadProgress = state.downloadProgress[app.packageName] ?: 0,
|
||||
onUpdateClick = { viewModel.downloadAndUpdateApp(context, app) },
|
||||
onCancelClick = { viewModel.cancelDownload(app.packageName) },
|
||||
onCardClick = { navController.navigate("app/${app.packageName}?platform=mobile") }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun UpdatesBanner(navController: NavController, checkAppsCount: Int) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(0.dp)
|
||||
.height(80.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = {
|
||||
navController.navigate("settings")
|
||||
}),
|
||||
//colors = CardDefaults.cardColors(containerColor = Color(109, 255, 30, 40))
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp)
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_settings_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
)
|
||||
Column {
|
||||
Text(stringResource(R.string.updates_app_count, checkAppsCount))
|
||||
Text(stringResource(R.string.updates_change_settings))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun UpdateAppCard(
|
||||
app: AppWithUpdates,
|
||||
isDownloading: Boolean,
|
||||
downloadProgress: Int,
|
||||
onUpdateClick: () -> Unit,
|
||||
onCancelClick: () -> Unit,
|
||||
onCardClick: () -> Unit
|
||||
) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(onClick = onCardClick)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (app.iconUrl != null) {
|
||||
AppIcon(
|
||||
app.iconUrl,
|
||||
modifier = Modifier
|
||||
.size(56.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
)
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(56.dp)
|
||||
.clip(RoundedCornerShape(12.dp)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_android_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = app.appName,
|
||||
fontWeight = FontWeight.Medium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
Text(
|
||||
text = "${app.installedVersionCode} → ${app.latestVersionCode}",
|
||||
fontSize = 12.sp,
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
// Text(
|
||||
// text = "from ${app.installSource}",
|
||||
// fontSize = 12.sp,
|
||||
// color = MaterialTheme.colorScheme.secondary,
|
||||
// maxLines = 1,
|
||||
// overflow = TextOverflow.Ellipsis
|
||||
// )
|
||||
if (isDownloading) {
|
||||
Spacer(modifier = Modifier.size(4.dp))
|
||||
LinearProgressIndicator(
|
||||
progress = { downloadProgress / 100f },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (isDownloading) {
|
||||
FilledTonalIconButton(onClick = onCancelClick) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_close_24px),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
} else {
|
||||
FilledTonalButton(onClick = onUpdateClick) {
|
||||
Text(stringResource(R.string.update))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,322 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.updates
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dev.mi6e4ka.openstore.R
|
||||
import dev.mi6e4ka.openstore.data.model.AppUpdateRequestEntry
|
||||
import dev.mi6e4ka.openstore.di.AppModule
|
||||
import dev.mi6e4ka.openstore.internal.installer.ApkInstaller
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
data class AppWithUpdates (
|
||||
val packageName: String,
|
||||
val appName: String,
|
||||
val installedVersionCode: Long,
|
||||
val installedVersionName: String,
|
||||
val iconUrl: String? = null,
|
||||
val latestVersionCode: Long? = null,
|
||||
val latestVersionName: String? = null,
|
||||
val appId: Int? = null,
|
||||
val installSource: String
|
||||
)
|
||||
|
||||
data class UpdatesState(
|
||||
val isLoading: Boolean = false,
|
||||
val isCheckingUpdates: Boolean = false,
|
||||
val installedApps: List<AppUpdateRequestEntry> = emptyList(),
|
||||
val appsWithUpdates: List<AppWithUpdates> = emptyList(),
|
||||
val error: String? = null,
|
||||
val downloadingPackages: Set<String> = emptySet(),
|
||||
val downloadProgress: Map<String, Int> = emptyMap(),
|
||||
val invalidDownloadedApkFiles: List<File>? = null,
|
||||
val invalidDownloadedAppPackage: String? = null,
|
||||
val invalidExpectedHash: String? = null,
|
||||
val invalidActualHash: String? = null
|
||||
)
|
||||
|
||||
class UpdatesViewModel(private val apkInstaller: ApkInstaller) : ViewModel() {
|
||||
private val _state = MutableStateFlow(UpdatesState())
|
||||
val state: StateFlow<UpdatesState> = _state.asStateFlow()
|
||||
|
||||
private val cancelDownloads = mutableMapOf<String, () -> Unit>()
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_SOURCES = "dev.mi6e4ka.openstore;dev.mi6e4ka.openstore.nightly;dev.mi6e4ka.openstore.debug;ru.vk.store"
|
||||
}
|
||||
|
||||
fun loadAndCheckUpdates(context: Context) {
|
||||
viewModelScope.launch {
|
||||
// Загружаем список приложений
|
||||
_state.update { it.copy(isLoading = true, error = null) }
|
||||
val installedApps = try {
|
||||
withContext(Dispatchers.IO) {
|
||||
getInstalledApps(context)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
_state.update { it.copy(error = e.message, isLoading = false) }
|
||||
return@launch
|
||||
}
|
||||
_state.update { it.copy(installedApps = installedApps, isLoading = false) }
|
||||
|
||||
// Сразу запускаем проверку
|
||||
checkForUpdatesInternal(installedApps)
|
||||
}
|
||||
}
|
||||
|
||||
fun checkForUpdates(context: Context) {
|
||||
loadAndCheckUpdates(context)
|
||||
}
|
||||
|
||||
private suspend fun checkForUpdatesInternal(installedApps: List<AppUpdateRequestEntry>) {
|
||||
_state.update { it.copy(isCheckingUpdates = true, appsWithUpdates = emptyList()) }
|
||||
|
||||
val rawUpdates = AppModule.searchRepository.getBatchUpdates(installedApps)
|
||||
|
||||
if (rawUpdates.isEmpty()) {
|
||||
_state.update {
|
||||
it.copy(
|
||||
isCheckingUpdates = false,
|
||||
appsWithUpdates = emptyList()
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val detailsUpdates = AppModule.searchRepository.getBatchItemDetails(rawUpdates.map {it.packageName} )
|
||||
|
||||
val detailsByPackageName = detailsUpdates.associateBy {it.packageName}
|
||||
val installedAppsByPackageName = installedApps.associateBy {it.packageName}
|
||||
|
||||
val appsWithUpdates = rawUpdates.mapNotNull {
|
||||
val details = detailsByPackageName[it.packageName] ?: return@mapNotNull null
|
||||
val installedApp = installedAppsByPackageName[it.packageName] ?: return@mapNotNull null
|
||||
AppWithUpdates(
|
||||
packageName = it.packageName,
|
||||
appName = it.appName,
|
||||
installedVersionCode = installedApp.versionCode,
|
||||
installedVersionName = installedApp.versionName,
|
||||
iconUrl = details.iconUrl,
|
||||
latestVersionCode = details.versionCode,
|
||||
latestVersionName = "?",
|
||||
appId = it.appId,
|
||||
installSource = installedApp.installSource
|
||||
)
|
||||
}
|
||||
|
||||
_state.update {
|
||||
it.copy(
|
||||
isCheckingUpdates = false,
|
||||
appsWithUpdates = appsWithUpdates
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadAndUpdateApp(context: Context, app: AppWithUpdates) {
|
||||
if (app.appId == null) return
|
||||
|
||||
viewModelScope.launch {
|
||||
_state.update {
|
||||
it.copy(
|
||||
downloadingPackages = it.downloadingPackages + app.packageName,
|
||||
downloadProgress = it.downloadProgress + (app.packageName to 0)
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
val appFiles = withContext(Dispatchers.IO) {
|
||||
AppModule.searchRepository.getAppFiles(
|
||||
app.appId,
|
||||
firstInstall = false,
|
||||
supportedAbis = Build.SUPPORTED_ABIS.toList(),
|
||||
withoutSplits = false,
|
||||
deviceType = "mobile"
|
||||
)
|
||||
}
|
||||
|
||||
cancelDownloads[app.packageName] = apkInstaller.downloadFilesWithProgress(
|
||||
appFiles,
|
||||
onProgress = { percent, _, _ ->
|
||||
_state.update {
|
||||
it.copy(downloadProgress = it.downloadProgress + (app.packageName to percent))
|
||||
}
|
||||
},
|
||||
onSuccess = { apkFiles ->
|
||||
installApp(context, app.packageName, apkFiles)
|
||||
},
|
||||
onError = { error ->
|
||||
handleError(context, app.packageName, error)
|
||||
},
|
||||
onCancel = {
|
||||
_state.update {
|
||||
it.copy(
|
||||
downloadingPackages = it.downloadingPackages - app.packageName,
|
||||
downloadProgress = it.downloadProgress - app.packageName
|
||||
)
|
||||
}
|
||||
},
|
||||
onInvalidHash = { apkFiles, expectedHash, actualHash ->
|
||||
_state.update {
|
||||
it.copy(
|
||||
downloadingPackages = it.downloadingPackages - app.packageName,
|
||||
downloadProgress = it.downloadProgress - app.packageName,
|
||||
invalidDownloadedApkFiles = apkFiles,
|
||||
invalidDownloadedAppPackage = app.packageName,
|
||||
invalidExpectedHash = expectedHash,
|
||||
invalidActualHash = actualHash
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
handleError(context, app.packageName, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun installApp(context: Context, packageName: String, apkFiles: List<File>) {
|
||||
apkInstaller.installApp(
|
||||
packageName = packageName,
|
||||
apkFiles = apkFiles,
|
||||
onSessionFinished = { success ->
|
||||
_state.update {
|
||||
it.copy(
|
||||
downloadingPackages = it.downloadingPackages - packageName,
|
||||
downloadProgress = it.downloadProgress - packageName,
|
||||
appsWithUpdates = if (success) {
|
||||
it.appsWithUpdates.filter { app -> app.packageName != packageName }
|
||||
} else it.appsWithUpdates
|
||||
)
|
||||
}
|
||||
if (success) {
|
||||
apkInstaller.cleanApkFiles(apkFiles.map { it.name })
|
||||
}
|
||||
},
|
||||
onError = { error ->
|
||||
handleError(context, packageName, error)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun handleError(context: Context, packageName: String, error: Throwable) {
|
||||
if (error.message?.contains("Failed to allocate") == true) {
|
||||
Toast.makeText(context, R.string.insufficient_memory, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, R.string.loading_error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
_state.update {
|
||||
it.copy(
|
||||
downloadingPackages = it.downloadingPackages - packageName,
|
||||
downloadProgress = it.downloadProgress - packageName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelDownload(packageName: String) {
|
||||
cancelDownloads[packageName]?.invoke()
|
||||
cancelDownloads.remove(packageName)
|
||||
}
|
||||
|
||||
fun retryDownloadAfterInvalid(context: Context) {
|
||||
val packageName = state.value.invalidDownloadedAppPackage ?: return
|
||||
_state.update {
|
||||
it.copy(
|
||||
invalidDownloadedAppPackage = null,
|
||||
invalidDownloadedApkFiles = null,
|
||||
invalidExpectedHash = null,
|
||||
invalidActualHash = null
|
||||
)
|
||||
}
|
||||
val app = state.value.appsWithUpdates.find { it.packageName == packageName } ?: return
|
||||
downloadAndUpdateApp(context, app)
|
||||
}
|
||||
|
||||
fun installAsIsAfterInvalid(context: Context) {
|
||||
val packageName = state.value.invalidDownloadedAppPackage ?: return
|
||||
val apkFiles = state.value.invalidDownloadedApkFiles ?: return
|
||||
_state.update {
|
||||
it.copy(
|
||||
invalidDownloadedAppPackage = null,
|
||||
invalidDownloadedApkFiles = null,
|
||||
invalidExpectedHash = null,
|
||||
invalidActualHash = null
|
||||
)
|
||||
}
|
||||
installApp(context, packageName, apkFiles)
|
||||
}
|
||||
|
||||
fun clearInvalidDownloadState() {
|
||||
_state.update {
|
||||
it.copy(
|
||||
invalidDownloadedAppPackage = null,
|
||||
invalidDownloadedApkFiles = null,
|
||||
invalidExpectedHash = null,
|
||||
invalidActualHash = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstalledApps(context: Context): List<AppUpdateRequestEntry> {
|
||||
val pm = context.packageManager
|
||||
val packages = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
pm.getInstalledPackages(PackageManager.PackageInfoFlags.of(0))
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
pm.getInstalledPackages(0)
|
||||
}
|
||||
|
||||
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||
|
||||
val allowedSources = prefs.getString("updates_sources", DEFAULT_SOURCES)?.split(";") ?: listOf()
|
||||
val allowAllSources = prefs.getBoolean("updates_check_all", false)
|
||||
|
||||
return packages
|
||||
.filter { !isSystemApp(it) && (allowAllSources || allowedSources.contains(getInstallSource(pm, it.packageName))) }
|
||||
.map { packageInfo ->
|
||||
val versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
packageInfo.longVersionCode
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
packageInfo.versionCode.toLong()
|
||||
}
|
||||
println("package "+packageInfo.packageName+" from "+getInstallSource(pm, packageInfo.packageName))
|
||||
AppUpdateRequestEntry(
|
||||
packageName = packageInfo.packageName,
|
||||
appName = pm.getApplicationLabel(packageInfo.applicationInfo!!).toString(),
|
||||
versionCode = versionCode,
|
||||
versionName = packageInfo.versionName ?: "Unknown",
|
||||
installSource = getInstallSource(pm, packageInfo.packageName)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSystemApp(packageInfo: PackageInfo): Boolean {
|
||||
return (packageInfo.applicationInfo?.flags?.and(ApplicationInfo.FLAG_SYSTEM) ?: 0) != 0
|
||||
}
|
||||
|
||||
private fun getInstallSource(pm: PackageManager, packageName: String): String {
|
||||
val installer = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
try {
|
||||
pm.getInstallSourceInfo(packageName).installingPackageName
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
pm.getInstallerPackageName(packageName)
|
||||
}
|
||||
return installer ?: "null"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package dev.mi6e4ka.openstore.ui.screen.updates
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import dev.mi6e4ka.openstore.internal.installer.ApkInstaller
|
||||
|
||||
class UpdatesViewModelFactory(
|
||||
private val apkInstaller: ApkInstaller
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(UpdatesViewModel::class.java)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return UpdatesViewModel(apkInstaller) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
225
app/src/main/java/dev/mi6e4ka/openstore/ui/theme/Color.kt
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
package dev.mi6e4ka.openstore.ui.theme
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val primaryLight = Color(0xFF36618E)
|
||||
val onPrimaryLight = Color(0xFFFFFFFF)
|
||||
val primaryContainerLight = Color(0xFFD1E4FF)
|
||||
val onPrimaryContainerLight = Color(0xFF194975)
|
||||
val secondaryLight = Color(0xFF535F70)
|
||||
val onSecondaryLight = Color(0xFFFFFFFF)
|
||||
val secondaryContainerLight = Color(0xFFD7E3F7)
|
||||
val onSecondaryContainerLight = Color(0xFF3B4858)
|
||||
val tertiaryLight = Color(0xFF6B5778)
|
||||
val onTertiaryLight = Color(0xFFFFFFFF)
|
||||
val tertiaryContainerLight = Color(0xFFF2DAFF)
|
||||
val onTertiaryContainerLight = Color(0xFF523F5F)
|
||||
val errorLight = Color(0xFFBA1A1A)
|
||||
val onErrorLight = Color(0xFFFFFFFF)
|
||||
val errorContainerLight = Color(0xFFFFDAD6)
|
||||
val onErrorContainerLight = Color(0xFF93000A)
|
||||
val backgroundLight = Color(0xFFF8F9FF)
|
||||
val onBackgroundLight = Color(0xFF191C20)
|
||||
val surfaceLight = Color(0xFFF8F9FF)
|
||||
val onSurfaceLight = Color(0xFF191C20)
|
||||
val surfaceVariantLight = Color(0xFFDFE2EB)
|
||||
val onSurfaceVariantLight = Color(0xFF42474E)
|
||||
val outlineLight = Color(0xFF73777F)
|
||||
val outlineVariantLight = Color(0xFFC3C7CF)
|
||||
val scrimLight = Color(0xFF000000)
|
||||
val inverseSurfaceLight = Color(0xFF2E3135)
|
||||
val inverseOnSurfaceLight = Color(0xFFEFF0F7)
|
||||
val inversePrimaryLight = Color(0xFFA0CAFD)
|
||||
val surfaceDimLight = Color(0xFFD8DAE0)
|
||||
val surfaceBrightLight = Color(0xFFF8F9FF)
|
||||
val surfaceContainerLowestLight = Color(0xFFFFFFFF)
|
||||
val surfaceContainerLowLight = Color(0xFFF2F3F9)
|
||||
val surfaceContainerLight = Color(0xFFECEEF4)
|
||||
val surfaceContainerHighLight = Color(0xFFE6E8EE)
|
||||
val surfaceContainerHighestLight = Color(0xFFE1E2E8)
|
||||
|
||||
val primaryLightMediumContrast = Color(0xFF003861)
|
||||
val onPrimaryLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val primaryContainerLightMediumContrast = Color(0xFF45709E)
|
||||
val onPrimaryContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val secondaryLightMediumContrast = Color(0xFF2B3746)
|
||||
val onSecondaryLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val secondaryContainerLightMediumContrast = Color(0xFF616E7F)
|
||||
val onSecondaryContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryLightMediumContrast = Color(0xFF412F4E)
|
||||
val onTertiaryLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryContainerLightMediumContrast = Color(0xFF7A6588)
|
||||
val onTertiaryContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val errorLightMediumContrast = Color(0xFF740006)
|
||||
val onErrorLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val errorContainerLightMediumContrast = Color(0xFFCF2C27)
|
||||
val onErrorContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val backgroundLightMediumContrast = Color(0xFFF8F9FF)
|
||||
val onBackgroundLightMediumContrast = Color(0xFF191C20)
|
||||
val surfaceLightMediumContrast = Color(0xFFF8F9FF)
|
||||
val onSurfaceLightMediumContrast = Color(0xFF0E1116)
|
||||
val surfaceVariantLightMediumContrast = Color(0xFFDFE2EB)
|
||||
val onSurfaceVariantLightMediumContrast = Color(0xFF32363D)
|
||||
val outlineLightMediumContrast = Color(0xFF4E535A)
|
||||
val outlineVariantLightMediumContrast = Color(0xFF696D75)
|
||||
val scrimLightMediumContrast = Color(0xFF000000)
|
||||
val inverseSurfaceLightMediumContrast = Color(0xFF2E3135)
|
||||
val inverseOnSurfaceLightMediumContrast = Color(0xFFEFF0F7)
|
||||
val inversePrimaryLightMediumContrast = Color(0xFFA0CAFD)
|
||||
val surfaceDimLightMediumContrast = Color(0xFFC4C6CC)
|
||||
val surfaceBrightLightMediumContrast = Color(0xFFF8F9FF)
|
||||
val surfaceContainerLowestLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val surfaceContainerLowLightMediumContrast = Color(0xFFF2F3F9)
|
||||
val surfaceContainerLightMediumContrast = Color(0xFFE6E8EE)
|
||||
val surfaceContainerHighLightMediumContrast = Color(0xFFDBDDE3)
|
||||
val surfaceContainerHighestLightMediumContrast = Color(0xFFD0D1D7)
|
||||
|
||||
val primaryLightHighContrast = Color(0xFF002E51)
|
||||
val onPrimaryLightHighContrast = Color(0xFFFFFFFF)
|
||||
val primaryContainerLightHighContrast = Color(0xFF1C4B77)
|
||||
val onPrimaryContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val secondaryLightHighContrast = Color(0xFF212D3C)
|
||||
val onSecondaryLightHighContrast = Color(0xFFFFFFFF)
|
||||
val secondaryContainerLightHighContrast = Color(0xFF3E4A5A)
|
||||
val onSecondaryContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryLightHighContrast = Color(0xFF362543)
|
||||
val onTertiaryLightHighContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryContainerLightHighContrast = Color(0xFF554262)
|
||||
val onTertiaryContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val errorLightHighContrast = Color(0xFF600004)
|
||||
val onErrorLightHighContrast = Color(0xFFFFFFFF)
|
||||
val errorContainerLightHighContrast = Color(0xFF98000A)
|
||||
val onErrorContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val backgroundLightHighContrast = Color(0xFFF8F9FF)
|
||||
val onBackgroundLightHighContrast = Color(0xFF191C20)
|
||||
val surfaceLightHighContrast = Color(0xFFF8F9FF)
|
||||
val onSurfaceLightHighContrast = Color(0xFF000000)
|
||||
val surfaceVariantLightHighContrast = Color(0xFFDFE2EB)
|
||||
val onSurfaceVariantLightHighContrast = Color(0xFF000000)
|
||||
val outlineLightHighContrast = Color(0xFF282C33)
|
||||
val outlineVariantLightHighContrast = Color(0xFF454950)
|
||||
val scrimLightHighContrast = Color(0xFF000000)
|
||||
val inverseSurfaceLightHighContrast = Color(0xFF2E3135)
|
||||
val inverseOnSurfaceLightHighContrast = Color(0xFFFFFFFF)
|
||||
val inversePrimaryLightHighContrast = Color(0xFFA0CAFD)
|
||||
val surfaceDimLightHighContrast = Color(0xFFB7B9BE)
|
||||
val surfaceBrightLightHighContrast = Color(0xFFF8F9FF)
|
||||
val surfaceContainerLowestLightHighContrast = Color(0xFFFFFFFF)
|
||||
val surfaceContainerLowLightHighContrast = Color(0xFFEFF0F7)
|
||||
val surfaceContainerLightHighContrast = Color(0xFFE1E2E8)
|
||||
val surfaceContainerHighLightHighContrast = Color(0xFFD2D4DA)
|
||||
val surfaceContainerHighestLightHighContrast = Color(0xFFC4C6CC)
|
||||
|
||||
val primaryDark = Color(0xFFA0CAFD)
|
||||
val onPrimaryDark = Color(0xFF003258)
|
||||
val primaryContainerDark = Color(0xFF194975)
|
||||
val onPrimaryContainerDark = Color(0xFFD1E4FF)
|
||||
val secondaryDark = Color(0xFFBBC7DB)
|
||||
val onSecondaryDark = Color(0xFF253140)
|
||||
val secondaryContainerDark = Color(0xFF3B4858)
|
||||
val onSecondaryContainerDark = Color(0xFFD7E3F7)
|
||||
val tertiaryDark = Color(0xFFD6BEE4)
|
||||
val onTertiaryDark = Color(0xFF3B2948)
|
||||
val tertiaryContainerDark = Color(0xFF523F5F)
|
||||
val onTertiaryContainerDark = Color(0xFFF2DAFF)
|
||||
val errorDark = Color(0xFFFFB4AB)
|
||||
val onErrorDark = Color(0xFF690005)
|
||||
val errorContainerDark = Color(0xFF93000A)
|
||||
val onErrorContainerDark = Color(0xFFFFDAD6)
|
||||
val backgroundDark = Color(0xFF111418)
|
||||
val onBackgroundDark = Color(0xFFE1E2E8)
|
||||
val surfaceDark = Color(0xFF111418)
|
||||
val onSurfaceDark = Color(0xFFE1E2E8)
|
||||
val surfaceVariantDark = Color(0xFF42474E)
|
||||
val onSurfaceVariantDark = Color(0xFFC3C7CF)
|
||||
val outlineDark = Color(0xFF8D9199)
|
||||
val outlineVariantDark = Color(0xFF42474E)
|
||||
val scrimDark = Color(0xFF000000)
|
||||
val inverseSurfaceDark = Color(0xFFE1E2E8)
|
||||
val inverseOnSurfaceDark = Color(0xFF2E3135)
|
||||
val inversePrimaryDark = Color(0xFF36618E)
|
||||
val surfaceDimDark = Color(0xFF111418)
|
||||
val surfaceBrightDark = Color(0xFF36393E)
|
||||
val surfaceContainerLowestDark = Color(0xFF0B0E13)
|
||||
val surfaceContainerLowDark = Color(0xFF191C20)
|
||||
val surfaceContainerDark = Color(0xFF1D2024)
|
||||
val surfaceContainerHighDark = Color(0xFF272A2F)
|
||||
val surfaceContainerHighestDark = Color(0xFF32353A)
|
||||
|
||||
val primaryDarkMediumContrast = Color(0xFFC6DEFF)
|
||||
val onPrimaryDarkMediumContrast = Color(0xFF002746)
|
||||
val primaryContainerDarkMediumContrast = Color(0xFF6A94C4)
|
||||
val onPrimaryContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val secondaryDarkMediumContrast = Color(0xFFD0DDF1)
|
||||
val onSecondaryDarkMediumContrast = Color(0xFF1A2735)
|
||||
val secondaryContainerDarkMediumContrast = Color(0xFF8592A4)
|
||||
val onSecondaryContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val tertiaryDarkMediumContrast = Color(0xFFEDD3FB)
|
||||
val onTertiaryDarkMediumContrast = Color(0xFF301E3C)
|
||||
val tertiaryContainerDarkMediumContrast = Color(0xFF9F89AD)
|
||||
val onTertiaryContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val errorDarkMediumContrast = Color(0xFFFFD2CC)
|
||||
val onErrorDarkMediumContrast = Color(0xFF540003)
|
||||
val errorContainerDarkMediumContrast = Color(0xFFFF5449)
|
||||
val onErrorContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val backgroundDarkMediumContrast = Color(0xFF111418)
|
||||
val onBackgroundDarkMediumContrast = Color(0xFFE1E2E8)
|
||||
val surfaceDarkMediumContrast = Color(0xFF111418)
|
||||
val onSurfaceDarkMediumContrast = Color(0xFFFFFFFF)
|
||||
val surfaceVariantDarkMediumContrast = Color(0xFF42474E)
|
||||
val onSurfaceVariantDarkMediumContrast = Color(0xFFD9DCE5)
|
||||
val outlineDarkMediumContrast = Color(0xFFAEB2BA)
|
||||
val outlineVariantDarkMediumContrast = Color(0xFF8C9098)
|
||||
val scrimDarkMediumContrast = Color(0xFF000000)
|
||||
val inverseSurfaceDarkMediumContrast = Color(0xFFE1E2E8)
|
||||
val inverseOnSurfaceDarkMediumContrast = Color(0xFF272A2F)
|
||||
val inversePrimaryDarkMediumContrast = Color(0xFF1B4A76)
|
||||
val surfaceDimDarkMediumContrast = Color(0xFF111418)
|
||||
val surfaceBrightDarkMediumContrast = Color(0xFF42454A)
|
||||
val surfaceContainerLowestDarkMediumContrast = Color(0xFF05080B)
|
||||
val surfaceContainerLowDarkMediumContrast = Color(0xFF1B1E22)
|
||||
val surfaceContainerDarkMediumContrast = Color(0xFF25282D)
|
||||
val surfaceContainerHighDarkMediumContrast = Color(0xFF303337)
|
||||
val surfaceContainerHighestDarkMediumContrast = Color(0xFF3B3E43)
|
||||
|
||||
val primaryDarkHighContrast = Color(0xFFE8F0FF)
|
||||
val onPrimaryDarkHighContrast = Color(0xFF000000)
|
||||
val primaryContainerDarkHighContrast = Color(0xFF9CC6F9)
|
||||
val onPrimaryContainerDarkHighContrast = Color(0xFF000C1B)
|
||||
val secondaryDarkHighContrast = Color(0xFFE8F0FF)
|
||||
val onSecondaryDarkHighContrast = Color(0xFF000000)
|
||||
val secondaryContainerDarkHighContrast = Color(0xFFB7C4D7)
|
||||
val onSecondaryContainerDarkHighContrast = Color(0xFF010C1A)
|
||||
val tertiaryDarkHighContrast = Color(0xFFFAEBFF)
|
||||
val onTertiaryDarkHighContrast = Color(0xFF000000)
|
||||
val tertiaryContainerDarkHighContrast = Color(0xFFD2BAE0)
|
||||
val onTertiaryContainerDarkHighContrast = Color(0xFF140420)
|
||||
val errorDarkHighContrast = Color(0xFFFFECE9)
|
||||
val onErrorDarkHighContrast = Color(0xFF000000)
|
||||
val errorContainerDarkHighContrast = Color(0xFFFFAEA4)
|
||||
val onErrorContainerDarkHighContrast = Color(0xFF220001)
|
||||
val backgroundDarkHighContrast = Color(0xFF111418)
|
||||
val onBackgroundDarkHighContrast = Color(0xFFE1E2E8)
|
||||
val surfaceDarkHighContrast = Color(0xFF111418)
|
||||
val onSurfaceDarkHighContrast = Color(0xFFFFFFFF)
|
||||
val surfaceVariantDarkHighContrast = Color(0xFF42474E)
|
||||
val onSurfaceVariantDarkHighContrast = Color(0xFFFFFFFF)
|
||||
val outlineDarkHighContrast = Color(0xFFECF0F9)
|
||||
val outlineVariantDarkHighContrast = Color(0xFFBFC3CB)
|
||||
val scrimDarkHighContrast = Color(0xFF000000)
|
||||
val inverseSurfaceDarkHighContrast = Color(0xFFE1E2E8)
|
||||
val inverseOnSurfaceDarkHighContrast = Color(0xFF000000)
|
||||
val inversePrimaryDarkHighContrast = Color(0xFF1B4A76)
|
||||
val surfaceDimDarkHighContrast = Color(0xFF111418)
|
||||
val surfaceBrightDarkHighContrast = Color(0xFF4D5055)
|
||||
val surfaceContainerLowestDarkHighContrast = Color(0xFF000000)
|
||||
val surfaceContainerLowDarkHighContrast = Color(0xFF1D2024)
|
||||
val surfaceContainerDarkHighContrast = Color(0xFF2E3135)
|
||||
val surfaceContainerHighDarkHighContrast = Color(0xFF393C40)
|
||||
val surfaceContainerHighestDarkHighContrast = Color(0xFF44474C)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
299
app/src/main/java/dev/mi6e4ka/openstore/ui/theme/Theme.kt
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
package dev.mi6e4ka.openstore.ui.theme
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
|
||||
private val lightScheme = lightColorScheme(
|
||||
primary = primaryLight,
|
||||
onPrimary = onPrimaryLight,
|
||||
primaryContainer = primaryContainerLight,
|
||||
onPrimaryContainer = onPrimaryContainerLight,
|
||||
secondary = secondaryLight,
|
||||
onSecondary = onSecondaryLight,
|
||||
secondaryContainer = secondaryContainerLight,
|
||||
onSecondaryContainer = onSecondaryContainerLight,
|
||||
tertiary = tertiaryLight,
|
||||
onTertiary = onTertiaryLight,
|
||||
tertiaryContainer = tertiaryContainerLight,
|
||||
onTertiaryContainer = onTertiaryContainerLight,
|
||||
error = errorLight,
|
||||
onError = onErrorLight,
|
||||
errorContainer = errorContainerLight,
|
||||
onErrorContainer = onErrorContainerLight,
|
||||
background = backgroundLight,
|
||||
onBackground = onBackgroundLight,
|
||||
surface = surfaceLight,
|
||||
onSurface = onSurfaceLight,
|
||||
surfaceVariant = surfaceVariantLight,
|
||||
onSurfaceVariant = onSurfaceVariantLight,
|
||||
outline = outlineLight,
|
||||
outlineVariant = outlineVariantLight,
|
||||
scrim = scrimLight,
|
||||
inverseSurface = inverseSurfaceLight,
|
||||
inverseOnSurface = inverseOnSurfaceLight,
|
||||
inversePrimary = inversePrimaryLight,
|
||||
surfaceDim = surfaceDimLight,
|
||||
surfaceBright = surfaceBrightLight,
|
||||
surfaceContainerLowest = surfaceContainerLowestLight,
|
||||
surfaceContainerLow = surfaceContainerLowLight,
|
||||
surfaceContainer = surfaceContainerLight,
|
||||
surfaceContainerHigh = surfaceContainerHighLight,
|
||||
surfaceContainerHighest = surfaceContainerHighestLight,
|
||||
)
|
||||
|
||||
private val darkScheme = darkColorScheme(
|
||||
primary = primaryDark,
|
||||
onPrimary = onPrimaryDark,
|
||||
primaryContainer = primaryContainerDark,
|
||||
onPrimaryContainer = onPrimaryContainerDark,
|
||||
secondary = secondaryDark,
|
||||
onSecondary = onSecondaryDark,
|
||||
secondaryContainer = secondaryContainerDark,
|
||||
onSecondaryContainer = onSecondaryContainerDark,
|
||||
tertiary = tertiaryDark,
|
||||
onTertiary = onTertiaryDark,
|
||||
tertiaryContainer = tertiaryContainerDark,
|
||||
onTertiaryContainer = onTertiaryContainerDark,
|
||||
error = errorDark,
|
||||
onError = onErrorDark,
|
||||
errorContainer = errorContainerDark,
|
||||
onErrorContainer = onErrorContainerDark,
|
||||
background = backgroundDark,
|
||||
onBackground = onBackgroundDark,
|
||||
surface = surfaceDark,
|
||||
onSurface = onSurfaceDark,
|
||||
surfaceVariant = surfaceVariantDark,
|
||||
onSurfaceVariant = onSurfaceVariantDark,
|
||||
outline = outlineDark,
|
||||
outlineVariant = outlineVariantDark,
|
||||
scrim = scrimDark,
|
||||
inverseSurface = inverseSurfaceDark,
|
||||
inverseOnSurface = inverseOnSurfaceDark,
|
||||
inversePrimary = inversePrimaryDark,
|
||||
surfaceDim = surfaceDimDark,
|
||||
surfaceBright = surfaceBrightDark,
|
||||
surfaceContainerLowest = surfaceContainerLowestDark,
|
||||
surfaceContainerLow = surfaceContainerLowDark,
|
||||
surfaceContainer = surfaceContainerDark,
|
||||
surfaceContainerHigh = surfaceContainerHighDark,
|
||||
surfaceContainerHighest = surfaceContainerHighestDark,
|
||||
)
|
||||
|
||||
private val mediumContrastLightColorScheme = lightColorScheme(
|
||||
primary = primaryLightMediumContrast,
|
||||
onPrimary = onPrimaryLightMediumContrast,
|
||||
primaryContainer = primaryContainerLightMediumContrast,
|
||||
onPrimaryContainer = onPrimaryContainerLightMediumContrast,
|
||||
secondary = secondaryLightMediumContrast,
|
||||
onSecondary = onSecondaryLightMediumContrast,
|
||||
secondaryContainer = secondaryContainerLightMediumContrast,
|
||||
onSecondaryContainer = onSecondaryContainerLightMediumContrast,
|
||||
tertiary = tertiaryLightMediumContrast,
|
||||
onTertiary = onTertiaryLightMediumContrast,
|
||||
tertiaryContainer = tertiaryContainerLightMediumContrast,
|
||||
onTertiaryContainer = onTertiaryContainerLightMediumContrast,
|
||||
error = errorLightMediumContrast,
|
||||
onError = onErrorLightMediumContrast,
|
||||
errorContainer = errorContainerLightMediumContrast,
|
||||
onErrorContainer = onErrorContainerLightMediumContrast,
|
||||
background = backgroundLightMediumContrast,
|
||||
onBackground = onBackgroundLightMediumContrast,
|
||||
surface = surfaceLightMediumContrast,
|
||||
onSurface = onSurfaceLightMediumContrast,
|
||||
surfaceVariant = surfaceVariantLightMediumContrast,
|
||||
onSurfaceVariant = onSurfaceVariantLightMediumContrast,
|
||||
outline = outlineLightMediumContrast,
|
||||
outlineVariant = outlineVariantLightMediumContrast,
|
||||
scrim = scrimLightMediumContrast,
|
||||
inverseSurface = inverseSurfaceLightMediumContrast,
|
||||
inverseOnSurface = inverseOnSurfaceLightMediumContrast,
|
||||
inversePrimary = inversePrimaryLightMediumContrast,
|
||||
surfaceDim = surfaceDimLightMediumContrast,
|
||||
surfaceBright = surfaceBrightLightMediumContrast,
|
||||
surfaceContainerLowest = surfaceContainerLowestLightMediumContrast,
|
||||
surfaceContainerLow = surfaceContainerLowLightMediumContrast,
|
||||
surfaceContainer = surfaceContainerLightMediumContrast,
|
||||
surfaceContainerHigh = surfaceContainerHighLightMediumContrast,
|
||||
surfaceContainerHighest = surfaceContainerHighestLightMediumContrast,
|
||||
)
|
||||
|
||||
private val highContrastLightColorScheme = lightColorScheme(
|
||||
primary = primaryLightHighContrast,
|
||||
onPrimary = onPrimaryLightHighContrast,
|
||||
primaryContainer = primaryContainerLightHighContrast,
|
||||
onPrimaryContainer = onPrimaryContainerLightHighContrast,
|
||||
secondary = secondaryLightHighContrast,
|
||||
onSecondary = onSecondaryLightHighContrast,
|
||||
secondaryContainer = secondaryContainerLightHighContrast,
|
||||
onSecondaryContainer = onSecondaryContainerLightHighContrast,
|
||||
tertiary = tertiaryLightHighContrast,
|
||||
onTertiary = onTertiaryLightHighContrast,
|
||||
tertiaryContainer = tertiaryContainerLightHighContrast,
|
||||
onTertiaryContainer = onTertiaryContainerLightHighContrast,
|
||||
error = errorLightHighContrast,
|
||||
onError = onErrorLightHighContrast,
|
||||
errorContainer = errorContainerLightHighContrast,
|
||||
onErrorContainer = onErrorContainerLightHighContrast,
|
||||
background = backgroundLightHighContrast,
|
||||
onBackground = onBackgroundLightHighContrast,
|
||||
surface = surfaceLightHighContrast,
|
||||
onSurface = onSurfaceLightHighContrast,
|
||||
surfaceVariant = surfaceVariantLightHighContrast,
|
||||
onSurfaceVariant = onSurfaceVariantLightHighContrast,
|
||||
outline = outlineLightHighContrast,
|
||||
outlineVariant = outlineVariantLightHighContrast,
|
||||
scrim = scrimLightHighContrast,
|
||||
inverseSurface = inverseSurfaceLightHighContrast,
|
||||
inverseOnSurface = inverseOnSurfaceLightHighContrast,
|
||||
inversePrimary = inversePrimaryLightHighContrast,
|
||||
surfaceDim = surfaceDimLightHighContrast,
|
||||
surfaceBright = surfaceBrightLightHighContrast,
|
||||
surfaceContainerLowest = surfaceContainerLowestLightHighContrast,
|
||||
surfaceContainerLow = surfaceContainerLowLightHighContrast,
|
||||
surfaceContainer = surfaceContainerLightHighContrast,
|
||||
surfaceContainerHigh = surfaceContainerHighLightHighContrast,
|
||||
surfaceContainerHighest = surfaceContainerHighestLightHighContrast,
|
||||
)
|
||||
|
||||
private val mediumContrastDarkColorScheme = darkColorScheme(
|
||||
primary = primaryDarkMediumContrast,
|
||||
onPrimary = onPrimaryDarkMediumContrast,
|
||||
primaryContainer = primaryContainerDarkMediumContrast,
|
||||
onPrimaryContainer = onPrimaryContainerDarkMediumContrast,
|
||||
secondary = secondaryDarkMediumContrast,
|
||||
onSecondary = onSecondaryDarkMediumContrast,
|
||||
secondaryContainer = secondaryContainerDarkMediumContrast,
|
||||
onSecondaryContainer = onSecondaryContainerDarkMediumContrast,
|
||||
tertiary = tertiaryDarkMediumContrast,
|
||||
onTertiary = onTertiaryDarkMediumContrast,
|
||||
tertiaryContainer = tertiaryContainerDarkMediumContrast,
|
||||
onTertiaryContainer = onTertiaryContainerDarkMediumContrast,
|
||||
error = errorDarkMediumContrast,
|
||||
onError = onErrorDarkMediumContrast,
|
||||
errorContainer = errorContainerDarkMediumContrast,
|
||||
onErrorContainer = onErrorContainerDarkMediumContrast,
|
||||
background = backgroundDarkMediumContrast,
|
||||
onBackground = onBackgroundDarkMediumContrast,
|
||||
surface = surfaceDarkMediumContrast,
|
||||
onSurface = onSurfaceDarkMediumContrast,
|
||||
surfaceVariant = surfaceVariantDarkMediumContrast,
|
||||
onSurfaceVariant = onSurfaceVariantDarkMediumContrast,
|
||||
outline = outlineDarkMediumContrast,
|
||||
outlineVariant = outlineVariantDarkMediumContrast,
|
||||
scrim = scrimDarkMediumContrast,
|
||||
inverseSurface = inverseSurfaceDarkMediumContrast,
|
||||
inverseOnSurface = inverseOnSurfaceDarkMediumContrast,
|
||||
inversePrimary = inversePrimaryDarkMediumContrast,
|
||||
surfaceDim = surfaceDimDarkMediumContrast,
|
||||
surfaceBright = surfaceBrightDarkMediumContrast,
|
||||
surfaceContainerLowest = surfaceContainerLowestDarkMediumContrast,
|
||||
surfaceContainerLow = surfaceContainerLowDarkMediumContrast,
|
||||
surfaceContainer = surfaceContainerDarkMediumContrast,
|
||||
surfaceContainerHigh = surfaceContainerHighDarkMediumContrast,
|
||||
surfaceContainerHighest = surfaceContainerHighestDarkMediumContrast,
|
||||
)
|
||||
|
||||
private val highContrastDarkColorScheme = darkColorScheme(
|
||||
primary = primaryDarkHighContrast,
|
||||
onPrimary = onPrimaryDarkHighContrast,
|
||||
primaryContainer = primaryContainerDarkHighContrast,
|
||||
onPrimaryContainer = onPrimaryContainerDarkHighContrast,
|
||||
secondary = secondaryDarkHighContrast,
|
||||
onSecondary = onSecondaryDarkHighContrast,
|
||||
secondaryContainer = secondaryContainerDarkHighContrast,
|
||||
onSecondaryContainer = onSecondaryContainerDarkHighContrast,
|
||||
tertiary = tertiaryDarkHighContrast,
|
||||
onTertiary = onTertiaryDarkHighContrast,
|
||||
tertiaryContainer = tertiaryContainerDarkHighContrast,
|
||||
onTertiaryContainer = onTertiaryContainerDarkHighContrast,
|
||||
error = errorDarkHighContrast,
|
||||
onError = onErrorDarkHighContrast,
|
||||
errorContainer = errorContainerDarkHighContrast,
|
||||
onErrorContainer = onErrorContainerDarkHighContrast,
|
||||
background = backgroundDarkHighContrast,
|
||||
onBackground = onBackgroundDarkHighContrast,
|
||||
surface = surfaceDarkHighContrast,
|
||||
onSurface = onSurfaceDarkHighContrast,
|
||||
surfaceVariant = surfaceVariantDarkHighContrast,
|
||||
onSurfaceVariant = onSurfaceVariantDarkHighContrast,
|
||||
outline = outlineDarkHighContrast,
|
||||
outlineVariant = outlineVariantDarkHighContrast,
|
||||
scrim = scrimDarkHighContrast,
|
||||
inverseSurface = inverseSurfaceDarkHighContrast,
|
||||
inverseOnSurface = inverseOnSurfaceDarkHighContrast,
|
||||
inversePrimary = inversePrimaryDarkHighContrast,
|
||||
surfaceDim = surfaceDimDarkHighContrast,
|
||||
surfaceBright = surfaceBrightDarkHighContrast,
|
||||
surfaceContainerLowest = surfaceContainerLowestDarkHighContrast,
|
||||
surfaceContainerLow = surfaceContainerLowDarkHighContrast,
|
||||
surfaceContainer = surfaceContainerDarkHighContrast,
|
||||
surfaceContainerHigh = surfaceContainerHighDarkHighContrast,
|
||||
surfaceContainerHighest = surfaceContainerHighestDarkHighContrast,
|
||||
)
|
||||
|
||||
@Immutable
|
||||
data class ColorFamily(
|
||||
val color: Color,
|
||||
val onColor: Color,
|
||||
val colorContainer: Color,
|
||||
val onColorContainer: Color
|
||||
)
|
||||
|
||||
val unspecified_scheme = ColorFamily(
|
||||
Color.Unspecified, Color.Unspecified, Color.Unspecified, Color.Unspecified
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun AppTheme(
|
||||
// Dynamic color is available on Android 12+
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable() () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val prefs = remember { context.getSharedPreferences("settings", Context.MODE_PRIVATE) }
|
||||
val appTheme = prefs.getString("app_theme", "auto")
|
||||
|
||||
val darkTheme = (isSystemInDarkTheme() && appTheme == "auto") || (appTheme == "dark")
|
||||
|
||||
val colorScheme = when {
|
||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
if (darkTheme)
|
||||
dynamicDarkColorScheme(context)
|
||||
else dynamicLightColorScheme(context)
|
||||
}
|
||||
|
||||
darkTheme -> darkScheme
|
||||
else -> lightScheme
|
||||
}
|
||||
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
val window = (view.context as Activity).window
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = !darkTheme
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
//typography = AppTypography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
21
app/src/main/res/drawable-v24/ic_launcher_background.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="130"
|
||||
android:viewportHeight="130">
|
||||
<path
|
||||
android:pathData="M0,0h130v130h-130z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startX="26.13"
|
||||
android:startY="10.13"
|
||||
android:endX="102.24"
|
||||
android:endY="117.59"
|
||||
android:type="linear">
|
||||
<item android:offset="0" android:color="#FF05A0FF"/>
|
||||
<item android:offset="1" android:color="#FF014DB1"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/apk_install_24px.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M160,880Q127,880 103.5,856.5Q80,833 80,800L80,160Q80,127 103.5,103.5Q127,80 160,80L480,80L720,320L720,490L640,490L640,360L440,360L440,160L160,160Q160,160 160,160Q160,160 160,160L160,800Q160,800 160,800Q160,800 160,800L600,800L600,880L160,880ZM160,800L160,490L160,490L160,360L160,160L160,160Q160,160 160,160Q160,160 160,160L160,800Q160,800 160,800Q160,800 160,800ZM200,760Q204,711 230,670Q256,629 298,605L260,537Q260,536 264,522Q269,520 273.5,520Q278,520 280,525L319,595Q339,587 359,582.5Q379,578 400,578Q421,578 441,582.5Q461,587 481,595L520,525Q520,525 535,521Q540,523 541,528Q542,533 540,537L502,605Q544,629 570,670Q596,711 600,760L200,760ZM310,700Q318,700 324,694Q330,688 330,680Q330,672 324,666Q318,660 310,660Q302,660 296,666Q290,672 290,680Q290,688 296,694Q302,700 310,700ZM490,700Q498,700 504,694Q510,688 510,680Q510,672 504,666Q498,660 490,660Q482,660 476,666Q470,672 470,680Q470,688 476,694Q482,700 490,700ZM800,880L640,720L696,663L760,726L760,560L840,560L840,726L904,663L960,720L800,880Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_adb_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M200,440L200,400Q200,328 232.5,268.5Q265,209 320,171L245,96L280,60L365,145Q391,133 420.5,126.5Q450,120 480,120Q510,120 539.5,126.5Q569,133 595,145L680,60L715,96L640,171Q695,209 727.5,268.5Q760,328 760,400L760,440L200,440ZM600,360Q617,360 628.5,348.5Q640,337 640,320Q640,303 628.5,291.5Q617,280 600,280Q583,280 571.5,291.5Q560,303 560,320Q560,337 571.5,348.5Q583,360 600,360ZM360,360Q377,360 388.5,348.5Q400,337 400,320Q400,303 388.5,291.5Q377,280 360,280Q343,280 331.5,291.5Q320,303 320,320Q320,337 331.5,348.5Q343,360 360,360ZM480,920Q363,920 281.5,838.5Q200,757 200,640L200,480L760,480L760,640Q760,757 678.5,838.5Q597,920 480,920Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_add_link_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M680,800L680,680L560,680L560,600L680,600L680,480L760,480L760,600L880,600L880,680L760,680L760,800L680,800ZM440,680L280,680Q197,680 138.5,621.5Q80,563 80,480Q80,397 138.5,338.5Q197,280 280,280L440,280L440,360L280,360Q230,360 195,395Q160,430 160,480Q160,530 195,565Q230,600 280,600L440,600L440,680ZM320,520L320,440L640,440L640,520L320,520ZM880,480L800,480Q800,430 765,395Q730,360 680,360L520,360L520,280L680,280Q763,280 821.5,338.5Q880,397 880,480Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_android_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M40,720Q49,613 105.5,523Q162,433 256,380L182,252Q176,243 179,233Q182,223 192,218Q200,213 210,216Q220,219 226,228L300,356Q386,320 480,320Q574,320 660,356L734,228Q740,219 750,216Q760,213 768,218Q778,223 781,233Q784,243 778,252L704,380Q798,433 854.5,523Q911,613 920,720L40,720ZM280,610Q301,610 315.5,595.5Q330,581 330,560Q330,539 315.5,524.5Q301,510 280,510Q259,510 244.5,524.5Q230,539 230,560Q230,581 244.5,595.5Q259,610 280,610ZM680,610Q701,610 715.5,595.5Q730,581 730,560Q730,539 715.5,524.5Q701,510 680,510Q659,510 644.5,524.5Q630,539 630,560Q630,581 644.5,595.5Q659,610 680,610Z"/>
|
||||
</vector>
|
||||
11
app/src/main/res/drawable/ic_arrow_back_24px.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:autoMirrored="true">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M313,520L537,744L480,800L160,480L480,160L537,216L313,440L800,440L800,520L313,520Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_arrow_circle_up_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M440,640L520,640L520,472L584,536L640,480L480,320L320,480L376,536L440,472L440,640ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
11
app/src/main/res/drawable/ic_arrow_forward_24px.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:autoMirrored="true">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M647,520L160,520L160,440L647,440L423,216L480,160L800,480L480,800L423,744L647,520Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_arrow_shape_up_stack_2_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M360,920L360,800L160,800L480,440L800,800L600,800L600,920L360,920ZM440,840L520,840L520,720L622,720L480,560L338,720L440,720L440,840ZM160,600L480,240L800,600L693,600L480,360L267,600L160,600ZM160,400L480,40L800,400L693,400L480,160L267,400L160,400ZM480,720L480,720L480,720L480,720L480,720L480,720L480,720Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_brightness_6_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,932L346,800L160,800L160,614L28,480L160,346L160,160L346,160L480,28L614,160L800,160L800,346L932,480L800,614L800,800L614,800L480,932ZM480,680Q563,680 621.5,621.5Q680,563 680,480Q680,397 621.5,338.5Q563,280 480,280L480,680ZM480,820L580,720L720,720L720,580L820,480L720,380L720,240L580,240L480,140L380,240L240,240L240,380L140,480L240,580L240,720L380,720L480,820ZM480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480L480,480Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_broken_image_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM240,503L400,343L560,503L720,343L760,383L760,200Q760,200 760,200Q760,200 760,200L200,200Q200,200 200,200Q200,200 200,200L200,463L240,503ZM200,760L760,760Q760,760 760,760Q760,760 760,760L760,496L720,456L560,616L400,456L240,616L200,576L200,760Q200,760 200,760Q200,760 200,760ZM200,760L200,760Q200,760 200,760Q200,760 200,760L200,496L200,576L200,463L200,383L200,200Q200,200 200,200Q200,200 200,200L200,200Q200,200 200,200Q200,200 200,200L200,463L200,463L200,576L200,576L200,760Q200,760 200,760Q200,760 200,760Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_captive_portal_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M838,895L720,777L720,866L640,866L640,640L866,640L866,720L776,720L894,838L838,895ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,500 878,520Q876,540 872,560L790,560Q795,540 797.5,520Q800,500 800,480Q800,460 797.5,440Q795,420 790,400L654,400Q657,420 658.5,440Q660,460 660,480Q660,500 658.5,520Q657,540 654,560L574,560Q577,540 578.5,520Q580,500 580,480Q580,460 578.5,440Q577,420 574,400L386,400Q383,420 381.5,440Q380,460 380,480Q380,500 381.5,520Q383,540 386,560L520,560L520,640L404,640Q416,683 435,722.5Q454,762 480,798Q500,798 520,795.5Q540,793 560,791L560,873Q540,875 520,877.5Q500,880 480,880ZM170,560L306,560Q303,540 301.5,520Q300,500 300,480Q300,460 301.5,440Q303,420 306,400L170,400Q165,420 162.5,440Q160,460 160,480Q160,500 162.5,520Q165,540 170,560ZM204,320L322,320Q331,283 344.5,247.5Q358,212 376,178Q321,196 277,232.5Q233,269 204,320ZM376,782Q358,748 344.5,712.5Q331,677 322,640L204,640Q233,691 277,727.5Q321,764 376,782ZM404,320L556,320Q544,277 525,237.5Q506,198 480,162Q454,198 435,237.5Q416,277 404,320ZM638,320L756,320Q727,269 683,232.5Q639,196 584,178Q602,212 615.5,247.5Q629,283 638,320Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_check_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M382,720L154,492L211,435L382,606L749,239L806,296L382,720Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_check_circle_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M424,664L706,382L650,326L424,552L310,438L254,494L424,664ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_checklist_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M222,760L80,618L136,562L221,647L391,477L447,534L222,760ZM222,440L80,298L136,242L221,327L391,157L447,214L222,440ZM520,680L520,600L880,600L880,680L520,680ZM520,360L520,280L880,280L880,360L520,360Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_close_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M256,760L200,704L424,480L200,256L256,200L480,424L704,200L760,256L536,480L760,704L704,760L480,536L256,760Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_download_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,640L280,440L336,382L440,486L440,160L520,160L520,486L624,382L680,440L480,640ZM240,800Q207,800 183.5,776.5Q160,753 160,720L160,600L240,600L240,720Q240,720 240,720Q240,720 240,720L720,720Q720,720 720,720Q720,720 720,720L720,600L800,600L800,720Q800,753 776.5,776.5Q753,800 720,800L240,800Z"/>
|
||||
</vector>
|
||||
14
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="137"
|
||||
android:viewportHeight="130">
|
||||
<group android:scaleX="0.7078261"
|
||||
android:scaleY="0.67165977"
|
||||
android:translateX="20.462858"
|
||||
android:translateY="21.342113">
|
||||
<path
|
||||
android:pathData="M107.11,60.88V95.33C107.11,97.72 106.26,99.76 104.56,101.45C102.86,103.15 100.82,104 98.44,104H37.78C35.39,104 33.35,103.15 31.65,101.45C29.96,99.76 29.11,97.72 29.11,95.33V60.88C27.45,59.37 26.17,57.42 25.26,55.03C24.36,52.65 24.34,50.05 25.21,47.23L29.76,32.5C30.34,30.62 31.37,29.07 32.85,27.84C34.33,26.61 36.04,26 37.99,26H98.22C100.18,26 101.87,26.6 103.32,27.79C104.76,28.98 105.81,30.55 106.46,32.5L111.01,47.23C111.88,50.05 111.86,52.61 110.95,54.92C110.05,57.24 108.77,59.22 107.11,60.88ZM77.64,56.33C79.59,56.33 81.07,55.67 82.08,54.33C83.09,52.99 83.49,51.49 83.28,49.83L80.89,34.67H72.44V50.7C72.44,52.22 72.95,53.53 73.96,54.65C74.97,55.77 76.2,56.33 77.64,56.33ZM58.14,56.33C59.8,56.33 61.16,55.77 62.2,54.65C63.25,53.53 63.78,52.22 63.78,50.7V34.67H55.33L52.94,49.83C52.65,51.57 53.03,53.08 54.08,54.38C55.13,55.68 56.48,56.33 58.14,56.33ZM38.86,56.33C40.16,56.33 41.3,55.86 42.27,54.92C43.25,53.99 43.84,52.79 44.06,51.35L46.44,34.67H37.99L33.66,49.18C33.22,50.63 33.46,52.18 34.36,53.84C35.27,55.5 36.76,56.33 38.86,56.33ZM97.36,56.33C99.45,56.33 100.97,55.5 101.91,53.84C102.85,52.18 103.06,50.63 102.56,49.18L98.01,34.67H89.78L92.16,51.35C92.38,52.79 92.97,53.99 93.95,54.92C94.92,55.86 96.06,56.33 97.36,56.33ZM37.78,95.33H98.44V64.78C98.08,64.93 97.85,65 97.74,65H97.36C95.41,65 93.69,64.68 92.21,64.03C90.73,63.38 89.27,62.33 87.82,60.88C86.53,62.18 85.04,63.19 83.38,63.92C81.72,64.64 79.95,65 78.07,65C76.13,65 74.3,64.64 72.6,63.92C70.91,63.19 69.41,62.18 68.11,60.88C66.88,62.18 65.45,63.19 63.83,63.92C62.2,64.64 60.45,65 58.58,65C56.48,65 54.58,64.64 52.89,63.92C51.19,63.19 49.69,62.18 48.39,60.88C46.88,62.4 45.38,63.47 43.9,64.08C42.42,64.69 40.74,65 38.86,65H38.37C38.19,65 37.99,64.93 37.78,64.78V95.33Z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</group>
|
||||
</vector>
|
||||
14
app/src/main/res/drawable/ic_launcher_monochrome.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="137"
|
||||
android:viewportHeight="130">
|
||||
<group android:scaleX="0.72"
|
||||
android:scaleY="0.6832117"
|
||||
android:translateX="19.18"
|
||||
android:translateY="20.59124">
|
||||
<path
|
||||
android:pathData="M107.11,60.88V95.33C107.11,97.72 106.26,99.76 104.56,101.45C102.86,103.15 100.82,104 98.44,104H37.78C35.39,104 33.35,103.15 31.65,101.45C29.96,99.76 29.11,97.72 29.11,95.33V60.88C27.45,59.37 26.17,57.42 25.26,55.03C24.36,52.65 24.34,50.05 25.21,47.23L29.76,32.5C30.34,30.62 31.37,29.07 32.85,27.84C34.33,26.61 36.04,26 37.99,26H98.22C100.18,26 101.87,26.6 103.32,27.79C104.76,28.98 105.81,30.55 106.46,32.5L111.01,47.23C111.88,50.05 111.86,52.61 110.95,54.92C110.05,57.24 108.77,59.22 107.11,60.88ZM77.64,56.33C79.59,56.33 81.07,55.67 82.08,54.33C83.09,52.99 83.49,51.49 83.28,49.83L80.89,34.67H72.44V50.7C72.44,52.22 72.95,53.53 73.96,54.65C74.97,55.77 76.2,56.33 77.64,56.33ZM58.14,56.33C59.8,56.33 61.16,55.77 62.2,54.65C63.25,53.53 63.78,52.22 63.78,50.7V34.67H55.33L52.94,49.83C52.65,51.57 53.03,53.08 54.08,54.38C55.13,55.68 56.48,56.33 58.14,56.33ZM38.86,56.33C40.16,56.33 41.3,55.86 42.27,54.92C43.25,53.99 43.84,52.79 44.06,51.35L46.44,34.67H37.99L33.66,49.18C33.22,50.63 33.46,52.18 34.36,53.84C35.27,55.5 36.76,56.33 38.86,56.33ZM97.36,56.33C99.45,56.33 100.97,55.5 101.91,53.84C102.85,52.18 103.06,50.63 102.56,49.18L98.01,34.67H89.78L92.16,51.35C92.38,52.79 92.97,53.99 93.95,54.92C94.92,55.86 96.06,56.33 97.36,56.33ZM37.78,95.33H98.44V64.78C98.08,64.93 97.85,65 97.74,65H97.36C95.41,65 93.69,64.68 92.21,64.03C90.73,63.38 89.27,62.33 87.82,60.88C86.53,62.18 85.04,63.19 83.38,63.92C81.72,64.64 79.95,65 78.07,65C76.13,65 74.3,64.64 72.6,63.92C70.91,63.19 69.41,62.18 68.11,60.88C66.88,62.18 65.45,63.19 63.83,63.92C62.2,64.64 60.45,65 58.58,65C56.48,65 54.58,64.64 52.89,63.92C51.19,63.19 49.69,62.18 48.39,60.88C46.88,62.4 45.38,63.47 43.9,64.08C42.42,64.69 40.74,65 38.86,65H38.37C38.19,65 37.99,64.93 37.78,64.78V95.33Z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</group>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_link_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M440,680L280,680Q197,680 138.5,621.5Q80,563 80,480Q80,397 138.5,338.5Q197,280 280,280L440,280L440,360L280,360Q230,360 195,395Q160,430 160,480Q160,530 195,565Q230,600 280,600L440,600L440,680ZM320,520L320,440L640,440L640,520L320,520ZM520,680L520,600L680,600Q730,600 765,565Q800,530 800,480Q800,430 765,395Q730,360 680,360L520,360L520,280L680,280Q763,280 821.5,338.5Q880,397 880,480Q880,563 821.5,621.5Q763,680 680,680L520,680Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_mobile_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M280,920Q247,920 223.5,896.5Q200,873 200,840L200,120Q200,87 223.5,63.5Q247,40 280,40L680,40Q713,40 736.5,63.5Q760,87 760,120L760,244Q778,251 789,266Q800,281 800,300L800,380Q800,399 789,414Q778,429 760,436L760,840Q760,873 736.5,896.5Q713,920 680,920L280,920ZM280,840L680,840Q680,840 680,840Q680,840 680,840L680,120Q680,120 680,120Q680,120 680,120L280,120Q280,120 280,120Q280,120 280,120L280,840Q280,840 280,840Q280,840 280,840ZM280,840Q280,840 280,840Q280,840 280,840L280,120Q280,120 280,120Q280,120 280,120L280,120Q280,120 280,120Q280,120 280,120L280,840Q280,840 280,840Q280,840 280,840ZM480,240Q497,240 508.5,228.5Q520,217 520,200Q520,183 508.5,171.5Q497,160 480,160Q463,160 451.5,171.5Q440,183 440,200Q440,217 451.5,228.5Q463,240 480,240Z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_open_in_browser_24px.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L600,840L600,760L760,760Q760,760 760,760Q760,760 760,760L760,280L200,280L200,760Q200,760 200,760Q200,760 200,760L360,760L360,840L200,840ZM440,840L440,594L376,658L320,600L480,440L640,600L584,658L520,594L520,840L440,840Z"/>
|
||||
</vector>
|
||||