mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
Including the option to share a challenge (#1147)
* Adding a Share button in the challenge overflow menu which copies the selected challenge's URL to the clipboard. * first attempt * mostly working, just need to add copy to clipboard * not using the ShareActionProvider * Removing unused dependencies and includes
This commit is contained in:
parent
bd0632b624
commit
29d8f761aa
2 changed files with 13 additions and 7 deletions
|
|
@ -5,4 +5,7 @@
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_edit"
|
android:id="@+id/action_edit"
|
||||||
android:title="@string/action_edit" />
|
android:title="@string/action_edit" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_share"
|
||||||
|
android:title="@string/share"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,9 @@ import android.os.Bundle
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.widget.*
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.Button
|
import com.habitrpg.android.habitica.BuildConfig
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import com.habitrpg.android.habitica.R
|
import com.habitrpg.android.habitica.R
|
||||||
import com.habitrpg.android.habitica.components.AppComponent
|
import com.habitrpg.android.habitica.components.AppComponent
|
||||||
import com.habitrpg.android.habitica.data.ChallengeRepository
|
import com.habitrpg.android.habitica.data.ChallengeRepository
|
||||||
|
|
@ -151,9 +149,6 @@ class ChallengeDetailFragment: BaseMainFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
if (!isCreator) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
inflater.inflate(R.menu.menu_challenge_details, menu)
|
inflater.inflate(R.menu.menu_challenge_details, menu)
|
||||||
val editMenuItem = menu.findItem(R.id.action_edit)
|
val editMenuItem = menu.findItem(R.id.action_edit)
|
||||||
editMenuItem?.isVisible = isCreator
|
editMenuItem?.isVisible = isCreator
|
||||||
|
|
@ -168,6 +163,14 @@ class ChallengeDetailFragment: BaseMainFragment() {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
else if (item.itemId == R.id.action_share) {
|
||||||
|
val shareGuildIntent = Intent().apply {
|
||||||
|
action = Intent.ACTION_SEND
|
||||||
|
putExtra(Intent.EXTRA_TEXT, "${BuildConfig.BASE_URL}/challenges/$challengeID")
|
||||||
|
type = "text/plain"
|
||||||
|
}
|
||||||
|
startActivity(shareGuildIntent)
|
||||||
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue