Issue 2477: Show account's creation date in Profile. (#2480)

* Show account's creation date in Profile.

* Fix broken test.

* Store account creation date in the Database.

* Reformat and reposition Joined Date according to PR Feedback.

* Revert "Store account creation date in the Database."

This reverts commit d9761f53 as it's not needed.

* Change Account's Creation Date to a java.util.Date.
Update Test.

* Fix wildcard import.

* Show full month instead of an abbreviation.

* Remove `lazy` usage in favor of local instantiation.

Co-authored-by: Martin Marconcini <martin.marconcini.rodriguez@nl.abnamro.com>
Co-authored-by: Konrad Pozniak <connyduck@users.noreply.github.com>
This commit is contained in:
Martin Marconcini 2022-05-17 19:49:42 +02:00 committed by GitHub
parent df49851042
commit d97493d312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 17 deletions

View File

@ -84,6 +84,9 @@ import com.keylesspalace.tusky.view.showMuteAccountDialog
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import java.text.NumberFormat
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Locale
import javax.inject.Inject
import kotlin.math.abs
@ -413,6 +416,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
updateToolbar()
updateMovedAccount()
updateRemoteAccount()
updateAccountJoinedDate()
updateAccountStats()
invalidateOptionsMenu()
@ -422,6 +426,20 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
}
}
private fun updateAccountJoinedDate() {
loadedAccount?.let { account ->
try {
binding.accountDateJoined.text = resources.getString(
R.string.account_date_joined,
SimpleDateFormat("MMMM, yyyy", Locale.getDefault()).format(account.createdAt)
)
binding.accountDateJoined.visibility = View.VISIBLE
} catch (e: ParseException) {
binding.accountDateJoined.visibility = View.GONE
}
}
}
/**
* Load account's avatar and header image
*/

View File

@ -23,6 +23,7 @@ data class Account(
@SerializedName("username") val localUsername: String,
@SerializedName("acct") val username: String,
@SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract
@SerializedName("created_at") val createdAt: Date,
val note: String,
val url: String,
val avatar: String,

View File

@ -235,6 +235,19 @@
tools:itemCount="2"
tools:listitem="@layout/item_account_field" />
<TextView
android:id="@+id/accountDateJoined"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
tools:text="April, 1971"
android:textColor="@color/textColorSecondary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/accountFieldList"
app:layout_constraintBottom_toTopOf="@id/accountRemoveView"/>
<TextView
android:id="@+id/accountRemoveView"
android:layout_width="match_parent"
@ -245,7 +258,7 @@
android:lineSpacingMultiplier="1.1"
android:text="@string/label_remote_account"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/accountFieldList"
app:layout_constraintTop_toBottomOf="@id/accountDateJoined"
tools:visibility="visible" />
<androidx.constraintlayout.widget.ConstraintLayout

View File

@ -643,10 +643,14 @@
<string name="action_unsubscribe_account">Unsubscribe</string>
<string name="tusky_compose_post_quicksetting_label">Compose Post</string>
<string name="account_date_joined">Joined %1$s</string>
<string name="saving_draft">Saving draft…</string>
<string name="tips_push_notification_migration">Re-login all accounts to enable push notification support.</string>
<string name="dialog_push_notification_migration">In order to use push notifications via UnifiedPush, Tusky needs permission to subscribe to notifications on your Mastodon server. This requires a re-login to change the OAuth scopes granted to Tusky. Using the re-login option here or in Account Preferences will preserve all of your local drafts and cache.</string>
<string name="dialog_push_notification_migration_other_accounts">You have re-logged into your current account to grant push subscription permission to Tusky. However, you still have other accounts that have not been migrated this way. Switch to them and re-login one by one in order to enable UnifiedPush notifications support.</string>
</resources>

View File

@ -47,6 +47,8 @@ import org.robolectric.Robolectric
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.fakes.RoboMenuItem
import java.util.Date
import kotlin.collections.HashMap
/**
* Created by charlag on 3/7/18.
@ -466,22 +468,23 @@ class ComposeActivityTest {
null,
listOf("en"),
Account(
"1",
"admin",
"admin",
"admin",
"",
"https://example.token",
"",
"",
false,
0,
0,
0,
null,
false,
emptyList(),
emptyList()
id = "1",
localUsername = "admin",
username = "admin",
displayName = "admin",
createdAt = Date(),
note = "",
url = "https://example.token",
avatar = "",
header = "",
locked = false,
statusesCount = 0,
followersCount = 0,
followingCount = 0,
source = null,
bot = false,
emojis = emptyList(),
fields = emptyList(),
),
maximumLegacyTootCharacters,
null,