mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Fixes #1393
This commit is contained in:
parent
9ebc89c702
commit
f1cc1652d7
6 changed files with 102 additions and 26 deletions
|
|
@ -4,14 +4,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@color/window_background">
|
||||
android:background="?attr/colorContentBackground">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="30dp"
|
||||
android:background="?attr/colorContentBackground">
|
||||
android:paddingTop="30dp">
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -138,10 +137,5 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/privacySpinner" />
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#1e000000"
|
||||
android:layout_marginTop="@dimen/spacing_medium" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
@ -4,7 +4,13 @@
|
|||
tools:context="com.habitrpg.android.habitica.TaskActivity">
|
||||
<item
|
||||
android:id="@+id/action_edit"
|
||||
android:title="@string/action_edit" />
|
||||
android:title="@string/action_edit"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_end_challenge"
|
||||
android:title="@string/action_end_challenge"
|
||||
app:showAsAction="never"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:title="@string/share"/>
|
||||
|
|
|
|||
13
Habitica/res/menu/menu_create_refresh.xml
Normal file
13
Habitica/res/menu/menu_create_refresh.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<item android:id="@+id/menu_create_item"
|
||||
android:title="@string/create"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/menu_refresh"
|
||||
android:orderInCategory="1"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/action_refresh" />
|
||||
</menu>
|
||||
|
|
@ -1116,4 +1116,9 @@
|
|||
<string name="fortify_shop">Fortify Potion</string>
|
||||
<string name="fortify_shop_description">Return all tasks to neutral value (yellow color), and restore all lost Health</string>
|
||||
<string name="purchase_immediately_description">This will take effect immediately after buying!</string>
|
||||
<string name="create_guild">Create Guild</string>
|
||||
<string name="create_guild_description">You can create a Guild on the Habitica website. To create a Guild: log in then tap the “Create” button on the “My Guilds” screen.</string>
|
||||
<string name="open_website">Open Website</string>
|
||||
<string name="action_end_challenge">End Challenge</string>
|
||||
<string name="end_challenge_description">You can end a Challenge on the Habitica website. To end a Challenge: log in then tap the “End Challenge” button on the right of the Challenge screen.</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.social
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import android.widget.TextView
|
||||
import androidx.core.net.toUri
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.ChallengeRepository
|
||||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentGuildsOverviewBinding
|
||||
import com.habitrpg.android.habitica.extensions.addCloseButton
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.social.Group
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import io.realm.RealmResults
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
|
@ -61,6 +63,39 @@ class GuildsOverviewFragment : BaseMainFragment<FragmentGuildsOverviewBinding>()
|
|||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.menu_create_refresh, menu)
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.menu_refresh -> {
|
||||
onRefresh()
|
||||
return true
|
||||
}
|
||||
R.id.menu_create_item -> {
|
||||
showCreationDialog()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun showCreationDialog() {
|
||||
val context = context ?: return
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.create_guild)
|
||||
dialog.setMessage(R.string.create_guild_description)
|
||||
dialog.addButton(R.string.open_website, true, false) { _, _ ->
|
||||
val uriUrl = "https://habitica.com/groups/myGuilds".toUri()
|
||||
val launchBrowser = Intent(Intent.ACTION_VIEW, uriUrl)
|
||||
startActivity(launchBrowser)
|
||||
}
|
||||
dialog.addCloseButton()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
override fun injectFragment(component: UserComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ import android.widget.ImageView
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.ChallengeRepository
|
||||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentChallengeDetailBinding
|
||||
import com.habitrpg.android.habitica.extensions.addCloseButton
|
||||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.members.Member
|
||||
|
|
@ -140,29 +142,50 @@ class ChallengeDetailFragment: BaseMainFragment<FragmentChallengeDetailBinding>(
|
|||
inflater.inflate(R.menu.menu_challenge_details, menu)
|
||||
val editMenuItem = menu.findItem(R.id.action_edit)
|
||||
editMenuItem?.isVisible = isCreator
|
||||
val endChallengeMenuItem = menu.findItem(R.id.action_end_challenge)
|
||||
endChallengeMenuItem?.isVisible = isCreator
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.action_edit) {
|
||||
val intent = Intent(getActivity(), ChallengeFormActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString(ChallengeFormActivity.CHALLENGE_ID_KEY, challengeID)
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent)
|
||||
return true
|
||||
}
|
||||
else if (item.itemId == R.id.action_share) {
|
||||
val shareGuildIntent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, "${context?.getString(R.string.base_url)}/challenges/$challengeID")
|
||||
type = "text/plain"
|
||||
when (item.itemId) {
|
||||
R.id.action_edit -> {
|
||||
val intent = Intent(getActivity(), ChallengeFormActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString(ChallengeFormActivity.CHALLENGE_ID_KEY, challengeID)
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent)
|
||||
return true
|
||||
}
|
||||
R.id.action_share -> {
|
||||
val shareGuildIntent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, "${context?.getString(R.string.base_url)}/challenges/$challengeID")
|
||||
type = "text/plain"
|
||||
}
|
||||
startActivity(Intent.createChooser(shareGuildIntent, context?.getString(R.string.share_challenge_with)))
|
||||
}
|
||||
R.id.action_end_challenge -> {
|
||||
showEndChallengeDialog()
|
||||
}
|
||||
startActivity(Intent.createChooser(shareGuildIntent, context?.getString(R.string.share_challenge_with)))
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun showEndChallengeDialog() {
|
||||
val context = context ?: return
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.action_end_challenge)
|
||||
dialog.setMessage(R.string.end_challenge_description)
|
||||
dialog.addButton(R.string.open_website, true, false) { _, _ ->
|
||||
val uriUrl = "https://habitica.com/challenges/${challengeID}".toUri()
|
||||
val launchBrowser = Intent(Intent.ACTION_VIEW, uriUrl)
|
||||
startActivity(launchBrowser)
|
||||
}
|
||||
dialog.addCloseButton()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun refresh() {
|
||||
challengeID?.let {id ->
|
||||
challengeRepository.retrieveChallenge(id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue