Implement username changes

This commit is contained in:
Phillip Thelen 2018-10-17 16:28:23 +02:00
parent 3007e788eb
commit 762d1faa2c
38 changed files with 412 additions and 343 deletions

View file

@ -7,10 +7,6 @@
android:screenOrientation="portrait"
android:installLocation="auto" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

View file

@ -14,7 +14,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.1'
classpath 'io.fabric.tools:gradle:1.25.4'
classpath('com.noveogroup.android:check:1.2.3') {
exclude module: 'checkstyle'
exclude module: 'pmd-java'
@ -60,10 +60,10 @@ dependencies {
kapt 'com.google.dagger:dagger-compiler:2.16'
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
//App Compatibility and Material Design
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:preference-v14:27.1.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:preference-v14:28.0.0'
//QR Code
implementation 'com.github.kenglxn.QRGen:android:2.5.0'
// Emojis
@ -131,9 +131,10 @@ dependencies {
android {
compileSdkVersion 28
buildToolsVersion '28.0.1'
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
applicationId "com.habitrpg.android.habitica"
vectorDrawables.useSupportLibrary = true
buildConfigField "String", "STORE", "\"google\""

View file

@ -1,18 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
xmlns:tools="http://schemas.android.com/tools"
android:padding="@dimen/spacing_large"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal">
<com.habitrpg.android.habitica.ui.AvatarView
android:id="@+id/avatarView"
android:layout_width="140dp"
@ -28,57 +23,49 @@
android:layout_weight="6"
android:orientation="vertical">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginBottom="@dimen/spacing_medium">
<com.habitrpg.android.habitica.ui.views.social.UsernameLabel
android:id="@+id/display_name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<ImageView
android:id="@+id/buff_icon_view"
android:layout_width="17dp"
android:layout_height="17dp"
android:contentDescription="@string/buffs"
android:layout_marginLeft="@dimen/spacing_small"
android:layout_gravity="center_vertical" />
<ImageView
android:id="@+id/class_icon_view"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_marginLeft="@dimen/spacing_small"
android:layout_gravity="center_vertical" />
<Space
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/user_lvl"
android:id="@+id/leader_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="lvl" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right">
<LinearLayout
android:id="@+id/class_background_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:background="@drawable/layout_rounded_bg">
<TextView
android:id="@+id/class_label"
style="@style/ChatMessageUserTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ellipsize="middle"
android:lines="1"
android:singleLine="true"
android:text="class"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
android:text="@string/leader"
style="@style/Pill"
android:textSize="12sp"/>
</LinearLayout>
<TextView
android:id="@+id/subline_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
tools:text="lvl"
android:layout_marginBottom="@dimen/spacing_large"/>
<com.habitrpg.android.habitica.ui.views.ValueBar
android:layout_width="wrap_content"
@ -90,4 +77,3 @@
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

View file

@ -190,30 +190,31 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/CardTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_id"
android:text="@string/username"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="@+id/userid"/>
<Button
android:id="@+id/username"
android:layout_gravity="right"/>
</LinearLayout>
<Button
android:text="@string/copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="@+id/copy_userid" />
</LinearLayout>
android:id="@+id/copy_username" />
</LinearLayout>
</android.support.v7.widget.CardView>

View file

@ -2,21 +2,17 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:padding="@dimen/spacing_large">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enter_recipient_uuid"/>
android:text="@string/enter_recipient_username"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/uuidEditText" android:layout_gravity="center_horizontal"
android:focusable="true"
android:maxLines="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/scan_qr_code"
android:id="@+id/scanQRCodeButton"/>
</LinearLayout>

View file

@ -28,18 +28,35 @@
android:layout_height="70dp"
android:layout_gravity="center"/>
</com.habitrpg.android.habitica.ui.views.RoundedCornerLayout>
<TextView
android:id="@+id/toolbarTitle"
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
tools:text="Habitica"
style="@style/Body1"
android:textColor="@color/white"/>
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/toolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
tools:text="Habitica"
style="@style/Body1"
android:textColor="@color/white"/>
<TextView
android:id="@+id/usernameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
tools:text="\@username"
android:textSize="12sp"
android:visibility="gone"
android:textColor="@color/white_80_alpha"/>
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="45dp"
android:layout_height="match_parent"

View file

@ -10,24 +10,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/SectionTitle"
android:text="@string/sidebar.inbox"
android:textAppearance="?android:attr/textAppearanceMedium" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/card_large_text"
style="@style/CardView.Default">
<LinearLayout
android:id="@+id/inbox_messages"
android:layout_width="match_parent"
@ -36,8 +18,5 @@
android:divider="?android:listDivider"
android:showDividers="middle">
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_large">
<com.habitrpg.android.habitica.ui.RoundedFrameLayout
android:layout_width="@dimen/avatar_chat_size"
android:layout_height="@dimen/avatar_chat_size"
android:clipChildren="true"
android:layout_marginRight="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
android:background="@drawable/rounded_avatar_bg">
<com.habitrpg.android.habitica.ui.AvatarView
android:id="@+id/avatar_view"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
app:showMount="false"
app:showPet="false" />
</com.habitrpg.android.habitica.ui.RoundedFrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/spacing_medium">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.habitrpg.android.habitica.ui.views.social.UsernameLabel
android:id="@+id/display_name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:id="@+id/timestamp_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="@color/gray_300"/>
</LinearLayout>
<TextView
android:id="@+id/username_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/message_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,94 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CardView.Default"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:padding="@dimen/spacing_large"
android:foreground="?android:attr/selectableItemBackground">
<com.habitrpg.android.habitica.ui.AvatarView
android:id="@+id/avatarView"
android:layout_width="103dp"
android:layout_height="90dp"
android:layout_marginRight="12dp"
app:showBackground="false"
app:showMount="false"
app:showPet="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/CardContent"
android:orientation="horizontal">
<com.habitrpg.android.habitica.ui.AvatarView
android:id="@+id/avatarView"
android:layout_width="103dp"
android:layout_height="90dp"
android:layout_marginRight="12dp"
app:showBackground="false"
app:showMount="false"
app:showPet="false" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="vertical">
android:layout_marginBottom="@dimen/spacing_medium">
<com.habitrpg.android.habitica.ui.views.social.UsernameLabel
android:id="@+id/display_name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<ImageView
android:id="@+id/buff_icon_view"
android:layout_width="17dp"
android:layout_height="17dp"
android:contentDescription="@string/buffs"
android:layout_marginLeft="@dimen/spacing_small"
android:layout_gravity="center_vertical"/>
<ImageView
android:id="@+id/class_icon_view"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_marginLeft="@dimen/spacing_small"
android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/username"
android:id="@+id/leader_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/username"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/user_lvl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
tools:text="lvl" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right">
<LinearLayout
android:id="@+id/class_background_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:background="@drawable/layout_rounded_bg">
<TextView
android:id="@+id/class_label"
style="@style/ChatMessageUserTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ellipsize="middle"
android:lines="1"
android:singleLine="true"
tools:text="class"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.habitrpg.android.habitica.ui.views.ValueBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hpBar"
app:barForegroundColor="@color/hpColor"
app:description="@string/HP_default"
app:lightBackground="true"/>
android:text="@string/leader"
style="@style/Pill"
android:textSize="12sp"/>
</LinearLayout>
<TextView
android:id="@+id/subline_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
tools:text="lvl"
android:layout_marginBottom="@dimen/spacing_large"/>
<com.habitrpg.android.habitica.ui.views.ValueBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hpBar"
app:barForegroundColor="@color/hpColor"
app:description="@string/HP_default"
app:lightBackground="true"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

View file

@ -55,7 +55,8 @@
android:textSize="12sp"
android:textColor="@color/white"
style="@style/Pill.Purple"
tools:text="Moderator"/>
tools:text="Moderator"
android:layout_marginLeft="@dimen/spacing_small"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
@ -83,7 +84,7 @@
</LinearLayout>
<TextView
android:id="@+id/ago_label"
android:id="@+id/subline_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"

View file

@ -825,4 +825,6 @@
<string name="confirm_username">Confirm Username</string>
<string name="username_not_confirmed">Username not confirmed</string>
<string name="username_confirmed">Username Confirmed</string>
<string name="username_level">%s ・Lvl %d</string>
<string name="enter_recipient_username">Enter a Recipient\'s username</string>
</resources>

View file

@ -104,6 +104,10 @@ open class Member : RealmObject(), Avatar {
val mountsTamedCount: Int
get() = this.items?.mounts?.size ?: 0
val username: String?
get() = authentication?.localAuthentication?.username
val formattedUsername: String?
get() = if (username != null) "@$username" else null
override fun getPreferences(): MemberPreferences? {
return preferences

View file

@ -56,6 +56,10 @@ open class ChatMessage : RealmObject() {
val likeCount: Int
get() = likes?.size ?: 0
var username: String? = null
val formattedUsername: String?
get() = if (username != null) "@$username" else null
fun getAgoString(res: Resources): String {
val diff = Date().time - (timestamp ?: 0)

View file

@ -66,6 +66,13 @@ open class Stats : RealmObject() {
field = value
}
}
val isBuffed: Boolean
get() {
return buffs?.str ?: 0f > 0 ||
buffs?.con ?: 0f > 0 ||
buffs?._int ?: 0f > 0 ||
buffs?.per ?: 0f > 0
}
@StringDef(Stats.STRENGTH, Stats.INTELLIGENCE, Stats.CONSTITUTION, Stats.PERCEPTION)
@Retention(RetentionPolicy.SOURCE)

View file

@ -150,6 +150,10 @@ open class User : RealmObject(), Avatar {
val contributorColor: Int
get() = this.contributor?.contributorColor ?: android.R.color.black
val username: String?
get() = authentication?.localAuthentication?.username
val formattedUsername: String?
get() = if (username != null) "@$username" else null
override fun getPreferences(): Preferences? {
return preferences

View file

@ -375,7 +375,7 @@ class ChallengeFormActivity : BaseActivity() {
}, RxErrorHandler.handleEmptyError())
createChallengeTaskList.addOnItemTouchListener(object : RecyclerView.SimpleOnItemTouchListener() {
override fun onInterceptTouchEvent(rv: RecyclerView?, e: MotionEvent?): Boolean {
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent): Boolean {
// Stop only scrolling.
return rv?.scrollState == RecyclerView.SCROLL_STATE_DRAGGING
}

View file

@ -10,7 +10,6 @@ import android.support.v7.widget.AppCompatImageView
import android.support.v7.widget.CardView
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.format.DateFormat
import android.view.*
import android.widget.*
import com.facebook.drawee.backends.pipeline.Fresco
@ -59,8 +58,8 @@ class FullProfileActivity : BaseActivity() {
private val profileImage: SimpleDraweeView by bindView(R.id.profile_image)
private val blurbTextView: TextView by bindView(R.id.profile_blurb)
private val avatarView: AvatarView by bindView(R.id.avatarView)
private val copyUserIdButton: Button by bindView(R.id.copy_userid)
private val userIdText: TextView by bindView(R.id.userid)
private val copyUsernameButton: Button by bindView(R.id.copy_username)
private val usernameText: TextView by bindView(R.id.username)
private val attributesCardView: CardView by bindView(R.id.profile_attributes_card)
private val attributesTableLayout: TableLayout by bindView(R.id.attributes_table)
private val attributesCollapseIcon: AppCompatImageView by bindView(R.id.attributes_collapse_icon)
@ -100,7 +99,7 @@ class FullProfileActivity : BaseActivity() {
setTitle(R.string.profile_loading_data)
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()
@ -193,30 +192,29 @@ class FullProfileActivity : BaseActivity() {
user.authentication?.timestamps?.lastLoggedIn.notNull { lastLoginView.text = dateFormatter.format(it) }
totalCheckinsView.text = user.loginIncentives.toString()
userIdText.text = userId
copyUserIdButton.visibility = View.VISIBLE
copyUserIdButton.setOnClickListener { view ->
usernameText.text = userId
copyUsernameButton.visibility = View.VISIBLE
copyUsernameButton.setOnClickListener { view ->
val clipboard = view.context
.getSystemService(Context.CLIPBOARD_SERVICE) as? android.content.ClipboardManager
val clip = android.content.ClipData.newPlainText(userId, userId)
clipboard?.primaryClip = clip
}
avatarView.setAvatar(user)
avatarWithBars?.updateData(user)
loadItemDataByOutfit(user.equipped).subscribe(Consumer { gear -> this.gotGear(gear, user) }, RxErrorHandler.handleEmptyError())
compositeSubscription.add(loadItemDataByOutfit(user.equipped).subscribe(Consumer { gear -> this.gotGear(gear, user) }, RxErrorHandler.handleEmptyError()))
if (user.preferences?.costume == true) {
loadItemDataByOutfit(user.costume).subscribe(Consumer<RealmResults<Equipment>> { this.gotCostume(it) }, RxErrorHandler.handleEmptyError())
compositeSubscription.add(loadItemDataByOutfit(user.costume).subscribe(Consumer<RealmResults<Equipment>> { this.gotCostume(it) }, RxErrorHandler.handleEmptyError()))
} else {
costumeCard.visibility = View.GONE
}
// Load the members achievements now
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) {
@ -295,28 +293,28 @@ class FullProfileActivity : BaseActivity() {
}
private fun addEquipmentRow(table: TableLayout, gearKey: String?, text: String, stats: String) {
val gearRow = layoutInflater.inflate(R.layout.profile_gear_tablerow, table, false) as TableRow
val gearRow = layoutInflater.inflate(R.layout.profile_gear_tablerow, table, false) as? TableRow
val draweeView = gearRow.findViewById<SimpleDraweeView>(R.id.gear_drawee)
val draweeView = gearRow?.findViewById<SimpleDraweeView>(R.id.gear_drawee)
draweeView.controller = Fresco.newDraweeControllerBuilder()
draweeView?.controller = Fresco.newDraweeControllerBuilder()
.setUri(AvatarView.IMAGE_URI_ROOT + "shop_" + gearKey + ".png")
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFailure(id: String?, throwable: Throwable?) {
draweeView.visibility = View.GONE
draweeView?.visibility = View.GONE
}
})
.build()
val keyTextView = gearRow.findViewById<TextView>(R.id.tableRowTextView1)
keyTextView.text = text
val keyTextView = gearRow?.findViewById<TextView>(R.id.tableRowTextView1)
keyTextView?.text = text
val valueTextView = gearRow.findViewById<TextView>(R.id.tableRowTextView2)
val valueTextView = gearRow?.findViewById<TextView>(R.id.tableRowTextView2)
if (!stats.isEmpty()) {
valueTextView.text = stats
valueTextView?.text = stats
} else {
valueTextView.visibility = View.GONE
valueTextView?.visibility = View.GONE
}
table.addView(gearRow)

View file

@ -51,7 +51,7 @@ class GemPurchaseActivity : BaseActivity(), InAppMessageListener {
component?.inject(this)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
activityCheckout?.onActivityResult(requestCode, resultCode, data)
}

View file

@ -412,7 +412,10 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
private fun updateSidebar() {
drawerFragment?.setUsername(user?.profile?.name)
drawerFragment?.setDisplayName(user?.profile?.name)
if (remoteConfigManager.enableUsernameRelease()) {
drawerFragment?.setUsername(user?.formattedUsername)
}
if (user?.preferences == null || user?.flags == null) {
return

View file

@ -42,9 +42,9 @@ class MaintenanceActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val data = intent.extras
val data = intent.extras ?: return
this.titleTextView.text = data?.getString("title")
this.titleTextView.text = data.getString("title")
@Suppress("DEPRECATION")
imageView.setImageURI(Uri.parse(data.getString("imageUrl")))

View file

@ -140,12 +140,13 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
return R.layout.activity_task_form
}
@Suppress("ReturnCount")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
popup = EmojiPopup(emojiToggle0.rootView, this, ContextCompat.getColor(this, R.color.brand))
val bundle = intent.extras
val bundle = intent.extras ?: return
taskType = bundle.getString(TASK_TYPE_KEY)
task = bundle.getParcelable(PARCELABLE_TASK) as? Task
@ -183,7 +184,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
finish()
dismissKeyboard()
taskId.notNull { taskRepository.deleteTask(it).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()) }
taskId.notNull { taskID -> taskRepository.deleteTask(taskID).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()) }
}.setNegativeButton(getString(R.string.no)) { dialog, _ -> dialog.dismiss() }.show()
}
@ -317,7 +318,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
if (isEmojiEditText(currentFocus)) {
val event = KeyEvent(
0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL)
currentFocus.dispatchKeyEvent(event)
currentFocus?.dispatchKeyEvent(event)
}
}
@ -329,16 +330,15 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
enableRepeatables()
tagRepository.getTags(userId)
compositeSubscription.add(tagRepository.getTags(userId)
.firstElement()
.subscribe(Consumer { loadedTags ->
tags = loadedTags
createTagsCheckBoxes()
}, RxErrorHandler.handleEmptyError()
)
}, RxErrorHandler.handleEmptyError()))
if (taskId != null) {
taskRepository.getTask(taskId ?: "")
compositeSubscription.add(taskRepository.getTask(taskId ?: "")
.firstElement()
.subscribe(Consumer { task ->
this.task = task
@ -353,7 +353,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
}
setTitle(task)
}, RxErrorHandler.handleEmptyError())
}, RxErrorHandler.handleEmptyError()))
btnDelete.isEnabled = true
} else if (task != null) {
@ -505,7 +505,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val dayOfTheWeek = sharedPreferences.getString("FirstDayOfTheWeek",
Integer.toString(Calendar.getInstance().firstDayOfWeek))
firstDayOfTheWeekHelper = FirstDayOfTheWeekHelper.newInstance(Integer.parseInt(dayOfTheWeek))
firstDayOfTheWeekHelper = FirstDayOfTheWeekHelper.newInstance(Integer.parseInt(dayOfTheWeek ?: "0"))
val weekdaysTemp = weekdays.asList()
Collections.rotate(weekdaysTemp, firstDayOfTheWeekHelper?.dailyTaskFormOffset ?: 0)
weekdays = weekdaysTemp.toTypedArray()
@ -705,7 +705,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
}
private fun selectNewReminderTime() {
remindersManager.createReminderTimeDialog({ it.notNull { this.addNewReminder(it) } }, taskType, this, null)
remindersManager.createReminderTimeDialog({ item -> item.notNull { this.addNewReminder(it) } }, taskType, this, null)
}
private fun createTagsCheckBoxes() {
@ -767,7 +767,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val dayOfTheWeek = sharedPreferences.getString("FirstDayOfTheWeek",
Integer.toString(Calendar.getInstance().firstDayOfWeek))
firstDayOfTheWeekHelper = FirstDayOfTheWeekHelper.newInstance(Integer.parseInt(dayOfTheWeek))
firstDayOfTheWeekHelper = FirstDayOfTheWeekHelper.newInstance(Integer.parseInt(dayOfTheWeek ?: ""))
val weekdaysTemp = weekdays.asList()
Collections.rotate(weekdaysTemp, firstDayOfTheWeekHelper?.dailyTaskFormOffset ?: 0)
weekdays = weekdaysTemp.toTypedArray()
@ -1191,7 +1191,7 @@ class TaskFormActivity : BaseActivity(), AdapterView.OnItemSelectedListener {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
val dayOfTheWeek = sharedPreferences.getString("FirstDayOfTheWeek",
Integer.toString(Calendar.getInstance().firstDayOfWeek))
val firstDayOfTheWeekHelper = FirstDayOfTheWeekHelper.newInstance(Integer.parseInt(dayOfTheWeek))
val firstDayOfTheWeekHelper = FirstDayOfTheWeekHelper.newInstance(Integer.parseInt(dayOfTheWeek ?: "0"))
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
@Suppress("DEPRECATION")
datePickerDialog.datePicker.calendarView.firstDayOfWeek = firstDayOfTheWeekHelper.firstDayOfTheWeek

View file

@ -67,7 +67,7 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int): Recycle
(holder as DrawerItemViewHolder?)?.tintColor = tintColor
holder.backgroundTintColor = backgroundTintColor
holder.bind(drawerItem, drawerItem.identifier == selectedItem)
holder.itemView?.setOnClickListener { itemSelectedEvents.onNext(drawerItem.identifier) }
holder.itemView.setOnClickListener { itemSelectedEvents.onNext(drawerItem.identifier) }
} else {
(holder as SectionHeaderViewHolder?)?.backgroundTintColor = backgroundTintColor
holder.bind(drawerItem)
@ -88,7 +88,7 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int): Recycle
}
}
class DrawerItemViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView) {
class DrawerItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tintColor: Int = 0
var backgroundTintColor: Int = 0
@ -145,12 +145,12 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int): Recycle
}
}
class SectionHeaderViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView) {
class SectionHeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var backgroundTintColor: Int = 0
fun bind(drawerItem: HabiticaDrawerItem) {
(itemView as TextView).text = drawerItem.text
(itemView as? TextView)?.text = drawerItem.text
itemView.setBackgroundColor(backgroundTintColor)
}
}

View file

@ -62,12 +62,12 @@ class SkillTasksRecyclerViewAdapter(data: OrderedRealmCollection<Task>?, autoUpd
internal fun bindHolder(task: Task) {
this.task = task
titleTextView.text = task.markdownText { titleTextView?.text = it }
titleTextView.text = task.markdownText { titleTextView.text = it }
if (task.notes?.isEmpty() == true) {
notesTextView.visibility = View.GONE
} else {
notesTextView.visibility = View.VISIBLE
notesTextView.text = task.markdownNotes { notesTextView?.text = it }
notesTextView.text = task.markdownNotes { notesTextView.text = it }
}
rightBorderView.setBackgroundResource(task.lightTaskColor)
}

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) : RealmRecyclerViewAdapter<ChatMessage, RecyclerView.ViewHolder>(data, autoUpdate) {
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) {
private var uuid: String = ""
private var expandedMessageId: String? = null
@ -107,7 +107,7 @@ class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUp
private val avatarView: AvatarView by bindView(R.id.avatar_view)
private val userLabel: UsernameLabel by bindView(R.id.user_label)
private val messageText: EmojiTextView by bindView(R.id.message_text)
private val agoLabel: TextView by bindView(R.id.ago_label)
private val sublineTextView: TextView by bindView(R.id.subline_textview)
private val likeBackground: LinearLayout by bindView(R.id.like_background_layout)
private val tvLikes: TextView by bindView(R.id.tvLikes)
private val buttonsWrapper: ViewGroup by bindView(R.id.buttons_wrapper)
@ -129,7 +129,13 @@ class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUp
messageText.setOnClickListener { _ -> expandMessage() }
messageText.movementMethod = LinkMovementMethod.getInstance()
userLabel.setOnClickListener { _ -> chatMessage?.uuid.notNull {userLabelClickEvents.onNext(it) } }
replyButton.setOnClickListener { _ -> chatMessage?.user.notNull { replyMessageEvents.onNext(it) } }
replyButton.setOnClickListener { _ ->
if (releasedUsernames) {
chatMessage?.username.notNull { replyMessageEvents.onNext(it) }
} else {
chatMessage?.user.notNull { replyMessageEvents.onNext(it) }
}
}
replyButton.setCompoundDrawablesWithIntrinsicBounds(BitmapDrawable(res, HabiticaIconsHelper.imageOfChatReplyIcon()),
null, null, null)
copyButton.setOnClickListener { _ -> chatMessage.notNull { copyMessageEvents.onNext(it) } }
@ -202,14 +208,19 @@ class ChatRecyclerViewAdapter(data: OrderedRealmCollection<ChatMessage>?, autoUp
}, { it.printStackTrace() })
}
if (name != null && msg.text?.contains(name) == true) {
val username = user?.username
if ((name != null && msg.text?.contains(name) == true) || (username != null && msg.text?.contains(username) == true)) {
messageWrapper.backgroundCompat = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_brand_700)
} else {
messageWrapper.backgroundCompat = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg)
}
messageWrapper.setScaledPadding(context, 8, 8, 8, 8)
agoLabel.text = msg.getAgoString(res)
if (msg.username != null && releasedUsernames) {
sublineTextView.text = "${msg.formattedUsername}${msg.getAgoString(res)}"
} else {
sublineTextView.text = msg.getAgoString(res)
}
if (expandedMessageId == msg.id) {
buttonsWrapper.visibility = View.VISIBLE

View file

@ -4,6 +4,7 @@ import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.inflate
@ -16,6 +17,7 @@ import com.habitrpg.android.habitica.ui.helpers.ViewHelper
import com.habitrpg.android.habitica.ui.helpers.bindView
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.ValueBar
import com.habitrpg.android.habitica.ui.views.social.UsernameLabel
import io.reactivex.BackpressureStrategy
import io.reactivex.Flowable
import io.reactivex.subjects.PublishSubject
@ -43,43 +45,56 @@ class PartyMemberRecyclerViewAdapter(data: OrderedRealmCollection<Member>?, auto
inner class MemberViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val avatarView: AvatarView by bindView(R.id.avatarView)
private val userName: TextView by bindView(R.id.username)
private val lvl: TextView by bindView(R.id.user_lvl)
private val classLabel: TextView by bindView(R.id.class_label)
private val classBackground: View by bindView(R.id.class_background_layout)
private val displayNameTextView: UsernameLabel by bindView(R.id.display_name_textview)
private val sublineTextView: TextView by bindView(R.id.subline_textview)
private val buffIconView: ImageView by bindView(R.id.buff_icon_view)
private val classIconView: ImageView by bindView(R.id.class_icon_view)
private val hpBar: ValueBar by bindView(R.id.hpBar)
init {
hpBar.setLightBackground(true)
hpBar.setIcon(HabiticaIconsHelper.imageOfHeartLightBg())
buffIconView.setImageBitmap(HabiticaIconsHelper.imageOfBuffIcon())
}
fun bind(user: Member) {
avatarView.setAvatar(user)
user.stats.notNull { AvatarWithBarsViewModel.setHpBarData(hpBar, it) }
displayNameTextView.username = user.profile?.name
displayNameTextView.tier = user.contributor?.level ?: 0
lvl.text = itemView.context.getString(R.string.user_level, user.stats?.lvl)
if (user.username != null) {
sublineTextView.text = itemView.context.getString(R.string.username_level, user.username, user.stats?.lvl)
} else {
sublineTextView.text = itemView.context.getString(R.string.user_level, user.stats?.lvl)
}
classLabel.text = user.stats?.getTranslatedClassName(itemView.context)
if (user.stats?.isBuffed == true) {
buffIconView.visibility = View.VISIBLE
} else {
buffIconView.visibility = View.GONE
}
val colorResourceID: Int = when (user.stats?.habitClass) {
classIconView.visibility = View.VISIBLE
when (user.stats?.habitClass) {
Stats.HEALER -> {
R.color.class_healer
classIconView.setImageBitmap(HabiticaIconsHelper.imageOfHealerLightBg())
}
Stats.WARRIOR -> {
R.color.class_warrior
classIconView.setImageBitmap(HabiticaIconsHelper.imageOfWarriorLightBg())
}
Stats.ROGUE -> {
R.color.class_rogue
classIconView.setImageBitmap(HabiticaIconsHelper.imageOfRogueLightBg())
}
Stats.MAGE -> {
R.color.class_wizard
classIconView.setImageBitmap(HabiticaIconsHelper.imageOfMageLightBg())
}
else -> {
classIconView.visibility = View.INVISIBLE
}
else -> R.color.task_gray
}
ViewHelper.SetBackgroundTint(classBackground, ContextCompat.getColor(itemView.context, colorResourceID))
userName.text = user.profile?.name
itemView.isClickable = true
itemView.setOnClickListener { userClickedEvents.onNext(user.id ?: "") }

View file

@ -187,7 +187,7 @@ class NavigationDrawerFragment : DialogFragment() {
}, RxErrorHandler.handleEmptyError()))
subscriptions?.add(userRepository.getUser().subscribe(Consumer {
setUsername(it.profile?.name)
setDisplayName(it.profile?.name)
avatarView.setAvatar(it)
questMenuView.configure(it)
}, RxErrorHandler.handleEmptyError()))
@ -354,7 +354,7 @@ class NavigationDrawerFragment : DialogFragment() {
adapter.updateItem(item)
}
fun setUsername(name: String?) {
fun setDisplayName(name: String?) {
if (toolbarTitle != null) {
if (name != null && name.isNotEmpty()) {
toolbarTitle.text = name
@ -364,6 +364,15 @@ class NavigationDrawerFragment : DialogFragment() {
}
}
fun setUsername(name: String?) {
if (usernameTextView != null) {
usernameTextView.text = name
usernameTextView.visibility = View.VISIBLE
} else {
usernameTextView.visibility = View.GONE
}
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition)

View file

@ -10,7 +10,6 @@ import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.support.v7.preference.Preference
import android.support.v7.preference.PreferenceScreen
import com.habitrpg.android.habitica.HabiticaApplication
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.data.InventoryRepository
@ -198,10 +197,12 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
}
"audioTheme" -> {
val newAudioTheme = sharedPreferences.getString(key, "off")
userRepository.updateUser(user, "preferences.sound", newAudioTheme)
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
soundManager.soundTheme = newAudioTheme
soundManager.preloadAllFiles()
if (newAudioTheme != null) {
compositeSubscription.add(userRepository.updateUser(user, "preferences.sound", newAudioTheme)
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
soundManager.soundTheme = newAudioTheme
soundManager.preloadAllFiles()
}
}
"dailyDueDefaultView" -> userRepository.updateUser(user, "preferences.dailyDueDefaultView", sharedPreferences.getBoolean(key, false))
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())

View file

@ -84,7 +84,7 @@ class ChatListFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
if (savedInstanceState.containsKey("userId")) {
this.userId = savedInstanceState.getString("userId")
if (this.userId != null) {
userRepository.getUser().subscribe(Consumer { habitRPGUser -> this.user = habitRPGUser }, RxErrorHandler.handleEmptyError())
compositeSubscription.add(userRepository.getUser().subscribe(Consumer { habitRPGUser -> this.user = habitRPGUser }, RxErrorHandler.handleEmptyError()))
}
}
@ -113,7 +113,7 @@ class ChatListFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
recyclerView.layoutManager = layoutManager
}
chatAdapter = ChatRecyclerViewAdapter(null, true, user, true)
chatAdapter = ChatRecyclerViewAdapter(null, true, user, true, configManager.enableUsernameRelease())
chatAdapter.notNull {adapter ->
compositeSubscription.add(adapter.getUserLabelClickFlowable().subscribe(Consumer { userId ->
context.notNull { FullProfileActivity.open(it, userId) }
@ -148,7 +148,7 @@ class ChatListFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener {
}
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
isScrolledToTop = layoutManager?.findFirstVisibleItemPosition() == 0
}

View file

@ -19,10 +19,13 @@ import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.models.social.ChatMessage
import com.habitrpg.android.habitica.modules.AppModule
import com.habitrpg.android.habitica.prefs.scanner.IntentIntegrator
import com.habitrpg.android.habitica.ui.AvatarView
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
import com.habitrpg.android.habitica.ui.helpers.KeyboardUtil
import com.habitrpg.android.habitica.ui.views.social.UsernameLabel
import io.reactivex.functions.Consumer
import io.realm.RealmResults
import kotlinx.android.synthetic.main.activity_login.*
import kotlinx.android.synthetic.main.fragment_inbox.*
import javax.inject.Inject
import javax.inject.Named
@ -33,14 +36,18 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
lateinit var socialRepository: SocialRepository
@field:[Inject Named(AppModule.NAMED_USER_ID)]
lateinit var userId: String
@Inject
lateinit var configManager: RemoteConfigManager
private var chooseRecipientDialogView: View? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
hideToolbar()
disableToolbarScrolling()
super.onCreateView(inflater, container, savedInstanceState)
this.socialRepository.markPrivateMessagesRead(user).subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
compositeSubscription.add(this.socialRepository.markPrivateMessagesRead(user).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
return inflater.inflate(R.layout.fragment_inbox, container, false)
}
@ -54,9 +61,9 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
}
private fun loadMessages() {
userRepository.getInboxOverviewList().subscribe(Consumer<RealmResults<ChatMessage>> {
compositeSubscription.add(userRepository.getInboxOverviewList().subscribe(Consumer<RealmResults<ChatMessage>> {
setInboxMessages(it)
}, RxErrorHandler.handleEmptyError())
}, RxErrorHandler.handleEmptyError()))
}
override fun onDestroy() {
@ -85,8 +92,6 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
assert(this.activity != null)
this.chooseRecipientDialogView = this.activity?.layoutInflater?.inflate(R.layout.dialog_choose_message_recipient, null)
val scaneQRCodeButton = chooseRecipientDialogView?.findViewById<View>(R.id.scanQRCodeButton) as? Button
this.activity.notNull { thisActivity ->
val alert = AlertDialog.Builder(thisActivity)
.setTitle(getString(R.string.choose_recipient_title))
@ -99,10 +104,6 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
dialog.cancel()
}
.create()
scaneQRCodeButton?.setOnClickListener {
val scanIntegrator = IntentIntegrator(getActivity())
scanIntegrator.initiateScan(this)
}
alert.setView(chooseRecipientDialogView)
alert.show()
}
@ -115,10 +116,10 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
override fun onRefresh() {
inbox_refresh_layout.isRefreshing = true
this.userRepository.retrieveInboxMessages()
compositeSubscription.add(this.userRepository.retrieveInboxMessages()
.subscribe(Consumer<List<ChatMessage>> {
inbox_refresh_layout.isRefreshing = false
}, RxErrorHandler.handleEmptyError())
}, RxErrorHandler.handleEmptyError()))
}
private fun setInboxMessages(messages: RealmResults<ChatMessage>) {
@ -128,13 +129,28 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
inbox_messages.removeAllViewsInLayout()
val inflater = context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val inflater = context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
if (messages.isNotEmpty()) {
for (message in messages) {
val entry = inflater.inflate(R.layout.plain_list_item, inbox_messages, false) as TextView
entry.text = message.user
entry.tag = message.uuid
entry.setOnClickListener(this)
val entry = inflater?.inflate(R.layout.item_inbox_overview, inbox_messages, false)
val avatarView = entry?.findViewById(R.id.avatar_view) as? AvatarView
message.userStyles?.let { avatarView?.setAvatar(it) }
val displayNameTextView = entry?.findViewById(R.id.display_name_textview) as? UsernameLabel
displayNameTextView?.username = message.user
displayNameTextView?.tier = message.contributor?.level ?: 0
val timestampTextView = entry?.findViewById(R.id.timestamp_textview) as? TextView
timestampTextView?.text = message.getAgoString(resources)
val usernameTextView = entry?.findViewById(R.id.username_textview) as? TextView
if (configManager.enableUsernameRelease() && message.username != null) {
usernameTextView?.text = message.formattedUsername
usernameTextView?.visibility = View.VISIBLE
} else {
usernameTextView?.visibility = View.GONE
}
val messageTextView = entry?.findViewById(R.id.message_textview) as? TextView
messageTextView?.text = message.text
entry?.tag = message.uuid
entry?.setOnClickListener(this)
inbox_messages.addView(entry)
}
} else {
@ -144,9 +160,9 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
}
override fun onClick(v: View) {
val entry = v as TextView
val replyToUserName = entry.text.toString()
openInboxMessages(entry.tag.toString(), replyToUserName)
val displaynameView = v.findViewById(R.id.display_name_textview) as? UsernameLabel
val replyToUserName = displaynameView?.username ?: ""
openInboxMessages(v.tag.toString(), replyToUserName)
}
private fun openInboxMessages(userID: String, username: String) {
@ -155,25 +171,6 @@ class InboxFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefreshListener,
this.activity?.displayFragment(inboxMessageListFragment)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
if (scanningResult != null && scanningResult.contents != null) {
if (this.chooseRecipientDialogView != null) {
val uuidEditText = this.chooseRecipientDialogView?.findViewById<View>(R.id.uuidEditText) as EditText
val qrCodeUrl = scanningResult.contents
val uri = Uri.parse(qrCodeUrl)
if (uri == null || uri.pathSegments.size < 3) {
return
}
val userID = uri.pathSegments[2]
uuidEditText.setText(userID)
}
}
}
override fun customTitle(): String {
return if (!isAdded) {
""

View file

@ -59,7 +59,7 @@ class InboxMessageListFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefres
val layoutManager = LinearLayoutManager(this.getActivity())
recyclerView.layoutManager = layoutManager
chatAdapter = ChatRecyclerViewAdapter(null, true, user, false)
chatAdapter = ChatRecyclerViewAdapter(null, true, user, false, configManager.enableUsernameRelease())
recyclerView.adapter = chatAdapter
recyclerView.itemAnimator = SafeDefaultItemAnimator()
chatAdapter.notNull { adapter ->
@ -71,7 +71,6 @@ class InboxMessageListFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefres
compositeSubscription.add(adapter.getCopyMessageFlowable().subscribe(Consumer { this.copyMessageToClipboard(it) }, RxErrorHandler.handleEmptyError()))
}
chatBarView.sendAction = { sendMessage(it) }
chatBarView.maxChatLength = configManager.maxChatLength()
@ -90,9 +89,9 @@ class InboxMessageListFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefres
private fun loadMessages() {
if (user?.isManaged == true) {
userRepository.getInboxMessages(replyToUserUUID)
compositeSubscription.add(userRepository.getInboxMessages(replyToUserUUID)
.firstElement()
.subscribe(Consumer { this.chatAdapter?.updateData(it) }, RxErrorHandler.handleEmptyError())
.subscribe(Consumer { this.chatAdapter?.updateData(it) }, RxErrorHandler.handleEmptyError()))
}
}
@ -113,12 +112,12 @@ class InboxMessageListFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefres
private fun refreshUserInbox() {
this.swipeRefreshLayout?.isRefreshing = true
this.userRepository.retrieveUser(true)
compositeSubscription.add(this.userRepository.retrieveUser(true)
.subscribe(Consumer<User> {
user = it
}, RxErrorHandler.handleEmptyError(), Action {
swipeRefreshLayout?.isRefreshing = false
})
}))
}
override fun onRefresh() {
@ -126,8 +125,8 @@ class InboxMessageListFragment : BaseMainFragment(), SwipeRefreshLayout.OnRefres
}
private fun sendMessage(chatText: String) {
replyToUserUUID?.notNull {
socialRepository.postPrivateMessage(it, chatText)
replyToUserUUID?.notNull {userID ->
socialRepository.postPrivateMessage(userID, chatText)
.subscribe(Consumer { this.refreshUserInbox() }, RxErrorHandler.handleEmptyError())
KeyboardUtil.dismissKeyboard(getActivity())
}

View file

@ -94,8 +94,8 @@ class TavernDetailFragment : BaseFragment() {
compositeSubscription.add(socialRepository.getGroup(Group.TAVERN_ID)
.filter { it.hasActiveQuest }
.doOnNext { descriptionView.setText(R.string.tavern_description_world_boss) }
.filter { it.quest?.rageStrikes?.any { it.key == "tavern" } ?: false }
.filter { it.quest?.rageStrikes?.filter { it.key == "tavern" }?.get(0)?.wasHit == true }
.filter { group -> group.quest?.rageStrikes?.any { it.key == "tavern" } ?: false }
.filter { group -> group.quest?.rageStrikes?.filter { it.key == "tavern" }?.get(0)?.wasHit == true }
.subscribe(Consumer {
val key = it.quest?.key
if (key != null) {
@ -103,7 +103,7 @@ class TavernDetailFragment : BaseFragment() {
}
}, RxErrorHandler.handleEmptyError()))
socialRepository.retrieveGroup(Group.TAVERN_ID).subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
compositeSubscription.add(socialRepository.retrieveGroup(Group.TAVERN_ID).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
user.notNull { questProgressView.configure(it) }
}
@ -116,8 +116,8 @@ class TavernDetailFragment : BaseFragment() {
}
private fun bindButtons() {
innButton.setOnClickListener {
user?.notNull { userRepository.sleep(it).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()) }
innButton.setOnClickListener { _ ->
user?.notNull { user -> userRepository.sleep(user).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()) }
}
guidelinesButton.setOnClickListener {
val i = Intent(Intent.ACTION_VIEW)

View file

@ -98,8 +98,8 @@ open class TaskRecyclerViewFragment : BaseFragment(), View.OnClickListener, Swip
}
private fun allowReordering() {
val itemTouchHelper = ItemTouchHelper(mItemTouchCallback)
itemTouchHelper.attachToRecyclerView(recyclerView)
val itemTouchHelper = mItemTouchCallback?.let { ItemTouchHelper(it) }
itemTouchHelper?.attachToRecyclerView(recyclerView)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -149,7 +149,7 @@ open class TaskRecyclerViewFragment : BaseFragment(), View.OnClickListener, Swip
override fun isLongPressDragEnabled(): Boolean = true
override fun clearView(recyclerView: RecyclerView?, viewHolder: RecyclerView.ViewHolder) {
override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
super.clearView(recyclerView, viewHolder)
refreshLayout?.isEnabled = true
@ -209,7 +209,7 @@ open class TaskRecyclerViewFragment : BaseFragment(), View.OnClickListener, Swip
refreshLayout.setOnRefreshListener(this)
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
refreshLayout?.isEnabled = (activity as MainActivity).isAppBarExpanded

View file

@ -694,4 +694,18 @@ public class HabiticaIconsHelper {
return imageOfAlertIcon;
}
private static Bitmap imageOfBuffIcon = null;
public static Bitmap imageOfBuffIcon() {
if (imageOfBuffIcon != null)
return imageOfBuffIcon;
int size = scaleSize(15);
imageOfBuffIcon = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfBuffIcon);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawBuffIcon(canvas);
return imageOfBuffIcon;
}
}

View file

@ -15,7 +15,7 @@ import com.habitrpg.android.habitica.ui.helpers.bindView
import java.math.RoundingMode
import java.text.NumberFormat
class ValueBar(context: Context?, attrs: AttributeSet?) : FrameLayout(context, attrs) {
class ValueBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) {
private val iconView: ImageView by bindView(R.id.ic_header)
private val secondaryIconView: ImageView by bindView(R.id.secondaryIconView)

View file

@ -89,7 +89,7 @@ public abstract class TaskListWidgetProvider extends BaseWidgetProvider {
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_task_list);
rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent);
rv.setEmptyView(R.id.list, R.id.emptyView);
rv.setEmptyView(R.id.list_view, R.id.emptyView);
rv.setTextViewText(R.id.widget_title, context.getString(getTitleResId()));
// if the user click on the title: open App

View file

@ -1,8 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.60'
ext.build_tools_version = '27.0.3'
ext.kotlin_version = '1.2.71'
ext.build_tools_version = '28.0.3'
ext.sdk_version = 28
repositories {
@ -11,7 +11,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:4.0.1'
classpath "io.realm:realm-gradle-plugin:5.3.1"

View file

@ -1,6 +1,6 @@
#Thu Jul 05 12:18:36 CEST 2018
#Mon Oct 15 18:23:38 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

View file

@ -1,13 +1,9 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.8.0'
}
}
repositories {
@ -70,16 +66,6 @@ dependencies {
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:robolectric:3.3.2"
testImplementation "org.robolectric:robolectric:3.8"
testImplementation "org.robolectric:shadows-multidex:3.8"
}
publish {
userOrg = 'seedsinc'
groupId = 'com.playseeds'
artifactId = 'android-sdk'
version = '0.4.2'
description = 'Android SDK for Seeds mobile analytics'
website = 'https://github.com/therealseeds/seeds-sdk-android'
}