Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4fe776d
optimize code and project structure
Steve-Mr Apr 5, 2025
8b2aec4
bump versionName
Steve-Mr Apr 5, 2025
eeadc49
prepare for ui
Steve-Mr Apr 5, 2025
d191261
upgrade agp version
Steve-Mr May 5, 2025
1f1e9d9
update dependency version & add preference datastore
Steve-Mr May 5, 2025
fbcb29b
Implement DataStore and add Hilt for dependency injection
Steve-Mr May 27, 2025
b3aaa44
Create notification channels in Application class and update dependen…
Steve-Mr Jun 14, 2025
344728c
Move ConnectionViewModel to viewmodel package
Steve-Mr Jun 14, 2025
f9abd79
feat: implement settings screen
Steve-Mr Jun 14, 2025
3e6a003
Refactor: Use PreferenceRepository for managing preferences
Steve-Mr Jun 14, 2025
9dd416f
Implement MainActivityAlias and hide in launcher feature
Steve-Mr Jun 14, 2025
5f99f84
Refactor: Improve concurrency and ear protection logic
Steve-Mr Jun 14, 2025
ae5c3f7
Refactor AudioDeviceCallback in ForegroundService
Steve-Mr Jun 14, 2025
adb83f0
Refactor Application class and update manifest
Steve-Mr Jun 14, 2025
c4d962b
Refactor ForegroundService for clarity and robustness
Steve-Mr Jun 14, 2025
c601cc2
Update Compose BOM and remove redundant version variables
Steve-Mr Jun 14, 2025
6795ee1
Refactor: Organize Activities into `activity` package
Steve-Mr Jun 15, 2025
dfe0e2c
Refactor: Use `PendingIntent.getActivity` for settings action
Steve-Mr Jun 15, 2025
d75dac9
Refactor: Implement navigation in SettingsScreen
Steve-Mr Jun 15, 2025
d1f145b
Implement WelcomeActivity and WelcomeViewModel
Steve-Mr Jun 15, 2025
a4bbb52
Refactor QSTileService and SettingsViewModel
Steve-Mr Jun 15, 2025
72008ed
Refactor "Hide in Launcher" to "Show Icon" and improve SwitchRow
Steve-Mr Jun 15, 2025
2b6033a
Refactor service start on boot with WorkManager
Steve-Mr Jun 15, 2025
8fea945
Refactor SettingsViewModel to use StateFlow from repository
Steve-Mr Jun 16, 2025
bbe8e32
Refactor WelcomeViewModel to use StateFlow for showIconState
Steve-Mr Jun 16, 2025
939d7de
Refactor: Add customizable ear protection threshold
Steve-Mr Jun 16, 2025
7de9402
Refactor service state handling and add auto-restart logic
Steve-Mr Jun 16, 2025
d38cdbf
Refactor icon visibility preference logic
Steve-Mr Jun 16, 2025
c6f3610
Animate ear protection threshold slider visibility
Steve-Mr Jun 16, 2025
9166077
Refactor: Consolidate settings item containers
Steve-Mr Jun 16, 2025
dc950bf
Refactor settings UI and conditionally show notification settings
Steve-Mr Jun 17, 2025
161b35c
Refactor foreground service control in SettingsViewModel
Steve-Mr Jun 17, 2025
f9ae1f6
Add spacing in SettingsScreen
Steve-Mr Jun 17, 2025
c19a897
Refactor SettingsScreen UI and component styling
Steve-Mr Jun 17, 2025
c4fdc4a
Refactor: Update TextContent to use tertiary color
Steve-Mr Jun 18, 2025
0728dbf
Refactor WelcomeScreen UI and navigation
Steve-Mr Jun 18, 2025
c43c49e
Enable `generateLocaleConfig` and specify `unqualifiedResLocale`
Steve-Mr Jun 18, 2025
ac86aa0
Update string resources for clarity and localization
Steve-Mr Jun 18, 2025
2786164
Update SettingsScreen UI text
Steve-Mr Jun 18, 2025
35bfc68
Add monochrome adaptive icon support
Steve-Mr Jun 18, 2025
7d356b5
Update Gradle plugin versions
Steve-Mr Jun 19, 2025
1f20fc9
Introduce build flavors for app icon visibility
Steve-Mr Jun 19, 2025
a91f16f
Refactor CI and upload script
Steve-Mr Jun 20, 2025
c86124e
Remove SettingsReceiver and related constants
Steve-Mr Jun 20, 2025
533d16d
Refactor: Remove unused code and imports
Steve-Mr Jun 20, 2025
a4365a2
Fix: Restart ForegroundService if killed by system when QS tile is ac…
Steve-Mr Jun 20, 2025
50618a8
Update dependencies and version name
Steve-Mr Jun 20, 2025
cb849e2
Refactor release process in CI
Steve-Mr Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 60 additions & 38 deletions .github/scripts/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,69 @@
urlPrefix = apiAddress + "bot" + os.getenv("TELEGRAM_TOKEN")


