mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-23 22:27:15 +00:00
allow users to accept party invites
This commit is contained in:
parent
cfced48f0d
commit
ad7a1b7566
5 changed files with 95 additions and 25 deletions
|
|
@ -6,6 +6,7 @@
|
|||
<data>
|
||||
<import type="com.magicmicky.habitrpgwrapper.lib.models.Group" />
|
||||
<import type="com.magicmicky.habitrpgwrapper.lib.models.inventory.QuestContent" />
|
||||
<import type="com.magicmicky.habitrpgwrapper.lib.models.invitations.PartyInvite" />
|
||||
<import type="com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser" />
|
||||
<import type="android.view.View" />
|
||||
<import type="android.text.Html"/>
|
||||
|
|
@ -26,6 +27,10 @@
|
|||
name="hideParticipantCard"
|
||||
type="Boolean" />
|
||||
|
||||
<variable
|
||||
name="invitation"
|
||||
type="PartyInvite" />
|
||||
|
||||
</data>
|
||||
|
||||
|
||||
|
|
@ -41,11 +46,54 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/CardView.Default"
|
||||
android:id="@+id/invitationWrapper"
|
||||
android:visibility="@{invitation == null ? View.GONE : View.VISIBLE}"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="@style/CardContent">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/invited_to_party" />
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="right">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnPartyInviteAccept"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/quest.accept"
|
||||
android:textColor="@color/btn_success"
|
||||
style="?android:buttonBarButtonStyle" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnPartyInviteReject"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/quest.reject"
|
||||
android:textColor="@color/btn_danger"
|
||||
style="?android:buttonBarButtonStyle" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/CardView.Default"
|
||||
android:id="@+id/qrWrapper"
|
||||
android:visibility="@{group == null ? View.VISIBLE : View.GONE}"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -396,5 +396,6 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="action_continue">Continue</string>
|
||||
<string name="scan_qr_code">Scan QR Code</string>
|
||||
<string name="enter_recipient_uuid">Enter Recipients User ID</string>
|
||||
<string name="invited_to_party">You were invited to join a party!</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import com.habitrpg.android.habitica.components.AppComponent;
|
|||
import com.habitrpg.android.habitica.databinding.FragmentGroupInfoBinding;
|
||||
import com.habitrpg.android.habitica.databinding.ValueBarBinding;
|
||||
import com.habitrpg.android.habitica.helpers.QrCodeManager;
|
||||
import com.habitrpg.android.habitica.prefs.scanner.IntentIntegrator;
|
||||
import com.habitrpg.android.habitica.ui.AvatarView;
|
||||
import com.habitrpg.android.habitica.ui.adapter.social.QuestCollectRecyclerViewAdapter;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Group;
|
||||
|
|
@ -16,35 +14,18 @@ import com.magicmicky.habitrpgwrapper.lib.models.inventory.QuestContent;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.glxn.qrgen.android.QRCode;
|
||||
import net.glxn.qrgen.core.image.ImageType;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -67,9 +48,11 @@ public class GroupInformationFragment extends BaseFragment {
|
|||
RecyclerView collectionStats;
|
||||
|
||||
@BindView(R.id.qrLayout)
|
||||
@Nullable
|
||||
LinearLayout qrLayout;
|
||||
|
||||
@BindView(R.id.qrWrapper)
|
||||
@Nullable
|
||||
CardView qrWrapper;
|
||||
|
||||
private View view;
|
||||
|
|
@ -123,10 +106,10 @@ public class GroupInformationFragment extends BaseFragment {
|
|||
if (this.group == null) {
|
||||
QrCodeManager qrCodeManager = new QrCodeManager(this.getContext());
|
||||
qrCodeManager.setUpView(qrLayout);
|
||||
}
|
||||
|
||||
if (user != null && user.getParty().getId() != null) {
|
||||
((ViewGroup) qrWrapper.getParent()).removeView(qrWrapper);
|
||||
if (user.getInvitations().getParty() != null && user.getInvitations().getParty().getId() != null) {
|
||||
viewBinding.setInvitation(user.getInvitations().getParty());
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
|
|
@ -331,4 +314,23 @@ public class GroupInformationFragment extends BaseFragment {
|
|||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnPartyInviteAccept)
|
||||
public void onPartyInviteAccepted() {
|
||||
apiHelper.apiService.joinGroup(user.getInvitations().getParty().getId())
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(group -> {
|
||||
setGroup(group);
|
||||
viewBinding.setInvitation(null);
|
||||
}, throwable -> {});
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnPartyInviteReject)
|
||||
public void onPartyInviteRejected() {
|
||||
apiHelper.apiService.rejectGroupInvite(user.getInvitations().getParty().getId())
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(aVoid -> {
|
||||
viewBinding.setInvitation(null);
|
||||
}, throwable -> {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public class PartyFragment extends BaseMainFragment {
|
|||
|
||||
@Inject
|
||||
ContentCache contentCache;
|
||||
private FragmentPagerAdapter viewPagerAdapter;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
|
|
@ -100,6 +101,8 @@ public class PartyFragment extends BaseMainFragment {
|
|||
this.tutorialStepIdentifier = "party";
|
||||
this.tutorialText = getString(R.string.tutorial_party);
|
||||
|
||||
updateGroupUI();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +112,15 @@ public class PartyFragment extends BaseMainFragment {
|
|||
}
|
||||
|
||||
private void updateGroupUI() {
|
||||
viewPagerAdapter.notifyDataSetChanged();
|
||||
|
||||
if (group == null) {
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
return;
|
||||
} else {
|
||||
tabLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (partyMemberListFragment != null) {
|
||||
partyMemberListFragment.setMemberList(group.members);
|
||||
}
|
||||
|
|
@ -130,6 +142,7 @@ public class PartyFragment extends BaseMainFragment {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -260,7 +273,7 @@ public class PartyFragment extends BaseMainFragment {
|
|||
return;
|
||||
}
|
||||
|
||||
this.viewPager.setAdapter(new FragmentPagerAdapter(fragmentManager) {
|
||||
viewPagerAdapter = new FragmentPagerAdapter(fragmentManager) {
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
|
@ -298,7 +311,11 @@ public class PartyFragment extends BaseMainFragment {
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 3;
|
||||
if (group == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -313,7 +330,8 @@ public class PartyFragment extends BaseMainFragment {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
};
|
||||
this.viewPager.setAdapter(viewPagerAdapter);
|
||||
|
||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -256,4 +256,5 @@ public interface ApiService {
|
|||
|
||||
@POST("debug/add-ten-gems")
|
||||
Observable<Void> debugAddTenGems();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue