Skip to content

Commit

Permalink
Add util to share to other apps
Browse files Browse the repository at this point in the history
  • Loading branch information
helloworld1 committed Dec 25, 2022
1 parent 0128724 commit 5b8e4ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package org.fedorahosted.freeotp.ui

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.widget.PopupMenu
import androidx.recyclerview.widget.RecyclerView
import org.fedorahosted.freeotp.R
import org.fedorahosted.freeotp.data.OtpToken
import org.fedorahosted.freeotp.data.OtpTokenFactory
import org.fedorahosted.freeotp.token.TokenLayout

class TokenViewHolder(private val activity: Activity,
Expand All @@ -28,6 +30,11 @@ class TokenViewHolder(private val activity: Activity,
activity.startActivity(i)
}

R.id.action_share -> {
val i = Intent(Intent.ACTION_VIEW, Uri.parse(OtpTokenFactory.toUri(token).toString()))
activity.startActivity(Intent.createChooser(i, null))
}

R.id.action_share_qr_code -> {
val i = Intent(tokenLayout.context, ShareQrCodeActivity::class.java)
i.putExtra(EditActivity.EXTRA_TOKEN_ID, token.id)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/menu/token.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
android:icon="@android:drawable/ic_menu_delete"
android:title="@string/delete"
/>
<item
android:id="@+id/action_share"
android:icon="@android:drawable/ic_menu_share"
android:title="@string/share_to_other_apps" />

<item
android:id="@+id/action_share_qr_code"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@
<string name="screenshot_mode">Screenshot mode</string>
<string name="launch_with_screenshot_enabled">Launch with screenshot enabled</string>
<string name="token_details">Token details</string>
<string name="share_to_other_apps">Share to other apps</string>
</resources>

0 comments on commit 5b8e4ea

Please sign in to comment.