Commit a32489c6 authored by Niklas Fix's avatar Niklas Fix 🎓

add onboarding for erstie event

parent 5872cf04
......@@ -49,6 +49,8 @@ interface DashboardContract {
fun loadAppUserFromServer()
/** Fetch user's pools **/
fun fetchPools()
/** Fetch user's friends **/
fun fetchFriends()
}
}
\ No newline at end of file
package de.akamu.tudarmstadt.features.dashboard
import de.akamu.tudarmstadt.data.friends.FriendsDataSource
import de.akamu.tudarmstadt.data.friends.FriendsDataSourceImpl
import de.akamu.tudarmstadt.data.questionpools.QuestionPoolsDataSource
import de.akamu.tudarmstadt.data.questionpools.QuestionPoolsDataSourceImpl
import de.akamu.tudarmstadt.data.user.UserDataSource
import de.akamu.tudarmstadt.features.friends.FriendsListInteractor
import de.akamu.tudarmstadt.features.questionpools.QuestionPoolsInteractor
import de.akamu.tudarmstadt.interactors.UserInteractor
import de.akamu.tudarmstadt.model.Pool
......@@ -65,6 +68,21 @@ class DashboardPresenter(private var view: DashboardContract.View?, private val
})
}
override fun fetchFriends() {
val friend_interactor = FriendsListInteractor(FriendsDataSourceImpl())
friend_interactor.fetchFriends(object : FriendsDataSource.FetchFriendsCallback {
override fun onFetchFriendsSuccess(friends: ArrayList<User>) {
if (friends.isEmpty()) {
view?.showInfoBox()
}
}
override fun onFetchFriendsFailed(reason: String) {
// silent
}
})
}
override fun stop() {
view = null
}
......
package de.akamu.tudarmstadt.features.dashboard
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentTransaction
......@@ -89,7 +87,8 @@ class MainActivity : BaseActivity(), DashboardContract.View, NextLevelEventHandl
fillProfile()
setupBottomNavigation()
presenter.fetchPools()
// presenter.fetchPools()
presenter.fetchFriends()
when(intent.getIntExtra(Constants.KEY_MAINACTIVITY_PAGE, 0)) {
Constants.DUEL_LIST_FRAGMENT -> navigateToDuelList()
......@@ -114,9 +113,15 @@ class MainActivity : BaseActivity(), DashboardContract.View, NextLevelEventHandl
super.onActivityResult(requestCode, resultCode, data)
if (data?.getBooleanExtra("finishActivity", false) == true) {
finish()
} else if (data?.getBooleanExtra("hasSelectedPools", false) == true) {
constraintlayout_main_info.visibility = View.GONE
}
/*else if (data?.getBooleanExtra("hasSelectedPools", false) == true) {
textView_main_info.text = getString(R.string.info_add_friend)
button_main_info_action.text = getString(R.string.find_friends)
button_main_info_action.setOnClickListener {
navigateToChallenge()
constraintlayout_main_info.visibility = View.GONE
}
}*/
}
@Suppress("UNUSED_PARAMETER")
......@@ -203,6 +208,8 @@ class MainActivity : BaseActivity(), DashboardContract.View, NextLevelEventHandl
override fun onResume() {
super.onResume()
presenter.loadAppUserFromServer()
// presenter.fetchPools()
presenter.fetchFriends()
}
override fun finishActivity() {
......@@ -244,10 +251,16 @@ class MainActivity : BaseActivity(), DashboardContract.View, NextLevelEventHandl
override fun showInfoBox() {
constraintlayout_main_info.visibility = View.VISIBLE
button_main_needs_pools.setOnClickListener {
/*button_main_info_action.setOnClickListener {
val i = Intent(this, QuestionPoolsActivity::class.java)
i.putExtra(Constants.KEY_NEEDS_POOL, true)
startActivityForResult(i, Constants.MAIN_ACTIVITY_REQ_CODE)
}*/
textView_main_info.text = getString(R.string.info_add_friend_tmpErstie)
button_main_info_action.text = getString(R.string.find_friends)
button_main_info_action.setOnClickListener {
navigateToChallenge()
constraintlayout_main_info.visibility = View.GONE
}
}
}
......@@ -186,26 +186,31 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textView_main_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/darkText"
android:layout_weight="0.6"
android:padding="6dp"
android:text="@string/info_needs_pools"
android:layout_weight="0.6"/>
android:textColor="@color/darkText" />
<Button
android:id="@+id/button_main_needs_pools"
android:id="@+id/button_main_info_action"
style="@style/AppButtonWhite"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/choose_pools"
android:layout_margin="6dp"
android:layout_weight="0.3"/>
android:layout_weight="0.3"
android:text="@string/choose_pools" />
</LinearLayout>
......
......@@ -235,4 +235,7 @@
<string name="updated_pools_failed">Pools konnten nicht geupdated werden: %1$s</string>
<string name="profilesubjectactivity_more">"Mit diesem Button lässt sich die Fragenpool-Info anzeigen. "</string>
<string name="no_questionpool_selected">Kein Fragenpool ausgewählt</string>
<string name="info_add_friend">Super! Suche als Nächstes nach deinen Freunden und fordere sie zum Duell heraus!</string>
<string name="find_friends">Freunde finden</string>
<string name="info_add_friend_tmpErstie">Schön, dass du dich entschieden hast Akamu zu spielen! Suche nach deinen Freunden und fordere sie zum Duell heraus!</string>
</resources>
\ No newline at end of file
......@@ -283,4 +283,7 @@
<string name="updated_pools_failed">Failed to update pool due to %1$s</string>
<string name="profilesubjectactivity_more">This is the button for showing</string>
<string name="no_questionpool_selected">No question pool selected</string>
<string name="find_friends">Find friends</string>
<string name="info_add_friend">Nice! Now search for your friends and challenge them to a duel!</string>
<string name="info_add_friend_tmpErstie">Thanks for playing Akamu! Search for your friends and challenge them to a duell!</string>
</resources>
......@@ -351,5 +351,8 @@
<string name="choose_pools">Choose pools</string>
<string name="updated_pools_success">Successfully updated your pools.</string>
<string name="updated_pools_failed">Failed to update pool due to %1$s</string>
<string name="find_friends">Find friends</string>
<string name="info_add_friend">Nice! Now search for your friends and challenge them to a duel!</string>
<string name="info_add_friend_tmpErstie">Thanks for playing Akamu! Search for your friends and challenge them to a duel!</string>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment