mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Improve deep linking
This commit is contained in:
parent
b9de152514
commit
abaf3f2612
11 changed files with 89 additions and 51 deletions
|
|
@ -37,6 +37,14 @@
|
|||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter android:label="@string/app_name">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https"
|
||||
android:host="habitica.com"
|
||||
android:pathPattern="/"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.PrefsActivity"
|
||||
|
|
@ -44,6 +52,14 @@
|
|||
android:label="@string/PS_settings_title"
|
||||
android:screenOrientation="portrait"
|
||||
tools:ignore="UnusedAttribute">
|
||||
<intent-filter android:label="@string/app_name">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https"
|
||||
android:host="habitica.com"
|
||||
android:pathPattern="/settings/.*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.FixCharacterValuesActivity"
|
||||
|
|
@ -141,16 +157,14 @@
|
|||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ui.activities.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.ChallengeDetailActivity"
|
||||
android:parentActivityName=".ui.activities.MainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:launchMode="singleTask"
|
||||
tools:ignore="UnusedAttribute">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ui.activities.MainActivity" />
|
||||
<intent-filter android:label="@string/app_name">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https"
|
||||
android:host="habitica.com"
|
||||
android:pathPattern="/profile/.*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.ChallengeFormActivity"
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/presents1"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="18dp"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/presents2"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="18dp"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
android:paddingBottom="21dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true">
|
||||
<TextView
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_down_black_24dp"
|
||||
android:id="@+id/subscribe.listitem1.expand"
|
||||
android:layout_gravity="right"/>
|
||||
android:layout_gravity="end"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
@ -134,7 +134,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_down_black_24dp"
|
||||
android:id="@+id/subscribe.listitem2.expand"
|
||||
android:layout_gravity="right"/>
|
||||
android:layout_gravity="end"/>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
|
|
@ -162,7 +162,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_down_black_24dp"
|
||||
android:id="@+id/subscribe.listitem3.expand"
|
||||
android:layout_gravity="right"/>
|
||||
android:layout_gravity="end"/>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
|
|
@ -190,7 +190,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_down_black_24dp"
|
||||
android:id="@+id/subscribe.listitem4.expand"
|
||||
android:layout_gravity="right"/>
|
||||
android:layout_gravity="end"/>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
android:id="@+id/equipmentOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.equipment.EquipmentOverviewFragment"
|
||||
android:label="@string/sidebar.equipment" >
|
||||
<deepLink app:uri="habitica.com/inventory/equipment" />
|
||||
<action
|
||||
android:id="@+id/openEquipmentDetail"
|
||||
app:destination="@id/equipmentDetailFragment" />
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
android:id="@+id/tasksFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.tasks.TasksFragment">
|
||||
<deepLink app:uri="habitica.com/tasks" />
|
||||
<deepLink app:uri="habitica.com" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/partyFragment"
|
||||
|
|
@ -43,6 +45,7 @@
|
|||
<fragment
|
||||
android:id="@+id/questDetailFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.QuestDetailFragment">
|
||||
<deepLink app:uri="habitica.com/party/quest" />
|
||||
<argument
|
||||
android:name="partyID"
|
||||
app:argType="string"/>
|
||||
|
|
@ -53,19 +56,26 @@
|
|||
<fragment
|
||||
android:id="@+id/skillsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.skills.SkillsFragment"
|
||||
android:label="@string/sidebar.skills" />
|
||||
android:label="@string/sidebar.skills">
|
||||
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/statsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.StatsFragment"
|
||||
android:label="@string/stats" />
|
||||
android:label="@string/stats">
|
||||
<deepLink app:uri="habitica.com/user/stats" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/tavernFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.TavernFragment"
|
||||
android:label="@string/sidebar.tavern" />
|
||||
android:label="@string/sidebar.tavern">
|
||||
<deepLink app:uri="habitica.com/tavern" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/guildsOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.GuildsOverviewFragment"
|
||||
android:label="@string/sidebar.guilds" >
|
||||
<deepLink app:uri="habitica.com/groups/myGuilds" />
|
||||
<action
|
||||
android:id="@+id/openGuildDetail"
|
||||
app:destination="@id/guildFragment" >
|
||||
|
|
@ -81,6 +91,8 @@
|
|||
android:id="@+id/challengesOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengesOverviewFragment"
|
||||
android:label="@string/sidebar.challenges" >
|
||||
<deepLink app:uri="habitica.com/challenges/myChallenges" />
|
||||
<deepLink app:uri="habitica.com/challenges/findChallenges" />
|
||||
<action
|
||||
android:id="@+id/openChallengeDetail"
|
||||
app:destination="@id/challengeDetailFragment" />
|
||||
|
|
@ -100,11 +112,14 @@
|
|||
<fragment
|
||||
android:id="@+id/itemsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemsFragment"
|
||||
android:label="@string/sidebar_items" />
|
||||
android:label="@string/sidebar_items">
|
||||
<deepLink app:uri="habitica.com/inventory/items" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/stableFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.stable.StableFragment"
|
||||
android:label="@string/sidebar.stable" >
|
||||
<deepLink app:uri="habitica.com/inventory/stable" />
|
||||
<action
|
||||
android:id="@+id/openPetDetail"
|
||||
app:destination="@id/petDetailRecyclerFragment" />
|
||||
|
|
@ -124,6 +139,7 @@
|
|||
android:id="@+id/FAQOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.faq.FAQOverviewFragment"
|
||||
android:label="@string/sidebar_help" >
|
||||
<deepLink app:uri="habitica.com/static/faq" />
|
||||
<action
|
||||
android:id="@+id/openFAQDetail"
|
||||
app:destination="@id/FAQDetailFragment" />
|
||||
|
|
@ -144,12 +160,14 @@
|
|||
android:id="@+id/guildFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.GuildFragment"
|
||||
android:label="@string/guild" >
|
||||
<deepLink app:uri="habitica.com/groups/guild/{groupID}" />
|
||||
<argument
|
||||
android:name="groupID"
|
||||
app:argType="string" />
|
||||
<argument
|
||||
android:name="isMember"
|
||||
app:argType="boolean" />
|
||||
app:argType="boolean"
|
||||
android:defaultValue="false"/>
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/publicGuildsFragment"
|
||||
|
|
@ -182,7 +200,8 @@
|
|||
android:id="@+id/prefsActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.PrefsActivity"
|
||||
android:label="@string/app_settings"
|
||||
tools:layout="@layout/activity_prefs" />
|
||||
tools:layout="@layout/activity_prefs">
|
||||
</activity>
|
||||
<fragment
|
||||
android:id="@+id/inboxMessageListFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.InboxMessageListFragment"
|
||||
|
|
@ -197,7 +216,7 @@
|
|||
<fragment
|
||||
android:id="@+id/petDetailRecyclerFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.stable.PetDetailRecyclerFragment"
|
||||
android:label="@string/pets" >
|
||||
android:label="@string/pets">
|
||||
<argument
|
||||
android:name="type"
|
||||
app:argType="string" />
|
||||
|
|
@ -219,7 +238,8 @@
|
|||
<fragment
|
||||
android:id="@+id/challengeDetailFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengeDetailFragment"
|
||||
android:label="@string/challenge" >
|
||||
android:label="@string/challenge">
|
||||
<deepLink app:uri="habitica.com/challenges/{challengeID}" />
|
||||
<argument
|
||||
android:name="challengeID"
|
||||
app:argType="string" />
|
||||
|
|
@ -228,4 +248,12 @@
|
|||
android:id="@+id/taskFormActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.TaskFormActivity"
|
||||
android:label="TaskFormActivity" />
|
||||
<activity
|
||||
android:id="@+id/fullProfileActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.FullProfileActivity"
|
||||
android:label="FullProfileActivity">
|
||||
<argument
|
||||
android:name="userID"
|
||||
app:argType="string" />
|
||||
</activity>
|
||||
</navigation>
|
||||
|
|
@ -7,9 +7,6 @@ import android.os.Bundle
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.*
|
||||
import android.widget.*
|
||||
import com.facebook.drawee.backends.pipeline.Fresco
|
||||
|
|
@ -22,6 +19,7 @@ import com.habitrpg.android.habitica.data.ApiClient
|
|||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.extensions.notNull
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.UserStatComputer
|
||||
import com.habitrpg.android.habitica.models.AchievementGroup
|
||||
|
|
@ -79,7 +77,7 @@ class FullProfileActivity : BaseActivity() {
|
|||
private val lastLoginView: TextView by bindView(R.id.last_login_view)
|
||||
private val totalCheckinsView: TextView by bindView(R.id.total_checkins_view)
|
||||
|
||||
private var userId = ""
|
||||
private var userID = ""
|
||||
private var userName: String? = null
|
||||
private var avatarWithBars: AvatarWithBarsViewModel? = null
|
||||
private var attributeStrSum = 0f
|
||||
|
|
@ -93,13 +91,14 @@ class FullProfileActivity : BaseActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val intent = intent
|
||||
val bundle = intent.extras
|
||||
this.userId = bundle?.getString("userId") ?: ""
|
||||
userID = intent?.extras?.getString("userID", "") ?: ""
|
||||
if (userID.isEmpty()) {
|
||||
userID = intent?.data?.path?.removePrefix("/profile/") ?: ""
|
||||
}
|
||||
|
||||
setTitle(R.string.profile_loading_data)
|
||||
|
||||
compositeSubscription.add(socialRepository.getMember(this.userId).subscribe(Consumer { this.updateView(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(socialRepository.getMember(this.userID).subscribe(Consumer { this.updateView(it) }, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
avatarWithBars?.valueBarLabelsToBlack()
|
||||
|
||||
|
|
@ -144,7 +143,7 @@ class FullProfileActivity : BaseActivity() {
|
|||
|
||||
val addMessageDialog = AlertDialog.Builder(this)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
socialRepository.postPrivateMessage(userId, emojiEditText.text.toString())
|
||||
socialRepository.postPrivateMessage(userID, emojiEditText.text.toString())
|
||||
.subscribe(Consumer {
|
||||
HabiticaSnackbar.showSnackbar(this@FullProfileActivity.fullprofile_scrollview.getChildAt(0) as ViewGroup,
|
||||
String.format(getString(R.string.profile_message_sent_to), userName), SnackbarDisplayType.NORMAL)
|
||||
|
|
@ -214,7 +213,7 @@ class FullProfileActivity : BaseActivity() {
|
|||
|
||||
|
||||
// Load the members achievements now
|
||||
compositeSubscription.add(socialRepository.getMemberAchievements(this.userId).subscribe(Consumer<AchievementResult> { this.fillAchievements(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(socialRepository.getMemberAchievements(this.userID).subscribe(Consumer<AchievementResult> { this.fillAchievements(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
private fun updatePetsMountsView(user: Member) {
|
||||
|
|
@ -467,17 +466,13 @@ class FullProfileActivity : BaseActivity() {
|
|||
|
||||
companion object {
|
||||
|
||||
fun open(context: Context, userId: String) {
|
||||
fun open(userId: String) {
|
||||
if (userId == "system") {
|
||||
return
|
||||
}
|
||||
val bundle = Bundle()
|
||||
bundle.putString("userId", userId)
|
||||
|
||||
val intent = Intent(context, FullProfileActivity::class.java)
|
||||
intent.putExtras(bundle)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|
||||
context.startActivity(intent)
|
||||
bundle.putString("userID", userId)
|
||||
MainNavigationController.navigate(R.id.fullProfileActivity, bundle)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import android.content.res.Configuration
|
|||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Bundle
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ class PublicGuildsRecyclerViewAdapter(data: OrderedRealmCollection<Group>?, auto
|
|||
val guildViewHolder = GuildViewHolder(parent.inflate(R.layout.item_public_guild))
|
||||
guildViewHolder.itemView.setOnClickListener { v ->
|
||||
val guild = v.tag as? Group ?: return@setOnClickListener
|
||||
MainNavigationController.navigate(PublicGuildsFragmentDirections.openGuildDetail(guild.id, isInGroup(guild)))
|
||||
val directions =PublicGuildsFragmentDirections.openGuildDetail(guild.id)
|
||||
directions.isMember = isInGroup(guild)
|
||||
MainNavigationController.navigate(directions)
|
||||
}
|
||||
guildViewHolder.joinLeaveButton.setOnClickListener { v ->
|
||||
val guild = v.tag as? Group ?: return@setOnClickListener
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class ChatFragment constructor(private val viewModel: PartyViewModel) : BaseFrag
|
|||
chatAdapter = ChatRecyclerViewAdapter(null, true, null, true)
|
||||
chatAdapter.notNull {adapter ->
|
||||
compositeSubscription.add(adapter.getUserLabelClickFlowable().subscribe(Consumer { userId ->
|
||||
context.notNull { FullProfileActivity.open(it, userId) }
|
||||
FullProfileActivity.open(userId)
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(adapter.getDeleteMessageFlowable().subscribe(Consumer { this.showDeleteConfirmationDialog(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(adapter.getFlagMessageClickFlowable().subscribe(Consumer { this.showFlagConfirmationDialog(it) }, RxErrorHandler.handleEmptyError()))
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class ChatListFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
|
|||
chatAdapter = ChatRecyclerViewAdapter(null, true, user, true)
|
||||
chatAdapter.notNull {adapter ->
|
||||
compositeSubscription.add(adapter.getUserLabelClickFlowable().subscribe(Consumer { userId ->
|
||||
context.notNull { FullProfileActivity.open(it, userId) }
|
||||
FullProfileActivity.open(userId)
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(adapter.getDeleteMessageFlowable().subscribe(Consumer { this.showDeleteConfirmationDialog(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(adapter.getFlagMessageClickFlowable().subscribe(Consumer { this.showFlagConfirmationDialog(it) }, RxErrorHandler.handleEmptyError()))
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class InboxMessageListFragment : BaseMainFragment(), androidx.swiperefreshlayout
|
|||
recyclerView.itemAnimator = SafeDefaultItemAnimator()
|
||||
chatAdapter.notNull { adapter ->
|
||||
compositeSubscription.add(adapter.getUserLabelClickFlowable().subscribe(Consumer<String> {
|
||||
context.notNull { context -> FullProfileActivity.open(context, it) }
|
||||
FullProfileActivity.open(it)
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(adapter.getDeleteMessageFlowable().subscribe(Consumer { this.showDeleteConfirmationDialog(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(adapter.getFlagMessageClickFlowable().subscribe(Consumer { this.showFlagConfirmationDialog(it) }, RxErrorHandler.handleEmptyError()))
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class ChallengeDetailFragment: BaseMainFragment() {
|
|||
|
||||
challengeLeaderWrapper?.setOnClickListener {
|
||||
val leaderID = challenge?.leaderId ?: return@setOnClickListener
|
||||
FullProfileActivity.open(it.context, leaderID)
|
||||
FullProfileActivity.open(leaderID)
|
||||
}
|
||||
|
||||
challengeID.notNull {id ->
|
||||
|
|
|
|||
|
|
@ -52,9 +52,7 @@ class PartyMemberListFragment constructor(private val viewModel: PartyViewModel)
|
|||
|
||||
recyclerView?.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
|
||||
adapter = PartyMemberRecyclerViewAdapter(null, true)
|
||||
context.notNull {
|
||||
adapter?.getUserClickedEvents()?.subscribe(Consumer { userId -> FullProfileActivity.open(it, userId) }, RxErrorHandler.handleEmptyError()).notNull { compositeSubscription.add(it) }
|
||||
}
|
||||
adapter?.getUserClickedEvents()?.subscribe(Consumer { userId -> FullProfileActivity.open(userId) }, RxErrorHandler.handleEmptyError()).notNull { compositeSubscription.add(it) }
|
||||
recyclerView?.adapter = adapter
|
||||
recyclerView?.itemAnimator = SafeDefaultItemAnimator()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue