Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Better Xml #366

Merged
merged 12 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added VibesterSplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
Expand Down
Binary file added app/release/app-release.aab
Binary file not shown.
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "ch.sdp.vibester",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ class MyProfileFragmentTest {
}


@Test
fun checkChangePhotoCancel() {
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, "VvPB47tQCLdjz3YebilS6h5EXdJ3")

createMockDataGetter(inputProfile)
createMockAuthenticator()
createMockImageGetter()

launchFragmentInHiltContainer<MyProfileFragment>(
themeResId = R.style.AppTheme
)

onView(withId(R.id.profile_image_CardView)).perform(click())
onView(withText("No")).perform(click())

onView(withId(R.id.profile_image_CardView)).check(matches(isDisplayed()))
}



@Test
fun checkProfileData() {
val inputProfile = User("Lalisa Bon", R.string.test_profile_image.toString(), "[email protected]", 12, 8)
Expand Down Expand Up @@ -191,7 +211,7 @@ class MyProfileFragmentTest {
)
)

onView(withId(R.id.profileContent)).check(matches(isDisplayed()))
onView(withId(R.id.profileLayout)).check(matches(isDisplayed()))
}


Expand All @@ -210,7 +230,6 @@ class MyProfileFragmentTest {
onView(withId(R.id.showQRCode)).perform(click())

onView(withId(R.id.QrCodePage)).check(matches(isDisplayed()))
onView(withId(R.id.profileContent)).check(matches(not(isDisplayed())))
onView(withId(R.id.qrCode)).check(matches(isDisplayed()))
}

Expand All @@ -228,10 +247,9 @@ class MyProfileFragmentTest {
)

onView(withId(R.id.showQRCode)).perform(click())
onView(withId(R.id.qrCode_returnToProfile)).perform(click())
onView(withText("CLOSE")).perform(click())

onView(withId(R.id.QrCodePage)).check(matches(not(isDisplayed())))
onView(withId(R.id.profileContent)).check(matches(isDisplayed()))
}


Expand Down Expand Up @@ -273,30 +291,14 @@ class MyProfileFragmentTest {
themeResId = R.style.AppTheme
)

onView(withId(R.id.editUser)).perform(scrollTo(), click())
onView(withText("Cancel")).perform(scrollTo(), click())
onView(withId(R.id.editUser)).perform(click())
onView(withText("Cancel")).perform(click())

onView(withId(R.id.username)).check(matches(withText("Lalisa Bon")))
}


@Test
fun checkChangePhotoCancel() {
val inputProfile = User( "Lalisa Bon","bit.ly/3IUnyAF", "[email protected]", 12, 8, "VvPB47tQCLdjz3YebilS6h5EXdJ3")

createMockDataGetter(inputProfile)
createMockAuthenticator()
createMockImageGetter()

launchFragmentInHiltContainer<MyProfileFragment>(
themeResId = R.style.AppTheme
)

onView(withId(R.id.profile_image_CardView)).perform(click())
onView(withText("No")).perform(click())

onView(withId(R.id.profile_image_CardView)).check(matches(isDisplayed()))
}

// FIXME fix the test
/*
Expand Down Expand Up @@ -335,9 +337,9 @@ class MyProfileFragmentTest {
themeResId = R.style.AppTheme
)

onView(withId(R.id.profile_image_CardView)).perform(click())
onView(withId(R.id.profile_image_ImageView)).perform(click())
onView(withText("NO")).perform(click())
onView(withId(R.id.profile_image_CardView)).check(matches(isDisplayed()))
onView(withId(R.id.profile_image_ImageView)).check(matches(isDisplayed()))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ScoreBoardFragmentTest {
)
)

onView(withId(R.id.profileContent)).check(matches(isDisplayed()))
onView(withId(R.id.profileLayout)).check(matches(isDisplayed()))
onView(withId(R.id.profileStatistics)).check(matches(isDisplayed()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class SearchUserFragmentTest {
)
)

onView(withId(R.id.profileContent)).check(matches(isDisplayed()))
onView(withId(R.id.profileLayout)).check(matches(isDisplayed()))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PublicProfileActivity : AppCompatActivity(), OnItemClickListener, ProfileI
setupRecycleViewForFriends()
followings = ArrayList()

setRetToMainBtnListener()
// TODO remove setRetToMainBtnListener()
setFollowingScoresBtnListener(R.id.profile_scores, R.id.profile_scroll_stat, R.id.profile_scroll_following)
setFollowingScoresBtnListener(R.id.profile_following, R.id.profile_scroll_following, R.id.profile_scroll_stat)

Expand Down Expand Up @@ -107,14 +107,6 @@ class PublicProfileActivity : AppCompatActivity(), OnItemClickListener, ProfileI
}


/**
* Generic listener for the return to main button.
*/
private fun setRetToMainBtnListener() {
findViewById<FloatingActionButton>(R.id.profile_returnToMain).setOnClickListener {
finish()
}
}

