Skip to content

Commit dcaaea1

Browse files
committed
Beta 4
1 parent 5025bee commit dcaaea1

File tree

24 files changed

+819
-651
lines changed

24 files changed

+819
-651
lines changed

app/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ android {
1414
applicationId = "com.troplo.privateuploader"
1515
minSdk = 28
1616
targetSdk = 34
17-
versionCode = 3
18-
versionName = "1.0.3"
17+
versionCode = 4
18+
versionName = "1.0.4"
1919
multiDexEnabled = true
2020
buildConfigField("String", "SERVER_URL", "\"https://privateuploader.com\"")
2121
buildConfigField("String", "BUILD_TIME", "\"${System.currentTimeMillis()}\"")
22-
buildConfigField("Integer", "BETA_VERSION", "3")
22+
buildConfigField("Integer", "BETA_VERSION", "4")
2323

2424
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2525
vectorDrawables {

app/release/app-release.apk

360 KB
Binary file not shown.

app/release/output-metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 3,
15-
"versionName": "1.0.3",
14+
"versionCode": 4,
15+
"versionName": "1.0.4",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/main/java/com/troplo/privateuploader/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.troplo.privateuploader
22

33
import android.Manifest
4+
import android.content.Intent
45
import android.content.pm.PackageManager
56
import android.os.Build
67
import android.os.Bundle
@@ -37,6 +38,7 @@ class MainActivity : ComponentActivity() {
3738

3839
override fun onCreate(savedInstanceState: Bundle?) {
3940
GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this)
41+
startService(Intent(this, UploadService::class.java))
4042
// if(BuildConfig.DEBUG) StrictMode.enableDefaults();
4143
Log.d("MainActivity.Instance", SessionManager(this).getInstanceURL())
4244
TpuApi.instance = SessionManager(this).getInstanceURL()

app/src/main/java/com/troplo/privateuploader/MainScreen.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,20 @@ fun MainScreen() {
6161
openPanel = true
6262
}
6363

64-
if (closePanels) {
65-
LaunchedEffect(Unit) {
66-
panelState.closePanels()
67-
closePanels = false
68-
}
64+
LaunchedEffect(closePanels) {
65+
if(!closePanels) return@LaunchedEffect
66+
panelState.closePanels()
67+
closePanels = false
6968
}
7069

71-
if (openPanel) {
72-
LaunchedEffect(Unit) {
73-
if (!panelState.isPanelsClosed) {
74-
panelState.closePanels()
75-
} else {
76-
panelState.openStartPanel()
77-
}
78-
openPanel = false
70+
LaunchedEffect(openPanel) {
71+
if(!openPanel) return@LaunchedEffect
72+
if (!panelState.isPanelsClosed) {
73+
panelState.closePanels()
74+
} else {
75+
panelState.openStartPanel()
7976
}
77+
openPanel = false
8078
}
8179

8280
Scaffold(
@@ -113,8 +111,10 @@ fun MainScreen() {
113111
Spacer(Modifier.height(12.dp))
114112
HomeScreen(
115113
openChat = { chatId ->
116-
ChatStore.setAssociationId(chatId, context)
117-
navController.navigate("${NavRoute.Chat.path}/$chatId")
114+
if(ChatStore.associationId.value != chatId) {
115+
ChatStore.setAssociationId(chatId, context)
116+
navController.navigate("${NavRoute.Chat.path}/$chatId")
117+
}
118118
closePanels = true
119119
},
120120
panelState = panelState,
@@ -132,7 +132,7 @@ fun MainScreen() {
132132
),
133133
navController = navController,
134134
user = user.value,
135-
context,
135+
context = context,
136136
panelsState = panelState
137137
)
138138
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.troplo.privateuploader
2+
3+
import android.app.Service
4+
import android.content.Intent
5+
import android.os.Build
6+
import android.os.FileObserver
7+
import android.os.IBinder
8+
import android.util.Log
9+
import androidx.annotation.RequiresApi
10+
import java.io.File
11+
12+
class UploadService : Service() {
13+
private var fileObserver: FileObserver? = null
14+
override fun onCreate() {
15+
super.onCreate()
16+
17+
// Create a FileObserver to monitor the Screenshots directory
18+
fileObserver = @RequiresApi(Build.VERSION_CODES.Q)
19+
object : FileObserver(File(SCREENSHOT_DIRECTORY), CREATE) {
20+
override fun onEvent(event: Int, path: String?) {
21+
if (event == CREATE) {
22+
Log.d(
23+
TAG,
24+
"New screenshot created: $path"
25+
)
26+
// You can perform any actions you need here when a new file is created
27+
}
28+
}
29+
}
30+
31+
// Start watching for file changes
32+
fileObserver?.startWatching()
33+
}
34+
35+
override fun onDestroy() {
36+
super.onDestroy()
37+
38+
// Stop watching for file changes
39+
fileObserver!!.stopWatching()
40+
}
41+
42+
override fun onBind(intent: Intent): IBinder? {
43+
// This service does not support binding
44+
return null
45+
}
46+
47+
companion object {
48+
private const val TAG = "ScreenshotWatcher"
49+
private const val SCREENSHOT_DIRECTORY = "/storage/emulated/0/Pictures/Screenshots"
50+
}
51+
}

app/src/main/java/com/troplo/privateuploader/api/ApiService.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.troplo.privateuploader.data.model.MessageSearchResponse
2020
import com.troplo.privateuploader.data.model.PatchUser
2121
import com.troplo.privateuploader.data.model.StarResponse
2222
import com.troplo.privateuploader.data.model.State
23+
import com.troplo.privateuploader.data.model.TenorResponse
2324
import com.troplo.privateuploader.data.model.UploadResponse
2425
import com.troplo.privateuploader.data.model.User
2526
import okhttp3.Interceptor
@@ -188,6 +189,15 @@ object TpuApi {
188189

189190
@GET("gallery")
190191
fun getGallery(
192+
@Query("page") page: Int = 1,
193+
@Query("search") search: String = "",
194+
@Query("textMetadata") textMetadata: Boolean = true,
195+
@Query("filter") filter: String = "all",
196+
@Query("sort") sort: String = "\"newest\""
197+
): Call<Gallery>
198+
199+
@GET("gallery/starred")
200+
fun getStarredGallery(
191201
@Query("page") page: Int = 1,
192202
@Query("search") search: String = "",
193203
@Query("textMetadata") textMetadata: Boolean = true,
@@ -268,6 +278,12 @@ object TpuApi {
268278
fun uploadFile(
269279
@Part attachment: MultipartBody.Part,
270280
): Call<UploadResponse>
281+
282+
@GET("providers/tenor")
283+
fun getTenorGallery(
284+
@Query("next") next: String = "",
285+
@Query("search") search: String = ""
286+
): Call<TenorResponse>
271287
}
272288

273289
val retrofitService: TpuApiService by lazy {

app/src/main/java/com/troplo/privateuploader/api/Functions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ object TpuFunctions {
104104

105105
fun getDate(date: String?): Date? {
106106
return try {
107-
val df1: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
107+
val df1: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX")
108+
df1.isLenient = false;
108109
df1.parse(date)
109110
} catch (e: Exception) {
110111
Log.d("TPU.Untagged", "Error formatting date (GD): $e")

app/src/main/java/com/troplo/privateuploader/components/chat/Attachment.kt

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.material.icons.Icons
88
import androidx.compose.material.icons.filled.GifBox
99
import androidx.compose.material.icons.filled.Image
1010
import androidx.compose.material.icons.filled.Smartphone
11+
import androidx.compose.material.icons.filled.Star
1112
import androidx.compose.material3.ExperimentalMaterial3Api
1213
import androidx.compose.material3.Icon
1314
import androidx.compose.material3.MaterialTheme
@@ -24,8 +25,13 @@ import androidx.compose.runtime.remember
2425
import androidx.compose.ui.Modifier
2526
import androidx.compose.ui.tooling.preview.Preview
2627
import androidx.compose.ui.unit.dp
28+
import androidx.core.net.toUri
2729
import androidx.lifecycle.ViewModel
30+
import com.troplo.privateuploader.api.ChatStore
31+
import com.troplo.privateuploader.api.stores.UserStore
2832
import com.troplo.privateuploader.components.chat.attachment.MyDevice
33+
import com.troplo.privateuploader.data.model.Upload
34+
import com.troplo.privateuploader.data.model.UploadTarget
2935
import com.troplo.privateuploader.screens.GalleryScreen
3036

3137
@OptIn(ExperimentalMaterial3Api::class)
@@ -35,7 +41,7 @@ fun Attachment(openBottomSheet: MutableState<Boolean>) {
3541
val bottomSheetState = rememberModalBottomSheetState(
3642
skipPartiallyExpanded = true
3743
)
38-
val selectedTab = remember { mutableIntStateOf(0) }
44+
val selectedTab: MutableState<Int> = remember { mutableIntStateOf(0) }
3945
ModalBottomSheet(
4046
onDismissRequest = { openBottomSheet.value = false },
4147
sheetState = bottomSheetState,
@@ -48,29 +54,46 @@ fun Attachment(openBottomSheet: MutableState<Boolean>) {
4854
) {
4955
Tab(
5056
selected = selectedTab.value == 0,
51-
onClick = { openBottomSheet.value = true },
57+
onClick = { selectedTab.value = 0 },
5258
text = { Text("My Device") },
53-
icon = { Icon(Icons.Default.Smartphone, contentDescription = null) }
59+
icon = { Icon(Icons.Default.Smartphone, contentDescription = "My Device") }
5460
)
5561
Tab(
5662
selected = selectedTab.value == 1,
57-
onClick = { openBottomSheet.value = true },
63+
onClick = { selectedTab.value = 1 },
5864
text = { Text("Gallery") },
59-
icon = { Icon(Icons.Default.Image, contentDescription = null) }
65+
icon = { Icon(Icons.Default.Image, contentDescription = "Gallery") }
6066
)
6167
Tab(
6268
selected = selectedTab.value == 2,
63-
onClick = { openBottomSheet.value = true },
69+
onClick = { selectedTab.value = 2 },
6470
text = { Text("Starred") },
65-
icon = { Icon(Icons.Default.Image, contentDescription = null) }
71+
icon = { Icon(Icons.Default.Star, contentDescription = "Starred") }
6672
)
6773
Tab(
6874
selected = selectedTab.value == 3,
69-
onClick = { openBottomSheet.value = true },
75+
onClick = { selectedTab.value = 3 },
7076
text = { Text("GIFs") },
71-
icon = { Icon(Icons.Default.GifBox, contentDescription = null) }
77+
icon = { Icon(Icons.Default.GifBox, contentDescription = "GIFs") }
7278
)
7379
}
80+
81+
fun onClick(upload: Upload, tenor: Boolean = false) {
82+
openBottomSheet.value = false
83+
ChatStore.attachmentsToUpload.add(
84+
UploadTarget(
85+
uri = if (tenor) {
86+
upload.attachment.toUri()
87+
} else {
88+
"https://${UserStore.user.value?.domain?.domain}/i/${upload.attachment}".toUri()
89+
},
90+
started = true,
91+
progress = 100f,
92+
url = upload.attachment
93+
)
94+
)
95+
}
96+
7497
Box(
7598
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 32.dp)
7699
) {
@@ -80,15 +103,21 @@ fun Attachment(openBottomSheet: MutableState<Boolean>) {
80103
}
81104

82105
1 -> {
83-
GalleryScreen()
106+
GalleryScreen("gallery", true, onClick = {
107+
onClick(it)
108+
})
84109
}
85110

86111
2 -> {
87-
GalleryScreen()
112+
GalleryScreen("starred", true, onClick = {
113+
onClick(it)
114+
})
88115
}
89116

90117
3 -> {
91-
GalleryScreen()
118+
GalleryScreen("tenor", true, onClick = {
119+
onClick(it, true)
120+
})
92121
}
93122
}
94123
}

app/src/main/java/com/troplo/privateuploader/components/chat/MarkdownText.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fun MarkdownText(
7272
style = style,
7373
textAlign = textAlign,
7474
viewId = viewId,
75-
onClick = onClick,
75+
onClick = onClick
7676
)
7777
},
7878
update = { textView ->
@@ -103,14 +103,15 @@ private fun createTextView(
103103
style: TextStyle,
104104
@IdRes viewId: Int? = null,
105105
onClick: (() -> Unit)? = null,
106-
onLongClick: (() -> Unit)? = null,
106+
onLongClick: (() -> Unit)? = null
107107
): TextView {
108108
val textColor = color.takeOrElse { style.color.takeOrElse { defaultColor } }
109109
val mergedStyle = style.merge(
110110
TextStyle(
111111
color = textColor,
112112
fontSize = if (fontSize != TextUnit.Unspecified) fontSize else style.fontSize,
113113
textAlign = textAlign,
114+
114115
)
115116
)
116117
return TextView(context).apply {

0 commit comments

Comments
 (0)