Skip to content

Commit

Permalink
feat: Added the delete message function and fixed bugs and improvements
Browse files Browse the repository at this point in the history
- Added the delete message function
- Added a long press menu to support deleting and reloading messages
- Fixed some new chat related issues
- Improved the about page
- Added beta warning

feat: 增加删除消息功能并修复错误和改进

- 新增删除消息功能
- 添加长按菜单,支持删除和重新加载消息
- 修复了一些新聊天相关的问题
- 完善关于页面
- 添加测试版警告

Signed-off-by: gohj99 <[email protected]>
  • Loading branch information
gohj99 committed Nov 2, 2024
1 parent a35dfa8 commit f8abe68
Show file tree
Hide file tree
Showing 25 changed files with 711 additions and 315 deletions.
1 change: 1 addition & 0 deletions .github/workflows/app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
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=false" >> app/src/main/assets/config.properties
- uses: gradle/gradle-build-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/app-dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
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:
Expand Down
3 changes: 1 addition & 2 deletions README.ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ adb install Telewatch.apk
- テキスト、画像、ビデオの閲覧またはダウンロード
- 画像やビデオの保存
- テキスト送信
- メッセージ編集処理
- メッセージ削除処理
- メッセージ削除
- クラウンローテーションのサポート

## 最小構成と推奨構成
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ adb install Telewatch.apk
- Viewing or downloading text, images, and videos
- Saving images or videos
- Text messaging
- Message editing
- Message deletion
- Support for rotating the digital crown

Expand Down
3 changes: 1 addition & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ adb install Telewatch.apk
- 文字、图片、视频查看或下载
- 保存图片或视频
- 文字发送
- 编辑消息处理
- 删除消息处理
- 删除消息
- 支持表冠旋转

## 最低配置和推荐配置
Expand Down
3 changes: 1 addition & 2 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ adb install Telewatch.apk
- 文字、圖片、影片檢視或下載
- 儲存圖片或視頻
- 文字發送
- 編輯訊息處理
- 刪除訊息處理
- 刪除訊息
- 支援錶冠旋轉

## 最低配置和建議配置
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
android:theme="@style/Theme.Telewatch"
tools:ignore="WearStandaloneAppFlag"
tools:targetApi="31">
<activity
android:name=".IsBetaActivity"
android:exported="false"
android:label="@string/Beta_title"
android:theme="@style/Theme.Telewatch" />
<activity
android:name=".NetworkSettingActivity"
android:exported="false"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/assets/config.properties.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
api_id=YOU_API_ID
api_hash=YOU_API_HASH
BUILD_DATE=2024
BUILD_DATE=2024
BETA=false
2 changes: 1 addition & 1 deletion app/src/main/java/com/gohj99/telewatch/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AboutActivity : ComponentActivity() {
}
}

private fun loadConfig(context: Context): Properties {
fun loadConfig(context: Context): Properties {
val properties = Properties()
try {
val inputStream = context.assets.open("config.properties")
Expand Down
360 changes: 222 additions & 138 deletions app/src/main/java/com/gohj99/telewatch/ChatActivity.kt

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions app/src/main/java/com/gohj99/telewatch/IsBetaActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (c) 2024 gohj99. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
* Vestibulum commodo. Ut rhoncus gravida arcu.
*/

package com.gohj99.telewatch

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
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.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.gohj99.telewatch.ui.CustomButton
import com.gohj99.telewatch.ui.theme.TelewatchTheme
import com.gohj99.telewatch.ui.verticalRotaryScroll

class IsBetaActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TelewatchTheme {
val scrollState = rememberScrollState()
LaunchedEffect(Unit) {
scrollState.scrollTo(80)
}

Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(scrollState)
.verticalRotaryScroll(scrollState),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
// 标题
Text(
text = stringResource(id = R.string.Beta_title),
fontSize = 20.sp,
fontWeight = FontWeight.Bold,
color = Color.White,
textAlign = TextAlign.Center,
modifier = Modifier.padding(top = 86.dp)
)

// 主要说明部分
Text(
text = stringResource(id = R.string.Beta_description),
fontSize = 16.sp,
color = Color.White,
textAlign = TextAlign.Center,
modifier = Modifier.padding(16.dp)
)

Spacer(modifier = Modifier.height(16.dp))

// 不同意和同意按钮
Row(
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 64.dp, start = 16.dp, end = 16.dp)
) {
CustomButton(
onClick = {
finish()
},
text = "OK"
)
}
}
}
}
}
}
11 changes: 10 additions & 1 deletion app/src/main/java/com/gohj99/telewatch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ class MainActivity : ComponentActivity() {
}

private fun initMain() {
val config = loadConfig(this)
if (config.getProperty("BETA") == "true") {
startActivity(
Intent(
this,
IsBetaActivity::class.java
)
)
}
lifecycleScope.launch(Dispatchers.IO) {
try {
val gson = Gson()
Expand Down Expand Up @@ -247,7 +256,7 @@ class MainActivity : ComponentActivity() {
TgApiManager.tgApi = TgApi(
this@MainActivity,
chatsList = chatsList,
UserId = jsonObject.keySet().firstOrNull().toString(),
userId = jsonObject.keySet().firstOrNull().toString(),
topTitle = topTitle,
chatsFoldersList = chatsFoldersList
)
Expand Down
43 changes: 31 additions & 12 deletions app/src/main/java/com/gohj99/telewatch/SettingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SettingActivity : ComponentActivity() {

val gson = Gson()
val sharedPref = getSharedPreferences("LoginPref", MODE_PRIVATE)
var userList = sharedPref.getString("userList", "")
val userList = sharedPref.getString("userList", "")
var chatId = ""
if (userList != "") {
val jsonObject: JsonObject = gson.fromJson(userList, JsonObject::class.java)
Expand Down Expand Up @@ -195,6 +195,36 @@ class SettingActivity : ComponentActivity() {
2 -> {
title = getString(R.string.App_setting)
settingsList.value = listOf(
SettingItem.Switch(
itemName = getString(R.string.show_unknown_message_type),
isSelected = settingsSharedPref.getBoolean("show_unknown_message_type", false),
onSelect = { dataCollection ->
with(settingsSharedPref.edit()) {
putBoolean("show_unknown_message_type", dataCollection)
commit()
}
}
),
SettingItem.Switch(
itemName = getString(R.string.is_home_page_pin),
isSelected = settingsSharedPref.getBoolean("is_home_page_pin", false),
onSelect = { dataCollection ->
with(settingsSharedPref.edit()) {
putBoolean("is_home_page_pin", dataCollection)
commit()
}
}
),
SettingItem.Switch(
itemName = getString(R.string.data_Collection),
isSelected = settingsSharedPref.getBoolean("Data_Collection", false),
onSelect = { dataCollection ->
with(settingsSharedPref.edit()) {
putBoolean("Data_Collection", dataCollection)
commit()
}
}
),
SettingItem.Click(
itemName = getString(R.string.Clearing_cache),
onClick = {
Expand Down Expand Up @@ -319,17 +349,6 @@ class SettingActivity : ComponentActivity() {
android.os.Process.killProcess(android.os.Process.myPid())
}, 1000)
}
),
SettingItem.Switch(
itemName = getString(R.string.data_Collection),
isSelected = settingsSharedPref.getBoolean("Data_Collection", false),
onSelect = { dataCollection ->
with(settingsSharedPref.edit()) {
putBoolean("Data_Collection", dataCollection)
//Log.d("SharedPreferences", "保存状态: " + commit() + "\n当前状态: " + dataCollection)
}
//Log.d("SharedPreferences", "当前获取状态: " + settingsSharedPref.getBoolean("Data_Collection", false))
}
)
)

Expand Down
Loading

0 comments on commit f8abe68

Please sign in to comment.