def findString(sourceStr, targetStr):
if str(sourceStr).find(str(targetStr)) == -1:
return False
else:
return True
def sendMediaGroup(user_id, paths):
url = urlPrefix + "/sendMediaGroup"
files = {}
media = []

for i, path in enumerate(paths):
file_key = f'file{i}'
files[file_key] = open(path, 'rb')
media_item = {
'type': 'document',
'media': f'attach://{file_key}'
}
media.append(media_item)

def genFileDirectory(path):
files_walk = os.walk(path)
target = {
data = {
'chat_id': user_id,
'media': json.dumps(media)
}
for root, dirs, file_name_dic in files_walk:
for fileName in file_name_dic:
if findString(fileName, "v8a"):
target["arm64"] = (fileName, open(path + "/" + fileName, "rb"))
if findString(fileName, "v7a"):
target["armeabi"] = (fileName, open(path + "/" + fileName, "rb"))
if findString(fileName, "x86.apk"):
target["i386"] = (fileName, open(path + "/" + fileName, "rb"))
if findString(fileName, "x86_64"):
target["amd64"] = (fileName, open(path + "/" + fileName, "rb"))

return target


def sendDocument(user_id, path, message = "", entities = None):
files = {'document': open(path, 'rb')}
data = {'chat_id': user_id,
'caption': message,
'parse_mode': 'Markdown',
'caption_entities': entities}
response = requests.post(urlPrefix + "/sendDocument", files=files, data=data)
print(response.json())


def sendAPKs(path):
apks = os.listdir("apks")
apks.sort()
apk = os.path.join("apks", apks[0])
sendDocument(user_id="@maaryIsTyping", path = apk, message="#app #apk https://github.com/Steve-Mr/LiveInPeace")

response = requests.post(url, files=files, data=data)
print("MediaGroup Response:", response.json())

for f in files.values():
f.close()


def sendTextMessage(user_id, message, disable_preview=False):
url = urlPrefix + "/sendMessage"

data = {
'chat_id': user_id,
'text': message,
'parse_mode': 'Markdown',
'disable_web_page_preview': disable_preview
}
response = requests.post(url, data=data)

response_data = response.json()



if __name__ == '__main__':
sendAPKs("./apks")
# 从环境变量中获取两个 APK 文件的路径
apk_path1 = os.getenv("APK_FILE_UPLOAD1")
apk_path2 = os.getenv("APK_FILE_UPLOAD2")

# 检查路径是否存在
if not apk_path1 or not apk_path2:
print("错误:未能在环境变量中找到 APK 文件路径。")
exit(1)

# 将两个 APK 路径放入一个列表
apk_paths = [apk_path1, apk_path2]

# 从环境变量中获取版本信息和提交信息来构建消息内容
version_name = os.getenv("VERSION_NAME", "N/A")
commit_message = os.getenv("COMMIT_MESSAGE", "无提交信息。")

message = (
f"#app #apk\n"
f"**版本:** `{version_name}`\n\n"
f"https://github.com/Steve-Mr/LiveInPeace"
)

sendMediaGroup(user_id="@maaryIsTyping", paths=apk_paths)
sendTextMessage(user_id="@maaryIsTyping", message=message, disable_preview=True)
131 changes: 75 additions & 56 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 17
Expand All @@ -19,107 +17,118 @@ jobs:
cache: gradle

- name: Storing key.properties
run: |
echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > ./key.properties
ls ./
ls -l key.properties
run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > ./key.properties

- name: Storing keystore
run: |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > ./app/key.keystore
ls ./app
ls -l ./app/key.keystore
run: echo "${{ secrets.KEYSTORE }}" | base64 --decode > ./app/key.keystore

- name: Storing keystore
run: |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > ./key.keystore
ls -l ./key.keystore
run: echo "${{ secrets.KEYSTORE }}" | base64 --decode > ./key.keystore

- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Build with Gradle 命令不变,它会自动构建所有 flavors 和 ABIs
- name: Build with Gradle
run: |
./gradlew :app:assembleRelease

echo "APK_FILE=$(find app/build/outputs/apk -name '*arm64*.apk')" >> $GITHUB_ENV
echo "APK_FILE_ARMV7=$(find app/build/outputs/apk -name '*v7a*.apk')" >> $GITHUB_ENV
echo "APK_FILE_X86=$(find app/build/outputs/apk -name '*x86*.apk')" >> $GITHUB_ENV
echo "APK_FILE_X64=$(find app/build/outputs/apk -name '*x64*.apk')" >> $GITHUB_ENV
echo "APK_FILE_ARMV8_ICON_ENABLED=$(find app/build/outputs/apk -name '*iconEnabled-arm64*.apk')" >> $GITHUB_ENV
echo "APK_FILE_UNI_ICON_ENABLED=$(find app/build/outputs/apk -name '*iconEnabled-universal*.apk')" >> $GITHUB_ENV
echo "APK_FILE_ARMV8_ICON_DISABLED=$(find app/build/outputs/apk -name '*iconDisabled-arm64*.apk')" >> $GITHUB_ENV
echo "APK_FILE_UNI_ICON_DISABLED=$(find app/build/outputs/apk -name '*iconDisabled-universal*.apk')" >> $GITHUB_ENV

- uses: actions/upload-artifact@v2
name: Upload apk (arm64-v8a)
- uses: actions/upload-artifact@v4
name: Upload apk (icon-enabled-arm64-v8a)
with:
name: LiveInPeace-arm64-v8a
path: ${{ env.APK_FILE }}
- uses: actions/upload-artifact@v2
name: Upload apk (armeabi-v7a)
name: LiveInPeace-icon-enabled-arm64-v8a.apk
path: ${{ env.APK_FILE_ARMV8_ICON_ENABLED }}
- uses: actions/upload-artifact@v4
name: Upload apk (icon-enabled-universal)
with:
name: LiveInPeace-armeabi-v7a
path: ${{ env.APK_FILE_ARMV7 }}
- uses: actions/upload-artifact@v2
name: Upload apk (x86_64)
name: LiveInPeace-icon-enabled-universal.apk
path: ${{ env.APK_FILE_UNI_ICON_ENABLED }}
- uses: actions/upload-artifact@v4
name: Upload apk (icon-disabled-arm64-v8a)
with:
name: LiveInPeace-x86_64
path: ${{ env.APK_FILE_X64 }}
- uses: actions/upload-artifact@v2
name: Upload apk (x86)
name: LiveInPeace-icon-disabled-arm64-v8a.apk
path: ${{ env.APK_FILE_ARMV8_ICON_DISABLED }}
- uses: actions/upload-artifact@v4
name: Upload apk (icon-disabled-universal)
with:
name: LiveInPeace-x86
path: ${{ env.APK_FILE_X86 }}
name: LiveInPeace-icon-disabled-universal.apk
path: ${{ env.APK_FILE_UNI_ICON_DISABLED }}

- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"

# 获取今天已有的 releases 数量,用于生成序号
- name: Get number of today's releases
id: release_count
run: |
DATE=${{ steps.date.outputs.date }}
COUNT=$(gh release list --limit 100 | grep "$DATE" | wc -l)
COUNT=$((COUNT + 1))
printf "count=%02d\n" "$COUNT" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: v${{ github.run_number }}
tag_name: release-${{ steps.date.outputs.date }}-${{ steps.release_count.outputs.count }}
release_name: Release ${{ steps.date.outputs.date }}
prerelease: true
release_name: Release v${{ github.run_number }}
body: |
## Changes
${{ github.event.pull_request.body }}
${{ steps.show_pr_commits.outputs.commits }}

# --- 修改开始:更新上传到 Release 的逻辑 ---
- uses: actions/upload-release-asset@v1
name: Upload apk (arm64-v8a)
name: Upload Release APK (iconEnabled, arm64-v8a)
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: LiveInPeace-arm64-v8a.apk
asset_path: ${{ env.APK_FILE }}
asset_content_type: application/zip
asset_path: ${{ env.APK_FILE_ARMV8_ICON_ENABLED }}
asset_name: LiveInPeace-icon-enabled-arm64-v8a.apk
asset_content_type: application/vnd.android.package-archive

- uses: actions/upload-release-asset@v1
name: Upload apk (armeabi-v7a)
name: Upload Release APK (iconEnabled, universal)
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: LiveInPeace-armeabi-v7a.apk
asset_path: ${{ env.APK_FILE_ARMV7 }}
asset_content_type: application/zip
asset_path: ${{ env.APK_FILE_UNI_ICON_ENABLED }}
asset_name: LiveInPeace-icon-enabled-universal.apk
asset_content_type: application/vnd.android.package-archive

- uses: actions/upload-release-asset@v1
name: Upload apk (x86_64)
name: Upload Release APK (iconDisabled, arm64-v8a)
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: LiveInPeace-x86_64.apk
asset_path: ${{ env.APK_FILE_X64 }}
asset_content_type: application/zip
asset_path: ${{ env.APK_FILE_ARMV8_ICON_DISABLED }}
asset_name: LiveInPeace-icon-disabled-arm64-v8a.apk
asset_content_type: application/vnd.android.package-archive

- uses: actions/upload-release-asset@v1
name: Upload apk (x86)
name: Upload Release APK (iconDisabled, universal)
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: LiveInPeace-x86.apk
asset_path: ${{ env.APK_FILE_X86 }}
asset_content_type: application/zip
asset_path: ${{ env.APK_FILE_UNI_ICON_DISABLED }}
asset_name: LiveInPeace-icon-disabled-universal.apk
asset_content_type: application/vnd.android.package-archive
# --- 修改结束 ---

upload:
name: Upload Release
Expand All @@ -129,11 +138,12 @@ jobs:
- telegram-bot-api
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4 # 建议使用 v3
with:
path: artifacts

- name: Download Telegram Bot API Binary
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: telegram-bot-api-binary
path: .
Expand All @@ -142,14 +152,21 @@ jobs:
run: |
mkdir apks
find artifacts -name "*.apk" -exec cp {} apks \;
echo "APK_FILE_UPLOAD=$(find apks -name '*arm64*.apk')" >> $GITHUB_ENV

# 添加一个调试步骤,列出所有复制过来的APK,方便排查
echo "--- Listing files in apks directory ---"
ls ./apks

# 修正这里的匹配模式,确保与 build job 一致
echo "APK_FILE_UPLOAD1=$(find apks -name '*iconEnabled-arm64*.apk')" >> $GITHUB_ENV
echo "APK_FILE_UPLOAD2=$(find apks -name '*iconDisabled-arm64*.apk')" >> $GITHUB_ENV


- name: Get Apk Info
id: apk
uses: JantHsueh/get-apk-info-action@master
with:
apkPath: ${{ env.APK_FILE_UPLOAD }}
apkPath: ${{ env.APK_FILE_UPLOAD1 }}

- name: Release
run: |
Expand All @@ -163,6 +180,8 @@ jobs:
VERSION_CODE: ${{steps.apk.outputs.versionCode}}
VERSION_NAME: ${{steps.apk.outputs.versionNum}}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
APK_FILE_UPLOAD1: ${{ env.APK_FILE_UPLOAD1 }}
APK_FILE_UPLOAD2: ${{ env.APK_FILE_UPLOAD2 }}

telegram-bot-api:
name: Telegram Bot API
Expand All @@ -176,7 +195,7 @@ jobs:
git status telegram-bot-api >> telegram-bot-api-status
- name: Cache Bot API Binary
id: cache-bot-api
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: telegram-bot-api-binary
key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }}
Expand Down
Loading
Loading