Skip to content

Commit

Permalink
profile image can be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
hettysymes committed Jun 15, 2023
1 parent c0f6c58 commit 2081be9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/example/drp25/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ fun updatePfp(uniId: String, userId: String, filepath: String) {
unisRef.child(uniId).child("users").child(userId).child("pfp").setValue(filepath)
}

fun deletePfp(uniId: String, userId: String) {
unisRef.child(uniId).child("users").child(userId).child("pfp").removeValue()
}

fun addMatchObserver(observer: Observer) {
matchObservers.add(observer)
observer.notify(matches)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/example/drp25/UserProfileActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
import io.getstream.chat.android.client.models.UserId
import java.io.File
import java.io.FileOutputStream

Expand Down Expand Up @@ -136,6 +137,11 @@ class UserProfileActivity : AppCompatActivity() {
val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
startActivityForResult(intent, PICK_IMAGE_REQUEST_CODE)
}

binding.deletePfpButton.setOnClickListener {
deletePfp(UNI_ID, USER_ID)
binding.profileImageView.setImageResource(R.drawable.default_profile)
}
}

@Deprecated("Deprecated in Java")
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_user_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
android:text="@string/upload_profile_picture"
android:layout_gravity="center" />

<Button
android:id="@+id/deletePfpButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/stream_ui_blue_alice"
android:textColor="@color/stream_ui_accent_blue"
android:text="Remove profile picture"
android:layout_gravity="center" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 2081be9

Please sign in to comment.