Fix a bunch of warnings

This commit is contained in:
Phillip Thelen 2022-06-30 12:14:31 +02:00
parent d2ef3af490
commit 3a8043e786
64 changed files with 143 additions and 265 deletions

View file

@ -41,7 +41,7 @@
android:src="@drawable/adventure_guide_art" />
<TextView
style="@style/Subheader1"
style="@style/SubHeader1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"

View file

@ -180,7 +180,7 @@
android:layout_height="43dp"
android:textColor="@color/white"
android:gravity="center"
style="@style/Subheader1"
style="@style/SubHeader1"
android:background="@drawable/layout_rounded_bg_yellow_10"
tools:text="Becoma a Healer"/>
</LinearLayout>

View file

@ -103,7 +103,7 @@
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/joined"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
<TextView
android:id="@+id/joined_view"
android:layout_width="wrap_content"
@ -120,7 +120,7 @@
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/last_login"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
<TextView
android:id="@+id/last_login_view"
android:layout_width="wrap_content"
@ -136,7 +136,7 @@
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/total_checkins"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
<TextView
android:id="@+id/total_checkins_view"
android:layout_width="wrap_content"

View file

@ -19,7 +19,7 @@
android:layout_height="wrap_content"
android:textColor="@color/text_primary"
android:text="@string/armoire_rate_equipment_title"
style="@style/Subheader1" />
style="@style/SubHeader1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:textColor="@color/text_primary"
android:text="@string/armoire_rate_food_title"
style="@style/Subheader1" />
style="@style/SubHeader1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -49,7 +49,7 @@
android:layout_height="wrap_content"
android:textColor="@color/text_primary"
android:text="@string/armoire_rate_experience_title"
style="@style/Subheader1" />
style="@style/SubHeader1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -33,7 +33,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/Subheader1"
style="@style/SubHeader1"
tools:text="4 Gems"
android:gravity="center"/>
<Button

View file

@ -35,7 +35,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/levelup_title_10"
style="@style/Subheader1"
style="@style/SubHeader1"
android:gravity="center_horizontal"
android:textColor="@color/text_primary"
android:layout_marginBottom="@dimen/spacing_medium"/>

View file

@ -14,13 +14,13 @@
android:layout_height="wrap_content"
android:text="@string/reward_dialog_buy"
android:textColor="@color/brand_300"
style="@style/Subheader1" />
style="@style/SubHeader1" />
<com.habitrpg.common.habitica.views.CurrencyView
android:id="@+id/priceLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="10"
tools:textColor="@color/green_10"
style="@style/Subheader1"
style="@style/SubHeader1"
android:layout_marginStart="12dp"/>
</LinearLayout>

View file

@ -14,7 +14,7 @@
android:layout_marginBottom="@dimen/spacing_large">
<TextView
style="@style/Subheader1"
style="@style/SubHeader1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/filters"

View file

@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:text="@string/pms_disabled"
android:gravity="center"
style="@style/Subheader1"
style="@style/SubHeader1"
android:textColor="@color/text_primary"
android:layout_marginBottom="4dp"/>
<TextView

View file

@ -65,7 +65,7 @@
android:id="@+id/promo_banner_duration_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
@ -91,7 +91,7 @@
android:id="@+id/prompt_button"
android:layout_width="match_parent"
android:layout_height="38dp"
style="@style/Subheader1"
style="@style/SubHeader1"
android:gravity="center" />
<TextView

View file

@ -62,7 +62,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
style="@style/Subheader1"
style="@style/SubHeader1"
android:textColor="@color/white"
android:layout_marginStart="84dp"
android:layout_marginEnd="84dp"
@ -111,7 +111,7 @@
android:layout_height="wrap_content"
android:text="@string/subscribe_prompt"
android:gravity="center"
style="@style/Subheader1"
style="@style/SubHeader1"
app:dayTextColor="@color/text_brand"
app:nightTextColor="@color/gray_400"
android:lineSpacingExtra="4dp"
@ -316,7 +316,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
style="@style/Subheader1"
style="@style/SubHeader1"
android:textColor="@color/text_brand"
android:text="@string/subscribe_options_title"
android:layout_marginBottom="20dp"/>

View file

@ -60,7 +60,7 @@
android:textColor="@color/white"
android:elevation="4dp"
android:textAllCaps="false"
style="@style/Subheader1"
style="@style/SubHeader1"
/>
</LinearLayout>
<LinearLayout
@ -110,7 +110,7 @@
android:textColor="@color/white"
android:elevation="4dp"
android:textAllCaps="false"
style="@style/Subheader1"
style="@style/SubHeader1"
/>
</LinearLayout>
<LinearLayout
@ -159,7 +159,7 @@
android:background="@drawable/support_info_lower_bg"
android:elevation="4dp"
android:textColor="@color/white"
style="@style/Subheader1"
style="@style/SubHeader1"
/>
</LinearLayout>
</LinearLayout>

View file

@ -12,7 +12,7 @@
<TextView
android:id="@+id/nameTextView"
style="@style/Subheader1"
style="@style/SubHeader1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View file

@ -19,5 +19,5 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
</LinearLayout>

View file

@ -11,7 +11,7 @@
android:layout_height="wrap_content"
tools:text="Title"
android:gravity="center"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
<com.habitrpg.common.habitica.views.PixelArtView
android:id="@+id/icon_view"
android:layout_width="@dimen/shopitem_image_size"

View file

@ -60,7 +60,7 @@
android:background="@drawable/purchase_button_background"
android:textColor="@color/brand_400"
android:gravity="center"
style="@style/Subheader1"
style="@style/SubHeader1"
android:letterSpacing="0.02"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"

View file

@ -40,7 +40,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Spell Name"
style="@style/Subheader1"/>
style="@style/SubHeader1"/>
<TextView
android:id="@+id/skill_notes"

View file

@ -27,7 +27,7 @@
<com.habitrpg.android.habitica.ui.views.Typewriter
android:id="@+id/textView"
style="@style/Subheader1"
style="@style/SubHeader1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="@string/welcome_text" />

View file

@ -35,7 +35,7 @@
</style>
<!-- Subheader -->
<style name="Subheader1">
<style name="SubHeader1">
<item name="android:fontFamily">@string/font_family_medium</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">?textColorSecondary</item>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
<color name="watch_white">#ffffff</color>
<color name="watch_black">#000000</color>
<color name="brand_50">#36205D</color>
<color name="brand_100">#432874</color>

View file

@ -80,21 +80,21 @@ class ApiClient @Inject constructor(
if (request.header("Cache-Control")?.isNotBlank() == true) {
return@addInterceptor chain.proceed(request)
}
var cacheContol = CacheControl.Builder()
cacheContol = if (request.method == "GET") {
var cacheControl = CacheControl.Builder()
cacheControl = if (request.method == "GET") {
if (hasNetwork(context)) {
cacheContol.maxAge(5, TimeUnit.MINUTES)
cacheControl.maxAge(5, TimeUnit.MINUTES)
} else {
cacheContol.maxAge(1, TimeUnit.DAYS)
cacheControl.maxAge(1, TimeUnit.DAYS)
.onlyIfCached()
}
} else {
cacheContol.noCache()
cacheControl.noCache()
.noStore()
}
chain.proceed(request.newBuilder().header(
"Cache-Control",
cacheContol.build().toString()
cacheControl.build().toString()
).build())
}
.addNetworkInterceptor { chain ->

View file

@ -14,12 +14,6 @@ open class ChecklistItem constructor(
var position: Int = 0
constructor(item: ChecklistItem) : this() {
this.text = item.text
this.id = item.id
this.completed = item.completed
}
override fun describeContents(): Int {
return 0
}

View file

@ -3,13 +3,6 @@ package com.habitrpg.wearos.habitica.models.tasks
import android.os.Parcel
import android.os.Parcelable
import com.squareup.moshi.JsonClass
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatterBuilder
import java.time.temporal.TemporalAccessor
@JsonClass(generateAdapter = true)
open class RemindersItem constructor() : Parcelable {
@ -51,44 +44,4 @@ open class RemindersItem constructor() : Parcelable {
override fun hashCode(): Int {
return id?.hashCode() ?: 0
}
fun getZonedDateTime(): ZonedDateTime? {
val formatter: DateTimeFormatter =
DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE)
.appendPattern("['T'][' ']")
.append(DateTimeFormatter.ISO_LOCAL_TIME)
.appendPattern("[XX]")
.toFormatter()
val parsed: TemporalAccessor = formatter.parseBest(
time,
ZonedDateTime::from, LocalDateTime::from
)
return if (parsed is ZonedDateTime) {
parsed
} else {
val defaultZone: ZoneId = ZoneId.of("UTC")
(parsed as LocalDateTime).atZone(defaultZone)
}
}
fun getLocalZonedDateTimeInstant(): Instant? {
val formatter: DateTimeFormatter =
DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE)
.appendPattern("['T'][' ']")
.append(DateTimeFormatter.ISO_LOCAL_TIME)
.appendPattern("[XX]")
.toFormatter()
val parsed: TemporalAccessor = formatter.parseBest(
time,
ZonedDateTime::from, LocalDateTime::from
)
return if (parsed is ZonedDateTime) {
parsed.withZoneSameLocal(ZoneId.systemDefault())?.toInstant()
} else {
val defaultZone: ZoneId = ZoneId.of("UTC")
(parsed as LocalDateTime).atZone(defaultZone).withZoneSameLocal(ZoneId.systemDefault())?.toInstant()
}
}
}

View file

@ -4,7 +4,6 @@ import android.os.Parcel
import android.os.Parcelable
import android.text.Spanned
import com.habitrpg.android.habitica.R
import com.habitrpg.common.habitica.helpers.MarkdownParser
import com.habitrpg.common.habitica.models.tasks.Attribute
import com.habitrpg.common.habitica.models.tasks.Frequency
import com.habitrpg.common.habitica.models.tasks.TaskType
@ -149,9 +148,6 @@ open class Task constructor(): Parcelable {
val isDisplayedActive: Boolean
get() = ((isDue == true && type == TaskType.DAILY) || type == TaskType.TODO) && !completed
val isChecklistDisplayActive: Boolean
get() = this.checklist?.size != this.completedChecklistCount
fun getNextReminderOccurence(oldTime: String?): ZonedDateTime? {
if (oldTime == null) {
return null
@ -191,39 +187,6 @@ open class Task constructor(): Parcelable {
(parsed as LocalDateTime).atZone(defaultZone)
}
}
fun parseMarkdown() {
parsedText = MarkdownParser.parseMarkdown(text)
parsedNotes = MarkdownParser.parseMarkdown(notes)
}
fun markdownText(callback: (CharSequence) -> Unit): CharSequence {
if (this.parsedText != null) {
return this.parsedText ?: ""
}
MarkdownParser.parseMarkdownAsync(this.text) { parsedText ->
this.parsedText = parsedText
callback(parsedText)
}
return this.text
}
fun markdownNotes(callback: (CharSequence) -> Unit): CharSequence? {
if (parsedNotes != null) {
return parsedNotes
}
if (notes?.isNotEmpty() == true) {
MarkdownParser.parseMarkdownAsync(notes) { parsedText ->
parsedNotes = parsedText
callback(parsedText)
}
}
return notes
}
override fun equals(other: Any?): Boolean {
if (other == null) {
return false
@ -245,30 +208,36 @@ open class Task constructor(): Parcelable {
priority != task.priority -> return true
attribute != task.attribute && attribute != null -> return true
}
if (type == TaskType.HABIT) {
return when {
up != task.up -> true
down != task.down -> true
frequency != task.frequency -> true
counterUp != task.counterUp -> true
counterDown != task.counterDown -> true
else -> false
when (type) {
TaskType.HABIT -> {
return when {
up != task.up -> true
down != task.down -> true
frequency != task.frequency -> true
counterUp != task.counterUp -> true
counterDown != task.counterDown -> true
else -> false
}
}
} else if (type == TaskType.DAILY) {
return when {
startDate != task.startDate -> true
everyX != task.everyX -> true
frequency != task.frequency -> true
repeat != task.repeat -> true
streak != task.streak -> true
else -> false
TaskType.DAILY -> {
return when {
startDate != task.startDate -> true
everyX != task.everyX -> true
frequency != task.frequency -> true
repeat != task.repeat -> true
streak != task.streak -> true
else -> false
}
}
TaskType.TODO -> {
return dueDate != task.dueDate
}
TaskType.REWARD -> {
return value != task.value
}
else -> {
return false
}
} else if (type == TaskType.TODO) {
return dueDate != task.dueDate
} else if (type == TaskType.REWARD) {
return value != task.value
} else {
return false
}
}

View file

@ -9,10 +9,10 @@ import com.habitrpg.common.habitica.helpers.AppTestingLevel
import com.habitrpg.common.habitica.helpers.KeyHelper
import com.habitrpg.shared.habitica.HLogger
import com.habitrpg.wearos.habitica.data.ApiClient
import com.habitrpg.wearos.habitica.data.AttributeAdapter
import com.habitrpg.wearos.habitica.data.FrequencyAdapter
import com.habitrpg.wearos.habitica.data.TaskTypeAdapter
import com.habitrpg.wearos.habitica.data.customDateAdapter
import com.habitrpg.wearos.habitica.util.AttributeAdapter
import com.habitrpg.wearos.habitica.util.FrequencyAdapter
import com.habitrpg.wearos.habitica.util.TaskTypeAdapter
import com.habitrpg.wearos.habitica.util.customDateAdapter
import com.habitrpg.wearos.habitica.models.tasks.WrappedTasklistAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory

View file

@ -26,7 +26,7 @@ abstract class BaseActivity<B: ViewBinding, VM: BaseViewModel> : ComponentActivi
lateinit var loadingManager: LoadingManager
val messageClient: MessageClient by lazy { Wearable.getMessageClient(this) }
val capabilityClient: CapabilityClient by lazy { Wearable.getCapabilityClient(this) }
private val capabilityClient: CapabilityClient by lazy { Wearable.getCapabilityClient(this) }
companion object {
var currentActivityClassName: String? = null
}
@ -76,6 +76,7 @@ abstract class BaseActivity<B: ViewBinding, VM: BaseViewModel> : ComponentActivi
fun stopAnimatingProgress() {
if (progressView != null) {
progressView?.stopAnimation()
wrapperBinding.root.removeView(progressView)
progressView = null
} else {

View file

@ -7,12 +7,12 @@ import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import com.habitrpg.android.habitica.databinding.ActivityHabitDirectionBinding
import com.habitrpg.common.habitica.models.responses.TaskDirection
import com.habitrpg.wearos.habitica.ui.viewmodels.HabitDrectionViewModel
import com.habitrpg.wearos.habitica.ui.viewmodels.HabitDirectionViewModel
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class HabitDirectionActivity: BaseActivity<ActivityHabitDirectionBinding, HabitDrectionViewModel>() {
override val viewModel: HabitDrectionViewModel by viewModels()
class HabitDirectionActivity: BaseActivity<ActivityHabitDirectionBinding, HabitDirectionViewModel>() {
override val viewModel: HabitDirectionViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
binding = ActivityHabitDirectionBinding.inflate(layoutInflater)

View file

@ -114,11 +114,11 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
openSettingsActivity()
}
)
viewModel.user.observe(this) {
adapter.title = it.profile?.name ?: ""
viewModel.user.observe(this) { user ->
adapter.title = user.profile?.name ?: ""
adapter.notifyItemChanged(0)
val index = adapter.data.indexOfFirst { it.identifier == "stats" }
adapter.data[index].detailText = getString(R.string.user_level, it.stats?.lvl ?: 0)
adapter.data[index].detailText = getString(R.string.user_level, user.stats?.lvl ?: 0)
adapter.notifyItemChanged(index+1)
}
viewModel.taskCounts.observe(this) {

View file

@ -1,8 +1,9 @@
package com.habitrpg.wearos.habitica.ui.activities
import android.animation.ValueAnimator
import android.os.Bundle
import android.view.View.*
import android.view.View.GONE
import android.view.View.INVISIBLE
import android.view.View.VISIBLE
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import com.habitrpg.android.habitica.R
@ -11,10 +12,8 @@ import com.habitrpg.common.habitica.views.HabiticaIconsHelper
import com.habitrpg.wearos.habitica.models.user.Stats
import com.habitrpg.wearos.habitica.models.user.User
import com.habitrpg.wearos.habitica.ui.viewmodels.StatsViewModel
import com.habitrpg.wearos.habitica.ui.views.StatValue
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class StatsActivity : BaseActivity<ActivityStatsBinding, StatsViewModel>() {
override val viewModel: StatsViewModel by viewModels()

View file

@ -89,8 +89,8 @@ class TaskListActivity : BaseActivity<ActivityTasklistBinding, TaskListViewModel
?.let { TaskDirection.valueOf(it) }
?: TaskDirection.UP
taskToScore?.let {
viewModel.scoreTask(it, direction) {
taskToScore?.let { task ->
viewModel.scoreTask(task, direction) {
if (it != null) {
showTaskScoringResult(it)
}

View file

@ -8,7 +8,7 @@ import com.habitrpg.wearos.habitica.models.tasks.Task
import com.habitrpg.wearos.habitica.ui.viewHolders.HeaderSectionViewHolder
import com.habitrpg.wearos.habitica.ui.viewHolders.tasks.TaskViewHolder
open class TaskListAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
open class TaskListAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var title: String = ""
var onTaskScore: ((Task) -> Unit)? = null
var onTaskTapped:((Task) -> Unit)? = null

View file

@ -13,7 +13,7 @@ abstract class CheckedTaskViewHolder(itemView: View) : TaskViewHolder(itemView)
abstract val checkboxWrapper: ViewGroup
override fun bind(data: Task) {
checkboxWrapper.setOnClickListener { _ ->
checkboxWrapper.setOnClickListener {
onTaskScore?.invoke()
}
super.bind(data)

View file

@ -1,17 +1,11 @@
package com.habitrpg.wearos.habitica.ui.viewHolders.tasks
import android.view.View
import android.widget.TextView
import com.habitrpg.android.habitica.databinding.RowRewardBinding
import com.habitrpg.wearos.habitica.models.tasks.Task
import com.habitrpg.wearos.habitica.ui.views.TaskTextView
class RewardViewHolder(itemView: View) : TaskViewHolder(itemView) {
private val binding = RowRewardBinding.bind(itemView)
override val titleView: TaskTextView
get() = binding.title
override fun bind(data: Task) {
super.bind(data)
}
}

View file

@ -3,7 +3,6 @@ package com.habitrpg.wearos.habitica.ui.viewHolders.tasks
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.habitrpg.android.habitica.databinding.RowTodoBinding
import com.habitrpg.wearos.habitica.ui.views.TaskTextView

View file

@ -2,19 +2,15 @@ package com.habitrpg.wearos.habitica.ui.viewmodels
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import com.habitrpg.common.habitica.models.responses.TaskDirection
import com.habitrpg.common.habitica.models.responses.TaskScoringResult
import com.habitrpg.wearos.habitica.data.repositories.TaskRepository
import com.habitrpg.wearos.habitica.data.repositories.UserRepository
import com.habitrpg.wearos.habitica.managers.LoadingManager
import com.habitrpg.wearos.habitica.util.ExceptionHandlerBuilder
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
class HabitDrectionViewModel @Inject constructor(
class HabitDirectionViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
userRepository: UserRepository,
taskRepository: TaskRepository,
@ -24,11 +20,4 @@ class HabitDrectionViewModel @Inject constructor(
val task = taskRepository.getTask(taskID).asLiveData()
val user = userRepository.getUser().asLiveData()
fun scoreTask(direction: TaskDirection, onResult: (TaskScoringResult?) -> Unit) {
viewModelScope.launch(exceptionBuilder.userFacing(this)) {
val result = task.value?.let { taskRepository.scoreTask(user.value, it, direction) }
onResult(result)
}
}
}

View file

@ -12,7 +12,6 @@ import com.google.android.gms.auth.UserRecoverableAuthException
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.common.GooglePlayServicesUtil
import com.google.android.gms.common.UserRecoverableException
@ -66,10 +65,9 @@ class LoginViewModel @Inject constructor(userRepository: UserRepository,
viewModelScope.launch(exceptionBuilder.userFacing(this)) {
val account = async {
try {
val account: GoogleSignInAccount = task.getResult(
return@async task.getResult(
ApiException::class.java
)
return@async account
} catch (e: IOException) {
return@async null
} catch (e: GoogleAuthException) {
@ -116,23 +114,7 @@ class LoginViewModel @Inject constructor(userRepository: UserRepository,
}
}
private fun checkPlayServices(activity: Activity): Boolean {
val googleAPI = GoogleApiAvailability.getInstance()
val result = googleAPI.isGooglePlayServicesAvailable(activity)
if (result != ConnectionResult.SUCCESS) {
if (googleAPI.isUserResolvableError(result)) {
googleAPI.getErrorDialog(
activity, result,
PLAY_SERVICES_RESOLUTION_REQUEST
)?.show()
}
return false
}
return true
}
suspend fun handleAuthResponse(userAuthResponse: UserAuthResponse?) {
private suspend fun handleAuthResponse(userAuthResponse: UserAuthResponse?) {
if (userAuthResponse == null) return
try {
saveTokens(userAuthResponse.apiToken, userAuthResponse.id)
@ -174,6 +156,5 @@ class LoginViewModel @Inject constructor(userRepository: UserRepository,
companion object {
private const val REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR = 1001
private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
}
}

View file

@ -20,9 +20,9 @@ class CircularProgressView(
private val ovalSpace = RectF()
private var ovalSize = (resources.displayMetrics.heightPixels / 2)
private var currentPercentage = 55f
private var PERCENTAGE_DIVIDER = 180f
private val ARC_FULL_ROTATION_DEGREE = 360
val attributes = context?.theme?.obtainStyledAttributes(
private var percentageDivider = 180f
private val arcFullRotationDegree = 360
private val attributes = context?.theme?.obtainStyledAttributes(
attrs,
R.styleable.CircularProgressView,
0, 0
@ -86,13 +86,9 @@ class CircularProgressView(
canvas.drawArc(ovalSpace, 270f, percentageToFill, false, fillArcPaint)
}
fun setBarColor(barColor: Int) {
fillArcColor = context?.resources?.getColor(barColor, null) ?: backgroundArcColor
}
fun setPercentageValues(currentValue: Float, maxValue: Float) {
currentPercentage = currentValue
PERCENTAGE_DIVIDER = maxValue
percentageDivider = maxValue
}
fun animateProgress(startValue: Float = 0f, animationDuration: Long = 1000) {
@ -100,7 +96,7 @@ class CircularProgressView(
val valuesHolder = PropertyValuesHolder.ofFloat(
PERCENTAGE_VALUE_HOLDER,
startValue,
currentPercent.toFloat()
currentPercent
)
val animator = ValueAnimator().apply {
@ -121,6 +117,6 @@ class CircularProgressView(
const val PERCENTAGE_VALUE_HOLDER = "percentage"
}
private fun getCurrentAngleToFill() = if(currentPercentage > 0) {(ARC_FULL_ROTATION_DEGREE.toFloat() * (currentPercentage / PERCENTAGE_DIVIDER))} else {1f}
private fun getCurrentAngleToFill() = if(currentPercentage > 0) {(arcFullRotationDegree.toFloat() * (currentPercentage / percentageDivider))} else {1f}
}

View file

@ -25,7 +25,7 @@ class HabitDirectionPickerButton @JvmOverloads constructor(
var mainTaskColor: Int = ContextCompat.getColor(context, R.color.watch_gray_200)
var darkerTaskColor: Int = ContextCompat.getColor(context, R.color.watch_gray_10)
var iconColor: Int = ContextCompat.getColor(context, R.color.white)
var iconColor: Int = ContextCompat.getColor(context, R.color.watch_white)
private val radius = 15.dpToPx(context)

View file

@ -9,9 +9,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
import com.habitrpg.android.habitica.databinding.StatValueLayoutBinding
import com.habitrpg.common.habitica.extensions.layoutInflater
import com.habitrpg.common.habitica.helpers.NumberAbbreviator
import kotlin.math.abs
import kotlin.math.ln
import kotlin.math.pow
class StatValue @JvmOverloads constructor(
context: Context,

View file

@ -70,5 +70,4 @@ open class EllipsizedTextView @JvmOverloads constructor(context: Context, attrs:
class TaskTextView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : EllipsizedTextView(context, attrs) {
}
) : EllipsizedTextView(context, attrs)

View file

@ -1,4 +1,4 @@
package com.habitrpg.wearos.habitica.data
package com.habitrpg.wearos.habitica.util
import android.os.Build
import com.habitrpg.common.habitica.models.tasks.Attribute

View file

@ -27,7 +27,7 @@ class HabiticaScrollingLayoutCallback : WearableLinearLayoutManager.LayoutCallba
return
}
// Adjust to the maximum scale
progressToCenter = Math.min(progressToCenter * 1.5f, MAX_ICON_PROGRESS)
progressToCenter = (progressToCenter * 1.5f).coerceAtMost(MAX_ICON_PROGRESS)
val scale = 1 - progressToCenter
scaleX = scale

View file

@ -21,14 +21,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/broken_heart"
android:importantForAccessibility="no"
android:layout_marginBottom="@dimen/spacing_medium"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/you_ran_out_of_hp"
android:gravity="center"
android:textColor="@color/white"
style="@style/Text.Subheader1"/>
android:textColor="@color/watch_white"
style="@style/Text.SubHeader1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -31,7 +31,7 @@
android:gravity="center"
android:textSize="16sp"
android:maxLines="2"
android:textColor="@color/white"/>
android:textColor="@color/watch_white"/>
<Space
android:layout_width="1dp"
android:layout_height="0dp"

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -15,13 +14,14 @@
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_gryphon_white"
android:importantForAccessibility="no"
android:layout_marginBottom="@dimen/spacing_medium"/>
<TextView
android:id="@+id/title_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Text.Subheader1"
android:textColor="@color/white"
style="@style/Text.SubHeader1"
android:textColor="@color/watch_white"
android:text="@string/sign_in"
android:layout_marginBottom="@dimen/spacing_large"/>
<TextView
@ -31,7 +31,7 @@
android:gravity="center"
android:text="@string/sign_in_description"
style="@style/Text.Body2"
android:textColor="@color/white"
android:textColor="@color/watch_white"
android:layout_marginBottom="18dp"/>
<Button
android:id="@+id/sign_in_on_phone_button"
@ -95,6 +95,7 @@
android:paddingHorizontal="16dp"
android:autofillHints="password"
android:textColorHint="@color/watch_gray_200"
android:inputType="textPassword"
android:textSize="14sp"
android:layout_marginBottom="@dimen/spacing_small"/>
<Button

View file

@ -25,8 +25,8 @@
android:layout_height="wrap_content"
android:text="@string/rya_description"
android:gravity="center"
android:textColor="@color/white"
style="@style/Text.Subheader1"
android:textColor="@color/watch_white"
style="@style/Text.SubHeader1"
android:layout_marginBottom="@dimen/spacing_large"/>
<Button
android:id="@+id/rya_button"

View file

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activities.MainActivity"
tools:context="com.habitrpg.wearos.habitica.ui.activities.SettingsActivity"
tools:deviceIds="wear">
</com.habitrpg.wearos.habitica.ui.views.HabiticaRecyclerView>

View file

@ -10,6 +10,7 @@
android:layout_height="wrap_content"
android:src="@drawable/icon_stats"
android:layout_centerInParent="true"
android:importantForAccessibility="no"
/>
<com.habitrpg.wearos.habitica.ui.views.CircularProgressView

View file

@ -18,8 +18,8 @@
android:id="@+id/task_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Text.Subheader1"
android:textColor="@color/white"
style="@style/Text.SubHeader1"
android:textColor="@color/watch_white"
android:gravity="center"
android:layout_marginBottom="12dp"/>
<TextView

View file

@ -23,7 +23,7 @@
android:id="@+id/confirmation_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Text.Subheader1"
style="@style/Text.SubHeader1"
android:textSize="14sp"
android:textColor="@color/gray_200"
/>
@ -33,7 +33,7 @@
android:layout_height="wrap_content"
style="@style/Text.Body1"
android:textSize="14sp"
android:textColor="@color/white"
android:textColor="@color/watch_white"
/>
<Button
android:id="@+id/save_button"
@ -95,7 +95,7 @@
style="@style/Chip.NoPadding"
android:gravity="start|center_vertical"
android:paddingHorizontal="20dp"
android:textColor="@color/white"
android:textColor="@color/watch_white"
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
android:text="@string/todo" />
@ -106,7 +106,7 @@
style="@style/Chip.NoPadding"
android:gravity="start|center_vertical"
android:paddingHorizontal="20dp"
android:textColor="@color/white"
android:textColor="@color/watch_white"
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
android:text="@string/daily" />
@ -117,7 +117,7 @@
style="@style/Chip.NoPadding"
android:gravity="start|center_vertical"
android:paddingHorizontal="20dp"
android:textColor="@color/white"
android:textColor="@color/watch_white"
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
android:text="@string/habit" />

View file

@ -10,5 +10,6 @@
android:layout_height="wrap_content"
android:src="@drawable/icon_plus"
android:layout_gravity="center"
android:importantForAccessibility="no"
/>
</merge>

View file

@ -17,7 +17,7 @@
android:textSize="18sp"
android:text="@string/log_out_of_habitica"
android:fontFamily="sans-serif-medium"
android:textColor="@color/white"
android:textColor="@color/watch_white"
android:layout_marginBottom="18dp"/>
<Button

View file

@ -34,7 +34,7 @@
android:maxLines="2"
android:ellipsize="end"
tools:text="Task Title that is long and wraps and"
android:textColor="@color/white"
android:textColor="@color/watch_white"
style="@style/Text.Body1"/>
</LinearLayout>
</LinearLayout>

View file

@ -10,6 +10,7 @@
android:layout_above="@id/text_view"
android:layout_centerHorizontal="true"
android:layout_marginBottom="2dp"
android:importantForAccessibility="no"
android:src="@mipmap/ic_launcher" />
<TextView

View file

@ -32,7 +32,7 @@
android:maxLines="2"
android:ellipsize="end"
tools:text="Task Title"
android:textColor="@color/white"
android:textColor="@color/watch_white"
style="@style/Text.Body2"/>
</LinearLayout>
</LinearLayout>

View file

@ -12,5 +12,5 @@
android:layout_gravity="center"
android:textColor="@color/watch_purple_200"
tools:text="Header Text"
style="@style/Text.Subheader1"/>
style="@style/Text.SubHeader1"/>
</FrameLayout>

View file

@ -21,8 +21,8 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="@color/white"
style="@style/Text.Subheader1"/>
android:textColor="@color/watch_white"
style="@style/Text.SubHeader1"/>
<TextView
android:id="@+id/detail_view"
android:layout_width="wrap_content"

View file

@ -14,7 +14,7 @@
android:maxLines="2"
android:ellipsize="end"
tools:text="Task Title"
android:textColor="@color/white"
android:textColor="@color/watch_white"
style="@style/Text.Body1"/>
</LinearLayout>
</FrameLayout>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:orientation="vertical"
android:layout_width="match_parent"
@ -17,7 +16,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Settings text"
android:textColor="@color/white"
android:textColor="@color/watch_white"
style="@style/Text.Body1"/>
<Space
android:layout_width="0dp"

View file

@ -33,7 +33,7 @@
android:maxLines="2"
android:ellipsize="end"
tools:text="Task Title"
android:textColor="@color/white"
android:textColor="@color/watch_white"
style="@style/Text.Body2"/>
</LinearLayout>
</LinearLayout>

View file

@ -5,6 +5,7 @@
android:layout_width="wrap_content"
android:layout_height="30dp"
android:paddingStart="16dp"
android:paddingEnd="0dp"
tools:parentTag="com.habitrpg.wearos.habitica.ui.views.StatValue">
<View
@ -24,6 +25,7 @@
android:layout_height="17dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="6dp"
android:importantForAccessibility="no"
app:layout_constraintBottom_toBottomOf="@+id/current_value"
app:layout_constraintEnd_toStartOf="@+id/current_value"
app:layout_constraintTop_toTopOf="parent" />
@ -38,7 +40,7 @@
android:autoSizeStepGranularity="2sp"
android:autoSizeTextType="uniform"
android:fontFamily="@font/press_start_reg"
android:text="00"
tools:text="00"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/view"
@ -53,8 +55,8 @@
android:autoSizeMinTextSize="4sp"
android:autoSizeTextType="uniform"
android:fontFamily="@font/press_start_reg"
android:text="/00"
android:textColor="@color/white"
tools:text="/00"
android:textColor="@color/watch_white"
android:textSize="6sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/view"

View file

@ -11,7 +11,7 @@
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:textSize="16sp"
android:textColor="@color/black"/>
android:textColor="@color/watch_black"/>
<ImageView
android:id="@+id/icon_view"
android:layout_width="wrap_content"
@ -19,6 +19,7 @@
android:scaleType="center"
android:layout_marginStart="6dp"
android:layout_marginEnd="0dp"
android:importantForAccessibility="no"
android:layout_gravity="center"/>
</merge>

View file

@ -8,7 +8,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="@color/white"
android:textColor="@color/watch_white"
android:text="@string/you_found"/>
<TextView
android:id="@+id/text_view"
@ -17,7 +17,7 @@
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
android:gravity="center"
android:textColor="@color/white"
android:textColor="@color/watch_white"
/>
<com.habitrpg.common.habitica.views.PixelArtView
android:id="@+id/image_view"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="HabiticaAppTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowBackground">@color/black</item>
<item name="android:windowBackground">@color/watch_black</item>
</style>
<style name="Chip">
<item name="android:layout_marginVertical">@dimen/row_spacing</item>
@ -23,7 +23,7 @@
<item name="android:paddingVertical">@dimen/row_padding_vertical</item>
<item name="android:background">@drawable/row_background</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textColor">@color/watch_white</item>
<item name="fontFamily">sans-serif-medium</item>
<item name="android:gravity">start|center_vertical</item>
<item name="android:minHeight">52dp</item>
@ -40,22 +40,22 @@
<style name="ChipButton.Purple" parent="ChipButton">
<item name="android:backgroundTint">@color/watch_purple_100</item>
<item name="android:textColor">@color/black</item>
<item name="android:textColor">@color/watch_black</item>
</style>
<style name="ChipButton.Red" parent="ChipButton">
<item name="android:backgroundTint">@color/watch_red_200</item>
<item name="android:textColor">@color/black</item>
<item name="android:textColor">@color/watch_black</item>
</style>
<style name="ChipButton.Small.Red" parent="ChipButton.Small">
<item name="android:backgroundTint">@color/watch_red_200</item>
<item name="android:textColor">@color/black</item>
<item name="android:textColor">@color/watch_black</item>
</style>
<style name="Text" />
<style name="Text.Subheader1">
<style name="Text.SubHeader1">
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textSize">16sp</item>
</style>