mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
display guild members and bank
This commit is contained in:
parent
adfc54b4ac
commit
598cadfcf4
7 changed files with 132 additions and 11 deletions
|
|
@ -23,6 +23,80 @@
|
|||
tools:text="Awesome Party"
|
||||
android:gravity="center"
|
||||
android:layout_margin="@dimen/spacing_large" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/spacing_large"
|
||||
android:paddingEnd="@dimen/spacing_large"
|
||||
android:paddingBottom="@dimen/spacing_medium">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="60dp"
|
||||
android:background="@drawable/layout_rounded_bg_white"
|
||||
android:layout_marginRight="@dimen/spacing_large"
|
||||
android:paddingTop="@dimen/spacing_small"
|
||||
android:paddingBottom="@dimen/spacing_small"
|
||||
android:paddingLeft="@dimen/spacing_medium"
|
||||
android:paddingRight="@dimen/spacing_medium"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/spacing_small">
|
||||
<ImageView
|
||||
android:id="@+id/guild_members_icon"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:layout_marginRight="@dimen/spacing_medium"/>
|
||||
<TextView
|
||||
android:id="@+id/guild_members_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="100.000"
|
||||
style="@style/Headline"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/guild_members"
|
||||
style="@style/Caption3"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="60dp"
|
||||
android:background="@drawable/layout_rounded_bg_white"
|
||||
android:paddingTop="@dimen/spacing_small"
|
||||
android:paddingBottom="@dimen/spacing_small"
|
||||
android:paddingLeft="@dimen/spacing_medium"
|
||||
android:paddingRight="@dimen/spacing_medium"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/spacing_small">
|
||||
<ImageView
|
||||
android:id="@+id/guild_bank_icon"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:layout_marginRight="@dimen/spacing_medium"/>
|
||||
<TextView
|
||||
android:id="@+id/guild_bank_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="100"
|
||||
style="@style/Headline"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/guild_bank"
|
||||
style="@style/Caption3"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -55,6 +129,7 @@
|
|||
android:layout_marginStart="@dimen/spacing_large"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/leader_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:gravity="center_vertical"
|
||||
|
|
@ -90,16 +165,28 @@
|
|||
android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/guild_summary"
|
||||
app:identifier="guildSummary">
|
||||
<TextView
|
||||
android:id="@+id/guild_summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="@string/inn_description"
|
||||
android:layout_marginTop="@dimen/spacing_large" />
|
||||
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
|
||||
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/guild_description"
|
||||
app:identifier="tavernInn">
|
||||
app:identifier="guildDescription">
|
||||
<TextView
|
||||
android:id="@+id/guild_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/inn_description"
|
||||
tools:text="@string/inn_description"
|
||||
android:layout_marginTop="@dimen/spacing_large" />
|
||||
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -290,4 +290,7 @@
|
|||
<action
|
||||
android:id="@+id/action_global_classSelectionActivity"
|
||||
app:destination="@id/classSelectionActivity" />
|
||||
<action
|
||||
android:id="@+id/openProfileActivity"
|
||||
app:destination="@id/fullProfileActivity" />
|
||||
</navigation>
|
||||
|
|
@ -906,4 +906,7 @@
|
|||
<string name="setup_task_habit_1_notes">Either a Habit, a Daily or a To-Do</string>
|
||||
<string name="setup_task_habit_2">Tap here to edit this into a bad habit you\'d like to quit</string>
|
||||
<string name="setup_task_habit_2_notes">Or delete it from the edit screen</string>
|
||||
<string name="guild_summary">Guild Summary</string>
|
||||
<string name="guild_members">Guild Members</string>
|
||||
<string name="guild_bank">Guild Bank</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -82,22 +82,24 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
}
|
||||
|
||||
override fun getPublicGuilds(): Flowable<RealmResults<Group>> = realm.where(Group::class.java)
|
||||
.equalTo("type", "guild")
|
||||
.equalTo("privacy", "public")
|
||||
.sort("memberCount", Sort.DESCENDING)
|
||||
.equalTo("type", "guild")
|
||||
.equalTo("privacy", "public")
|
||||
.notEqualTo("id", Group.TAVERN_ID)
|
||||
.sort("memberCount", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
|
||||
override fun getUserGroups(userID: String): Flowable<RealmResults<Group>> = realm.where(GroupMembership::class.java)
|
||||
.equalTo("userID", userID)
|
||||
.findAll()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
.flatMap {
|
||||
.flatMap {memberships ->
|
||||
realm.where(Group::class.java)
|
||||
.equalTo("type", "guild")
|
||||
.`in`("id", it.map {
|
||||
.notEqualTo("id", Group.TAVERN_ID)
|
||||
.`in`("id", memberships.map {
|
||||
return@map it.groupID
|
||||
}.toTypedArray())
|
||||
.sort("memberCount", Sort.DESCENDING)
|
||||
|
|
|
|||
|
|
@ -51,4 +51,9 @@ open class Group : RealmObject() {
|
|||
get() {
|
||||
return quest?.active ?: false
|
||||
}
|
||||
|
||||
val gemCount: Int
|
||||
get() {
|
||||
return (balance * 4.0).toInt()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -715,7 +715,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
val sharingIntent = Intent(Intent.ACTION_SEND)
|
||||
sharingIntent.type = "*/*"
|
||||
sharingIntent.putExtra(Intent.EXTRA_TEXT, event.sharedMessage)
|
||||
val f = BitmapUtils.saveToShareableFile(filesDir.toString() + "/shared_images", "share.png", event.shareImage)
|
||||
val f = BitmapUtils.saveToShareableFile("$filesDir/shared_images", "share.png", event.shareImage)
|
||||
val fileUri = FileProvider.getUriForFile(this, getString(R.string.content_provider), f)
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, fileUri)
|
||||
val resInfoList = this.packageManager.queryIntentActivities(sharingIntent, PackageManager.MATCH_DEFAULT_ONLY)
|
||||
|
|
|
|||
|
|
@ -8,12 +8,15 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.habitrpg.android.habitica.MainNavDirections
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.models.members.Member
|
||||
import com.habitrpg.android.habitica.models.social.Group
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
|
|
@ -25,6 +28,8 @@ import com.habitrpg.android.habitica.ui.helpers.MarkdownParser
|
|||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.ui.helpers.resetViews
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.GroupViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIcons
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import com.habitrpg.android.habitica.ui.views.social.UsernameLabel
|
||||
import javax.inject.Inject
|
||||
|
|
@ -36,7 +41,13 @@ class GuildDetailFragment : BaseFragment() {
|
|||
|
||||
val refreshLayout: SwipeRefreshLayout by bindView(R.id.refreshLayout)
|
||||
private val guildTitleView: TextView by bindView(R.id.title_view)
|
||||
private val guildMembersIconView: ImageView by bindView(R.id.guild_members_icon)
|
||||
private val guildMembersTextView: TextView by bindView(R.id.guild_members_text)
|
||||
private val guildBankIconView: ImageView by bindView(R.id.guild_bank_icon)
|
||||
private val guildBankTextView: TextView by bindView(R.id.guild_bank_text)
|
||||
private val guildSummaryView: TextView by bindView(R.id.guild_summary)
|
||||
private val guildDescriptionView: TextView by bindView(R.id.guild_description)
|
||||
private val leaderWrapperView: ViewGroup by bindView(R.id.leader_wrapper)
|
||||
private val leaderAvatarView: AvatarView by bindView(R.id.leader_avatar_view)
|
||||
private val leaderProfileNameView: UsernameLabel by bindView(R.id.leader_profile_name)
|
||||
private val leaderUsernameView: TextView by bindView(R.id.leader_username)
|
||||
|
|
@ -62,7 +73,7 @@ class GuildDetailFragment : BaseFragment() {
|
|||
viewModel?.getIsMemberData()?.observe(viewLifecycleOwner, Observer { updateMembership(it) })
|
||||
|
||||
guildDescriptionView.movementMethod = LinkMovementMethod.getInstance()
|
||||
|
||||
guildBankIconView.setImageBitmap(HabiticaIconsHelper.imageOfGem())
|
||||
leaveGuildButton.setOnClickListener {
|
||||
viewModel?.leaveGroup {
|
||||
val activity = activity as? MainActivity
|
||||
|
|
@ -79,6 +90,12 @@ class GuildDetailFragment : BaseFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
leaderWrapperView.setOnClickListener {
|
||||
viewModel?.getGroupData()?.value?.leaderID?.let {leaderID ->
|
||||
val profileDirections = MainNavDirections.openProfileActivity(leaderID)
|
||||
MainNavigationController.navigate(profileDirections)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setLeader(leader: Member?) {
|
||||
|
|
@ -119,6 +136,10 @@ class GuildDetailFragment : BaseFragment() {
|
|||
|
||||
private fun updateGuild(guild: Group?) {
|
||||
guildTitleView.text = guild?.name
|
||||
guildMembersIconView.setImageBitmap(HabiticaIcons.imageOfGuildCrestMedium((guild?.memberCount ?: 0).toFloat()))
|
||||
guildMembersTextView.text = guild?.memberCount.toString()
|
||||
guildBankTextView.text = guild?.gemCount.toString()
|
||||
guildSummaryView.text = MarkdownParser.parseMarkdown(guild?.summary)
|
||||
guildDescriptionView.text = MarkdownParser.parseMarkdown(guild?.description)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue