Skip to content

Commit

Permalink
Merge pull request #21 from gohj99/develop
Browse files Browse the repository at this point in the history
Updated to 1.2.9
  • Loading branch information
gohj99 authored Nov 16, 2024
2 parents b5a25ef + 90f1aa0 commit 1a9226d
Show file tree
Hide file tree
Showing 31 changed files with 389 additions and 109 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/app-dev-build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Android Build

on:
pull_request:
branches:
- master
- develop

workflow_dispatch:
push:
branches:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/app-pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Android Build

on:
pull_request:
branches:
- master
- develop

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Extract repository name
id: repo-name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV

- name: Extract version name
id: version_name
run: |
VERSION_NAME=$(grep -oP 'versionName\s*=\s*"\K[^"]+' ./app/build.gradle.kts)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install Android Build Tools
run: sdkmanager "build-tools;29.0.3"

- name: Extract formatted build date
run: echo "BUILD_DATE=$(date -u '+%Y%m%d%H')" >> $GITHUB_ENV

- name: Inject Secrets into config.properties
run: |
echo "api_id=${{ secrets.API_ID }}" > app/src/main/assets/config.properties
echo "api_hash=${{ secrets.API_HASH }}" >> app/src/main/assets/config.properties
echo "BUILD_DATE=${{ env.BUILD_DATE }}" >> app/src/main/assets/config.properties
echo "BETA=true" >> app/src/main/assets/config.properties
- uses: gradle/gradle-build-action@v3
with:
gradle-version: 8.9
arguments: assembleRelease
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: gh login
run: echo "${{ secrets.SECRET_TOKEN }}" | gh auth login --with-token
Expand All @@ -28,21 +28,21 @@ jobs:
if gh secret list | grep -q "GIST_ID"
then
echo "GIST_ID found"
echo "GIST=${{ secrets.GIST_ID }}" >> $GITHUB_OUTPUT
echo ::set-output name=GIST::${{ secrets.GIST_ID }}
curl https://gist.githubusercontent.com/${{ github.actor }}/${{ secrets.GIST_ID }}/raw/clone.json > clone_before.json
if cat clone_before.json | grep '404: Not Found'; then
echo "GIST_ID not valid anymore. Creating another gist..."
gist_id=$(gh gist create clone.json | awk -F / '{print $NF}')
echo $gist_id | gh secret set GIST_ID
echo "GIST=$gist_id" >> $GITHUB_OUTPUT
echo ::set-output name=GIST::$gist_id
cp clone.json clone_before.json
git rm --ignore-unmatch CLONE.md
fi
else
echo "GIST_ID not found. Creating a gist..."
gist_id=$(gh gist create clone.json | awk -F / '{print $NF}')
echo $gist_id | gh secret set GIST_ID
echo "GIST=$gist_id" >> $GITHUB_OUTPUT
echo ::set-output name=GIST::$gist_id
cp clone.json clone_before.json
fi
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/github-traffic-count-badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: GitHub Traffic Count Update Everyday

on:
schedule:
- cron: "0 */24 * * *"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: gh login
run: echo "${{ secrets.SECRET_TOKEN }}" | gh auth login --with-token

- name: parse latest traffic count
run: |
curl --user "${{ github.actor }}:${{ secrets.SECRET_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/traffic/views \
> traffic.json
- name: create gist and download previous count
id: set_id
run: |
if gh secret list | grep -q "TRAFFIC_ID"
then
echo "TRAFFIC_ID found"
echo ::set-output name=GIST::${{ secrets.TRAFFIC_ID }}
curl https://gist.githubusercontent.com/${{ github.actor }}/${{ secrets.TRAFFIC_ID }}/raw/traffic.json > traffic_before.json
if cat traffic_before.json | grep '404: Not Found'; then
echo "TRAFFIC_ID not valid anymore. Creating another gist..."
traffic_id=$(gh gist create traffic.json | awk -F / '{print $NF}')
echo $traffic_id | gh secret set TRAFFIC_ID
echo ::set-output name=GIST::$traffic_id
cp traffic.json traffic_before.json
git rm --ignore-unmatch TRAFFIC.md
fi
else
echo "TRAFFIC_ID not found. Creating a gist..."
traffic_id=$(gh gist create traffic.json | awk -F / '{print $NF}')
echo $traffic_id | gh secret set TRAFFIC_ID
echo ::set-output name=GIST::$traffic_id
cp traffic.json traffic_before.json
fi
- name: update traffic.json
run: |
curl https://gist.githubusercontent.com/MShawon/d37c49ee4ce03f64b92ab58b0cec289f/raw/traffic.py > traffic.py
python3 traffic.py
- name: Update gist with latest count
run: |
content=$(sed -e 's/\\/\\\\/g' -e 's/\t/\\t/g' -e 's/\"/\\"/g' -e 's/\r//g' "traffic.json" | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
echo '{"description": "${{ github.repository }} traffic statistics", "files": {"traffic.json": {"content": "'"$content"'"}}}' > post_traffic.json
curl -s -X PATCH \
--user "${{ github.actor }}:${{ secrets.SECRET_TOKEN }}" \
-H "Content-Type: application/json" \
-d @post_traffic.json https://api.github.com/gists/${{ steps.set_id.outputs.GIST }} > /dev/null 2>&1
if [ ! -f TRAFFIC.md ]; then
shields="https://img.shields.io/badge/dynamic/json?color=success&label=Views&query=count&url="
url="https://gist.githubusercontent.com/${{ github.actor }}/${{ steps.set_id.outputs.GIST }}/raw/traffic.json"
repo="https://github.com/MShawon/github-clone-count-badge"
echo ''> TRAFFIC.md
echo '
**Markdown**
```markdown' >> TRAFFIC.md
echo "[![GitHub Traffic]($shields$url&logo=github)]($repo)" >> TRAFFIC.md
echo '
```
**HTML**
```html' >> TRAFFIC.md
echo "<a href='$repo'><img alt='GitHub Traffic' src='$shields$url&logo=github'></a>" >> TRAFFIC.md
echo '```' >> TRAFFIC.md
git add TRAFFIC.md
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
git commit -m "create traffic count badge"
fi
- name: Push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
minSdk = 26
//noinspection OldTargetApi
targetSdk = 34
versionCode = 19
versionName = "1.2.8"
versionCode = 20
versionName = "1.2.9"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
-dontwarn org.bouncycastle.jsse.**
-dontwarn org.conscrypt.**
-dontwarn org.openjsse.**
-keepattributes Signature
-keep class com.google.gson.reflect.TypeToken { *; }
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:required="true" />

<application
android:name=".ACRA"
android:name=".utils.ACRA"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
Expand Down
16 changes: 4 additions & 12 deletions app/src/main/java/com/gohj99/telewatch/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import android.annotation.SuppressLint
import android.content.ContentValues
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
Expand All @@ -31,12 +29,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.core.content.FileProvider
import androidx.lifecycle.lifecycleScope
import com.gohj99.telewatch.telegram.TgApi
import com.gohj99.telewatch.ui.chat.SplashChatScreen
import com.gohj99.telewatch.ui.main.Chat
import com.gohj99.telewatch.ui.main.ErrorScreen
import com.gohj99.telewatch.ui.main.SplashLoadingScreen
import com.gohj99.telewatch.ui.theme.TelewatchTheme
import com.gohj99.telewatch.utils.telegram.TgApi
import com.gohj99.telewatch.utils.urlHandle
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -352,15 +351,8 @@ class ChatActivity : ComponentActivity() {
lastReadInboxMessageId = lastReadInboxMessageId,
listState = listState,
onLinkClick = { url ->
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val packageManager: PackageManager = packageManager
val activities: List<ResolveInfo> = packageManager.queryIntentActivities(intent, 0)

if (activities.isNotEmpty()) {
startActivity(intent)
} else {
// 处理没有可用浏览器的情况
Toast.makeText(this, getString(R.string.No_app_to_handle_this_url), Toast.LENGTH_SHORT).show()
urlHandle(url, this) {
if (it) goToChat.value = true
}
},
reInit = {
Expand Down
29 changes: 17 additions & 12 deletions app/src/main/java/com/gohj99/telewatch/ConfirmLogoutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
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.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
Expand All @@ -40,9 +39,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.gohj99.telewatch.telegram.TgApi
import com.gohj99.telewatch.ui.theme.TelewatchTheme
import com.gohj99.telewatch.ui.verticalRotaryScroll
import com.gohj99.telewatch.utils.telegram.TgApi
import com.google.gson.Gson
import com.google.gson.JsonObject
import java.io.File
Expand Down Expand Up @@ -166,28 +165,32 @@ fun SplashConfirmLogoutActivityScreen(set: (Boolean) -> Unit) {
Spacer(modifier = Modifier.height(16.dp))

// 不同意和同意按钮
Row(
horizontalArrangement = Arrangement.Center,
Box(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 64.dp, start = 16.dp, end = 16.dp)
.padding(bottom = 4.dp, start = 16.dp, end = 16.dp)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Button(
onClick = { set(false) },
modifier = Modifier.weight(1f),
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(
containerColor = Color(0xFF3E4D58), // 按钮背景颜色
contentColor = Color.White // 按钮文字颜色
)
) {
Text(text = stringResource(id = R.string.disagree))
}

Spacer(modifier = Modifier.width(8.dp))

}
Box(
modifier = Modifier
.padding(bottom = 16.dp, start = 16.dp, end = 16.dp)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Button(
onClick = { set(true) },
modifier = Modifier.weight(1f),
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(
containerColor = Color(0xFF3A7FBE), // 按钮背景颜色
contentColor = Color.White // 按钮文字颜色
Expand All @@ -196,6 +199,8 @@ fun SplashConfirmLogoutActivityScreen(set: (Boolean) -> Unit) {
Text(text = stringResource(id = R.string.agree))
}
}

Spacer(modifier = Modifier.height(42.dp))
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/gohj99/telewatch/ImgViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.gohj99.telewatch.telegram.TgApi
import com.gohj99.telewatch.ui.main.ErrorScreen
import com.gohj99.telewatch.ui.main.SplashLoadingScreen
import com.gohj99.telewatch.ui.theme.TelewatchTheme
import com.gohj99.telewatch.utils.telegram.TgApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/gohj99/telewatch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.lifecycle.lifecycleScope
import com.gohj99.telewatch.telegram.TgApi
import com.gohj99.telewatch.ui.main.Chat
import com.gohj99.telewatch.ui.main.ErrorScreen
import com.gohj99.telewatch.ui.main.MainScreen
import com.gohj99.telewatch.ui.main.SplashLoadingScreen
import com.gohj99.telewatch.ui.theme.TelewatchTheme
import com.gohj99.telewatch.utils.telegram.TgApi
import com.google.gson.Gson
import com.google.gson.JsonObject
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -84,6 +84,8 @@ class MainActivity : ComponentActivity() {
)
finish()
} else {
initializeApp()
/*
// 显示启动页面
setContent {
TelewatchTheme {
Expand All @@ -95,6 +97,7 @@ class MainActivity : ComponentActivity() {
Handler(Looper.getMainLooper()).postDelayed({
initializeApp()
}, 600) // 延迟
*/
}
}

Expand Down
Loading

0 comments on commit 1a9226d

Please sign in to comment.