Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add copyboard to public key #1857

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.github.dedis.popstellar.R
import com.github.dedis.popstellar.databinding.QrFragmentBinding
import com.github.dedis.popstellar.model.qrcode.MainPublicKeyData
import com.github.dedis.popstellar.utility.ActivityUtils.getQRCodeColor
import com.github.dedis.popstellar.utility.GeneralUtils
import com.github.dedis.popstellar.utility.security.KeyManager
import com.google.gson.Gson
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -25,6 +26,7 @@ class QrFragment : Fragment() {

private lateinit var binding: QrFragmentBinding
private lateinit var viewModel: HomeViewModel
private lateinit var clipboardManager: GeneralUtils.ClipboardUtil

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -34,6 +36,7 @@ class QrFragment : Fragment() {
// Inflate the layout for this fragment
binding = QrFragmentBinding.inflate(inflater, container, false)
binding.lifecycleOwner = activity
clipboardManager = GeneralUtils.ClipboardUtil(requireActivity())

viewModel = HomeActivity.obtainViewModel(requireActivity())

Expand All @@ -44,6 +47,16 @@ class QrFragment : Fragment() {
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupCopyButton()
}

private fun setupCopyButton() {
clipboardManager.setupCopyButton(
binding.copyServerButton, binding.pkText, "Public Key")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe copyServerButton should be renamed in copyPublicKeyButton or something like that

}

override fun onResume() {
super.onResume()
viewModel.setPageTitle(R.string.witness_qr)
Expand Down
28 changes: 20 additions & 8 deletions fe2-android/app/src/main/res/layout/qr_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,42 @@
android:layout_width="@dimen/qr_rollcall_img"
android:layout_height="@dimen/qr_rollcall_img"
android:contentDescription="@string/witness"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/pk_title"
style="@style/explication_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/my_public_key"
style="@style/explication_text_style"
app:layout_constraintTop_toBottomOf="@id/pk_qr_code"
android:layout_marginTop="@dimen/home_button_vertical_margin"
android:text="@string/my_public_key"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintTop_toBottomOf="@id/pk_qr_code" />

<ImageButton
android:id="@+id/copy_server_button"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, I think you just forgot to adapt the id 👍

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/margin_button"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/copy_to_clipboard_public_key"
app:layout_constraintStart_toEndOf="@id/pk_title"
app:layout_constraintTop_toTopOf="@+id/pk_title"
app:srcCompat="@drawable/ic_content_copy" />

<TextView
android:id="@+id/pk_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/pk_title"
android:layout_marginTop="@dimen/home_button_vertical_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintTop_toBottomOf="@id/pk_title" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
17 changes: 3 additions & 14 deletions fe2-android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<!-- copy to clipboard -->
<string name="copy_to_clipboard_server">Copy to Clipboard Server Address</string>
<string name="copy_to_clipboard_lao_id">Copy to Clipboard Lao ID</string>
<string name="copy_to_clipboard_public_key">Copy to Public Key</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick but there a typo, should be Copy to Clipboard Public Key


<!-- bottom nav -->
<string name="tab_social_media">Social Media</string>
Expand All @@ -25,7 +26,6 @@
<string name="witnessing">Witnessing</string>
<string name="invite">Invite</string>
<string name="tokens">Tokens</string>
<string name="linked_organizations">Linked organizations</string>
<string name="disconnect">Disconnect</string>

<!-- Home -->
Expand Down Expand Up @@ -294,15 +294,6 @@
<string name="popcha_scan_title">Enter PoPCHA URL to log in</string>
<string name="manual_popcha_hint">PoPCHA URL</string>

<!-- Federation -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do those deletions come from? Maybe a wrong merge? Those strings look like a recent addition from Federation team, why are they getting deleted in this PR?

<string name="no_organizations_organizer_text">There are no linked organizations for now. To create a new link, tap the + button on the bottom right corner.</string>
<string name="no_organizations_non_organizer_text">There are no linked organizations for now.</string>
<string name="invite_other_organization">Invite an organization</string>
<string name="join_other_organization_invitation">Join an invitation</string>
<string name="scan_qr_code">Scan the QR code with the other organizers device</string>
<string name="next_step">Next step</string>
<string name="finish">Finish</string>

<!-- Storage-->
<string name="nothing_stored">No stored data found</string>
<string name="clear_text">Clear all storage</string>
Expand All @@ -329,10 +320,6 @@
<string name="receive_button_content_desc">Receive button</string>
<string name="qr_sight_content_desc">The sight on top of camera</string>
<string name="add_manual_close_button_desc">Close button for manual add window</string>
<string name="add_linked_organization_desc">Create a new link</string>
<string name="invite_other_organization_desc">Invite another organization</string>
<string name="join_other_organization_invitation_desc">Join another organization invitation</string>
<string name="qr_code_federation_image_description">Qr code image to display federation connecting information</string>

<!-- Error Messages -->
<string name="error_no_lao">You are not in a LAO</string>
Expand Down Expand Up @@ -389,4 +376,6 @@
<string name="invalid_qrcode_lao_data">Invalid QRCode laoData</string>
<string name="invalid_qrcode_popcha_data">Invalid URL</string>

<string name="network_status_connection_fail">No internet connection</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this addition, it looks like it should not be related to this PR


</resources>