Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
fba1d969
Commit
fba1d969
authored
1 year ago
by
Pierre Nicolas
Browse files
Options
Downloads
Patches
Plain Diff
chatview: add timestampToDate util method
Change-Id: I2817c9f1322bdc016b11c998f48ff0d1783a275b
parent
b82d30d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
jami-android/app/src/main/java/cx/ring/utils/TextUtils.kt
+33
-0
33 additions, 0 deletions
jami-android/app/src/main/java/cx/ring/utils/TextUtils.kt
jami-android/app/src/main/res/values/strings.xml
+3
-0
3 additions, 0 deletions
jami-android/app/src/main/res/values/strings.xml
with
36 additions
and
0 deletions
jami-android/app/src/main/java/cx/ring/utils/TextUtils.kt
+
33
−
0
View file @
fba1d969
...
...
@@ -72,6 +72,39 @@ object TextUtils {
return
timeStr
.
out
().
toString
().
uppercase
(
Locale
.
getDefault
())
}
/**
* Converts a timestamp into a date.
* May returns terms like 'Today' or 'Yesterday'. In all other cases, the complete date.
*/
fun
timestampToDate
(
context
:
Context
,
formatter
:
Formatter
,
timestamp
:
Long
):
String
{
(
formatter
.
out
()
as
?
StringBuilder
)
?.
setLength
(
0
)
fun
isYesterday
(
timestamp
:
Long
):
Boolean
{
return
DateUtils
.
isToday
(
timestamp
+
DateUtils
.
DAY_IN_MILLIS
)
}
if
(
DateUtils
.
isToday
(
timestamp
))
return
context
.
getString
(
R
.
string
.
today
).
uppercase
()
else
if
(
isYesterday
(
timestamp
))
return
context
.
getString
(
R
.
string
.
yesterday
).
uppercase
()
val
timeStr
:
Formatter
=
DateUtils
.
formatDateRange
(
context
,
formatter
,
timestamp
,
timestamp
,
DateUtils
.
FORMAT_SHOW_DATE
or
DateUtils
.
FORMAT_NO_YEAR
or
DateUtils
.
FORMAT_ABBREV_MONTH
)
return
timeStr
.
out
().
toString
().
uppercase
(
Locale
.
getDefault
())
}
/**
* Converts a timestamp into a time. Don't display the date.
* Example of the output format = 11:32 A.M.
*/
fun
timestampToTime
(
context
:
Context
,
formatter
:
Formatter
,
timestamp
:
Long
):
String
{
(
formatter
.
out
()
as
?
StringBuilder
)
?.
setLength
(
0
)
return
DateUtils
// Example of the format in the message = 11:32 A.M.
.
formatDateRange
(
context
,
formatter
,
timestamp
,
timestamp
,
DateUtils
.
FORMAT_SHOW_TIME
)
.
out
().
toString
().
uppercase
(
Locale
.
getDefault
())
}
fun
getReadableFileTransferStatus
(
context
:
Context
,
transferStatus
:
InteractionStatus
):
String
{
return
when
(
transferStatus
)
{
InteractionStatus
.
TRANSFER_CREATED
->
context
.
getString
(
R
.
string
.
file_transfer_status_created
)
...
...
This diff is collapsed.
Click to expand it.
jami-android/app/src/main/res/values/strings.xml
+
3
−
0
View file @
fba1d969
...
...
@@ -344,6 +344,9 @@ along with this program; if not, write to the Free Software
<string
name=
"conversation_contact_banned"
>
%1$s was banned
</string>
<string
name=
"conversation_search_hint"
>
Search conversation
</string>
<string
name=
"today"
>
Today
</string>
<string
name=
"yesterday"
>
Yesterday
</string>
<!-- Contacts -->
<string
name=
"add_call_contact_number_to_contacts"
>
Add %1$s?
</string>
<string
name=
"prompt_new_password"
>
New password
</string>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment