-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1343 from dedis/work-fe2-jpluss-drawer
Drawer menu
- Loading branch information
Showing
56 changed files
with
1,392 additions
and
1,367 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
fe2-android/app/src/main/java/com/github/dedis/popstellar/model/Role.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.dedis.popstellar.model; | ||
|
||
import androidx.annotation.StringRes; | ||
|
||
import com.github.dedis.popstellar.R; | ||
|
||
public enum Role { | ||
ORGANIZER(R.string.organizer), | ||
WITNESS(R.string.witness), | ||
ATTENDEE(R.string.attendee), | ||
MEMBER(R.string.member); | ||
|
||
@StringRes private final int roleString; | ||
|
||
Role(@StringRes int role) { | ||
this.roleString = role; | ||
} | ||
|
||
@StringRes | ||
public int getStringId() { | ||
return roleString; | ||
} | ||
} |
113 changes: 0 additions & 113 deletions
113
fe2-android/app/src/main/java/com/github/dedis/popstellar/ui/detail/IdentityFragment.java
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
fe2-android/app/src/main/java/com/github/dedis/popstellar/ui/detail/InviteFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.github.dedis.popstellar.ui.detail; | ||
|
||
import android.graphics.Bitmap; | ||
import android.os.Bundle; | ||
import android.view.*; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.Fragment; | ||
|
||
import com.github.dedis.popstellar.R; | ||
import com.github.dedis.popstellar.databinding.InviteFragmentBinding; | ||
import com.github.dedis.popstellar.model.objects.view.LaoView; | ||
import com.github.dedis.popstellar.model.qrcode.ConnectToLao; | ||
import com.github.dedis.popstellar.repository.remote.GlobalNetworkManager; | ||
import com.github.dedis.popstellar.utility.error.ErrorUtils; | ||
import com.github.dedis.popstellar.utility.error.UnknownLaoException; | ||
import com.google.gson.Gson; | ||
|
||
import net.glxn.qrgen.android.QRCode; | ||
|
||
import javax.inject.Inject; | ||
|
||
import dagger.hilt.android.AndroidEntryPoint; | ||
|
||
@AndroidEntryPoint | ||
public class InviteFragment extends Fragment { | ||
|
||
private static final String TAG = InviteFragment.class.getSimpleName(); | ||
|
||
@Inject Gson gson; | ||
@Inject GlobalNetworkManager networkManager; | ||
|
||
private static final int QR_SIDE = 800; | ||
|
||
private LaoDetailViewModel viewModel; | ||
|
||
public static InviteFragment newInstance() { | ||
return new InviteFragment(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView( | ||
@NonNull LayoutInflater inflater, | ||
@Nullable ViewGroup container, | ||
@Nullable Bundle savedInstanceState) { | ||
InviteFragmentBinding binding = InviteFragmentBinding.inflate(inflater, container, false); | ||
viewModel = LaoDetailActivity.obtainViewModel(requireActivity()); | ||
|
||
binding.laoPropertiesIdentifierText.setText(viewModel.getPublicKey().getEncoded()); | ||
binding.laoPropertiesServerText.setText(networkManager.getCurrentUrl()); | ||
|
||
try { | ||
LaoView laoView = viewModel.getLao(); | ||
|
||
ConnectToLao data = new ConnectToLao(networkManager.getCurrentUrl(), laoView.getId()); | ||
Bitmap myBitmap = QRCode.from(gson.toJson(data)).withSize(QR_SIDE, QR_SIDE).bitmap(); | ||
binding.channelQrCode.setImageBitmap(myBitmap); | ||
binding.laoPropertiesNameText.setText(laoView.getName()); | ||
|
||
viewModel | ||
.getRole() | ||
.observe( | ||
getViewLifecycleOwner(), | ||
role -> binding.laoPropertiesRoleText.setText(role.getStringId())); | ||
|
||
} catch (UnknownLaoException e) { | ||
ErrorUtils.logAndShow(requireContext(), TAG, e, R.string.unknown_lao_exception); | ||
return null; | ||
} | ||
return binding.getRoot(); | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
viewModel.setPageTitle(R.string.invite); | ||
viewModel.setIsTab(true); | ||
} | ||
} |
Oops, something went wrong.