Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
PixelDroid
PixelDroid
Commits
69a3927e
Commit
69a3927e
authored
Oct 05, 2020
by
Matthieu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'upload_fix' into 'master'
Fix upload adding error Closes
#257
See merge request
!252
parents
9ed4f3b2
96fd086c
Pipeline
#145
failed with stage
in 2 minutes and 44 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
18 deletions
+18
-18
app/build.gradle
app/build.gradle
+2
-2
app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt
app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt
+15
-16
app/src/main/res/layout/activity_post_creation.xml
app/src/main/res/layout/activity_post_creation.xml
+1
-0
No files found.
app/build.gradle
View file @
69a3927e
...
...
@@ -23,8 +23,8 @@ android {
applicationId
"com.h.pixeldroid"
minSdkVersion
23
targetSdkVersion
29
versionCode
4
versionName
"1.0.alpha4"
versionCode
5
versionName
"1.0.alpha4
.1
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments
clearPackageData:
'true'
...
...
app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt
View file @
69a3927e
...
...
@@ -16,7 +16,7 @@ import androidx.core.net.toFile
import
androidx.recyclerview.widget.GridLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.bumptech.glide.Glide
import
com.google.android.material.textfield.TextInput
EditTex
t
import
com.google.android.material.textfield.TextInput
Layou
t
import
com.h.pixeldroid.api.PixelfedAPI
import
com.h.pixeldroid.db.AppDatabase
import
com.h.pixeldroid.db.UserDatabaseEntity
...
...
@@ -58,9 +58,6 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
private
var
posts
:
ArrayList
<
String
>
=
ArrayList
()
private
var
maxLength
:
Int
=
Instance
.
DEFAULT_MAX_TOOT_CHARS
private
var
description
:
String
=
""
@Inject
lateinit
var
db
:
AppDatabase
...
...
@@ -86,7 +83,10 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
user
=
db
.
userDao
().
getActiveUser
()
val
instances
=
db
.
instanceDao
().
getAll
()
maxLength
=
if
(
user
!=
null
){
val
textField
=
findViewById
<
TextInputLayout
>(
R
.
id
.
postTextInputLayout
)
textField
.
counterMaxLength
=
if
(
user
!=
null
){
val
thisInstances
=
instances
.
filter
{
instanceDatabaseEntity
->
instanceDatabaseEntity
.
uri
.
contains
(
user
!!
.
instance_uri
)
...
...
@@ -115,7 +115,7 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
// get the description and send the post
findViewById
<
Button
>(
R
.
id
.
post_creation_send_button
).
setOnClickListener
{
if
(
set
Description
()
&&
muListOfIds
.
isNotEmpty
())
post
()
if
(
validate
Description
()
&&
muListOfIds
.
isNotEmpty
())
post
()
}
// Button to retry image upload when it fails
...
...
@@ -127,16 +127,14 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
}
}
private
fun
set
Description
():
Boolean
{
val
textField
=
findViewById
<
TextInput
EditTex
t
>(
R
.
id
.
new_post_description_input_field
)
val
content
=
textField
.
text
.
toString
()
if
(
content
.
length
>
m
axLength
)
{
private
fun
validate
Description
():
Boolean
{
val
textField
=
findViewById
<
TextInput
Layou
t
>(
R
.
id
.
postTextInputLayout
)
val
content
=
textField
.
editText
?.
length
()
?:
0
if
(
content
>
textField
.
counterM
axLength
)
{
// error, too many characters
textField
.
error
=
getString
(
R
.
string
.
description_max_characters
).
format
(
m
axLength
)
textField
.
error
=
getString
(
R
.
string
.
description_max_characters
).
format
(
textField
.
counterM
axLength
)
return
false
}
// store the description
description
=
content
return
true
}
...
...
@@ -224,6 +222,7 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
}
private
fun
post
()
{
val
description
=
new_post_description_input_field
.
text
.
toString
()
enableButton
(
false
)
pixelfedAPI
.
postStatus
(
authorization
=
"Bearer $accessToken"
,
...
...
@@ -285,7 +284,7 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
progressList
[
positionResult
]
=
0
upload
(
editedImage
=
positionResult
)
}
else
if
(
resultCode
==
Activity
.
RESULT_CANCELED
){
Toast
.
makeText
(
applicationContext
,
"Editing cancel
l
ed"
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
applicationContext
,
"Editing canceled"
,
Toast
.
LENGTH_SHORT
).
show
()
}
else
{
Toast
.
makeText
(
applicationContext
,
"Error while editing"
,
Toast
.
LENGTH_SHORT
).
show
()
}
...
...
@@ -297,12 +296,12 @@ class PostCreationActivity : AppCompatActivity(), PostCreationListener {
val
imageUri
:
String
=
data
.
clipData
!!
.
getItemAt
(
i
).
uri
.
toString
()
posts
.
add
(
imageUri
)
progressList
.
add
(
0
)
muListOfIds
.
add
(
i
,
""
)
muListOfIds
.
add
(
""
)
}
adapter
.
notifyDataSetChanged
()
upload
(
newImagesStartingIndex
=
posts
.
size
-
count
)
}
else
if
(
resultCode
==
Activity
.
RESULT_CANCELED
){
Toast
.
makeText
(
applicationContext
,
"Adding images"
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
applicationContext
,
"Adding images
canceled
"
,
Toast
.
LENGTH_SHORT
).
show
()
}
else
{
Toast
.
makeText
(
applicationContext
,
"Error while adding images"
,
Toast
.
LENGTH_SHORT
).
show
()
}
...
...
app/src/main/res/layout/activity_post_creation.xml
View file @
69a3927e
...
...
@@ -114,6 +114,7 @@
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:hint=
"@string/description"
app:counterEnabled=
"true"
android:paddingStart=
"15dp"
android:paddingEnd=
"15dp"
android:textColorHint=
"@color/colorPrimaryTab"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment