mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 20:29:02 +00:00
fix formatting
This commit is contained in:
parent
8dc433e7bf
commit
6d18238df5
22 changed files with 68 additions and 113 deletions
5
Habitica/res/drawable/bottom_sheet_title.xml
Normal file
5
Habitica/res/drawable/bottom_sheet_title.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/window_background" />
|
||||
</shape>
|
||||
|
|
@ -5,7 +5,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/BottomMenu"
|
||||
android:clickable="false">
|
||||
android:clickable="false"
|
||||
android:background="@drawable/rounded_avatar_bg">
|
||||
<TextView
|
||||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -13,7 +14,7 @@
|
|||
tools:text="Title"
|
||||
android:gravity="center"
|
||||
style="@style/Subheader1"
|
||||
android:background="@color/window_background"
|
||||
android:background="@drawable/bottom_sheet_title"
|
||||
android:padding="8dp"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/menu_items"
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import kotlin.reflect.KMutableProperty1
|
|||
import kotlin.reflect.full.starProjectedType
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
open class HabiticaTestCase: TestCase() {
|
||||
open class HabiticaTestCase : TestCase() {
|
||||
val gson = GSonFactoryCreator.createGson()
|
||||
|
||||
val apiClient: ApiClient = mockk(relaxed = true)
|
||||
|
|
@ -107,7 +107,7 @@ open class HabiticaTestCase: TestCase() {
|
|||
}
|
||||
|
||||
internal fun <T> loadJsonFile(s: String, type: Type): T {
|
||||
val userStream = javaClass.classLoader?.getResourceAsStream("${s}.json")
|
||||
val userStream = javaClass.classLoader?.getResourceAsStream("$s.json")
|
||||
return gson.fromJson(gson.newJsonReader(InputStreamReader(userStream)), type)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import io.reactivex.rxjava3.core.Flowable
|
|||
import org.hamcrest.Description
|
||||
import org.hamcrest.TypeSafeMatcher
|
||||
|
||||
|
||||
class Capture<T : View>(val klass: Class<T>) : TypeSafeMatcher<View>(View::class.java) {
|
||||
|
||||
companion object {
|
||||
|
|
@ -105,7 +104,6 @@ class Capture<T : View>(val klass: Class<T>) : TypeSafeMatcher<View>(View::class
|
|||
var view: T? = null
|
||||
|
||||
override fun describeTo(desc: Description) {
|
||||
|
||||
}
|
||||
|
||||
override fun matchesSafely(v: View): Boolean {
|
||||
|
|
@ -115,4 +113,4 @@ class Capture<T : View>(val klass: Class<T>) : TypeSafeMatcher<View>(View::class
|
|||
this.view = v as T
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,4 @@ package com.habitrpg.android.habitica.ui.activities
|
|||
|
||||
import com.habitrpg.android.habitica.HabiticaTestCase
|
||||
|
||||
open class ActivityTestCase: HabiticaTestCase() {
|
||||
}
|
||||
open class ActivityTestCase : HabiticaTestCase()
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ class MainActivityTest : ActivityTestCase() {
|
|||
screen.pressBack()
|
||||
screen.pressBack()
|
||||
KButton { withText("Discard") }.click()
|
||||
KView { withId(R.id.dailies_tab)}.click()
|
||||
KView { withId(R.id.dailies_tab) }.click()
|
||||
KView { withId(R.id.add_button) }.click()
|
||||
KView { withText("Create Daily") }.isVisible()
|
||||
screen.pressBack()
|
||||
screen.pressBack()
|
||||
KView { withId(R.id.todos_tab)}.click()
|
||||
KView { withId(R.id.todos_tab) }.click()
|
||||
KView { withId(R.id.add_button) }.click()
|
||||
KView { withText("Create To Do") }.isVisible()
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ class MainActivityTest : ActivityTestCase() {
|
|||
KView { withId(R.id.action_filter) }.click()
|
||||
KView { withText(R.string.filters) }.isVisible()
|
||||
screen.pressBack()
|
||||
KView { withText(R.string.filters)}.doesNotExist()
|
||||
KView { withText(R.string.filters) }.doesNotExist()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,11 +38,10 @@ import org.junit.runner.RunWith
|
|||
import java.util.Date
|
||||
import java.util.UUID
|
||||
|
||||
|
||||
class TaskFormScreen : Screen<TaskFormScreen>() {
|
||||
val toolbar = KToolbar { withId(R.id.toolbar) }
|
||||
val textEditText = KEditText { withId(R.id.text_edit_text)}
|
||||
val notesEditText = KEditText { withId(R.id.notes_edit_text)}
|
||||
val textEditText = KEditText { withId(R.id.text_edit_text) }
|
||||
val notesEditText = KEditText { withId(R.id.notes_edit_text) }
|
||||
val taskDifficultyButtons = KView { withId(R.id.task_difficulty_buttons) }
|
||||
val tagsWrapper = KView { withId(R.id.tags_wrapper) }
|
||||
}
|
||||
|
|
@ -162,7 +161,7 @@ class TaskFormActivityTest : ActivityTestCase() {
|
|||
screen {
|
||||
device.activities.isCurrent(TaskFormActivity::class.java)
|
||||
textEditText.typeText("New Habit")
|
||||
KButton { withId(R.id.action_save)}.click()
|
||||
KButton { withId(R.id.action_save) }.click()
|
||||
verify(exactly = 1) { taskRepository.createTaskInBackground(any()) }
|
||||
}
|
||||
}
|
||||
|
|
@ -208,8 +207,8 @@ class TaskFormActivityTest : ActivityTestCase() {
|
|||
scenario = launchActivity(intent)
|
||||
screen {
|
||||
device.activities.isCurrent(TaskFormActivity::class.java)
|
||||
KButton { withId(R.id.action_delete)}.click()
|
||||
KButton { withText(R.string.delete_task) }.click()
|
||||
KButton { withId(R.id.action_delete) }.click()
|
||||
KButton { withText(R.string.delete_task) }.click()
|
||||
verify(exactly = 1) { taskRepository.deleteTask(task.id!!) }
|
||||
}
|
||||
}
|
||||
|
|
@ -295,8 +294,8 @@ class TaskFormActivityTest : ActivityTestCase() {
|
|||
intent.putExtras(bundle)
|
||||
scenario = launchActivity(intent)
|
||||
screen {
|
||||
KView { withId(R.id.start_date_wrapper)}.click()
|
||||
KDatePickerDialog() perform {
|
||||
KView { withId(R.id.start_date_wrapper) }.click()
|
||||
KDatePickerDialog() perform {
|
||||
datePicker.setDate(2021, 10, 2)
|
||||
okButton.click()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ class NavigationDrawerScreen : Screen<NavigationDrawerScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionHeaderItem)
|
||||
itemType(::MainItem)
|
||||
})
|
||||
itemType(::SectionHeaderItem)
|
||||
itemType(::MainItem)
|
||||
})
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
|
|
@ -60,4 +60,4 @@ internal class NavigationDrawerFragmentTest : FragmentTestCase<NavigationDrawerF
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,21 +24,22 @@ import org.junit.Test
|
|||
private val KTextView.text: CharSequence?
|
||||
get() {
|
||||
var string: CharSequence? = null
|
||||
(this.view.perform(object : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return isA(TextView::class.java)
|
||||
}
|
||||
(
|
||||
this.view.perform(object : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return isA(TextView::class.java)
|
||||
}
|
||||
|
||||
override fun getDescription(): String {
|
||||
return "getting text from a TextView";
|
||||
}
|
||||
override fun getDescription(): String {
|
||||
return "getting text from a TextView"
|
||||
}
|
||||
|
||||
override fun perform(uiController: UiController?, view: View?) {
|
||||
val tv = view as TextView
|
||||
string = tv.text
|
||||
}
|
||||
|
||||
}))
|
||||
override fun perform(uiController: UiController?, view: View?) {
|
||||
val tv = view as TextView
|
||||
string = tv.text
|
||||
}
|
||||
})
|
||||
)
|
||||
return string
|
||||
}
|
||||
|
||||
|
|
@ -51,8 +52,8 @@ class ItemScreen : Screen<ItemScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::ItemItem)
|
||||
})
|
||||
itemType(::ItemItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class ItemRecyclerFragmentTest : FragmentTestCase<ItemRecyclerFragment, FragmentRecyclerviewBinding, ItemScreen>(false) {
|
||||
|
|
@ -91,7 +92,7 @@ internal class ItemRecyclerFragmentTest : FragmentTestCase<ItemRecyclerFragment,
|
|||
fun doesNotHaveDuplicates() {
|
||||
clearMocks(inventoryRepository)
|
||||
every { inventoryRepository.getOwnedItems("food") } answers {
|
||||
var items = user.items?.food!!.filter { it.numberOwned > 0 }
|
||||
var items = user.items?.food!!.filter { it.numberOwned > 0 }
|
||||
items = (items + items).sortedBy { it.key }
|
||||
Flowable.just(items)
|
||||
}
|
||||
|
|
@ -110,4 +111,4 @@ internal class ItemRecyclerFragmentTest : FragmentTestCase<ItemRecyclerFragment,
|
|||
}
|
||||
assert(foundItems.distinct().size == foundItems.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ class PetDetailScreen : Screen<PetDetailScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class PetDetailRecyclerFragmentTest : FragmentTestCase<PetDetailRecyclerFragment, FragmentRecyclerviewBinding, PetDetailScreen>(false) {
|
||||
|
|
@ -34,4 +34,4 @@ internal class PetDetailRecyclerFragmentTest : FragmentTestCase<PetDetailRecycle
|
|||
}
|
||||
|
||||
override val screen = PetDetailScreen()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ class StableScreen : Screen<StableScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class StableRecyclerFragmentTest : FragmentTestCase<StableRecyclerFragment, FragmentRecyclerviewBinding, StableScreen>(false) {
|
||||
|
|
@ -145,4 +145,4 @@ internal class StableRecyclerFragmentTest : FragmentTestCase<StableRecyclerFragm
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import io.reactivex.rxjava3.core.Flowable
|
|||
import org.hamcrest.Matcher
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
open class TaskItem(val parent: Matcher<View>) : KRecyclerItem<TaskItem>(parent) {
|
||||
val title = KTextView(parent) { withId(R.id.checkedTextView) }
|
||||
val notes = KTextView(parent) { withId(R.id.notesTextView) }
|
||||
|
|
@ -31,8 +30,8 @@ class TaskListScreen : Screen<TaskListScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::TaskItem)
|
||||
})
|
||||
itemType(::TaskItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class TaskRecyclerViewFragmentTest : FragmentTestCase<TaskRecyclerViewFragment, FragmentRefreshRecyclerviewBinding, TaskListScreen>(false) {
|
||||
|
|
@ -219,7 +218,6 @@ internal class TaskRecyclerViewFragmentTest : FragmentTestCase<TaskRecyclerViewF
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun completeDaily() {
|
||||
val dailies = tasks.filter { it.type == TaskType.DAILY }
|
||||
|
|
@ -263,4 +261,4 @@ internal class TaskRecyclerViewFragmentTest : FragmentTestCase<TaskRecyclerViewF
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,12 @@ open class TutorialStep : RealmObject(), BaseMainObject {
|
|||
|
||||
val shouldDisplay: Boolean
|
||||
get() {
|
||||
return !this.wasCompleted && (this.displayedOn == null || Date().time - (displayedOn?.time
|
||||
?: 0) > 86400000)
|
||||
return !this.wasCompleted && (
|
||||
this.displayedOn == null || Date().time - (
|
||||
displayedOn?.time
|
||||
?: 0
|
||||
) > 86400000
|
||||
)
|
||||
}
|
||||
override val realmClass: Class<out RealmModel>
|
||||
get() = TutorialStep::class.java
|
||||
|
|
@ -35,5 +39,5 @@ open class TutorialStep : RealmObject(), BaseMainObject {
|
|||
get() = "key"
|
||||
|
||||
val flagPath: String
|
||||
get() = "flags.tutorial.$tutorialGroup.$identifier"
|
||||
get() = "flags.tutorial.$tutorialGroup.$identifier"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class AvatarWithBarsViewModel(private val context: Context, private val binding:
|
|||
if (!stats.isBuffed) {
|
||||
binding.buffImageView.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
if (user is User) {
|
||||
binding.currencyView.gold = stats.gp ?: 0.0
|
||||
binding.currencyView.hourglasses = user.hourglassCount.toDouble()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.habitrpg.android.habitica.ui.adapter.inventory
|
|||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
|
@ -168,7 +167,7 @@ class ItemRecyclerAdapter(val context: Context, val user: User?) : BaseRecyclerV
|
|||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.hatch_egg)))
|
||||
} else if (item is QuestContent) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.details)))
|
||||
if (user?.hasParty == true){
|
||||
if (user?.hasParty == true) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.invite_party)))
|
||||
} else {
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.create_new_party)))
|
||||
|
|
@ -201,7 +200,6 @@ class ItemRecyclerAdapter(val context: Context, val user: User?) : BaseRecyclerV
|
|||
} else {
|
||||
createNewPartySubject.onNext(true)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
is SpecialItem ->
|
||||
|
|
|
|||
|
|
@ -233,7 +233,6 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
this.ownedTextView.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
}
|
||||
|
||||
|
||||
itemView.contentDescription = "${titleView.text} ${ownedTextView.text}"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ abstract class BaseDialogFragment<VB : ViewBinding> : DialogFragment() {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
Consumer { step ->
|
||||
if (step.isValid && step.isManaged && step.shouldDisplay()) {
|
||||
if (step.isValid && step.isManaged && step.shouldDisplay) {
|
||||
val mainActivity = activity as? MainActivity ?: return@Consumer
|
||||
mainActivity.displayTutorialStep(step, tutorialTexts, tutorialCanBeDeferred)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ abstract class BaseFragment<VB : ViewBinding> : Fragment() {
|
|||
.firstElement()
|
||||
.delay(1, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ step ->
|
||||
.subscribe(
|
||||
{ step ->
|
||||
if (step.isValid && step.isManaged && step.shouldDisplay) {
|
||||
val mainActivity = activity as? MainActivity ?: return@subscribe
|
||||
mainActivity.displayTutorialStep(step, tutorialTexts, tutorialCanBeDeferred)
|
||||
|
|
|
|||
|
|
@ -247,7 +247,6 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
},
|
||||
RxErrorHandler.handleEmptyError()
|
||||
)
|
||||
|
||||
}
|
||||
alert?.addButton(R.string.close, false) { _, _ ->
|
||||
alert.dismiss()
|
||||
|
|
@ -290,7 +289,6 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
compositeSubscription.add(inventoryRepository.getPets().subscribe({ adapter?.setExistingPets(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ class TasksFragment : BaseMainFragment<FragmentViewpagerBinding>(), SearchView.O
|
|||
else -> TaskType.HABIT
|
||||
}
|
||||
val tab = bottomNavigation?.tabWithId(id)
|
||||
if (step.shouldDisplay()) {
|
||||
if (step.shouldDisplay) {
|
||||
tab?.badgeCount = 1
|
||||
activeTutorialFragments.add(taskType)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -290,49 +290,6 @@ class TeamBoardFragment : BaseMainFragment<FragmentViewpagerBinding>(), SearchVi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateBottomBarBadges() {
|
||||
if (bottomNavigation == null) {
|
||||
return
|
||||
}
|
||||
compositeSubscription.add(
|
||||
tutorialRepository.getTutorialSteps(listOf("habits", "dailies", "todos", "rewards")).subscribe(
|
||||
{ tutorialSteps ->
|
||||
val activeTutorialFragments = ArrayList<TaskType>()
|
||||
for (step in tutorialSteps) {
|
||||
var id = -1
|
||||
val taskType = when (step.identifier) {
|
||||
"habits" -> {
|
||||
id = R.id.habits_tab
|
||||
TaskType.HABIT
|
||||
}
|
||||
"dailies" -> {
|
||||
id = R.id.dailies_tab
|
||||
TaskType.DAILY
|
||||
}
|
||||
"todos" -> {
|
||||
id = R.id.todos_tab
|
||||
TaskType.TODO
|
||||
}
|
||||
"rewards" -> {
|
||||
id = R.id.rewards_tab
|
||||
TaskType.REWARD
|
||||
}
|
||||
else -> TaskType.HABIT
|
||||
}
|
||||
val tab = bottomNavigation?.tabWithId(id)
|
||||
if (step.shouldDisplay()) {
|
||||
tab?.badgeCount = 1
|
||||
activeTutorialFragments.add(taskType)
|
||||
} else {
|
||||
tab?.badgeCount = 0
|
||||
}
|
||||
}
|
||||
},
|
||||
RxErrorHandler.handleEmptyError()
|
||||
)
|
||||
)
|
||||
}
|
||||
// endregion
|
||||
|
||||
private fun openNewTaskActivity(type: TaskType) {
|
||||
|
|
@ -390,7 +347,6 @@ class TeamBoardFragment : BaseMainFragment<FragmentViewpagerBinding>(), SearchVi
|
|||
val index = indexForTaskType(taskType)
|
||||
if (binding?.viewPager != null && index != -1) {
|
||||
binding?.viewPager?.currentItem = index
|
||||
updateBottomBarBadges()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -424,7 +380,6 @@ class TeamBoardFragment : BaseMainFragment<FragmentViewpagerBinding>(), SearchVi
|
|||
else -> 0
|
||||
}
|
||||
binding?.viewPager?.setCurrentItem(newItem, smooth)
|
||||
updateBottomBarBadges()
|
||||
}
|
||||
|
||||
override fun onAdd(taskType: TaskType) {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ class ChatRecyclerMessageViewHolder(itemView: View, private var userId: String,
|
|||
itemView.setPadding(16.dpToPx(context), itemView.paddingTop, itemView.paddingRight, itemView.paddingBottom)
|
||||
}
|
||||
|
||||
|
||||
binding.messageText.setParsedMarkdown(chatMessage?.parsedText)
|
||||
if (msg.parsedText == null) {
|
||||
binding.messageText.text = chatMessage?.text
|
||||
|
|
|
|||
Loading…
Reference in a new issue