mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 13:19:02 +00:00
Implement new no-party screen. Fixes #814
This commit is contained in:
parent
cd234b9980
commit
483c4f6e12
6 changed files with 151 additions and 14 deletions
6
Habitica/res/drawable/layout_rounded_bg_gray_600.xml
Normal file
6
Habitica/res/drawable/layout_rounded_bg_gray_600.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/gray_600" />
|
||||
<corners android:radius="@dimen/rounded_button_radius"/>
|
||||
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||
</shape>
|
||||
|
|
@ -52,20 +52,118 @@
|
|||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
<LinearLayout
|
||||
android:id="@+id/noPartyWrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/CardView.Default"
|
||||
android:id="@+id/qrWrapper">
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="@style/CardContent">
|
||||
|
||||
<include layout="@layout/qr_code" />
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="@dimen/spacing_large">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Title1"
|
||||
android:text="@string/no_party_title"
|
||||
android:gravity="center"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Body1"
|
||||
android:text="@string/no_party_description"
|
||||
android:textColor="@color/gray_300"
|
||||
android:gravity="center"/>
|
||||
<Button
|
||||
android:id="@+id/craetePartyButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/HabiticaButton.Gray.600"
|
||||
android:text="@string/create_party_website"
|
||||
android:layout_marginTop="@dimen/spacing_large"/>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/gray_500"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="@dimen/spacing_large">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Title2"
|
||||
android:text="@string/join_party_title"
|
||||
android:gravity="center"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Body1"
|
||||
android:text="@string/join_party_description"
|
||||
android:textColor="@color/gray_300"
|
||||
android:gravity="center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userIdView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/brand_400"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="@dimen/spacing_large"
|
||||
android:layout_marginBottom="@dimen/spacing_large"/>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/qrLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<FrameLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="300dp"
|
||||
android:id="@+id/qrCodeWrapper">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/QRImageView"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<RelativeLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/white"
|
||||
android:clipChildren="true"
|
||||
android:padding="1dp"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/QRDownloadButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/download"
|
||||
style="@style/HabiticaButton.Gray.600"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/groupNameView"
|
||||
|
|
|
|||
|
|
@ -756,4 +756,10 @@
|
|||
<string name="stable_owner_long">Matt the beast master</string>
|
||||
<string name="hide_boss_art">Hide Boss Art</string>
|
||||
<string name="active_world_boss">Active World Boss</string>
|
||||
<string name="no_party_description">Take on quests with friends or on your own. Battle monsters, create Challenges, and help yourself stay accountable through Parties.</string>
|
||||
<string name="no_party_title">Play Habitica in a Party</string>
|
||||
<string name="join_party_description">Give them your User ID or have them scan your QR code while inviting</string>
|
||||
<string name="join_party_title">Want to join a party?</string>
|
||||
<string name="create_party_website">Open website to create party</string>
|
||||
<string name="id_copied">ID copied to clipboard</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -376,6 +376,11 @@
|
|||
<item name="android:textColor">@color/brand_400</item>
|
||||
</style>
|
||||
|
||||
<style name="HabiticaButton.Gray.600" parent="HabiticaButton">
|
||||
<item name="android:background">@drawable/layout_rounded_bg_gray_600</item>
|
||||
<item name="android:textColor">@color/brand_400</item>
|
||||
</style>
|
||||
|
||||
<style name="HabiticaButton.Red" parent="HabiticaButton">
|
||||
<item name="android:background">@drawable/layout_rounded_bg_red</item>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,16 @@ import com.habitrpg.android.habitica.models.social.Group
|
|||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
import kotlinx.android.synthetic.main.fragment_group_info.*
|
||||
import kotlinx.android.synthetic.main.qr_code.*
|
||||
import rx.functions.Action1
|
||||
import javax.inject.Inject
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
|
||||
|
||||
class GroupInformationFragment : BaseFragment() {
|
||||
|
||||
|
|
@ -74,6 +81,20 @@ class GroupInformationFragment : BaseFragment() {
|
|||
}
|
||||
})
|
||||
|
||||
userIdView.setOnClickListener {
|
||||
val clipboard = context?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText(context?.getString(R.string.user_id), user?.id)
|
||||
clipboard.primaryClip = clip
|
||||
val activity = activity as MainActivity?
|
||||
if (activity != null) {
|
||||
HabiticaSnackbar.showSnackbar(activity.getFloatingMenuWrapper(), getString(R.string.id_copied), HabiticaSnackbar.SnackbarDisplayType.NORMAL)
|
||||
}
|
||||
}
|
||||
|
||||
craetePartyButton.setOnClickListener {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://habitica.com/party"))
|
||||
startActivity(browserIntent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUser(user: User?) {
|
||||
|
|
@ -82,6 +103,7 @@ class GroupInformationFragment : BaseFragment() {
|
|||
} else {
|
||||
setInvitation(null)
|
||||
}
|
||||
userIdView.text = user?.id
|
||||
}
|
||||
|
||||
private fun setInvitation(invitation: PartyInvite?) {
|
||||
|
|
@ -101,15 +123,16 @@ class GroupInformationFragment : BaseFragment() {
|
|||
fun setGroup(group: Group?) {
|
||||
this.group = group
|
||||
|
||||
if (qrWrapper == null) {
|
||||
if (noPartyWrapper == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val hasGroup = group != null
|
||||
val groupItemVisibility = if (hasGroup) View.VISIBLE else View.GONE
|
||||
qrWrapper.visibility = if (hasGroup) View.GONE else View.VISIBLE
|
||||
noPartyWrapper.visibility = if (hasGroup) View.GONE else View.VISIBLE
|
||||
groupNameView.visibility = groupItemVisibility
|
||||
groupDescriptionView.visibility = groupItemVisibility
|
||||
groupDescriptionWrapper.visibility = groupItemVisibility
|
||||
|
||||
groupDescriptionView.text = group?.description
|
||||
leadernameWrapper.visibility = if (group?.leaderName != null) View.VISIBLE else View.GONE
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import com.habitrpg.android.habitica.ui.fragments.social.QuestDetailFragment;
|
|||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
|
||||
import com.habitrpg.android.habitica.ui.views.social.OldQuestProgressView;
|
||||
import com.habitrpg.android.habitica.ui.views.social.QuestProgressView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
|
@ -196,7 +195,7 @@ public class PartyDetailFragment extends BaseFragment {
|
|||
DataBindingUtils.INSTANCE.loadImage(questImageView, "quest_"+questContent.getKey());
|
||||
if (isQuestActive()) {
|
||||
questProgressView.setVisibility(View.VISIBLE);
|
||||
questProgressView.setData(questContent, quest);
|
||||
questProgressView.setData(questContent, quest.getProgress());
|
||||
|
||||
questParticipationView.setText(getString(R.string.number_participants, quest.getMembers().size()));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue