Fix various issues

This commit is contained in:
Phillip Thelen 2018-11-09 16:35:06 +01:00
parent c5bb9211d2
commit e4b58d9cb7
47 changed files with 270 additions and 54 deletions

View file

@ -131,6 +131,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.0.1'
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
kapt "androidx.lifecycle:lifecycle-compiler:2.0.0"
implementation 'com.plattysoft.leonids:LeonidsLib:1.3.2'
}
android {
@ -145,7 +146,7 @@ android {
buildConfigField "String", "STORE", "\"google\""
multiDexEnabled true
versionCode 2024
versionCode 2027
versionName "1.6"
}

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="@color/scrollbarThumb"
android:scrollbars="vertical">
@ -11,7 +11,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Space
android:id="@+id/anchor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="72dp"
android:layout_height="72dp"
@ -115,7 +118,8 @@
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="30sp"
android:textSize="@dimen/abc_text_size_small_material" />
android:textSize="@dimen/abc_text_size_small_material"
tools:text="Version 1.0 (1)"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -835,4 +835,6 @@
<string name="display_name_length_error">Display names must be between 1 and 30 characters</string>
<string name="setup_task_join_habitica">Join Habitica (Check me off!)</string>
<string name="setup_task_join_habitica_notes">You can either complete this To-Do, edit it, or remove it.</string>
<string name="setup_task_reward">Reward yourself</string>
<string name="setup_task_reward_notes">Watch TV, play a game, eat a treat, its up to you!</string>
</resources>

View file

@ -152,6 +152,7 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
this.taskRepository.createTasks(it).subscribe(Consumer { onUserReceived(user) }, RxErrorHandler.handleEmptyError())
}
} else if (pager.currentItem == 0) {
confirmNames(welcomeFragment?.displayName ?: "", welcomeFragment?.username ?: "")
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager

View file

@ -31,7 +31,7 @@ import io.realm.OrderedRealmCollection
import io.realm.RealmRecyclerViewAdapter
import net.pherth.android.emoji_library.EmojiTextView
class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUpdate: Boolean, private val user: User?, private val isTavern: Boolean, private val releasedUsernames: Boolean) : RealmRecyclerViewAdapter<ChatMessage, RecyclerView.ViewHolder>(data, autoUpdate) {
class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUpdate: Boolean, internal var user: User?, private val isTavern: Boolean, private val releasedUsernames: Boolean) : RealmRecyclerViewAdapter<ChatMessage, RecyclerView.ViewHolder>(data, autoUpdate) {
private var uuid: String = ""
private var expandedMessageId: String? = null
@ -155,8 +155,8 @@ class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUp
setLikeProperties()
val name = user?.profile?.name
if (messageWasSent() && user != null) {
userLabel.tier = user.contributor?.level ?: 0
if (messageWasSent()) {
userLabel.tier = user?.contributor?.level ?: 0
userLabel.username = name
} else {
userLabel.tier = msg.contributor?.level ?: 0

View file

@ -5,13 +5,21 @@ import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.net.toUri
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.notNull
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
import com.plattysoft.leonids.ParticleSystem
import kotlinx.android.synthetic.main.fragment_about.*
import android.view.animation.AccelerateInterpolator
class AboutFragment : Fragment() {
@ -19,6 +27,8 @@ class AboutFragment : Fragment() {
private val androidSourceCodeLink = "https://github.com/HabitRPG/habitrpg-android/"
private val twitterLink = "https://twitter.com/habitica"
private var versionNumberTappedCount = 0
private fun openGooglePlay() {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = "market://details?id=com.habitrpg.android.habitica".toUri()
@ -32,6 +42,28 @@ class AboutFragment : Fragment() {
return inflater.inflate(R.layout.fragment_about, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
versionInfo.setOnClickListener {
versionNumberTappedCount += 1
when (versionNumberTappedCount) {
1 -> context.notNull { context ->
Toast.makeText(context, "Oh! You tapped me!", Toast.LENGTH_SHORT).show()
}
in 4..7 -> context.notNull { context ->
Toast.makeText(context, "Only ${8 - versionNumberTappedCount} taps left!", Toast.LENGTH_SHORT).show()
}
8 -> {
context.notNull { context ->
Toast.makeText(context, "You were blessed with cats!", Toast.LENGTH_SHORT).show()
}
doTheThing()
}
}
}
}
private val versionName: String by lazy {
try {
@Suppress("DEPRECATION")
@ -84,4 +116,43 @@ class AboutFragment : Fragment() {
emailIntent.putExtra(Intent.EXTRA_TEXT, bodyOfEmail)
startActivity(Intent.createChooser(emailIntent, "Send email..."))
}
private fun doTheThing() {
DataBindingUtils.loadImage("Pet-Sabretooth-Base") {bitmap ->
activity?.runOnUiThread {
activity.notNull {
ParticleSystem(it, 50, bitmap, 3000)
.setAcceleration(0.00013f, 90)
.setSpeedByComponentsRange(-0.08f, 0.08f, 0.05f, 0.1f)
.setFadeOut(200, AccelerateInterpolator())
.setRotationSpeed(100f)
.emitWithGravity(anchor, Gravity.BOTTOM, 20, 10000)
}
}
}
DataBindingUtils.loadImage("Pet-Sabretooth-Golden") {bitmap ->
activity?.runOnUiThread {
activity.notNull {
ParticleSystem(it, 50, bitmap, 3000)
.setAcceleration(0.00013f, 90)
.setSpeedByComponentsRange(-0.08f, 0.08f, 0.05f, 0.1f)
.setFadeOut(200, AccelerateInterpolator())
.setRotationSpeed(100f)
.emitWithGravity(anchor, Gravity.BOTTOM, 20, 10000)
}
}
}
DataBindingUtils.loadImage("Pet-Sabretooth-Red") {bitmap ->
activity?.runOnUiThread {
activity.notNull {
ParticleSystem(it, 50, bitmap, 3000)
.setAcceleration(0.00013f, 90)
.setSpeedByComponentsRange(-0.08f, 0.08f, 0.05f, 0.1f)
.setFadeOut(200, AccelerateInterpolator())
.setRotationSpeed(100f)
.emitWithGravity(anchor, Gravity.BOTTOM, 20, 10000)
}
}
}
}
}

View file

@ -119,6 +119,7 @@ class TaskSetupFragment : BaseFragment() {
tasks.add(taskObject)
}
}
tasks.add(makeTaskObject(Task.TYPE_REWARD, getString(R.string.setup_task_reward), null, null, getString(R.string.setup_task_reward_notes)))
tasks.add(makeTaskObject(Task.TYPE_TODO, getString(R.string.setup_task_join_habitica), null, null, getString(R.string.setup_task_join_habitica_notes)))
return tasks
}

View file

@ -6,10 +6,13 @@ import android.content.ClipboardManager
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.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.core.net.toUri
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.habitrpg.android.habitica.R
@ -38,46 +41,38 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
@SuppressLint("ValidFragment")
class ChatFragment(private var viewModel: PartyViewModel) : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
class ChatFragment constructor(private val viewModel: PartyViewModel) : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
@Inject
lateinit var configManager: RemoteConfigManager
private var isTavern: Boolean = false
internal var layoutManager: LinearLayoutManager? = null
internal var groupId: String? = null
private var user: User? = null
private var userId: String? = null
private var chatAdapter: ChatRecyclerViewAdapter? = null
private var navigatedOnceToFragment = false
private var isScrolledToTop = true
private var refreshDisposable: Disposable? = null
fun configure(groupId: String, user: User?, isTavern: Boolean) {
this.groupId = groupId
this.user = user
if (this.user != null) {
this.userId = this.user?.id
}
this.isTavern = isTavern
}
override fun injectFragment(component: AppComponent) {
component.inject(this)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
return inflater.inflate(R.layout.fragment_chat, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
refreshLayout.setOnRefreshListener(this)
layoutManager = recyclerView.layoutManager as? androidx.recyclerview.widget.LinearLayoutManager
layoutManager = recyclerView.layoutManager as? LinearLayoutManager
if (layoutManager == null) {
layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
layoutManager = LinearLayoutManager(context)
recyclerView.layoutManager = layoutManager
}
chatAdapter = ChatRecyclerViewAdapter(null, true, user, true, configManager.enableUsernameRelease())
chatAdapter = ChatRecyclerViewAdapter(null, true, null, true, configManager.enableUsernameRelease())
chatAdapter.notNull {adapter ->
compositeSubscription.add(adapter.getUserLabelClickFlowable().subscribe(Consumer { userId ->
context.notNull { FullProfileActivity.open(it, userId) }
@ -97,16 +92,21 @@ class ChatFragment(private var viewModel: PartyViewModel) : BaseFragment(), Swip
compositeSubscription.add(viewModel.getChatMessages().firstElement().subscribe(Consumer<RealmResults<ChatMessage>> { this.setChatMessages(it) }, RxErrorHandler.handleEmptyError()))
if (user?.flags?.isCommunityGuidelinesAccepted == true) {
communityGuidelinesView.visibility = View.GONE
} else {
communityGuidelinesView.setOnClickListener { _ ->
val i = Intent(Intent.ACTION_VIEW)
i.data = "https://habitica.com/static/community-guidelines".toUri()
context?.startActivity(i)
viewModel.updateUser(user, "flags.communityGuidelinesAccepted", true)
viewModel.getUserData().observe(viewLifecycleOwner, Observer {
chatAdapter?.user = it
if (it?.flags?.isCommunityGuidelinesAccepted == true) {
communityGuidelinesView.visibility = View.GONE
} else {
communityGuidelinesView.setOnClickListener { _ ->
val i = Intent(Intent.ACTION_VIEW)
i.data = "https://habitica.com/static/community-guidelines".toUri()
context?.startActivity(i)
viewModel.updateUser("flags.communityGuidelinesAccepted", true)
}
}
}
})
recyclerView.addOnScrollListener(object : androidx.recyclerview.widget.RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: androidx.recyclerview.widget.RecyclerView, dx: Int, dy: Int) {
@ -225,13 +225,6 @@ class ChatFragment(private var viewModel: PartyViewModel) : BaseFragment(), Swip
}
}
override fun onSaveInstanceState(outState: Bundle) {
outState.putString("userId", this.userId)
outState.putString("groupId", this.groupId)
outState.putBoolean("isTavern", this.isTavern)
super.onSaveInstanceState(outState)
}
private fun setChatMessages(chatMessages: RealmResults<ChatMessage>) {
chatAdapter?.updateData(chatMessages)
recyclerView.scrollToPosition(0)

View file

@ -97,8 +97,6 @@ class PartyFragment : BaseMainFragment() {
partyMemberListFragment?.setPartyId(group.id)
chatFragment?.groupId = group.id
this.activity?.invalidateOptionsMenu()
}
@ -204,12 +202,9 @@ class PartyFragment : BaseMainFragment() {
viewPagerAdapter = object : FragmentPagerAdapter(fragmentManager) {
override fun getItem(position: Int): androidx.fragment.app.Fragment? {
val fragment: androidx.fragment.app.Fragment?
when (position) {
return when (position) {
0 -> {
fragment = if (user?.hasParty() == true) {
if (user?.hasParty() == true) {
val detailFragment = PartyDetailFragment(viewModel)
detailFragment
} else {
@ -220,7 +215,7 @@ class PartyFragment : BaseMainFragment() {
if (chatFragment == null) {
chatFragment = ChatFragment(viewModel)
}
fragment = chatFragment
chatFragment
}
2 -> {
if (partyMemberListFragment == null) {
@ -229,12 +224,11 @@ class PartyFragment : BaseMainFragment() {
partyMemberListFragment?.setPartyId(user?.party?.id ?: "")
}
}
fragment = partyMemberListFragment
partyMemberListFragment
}
else -> fragment = Fragment()
else -> Fragment()
}
return fragment
}
override fun getCount(): Int {

View file

@ -49,7 +49,7 @@ abstract class BaseViewModel: ViewModel() {
disposable.add(userRepository.getUser().observeOn(AndroidSchedulers.mainThread()).subscribe(Consumer { user.value = it }, RxErrorHandler.handleEmptyError()))
}
fun updateUser(user: User?, path: String, value: Any) {
disposable.add(userRepository.updateUser(user, path, value).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
fun updateUser(path: String, value: Any) {
disposable.add(userRepository.updateUser(getUserData().value, path, value).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
}
}

View file

@ -1 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,3 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.

View file

@ -0,0 +1,6 @@
This update fixes various bugs and adds support for an upcoming feature.
This update also reworks a lot of the internals for the party view, to make it more reliable. Please report any new oddities on that screen.
NEW:
- Add Cat support (Can you find it?)