mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
update code for kotlin changes
This commit is contained in:
parent
d9e4a36459
commit
f588220df6
16 changed files with 29 additions and 29 deletions
|
|
@ -202,7 +202,7 @@ constructor(ctx: Context, var sharedPreferences: SharedPreferences, var keyStore
|
|||
putString(PUBLIC_IV, publicIV)
|
||||
}
|
||||
}
|
||||
return publicIV
|
||||
return publicIV ?: ""
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -256,14 +256,14 @@ open class Task : RealmObject, Parcelable {
|
|||
dest.writeString(this.attribute)
|
||||
dest.writeString(this.type)
|
||||
dest.writeDouble(this.value)
|
||||
dest.writeList(this.tags)
|
||||
dest.writeList(this.tags as List<*>?)
|
||||
dest.writeLong(this.dateCreated?.time ?: -1)
|
||||
dest.writeInt(this.position)
|
||||
dest.writeValue(this.up)
|
||||
dest.writeValue(this.down)
|
||||
dest.writeByte(if (this.completed) 1.toByte() else 0.toByte())
|
||||
dest.writeList(this.checklist)
|
||||
dest.writeList(this.reminders)
|
||||
dest.writeList(this.checklist as List<*>?)
|
||||
dest.writeList(this.reminders as List<*>?)
|
||||
dest.writeString(this.frequency)
|
||||
dest.writeValue(this.everyX)
|
||||
dest.writeValue(this.streak)
|
||||
|
|
@ -287,7 +287,7 @@ open class Task : RealmObject, Parcelable {
|
|||
this.type = `in`.readString() ?: ""
|
||||
this.value = `in`.readDouble()
|
||||
this.tags = RealmList()
|
||||
`in`.readList(this.tags, TaskTag::class.java.classLoader)
|
||||
`in`.readList(this.tags as List<*>, TaskTag::class.java.classLoader)
|
||||
val tmpDateCreated = `in`.readLong()
|
||||
this.dateCreated = if (tmpDateCreated == -1L) null else Date(tmpDateCreated)
|
||||
this.position = `in`.readInt()
|
||||
|
|
@ -295,9 +295,9 @@ open class Task : RealmObject, Parcelable {
|
|||
this.down = `in`.readValue(Boolean::class.java.classLoader) as? Boolean ?: false
|
||||
this.completed = `in`.readByte().toInt() != 0
|
||||
this.checklist = RealmList()
|
||||
`in`.readList(this.checklist, ChecklistItem::class.java.classLoader)
|
||||
`in`.readList(this.checklist as List<*>, ChecklistItem::class.java.classLoader)
|
||||
this.reminders = RealmList()
|
||||
`in`.readList(this.reminders, RemindersItem::class.java.classLoader)
|
||||
`in`.readList(this.reminders as List<*>, RemindersItem::class.java.classLoader)
|
||||
this.frequency = `in`.readString()
|
||||
this.everyX = `in`.readValue(Int::class.java.classLoader) as? Int ?: 1
|
||||
this.streak = `in`.readValue(Int::class.java.classLoader) as? Int ?: 0
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class AvatarView : View {
|
|||
val canvasRect = Rect()
|
||||
avatarRectF?.round(canvasRect)
|
||||
avatarBitmap = Bitmap.createBitmap(canvasRect.width(), canvasRect.height(), Bitmap.Config.ARGB_8888)
|
||||
avatarCanvas = Canvas(avatarBitmap)
|
||||
avatarBitmap?.let { avatarCanvas = Canvas(it) }
|
||||
draw(avatarCanvas)
|
||||
|
||||
return avatarBitmap
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class FullProfileActivity : BaseActivity() {
|
|||
val clipboard = view.context
|
||||
.getSystemService(Context.CLIPBOARD_SERVICE) as? android.content.ClipboardManager
|
||||
val clip = android.content.ClipData.newPlainText(user.username, user.username)
|
||||
clipboard?.primaryClip = clip
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
}
|
||||
|
||||
avatarView.setAvatar(user)
|
||||
|
|
@ -371,10 +371,10 @@ class FullProfileActivity : BaseActivity() {
|
|||
val buffs = stats.buffs
|
||||
|
||||
addAttributeRow(getString(R.string.profile_allocated), stats.strength?.toFloat() ?: 0f, stats.intelligence?.toFloat() ?: 0f, stats.constitution?.toFloat() ?: 0f, stats.per?.toFloat() ?: 0f, true, false)
|
||||
addAttributeRow(getString(R.string.buffs), buffs?.getStr() ?: 0f, buffs?.get_int() ?: 0f, buffs?.getCon() ?: 0f, buffs?.getPer() ?: 0f, true, false)
|
||||
addAttributeRow(getString(R.string.buffs), buffs?.getStr() ?: 0f, buffs?.get_int() ?: 0f, buffs?.getCon() ?: 0f, buffs?.getPer() ?: 0f, roundDown = true, isSummary = false)
|
||||
|
||||
// Summary row
|
||||
addAttributeRow("", attributeStrSum, attributeIntSum, attributeConSum, attributePerSum, false, true)
|
||||
addAttributeRow("", attributeStrSum, attributeIntSum, attributeConSum, attributePerSum, roundDown = false, isSummary = true)
|
||||
}
|
||||
|
||||
private fun addAttributeRow(label: String, strVal: Float, intVal: Float, conVal: Float, perVal: Float, roundDown: Boolean, isSummary: Boolean) {
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
}
|
||||
|
||||
if (intent.hasExtra("notificationIdentifier")) {
|
||||
val identifier = intent.getStringExtra("notificationIdentifier")
|
||||
val identifier = intent.getStringExtra("notificationIdentifier") ?: ""
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = identifier
|
||||
AmplitudeManager.sendEvent("open notification", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT, additionalData)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ class SimpleSpinnerAdapter(context: Context, resource: Int) : ArrayAdapter<CharS
|
|||
return view
|
||||
}
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||
val view = parent?.inflate(android.R.layout.simple_spinner_item, false) ?: View(context)
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
val view = convertView ?: parent.inflate(android.R.layout.simple_spinner_item, false)
|
||||
(view as? TextView)?.text = getItem(position)
|
||||
return view
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ class HabiticaClassArrayAdapter(context: Context, resource: Int, objects: List<C
|
|||
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup?): View =
|
||||
createView(position, convertView ?: parent?.inflate(R.layout.class_spinner_dropdown_item, false))
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View =
|
||||
createView(position, convertView ?: parent?.inflate(R.layout.class_spinner_dropdown_item_selected, false))
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View =
|
||||
createView(position, convertView ?: parent.inflate(R.layout.class_spinner_dropdown_item_selected, false))
|
||||
|
||||
private fun createView(position: Int, row: View?): View {
|
||||
val textView: TextView? = row?.findViewById(R.id.textView)
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ class APIPreferenceFragment: BasePreferencesFragment() {
|
|||
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
if (preference.key == getString(R.string.SP_APIToken)) {
|
||||
clipMan?.primaryClip = ClipData.newPlainText(preference.key, hostConfig.apiKey)
|
||||
clipMan?.setPrimaryClip(if (preference.key == getString(R.string.SP_APIToken)) {
|
||||
ClipData.newPlainText(preference.key, hostConfig.apiKey)
|
||||
} else {
|
||||
clipMan?.primaryClip = ClipData.newPlainText(preference.key, preference.summary)
|
||||
}
|
||||
ClipData.newPlainText(preference.key, preference.summary)
|
||||
})
|
||||
Toast.makeText(activity, "Copied " + preference.key + " to clipboard.", Toast.LENGTH_SHORT).show()
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() {
|
|||
"add_local_auth" -> showAddLocalAuthDialog()
|
||||
else -> {
|
||||
val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
clipMan?.primaryClip = ClipData.newPlainText(preference.key, preference.summary)
|
||||
clipMan?.setPrimaryClip(ClipData.newPlainText(preference.key, preference.summary))
|
||||
Toast.makeText(activity, "Copied " + preference.key + " to clipboard.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class ChatFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
|
|||
private fun copyMessageToClipboard(chatMessage: ChatMessage) {
|
||||
val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
val messageText = ClipData.newPlainText("Chat message", chatMessage.text)
|
||||
clipMan?.primaryClip = messageText
|
||||
clipMan?.setPrimaryClip(messageText)
|
||||
val activity = activity as? MainActivity
|
||||
if (activity != null) {
|
||||
showSnackbar(activity.snackbarContainer, getString(R.string.chat_message_copied), SnackbarDisplayType.NORMAL)
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ class ChatListFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
|
|||
private fun copyMessageToClipboard(chatMessage: ChatMessage) {
|
||||
val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
val messageText = ClipData.newPlainText("Chat message", chatMessage.text)
|
||||
clipMan?.primaryClip = messageText
|
||||
clipMan?.setPrimaryClip(messageText)
|
||||
val activity = activity as? MainActivity
|
||||
if (activity != null) {
|
||||
showSnackbar(activity.snackbarContainer, getString(R.string.chat_message_copied), SnackbarDisplayType.NORMAL)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class GroupInformationFragment : BaseFragment() {
|
|||
username_textview.setOnClickListener {
|
||||
val clipboard = context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
val clip = ClipData.newPlainText(context?.getString(R.string.username), user?.username)
|
||||
clipboard?.primaryClip = clip
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
val activity = activity as? MainActivity
|
||||
if (activity != null) {
|
||||
HabiticaSnackbar.showSnackbar(activity.snackbarContainer, getString(R.string.username_copied), HabiticaSnackbar.SnackbarDisplayType.NORMAL)
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class InboxMessageListFragment : BaseMainFragment(), androidx.swiperefreshlayout
|
|||
private fun copyMessageToClipboard(chatMessage: ChatMessage) {
|
||||
val clipMan = getActivity()?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
val messageText = ClipData.newPlainText("Chat message", chatMessage.text)
|
||||
clipMan?.primaryClip = messageText
|
||||
clipMan?.setPrimaryClip(messageText)
|
||||
val activity = getActivity() as? MainActivity
|
||||
if (activity != null) {
|
||||
showSnackbar(activity.snackbarContainer, getString(R.string.chat_message_copied), HabiticaSnackbar.SnackbarDisplayType.NORMAL)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
|||
import io.reactivex.functions.Consumer
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class NPCBannerView(context: Context?, attrs: AttributeSet?) : FrameLayout(context, attrs) {
|
||||
class NPCBannerView(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) {
|
||||
|
||||
private val backgroundView: ImageView by bindView(R.id.backgroundView)
|
||||
private val sceneView: SimpleDraweeView by bindView(R.id.sceneView)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class RoundedCornerLayout : FrameLayout {
|
|||
maskBitmap = createMask(width, height)
|
||||
}
|
||||
|
||||
offscreenCanvas.drawBitmap(maskBitmap, 0f, 0f, maskPaint)
|
||||
maskBitmap?.let { offscreenCanvas.drawBitmap(it, 0f, 0f, maskPaint) }
|
||||
canvas.drawBitmap(offscreenBitmap, 0f, 0f, paint)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ import android.widget.RatingBar
|
|||
import android.widget.TextView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestDropItem
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
|
||||
class PurchaseDialogQuestContent : PurchaseDialogContent {
|
||||
|
|
@ -51,7 +51,7 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
|||
} else {
|
||||
questTypeTextView.setText(R.string.collection_quest)
|
||||
val collectionList = questContent.collect?.map { it.count.toString() + " " + it.text }
|
||||
questCollectTextView.text = TextUtils.join(", ", collectionList)
|
||||
questCollectTextView.text = TextUtils.join(", ", collectionList ?: listOf<String>())
|
||||
|
||||
bossHealthView.visibility = View.GONE
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue