Compare commits

...

34 Commits

Author SHA1 Message Date
HagaDalpintoGinting
cebaf14306 Menyelesaikan merge conflict 2025-11-13 15:46:19 +07:00
HagaDalpintoGinting
179b2cf0ce update massage allert 2025-11-13 15:44:22 +07:00
HagaDalpintoGinting
55b7a311cc Praktek 1 2025-11-13 15:29:38 +07:00
HagaDalpintoGinting
024a147fbd first commit 2025-11-13 15:25:04 +07:00
HagaDalpintoGinting
82212b9cc7 praktik 1 2025-11-13 15:20:57 +07:00
08c24bdfdd Updated 2025-11-13 14:48:04 +07:00
d3c1410a11 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:47:37 +07:00
1ce89ad197 Updated 2025-11-13 14:47:11 +07:00
228d9f8f77 Hadi P. 2025-11-13 14:46:11 +07:00
5dffb47576 Hadi P 2025-11-13 14:45:15 +07:00
992c0d627c Hadi 2025-11-13 14:44:54 +07:00
4f1f8577bc Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:44:26 +07:00
6370eba0da Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:43:41 +07:00
c4aee9ee3c a. 2025-11-13 14:43:25 +07:00
5cccdf5368 a. 2025-11-13 14:42:12 +07:00
b73d429200 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:42:08 +07:00
89c60eb81e Hadi 2025-11-13 14:41:29 +07:00
6fcbb52b90 askd.., 2025-11-13 14:40:56 +07:00
cd156ca010 kasdka 2025-11-13 14:39:02 +07:00
4488dfd0cb Hadi 2025-11-13 14:38:11 +07:00
4281e24379 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:37:45 +07:00
5170efe60e askd.. 2025-11-13 14:37:17 +07:00
4ac1678d48 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:37:00 +07:00
357a25744c Hadi 2025-11-13 14:36:29 +07:00
cf5adbd923 askd. 2025-11-13 14:36:18 +07:00
d77a9409de Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:35:21 +07:00
a115da0783 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2025-11-13 14:35:01 +07:00
8f9ca68257 Merge remote-tracking branch 'origin/master' 2025-11-13 14:34:53 +07:00
83fabde258 askd 2025-11-13 14:34:41 +07:00
8f24ef2640 Merge remote-tracking branch 'origin/master' 2025-11-13 14:34:33 +07:00
3e3da371dc Hadi 2025-11-13 14:34:28 +07:00
6d30bb4a88 nama 2025-11-13 14:33:21 +07:00
wafi14-art
ae1ae8cd80 Fadhlul Wafi 2025-11-13 14:33:21 +07:00
55d17abb93 Praktikum 1 2025-11-13 14:29:32 +07:00
4 changed files with 89 additions and 29 deletions

View File

@ -27,8 +27,16 @@ Repository ini digunakan untuk praktikum perkuliahan pemrograman mobile.
- 15. Indris Alpasela (202310715200)
- 16. Raihan Ariq Muzakki (202310715297)
- 17. Dirson Ali Wardana (202310715246)
<<<<<<< HEAD
- 18. Dimas Hendri Pamungkas (202310715274)
- 19. Fadhlul Wafi (202310715188)
- 20. Muhammad Yusron Amrullah (202310715060)
- 21. Muhammad Fadillah (202310715213)
- 21. Hadi Guna Prakoso (202310715312)
=======
=======
- Fadlan Rivaldi (202310715280)
- B
- C
>>>>>>> d4f073d (First Commit)
>>>>>>> 59a5f2b68a9a33028bb744220857c043749c6949

View File

@ -57,4 +57,11 @@ dependencies {
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.test.manifest)
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("androidx.compose.material3:material3:1.1.1")
//praktikum 1
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("androidx.compose.material3:material3:1.1.1")
}

View File

@ -23,5 +23,5 @@
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

View File

@ -3,45 +3,90 @@ package id.ac.ubharajaya.panicbutton
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import id.ac.ubharajaya.panicbutton.ui.theme.PanicButtonTheme
import androidx.compose.ui.unit.dp
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
PanicButtonTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Greeting(
name = "Android",
modifier = Modifier.padding(innerPadding)
)
}
}
MyApp()
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
fun MyApp() {
// State untuk menampilkan hasil request
var message by remember { mutableStateOf("Klik tombol untuk mengirim notifikasi") }
// UI
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = message, Modifier.padding(bottom = 16.dp))
Button(onClick = {
// Kirim HTTP request saat tombol ditekan
sendNotification { response ->
message = response
}
}) {
Text(text = "Kirim Alert")
}
}
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
PanicButtonTheme {
Greeting("Android")
}
}
// Fungsi untuk mengirimkan HTTP request
fun sendNotification(onResult: (String) -> Unit) {
val client = OkHttpClient()
val url = "https://ntfy.ubharajaya.ac.id/panic-button" // Ganti <your-topic> dengan topik Anda
val requestBody = RequestBody.create(
"text/plain".toMediaType(), // Mengirim plain text
"Notifikasi dari Haga Dalpinto Ginting 202310715176" // Pesan yang akan tampil
)
val request = Request.Builder()
.url(url)
.addHeader("Title", "Alert")
.addHeader("Priority", "urgent")
.addHeader("Tags", "alert warning,rotating_light")
.post(requestBody)
.build()
// Eksekusi request di thread terpisah
Thread {
try {
val response = client.newCall(request).execute()
if (response.isSuccessful) {
onResult("Notifikasi berhasil dikirim!")
} else {
onResult("Gagal mengirim notifikasi: ${response.code}")
}
} catch (e: Exception) {
onResult("Error: ${e.message}")
}
}.start()
}