Skip to content

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
BonaventuraD committed Feb 1, 2024
2 parents f6e7015 + 2729c44 commit 8e22c44
Show file tree
Hide file tree
Showing 21 changed files with 1,344 additions and 406 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("com.pusher:pusher-java-client:2.4.2")
implementation("id.zelory:compressor:3.0.1")
}

secrets {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ class LoginActivity() : AppCompatActivity(), Parcelable {
if (response.isSuccessful) {
val responseBody = response.body()
val token = responseBody?.data!!.token
val role = responseBody.data.role
val sharedPreferences =
getSharedPreferences("Preferences", Context.MODE_PRIVATE)
with(sharedPreferences.edit()) {
putString("token", token)
putString("role", role)
apply()
}

val role = when (username) {
"admin" -> "bidan"
"kader" -> "kader"
else -> "default"
}
// val role = when (username) {
// "admin" -> "bidan"
// "kader" -> "kader"
// else -> "default"
// }


proceedToMain(token, role)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.bumptech.glide.Glide
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.LazyHeaders
import com.example.posyandu.BuildConfig
import com.example.posyandu.R
import com.example.posyandu.databinding.ActivityDaftarRemajaBinding
import com.example.posyandu.databinding.FragmentDaftarRemajaShowBinding
Expand All @@ -32,6 +36,7 @@ import java.util.Locale
class DaftarRemajaActivity : AppCompatActivity() {
private lateinit var binding: ActivityDaftarRemajaBinding
private lateinit var viewModel: DaftarRemajaViewModel
private lateinit var token: String

val startNewActivity =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
Expand Down Expand Up @@ -87,6 +92,9 @@ class DaftarRemajaActivity : AppCompatActivity() {
startNewActivity.launch(intent)
}

val prefs = getSharedPreferences("Preferences", MODE_PRIVATE)
token = prefs.getString("token", "no token").toString()

setContentView(view)
}

Expand Down Expand Up @@ -114,6 +122,16 @@ class DaftarRemajaActivity : AppCompatActivity() {
val binding = FragmentDaftarRemajaShowBinding.inflate(layoutInflater)
val customView = binding.root

val glideUrl = GlideUrl(
BuildConfig.BASE_URL + "file/" + model.user.foto, LazyHeaders.Builder()
.addHeader("Authorization", "Bearer $token")
.build()
)

Glide.with(this@DaftarRemajaActivity)
.load(glideUrl)
.into(binding.foto)

val user = model.user
binding.nama.text = user.nama
binding.nik.text = user.nik.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.posyandu.features.jadwalPosyandu

import android.content.SharedPreferences
import android.os.Build
import android.os.Bundle
import android.view.View
Expand All @@ -25,13 +26,18 @@ import java.util.TimeZone
class JadwalPosyanduActivity : AppCompatActivity() {
private lateinit var binding: ActivityJadwalPosyanduBinding
private lateinit var viewModel: JadwalPosyanduViewModel
private lateinit var prefs: SharedPreferences
private lateinit var role: String

@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityJadwalPosyanduBinding.inflate(layoutInflater)
val view = binding.root

prefs = getSharedPreferences("Preferences", MODE_PRIVATE)
role = prefs.getString("role", "")!!

supportActionBar?.hide()

viewModel = ViewModelProvider(this)[JadwalPosyanduViewModel::class.java]
Expand All @@ -42,8 +48,12 @@ class JadwalPosyanduActivity : AppCompatActivity() {
val layoutManager = LinearLayoutManager(this)
binding.rvReview.layoutManager = layoutManager

binding.btnTambah.setOnClickListener {
showCreateDialog(view)
if (role == "bidan") {
binding.btnTambah.setOnClickListener {
showCreateDialog(view)
}
} else {
binding.btnTambah.visibility = View.GONE
}

setContentView(view)
Expand All @@ -62,13 +72,15 @@ class JadwalPosyanduActivity : AppCompatActivity() {
binding.nullAlert.visibility = View.VISIBLE
}

adapter.setOnClickListener(object :
JadwalPosyanduIndexAdapter.OnClickListener {
@RequiresApi(Build.VERSION_CODES.O)
override fun onClick(position: Int, model: JadwalPosyandu) {
showEditDialog(view, model)
}
})
if (role == "bidan") {
adapter.setOnClickListener(object :
JadwalPosyanduIndexAdapter.OnClickListener {
@RequiresApi(Build.VERSION_CODES.O)
override fun onClick(position: Int, model: JadwalPosyandu) {
showEditDialog(view, model)
}
})
}
}

@RequiresApi(Build.VERSION_CODES.O)
Expand Down
Loading

0 comments on commit 8e22c44

Please sign in to comment.