override fun setFollowingScoresBtnListener(btnId: Int, show: Int, hide: Int) {
findViewById<Button>(btnId).setOnClickListener {
Expand Down Expand Up @@ -142,7 +134,7 @@ class PublicProfileActivity : AppCompatActivity(), OnItemClickListener, ProfileI
imageGetter.fetchImage("profileImg/${user.uid}", this::setImage)

if (user.uid != "") {
generateQrCode(user.uid)
generateQrCode(user.uid, findViewById(R.id.qrCode))
}

if (user.following.isNotEmpty()) {
Expand All @@ -151,7 +143,7 @@ class PublicProfileActivity : AppCompatActivity(), OnItemClickListener, ProfileI

}

override fun generateQrCode(data: String) {
override fun generateQrCode(data: String, imgView: ImageView) {
val size = 512
val hints = HashMap<EncodeHintType?, Any?>()
hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.H
Expand All @@ -168,7 +160,7 @@ class PublicProfileActivity : AppCompatActivity(), OnItemClickListener, ProfileI

qrCodeCanvas.drawBitmap(logo, xLogo, yLogo, null)

findViewById<ImageView>(R.id.qrCode).setImageBitmap(bmp)
imgView.setImageBitmap(bmp)
}

override fun onItemClick(position: Int) {
Expand Down
48 changes: 30 additions & 18 deletions app/src/main/java/ch/sdp/vibester/fragment/MyProfileFragment.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package ch.sdp.vibester.fragment

import android.app.Activity
import android.content.DialogInterface
import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.net.Uri
import android.os.Bundle
import android.text.InputType
import android.util.Log
import android.view.View
import android.widget.*
import androidx.appcompat.app.AlertDialog
Expand All @@ -30,7 +32,6 @@ import ch.sdp.vibester.helper.ViewModel
import ch.sdp.vibester.user.OnItemClickListener
import ch.sdp.vibester.user.ProfileFollowingAdapter
import ch.sdp.vibester.user.User
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.firebase.auth.FirebaseAuth
import com.google.zxing.BarcodeFormat
import com.google.zxing.EncodeHintType
Expand Down Expand Up @@ -60,7 +61,6 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen

private var vmMyProfile = ViewModel()
private lateinit var qrCodePage: View
private lateinit var profileContent: View


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand All @@ -77,7 +77,6 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen
followings = ArrayList()

qrCodePage = vmMyProfile.view.findViewById<ConstraintLayout>(R.id.QrCodePage)
profileContent = vmMyProfile.view.findViewById<RelativeLayout>(R.id.profileContent)

setFollowingScoresBtnListener(R.id.profile_scores, R.id.profile_scroll_stat, R.id.profile_scroll_following)
setFollowingScoresBtnListener(R.id.profile_following, R.id.profile_scroll_following, R.id.profile_scroll_stat)
Expand All @@ -89,18 +88,16 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen
setEditUserNameBtnListener()
setChangeImageBtnListener()
setLogOutBtnListener()
setQrCodeListeners()
setShowQrCodeBtnListener()
}

private fun setViewsVisibility() {
val editView = vmMyProfile.view.findViewById<ImageView>(R.id.editUser)
val qrView = vmMyProfile.view.findViewById<ImageView>(R.id.showQRCode)
val logoutView = vmMyProfile.view.findViewById<Button>(R.id.logout)
val returnView = vmMyProfile.view.findViewById<FloatingActionButton>(R.id.profile_returnToMain)
setViewVisibility(editView, true)
setViewVisibility(qrView, true)
setViewVisibility(logoutView, true)
setViewVisibility(returnView, false)
}

override fun queryDatabase() {
Expand Down Expand Up @@ -134,7 +131,7 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen
* helper function to show dialog
*/
private fun showDialogWhenChangeImage() {
showGeneralDialog(R.string.profile_verify_change_profile_pic.toString(), false)
showGeneralDialog(getString(R.string.profile_verify_change_profile_pic), false)
}

/**
Expand All @@ -148,13 +145,31 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen
}


private fun setQrCodeListeners() {
val showQrCode = vmMyProfile.view.findViewById<ImageView>(R.id.showQRCode)
val hideQrCode = vmMyProfile.view.findViewById<FloatingActionButton>(R.id.qrCode_returnToProfile)
showQrCode.setOnClickListener { showAHideB(qrCodePage, profileContent) }
hideQrCode.setOnClickListener { showAHideB(profileContent, qrCodePage) }
/**
* Generic listener for the show qr code button.
*/
private fun setShowQrCodeBtnListener() {
val qrDialog = AlertDialog.Builder(requireContext())
vmMyProfile.view.findViewById<ImageView>(R.id.showQRCode).setOnClickListener {
val qrView = layoutInflater.inflate(R.layout.display_qr_code, null)
val qrImg = qrView.findViewById<ImageView>(R.id.qrCode)
val uid = FireBaseAuthenticator().getCurrUID()
if (uid != "") {
generateQrCode(uid, qrImg)
}
qrDialog.setNeutralButton("CLOSE",
{ dialogInterface: DialogInterface, i: Int -> dialogInterface.dismiss()})
qrDialog.setView(qrView)
qrDialog.create()

qrDialog.show()
}


}



/**
* A function that displays the dialog
* @param title title of the dialog
Expand Down Expand Up @@ -269,17 +284,14 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen

imageGetter.fetchImage("profileImg/${user.uid}", this::setImage)

if (user.uid != "") {
generateQrCode(user.uid)
}

if (user.following.isNotEmpty()) {
loadFollowing(user.following, dataGetter)
}

}

override fun generateQrCode(data: String) {

override fun generateQrCode(data: String, imgView: ImageView) {
val size = 512
val hints = HashMap<EncodeHintType?, Any?>()
hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.H
Expand All @@ -296,7 +308,7 @@ class MyProfileFragment : Fragment(R.layout.activity_profile), OnItemClickListen

qrCodeCanvas.drawBitmap(logo, xLogo, yLogo, null)

vmMyProfile.view.findViewById<ImageView>(R.id.qrCode).setImageBitmap(bmp)
imgView.setImageBitmap(bmp)
}

override fun onItemClick(position: Int) {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/ch/sdp/vibester/helper/ProfileInterface.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.view.View
import android.widget.ImageView
import ch.sdp.vibester.R
import ch.sdp.vibester.database.DataGetter
import ch.sdp.vibester.database.ImageGetter
Expand Down Expand Up @@ -86,7 +87,7 @@ interface ProfileInterface {
* generate the qr code bitmap of the given data
* @param data Qr Code data
*/
fun generateQrCode(data: String)
fun generateQrCode(data: String, imgView: ImageView)

/**
* helper function to add user from followingMap to followings
Expand Down
Binary file added app/src/main/res/drawable-nodpi/glogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions app/src/main/res/layout/activity_party_room.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/PartyRoom_joinedPeople"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/roomId"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.275" />
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/roomId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/startGame"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/emails"
app:layout_constraintVertical_bias="0.36" />

<Button
Expand All @@ -40,5 +38,6 @@
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emails" />
app:layout_constraintTop_toBottomOf="@+id/roomId"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading