Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
f46fef0f
Commit
f46fef0f
authored
May 05, 2018
by
Divyanshu Bhargava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved draw code quality
parent
b4971649
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
58 deletions
+15
-58
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+11
-10
CustomDrawView.kt
...in/java/chat/rocket/android/widget/draw/CustomDrawView.kt
+0
-2
Line.kt
app/src/main/java/chat/rocket/android/widget/draw/Line.kt
+1
-22
Move.kt
app/src/main/java/chat/rocket/android/widget/draw/Move.kt
+1
-9
PaintOptions.kt
...main/java/chat/rocket/android/widget/draw/PaintOptions.kt
+1
-2
Quad.kt
app/src/main/java/chat/rocket/android/widget/draw/Quad.kt
+1
-13
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
f46fef0f
...
@@ -662,8 +662,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -662,8 +662,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
image_send_drawing
.
setOnClickListener
{
image_send_drawing
.
setOnClickListener
{
if
(!
canWriteToExternalStorage
())
{
if
(!
canWriteToExternalStorage
())
{
checkWritingPermission
()
checkWritingPermission
()
return
@setOnClickListener
}
else
{
}
val
bitmap
=
custom_draw_view
.
getBitmap
()
val
bitmap
=
custom_draw_view
.
getBitmap
()
val
uri
=
saveImage
(
bitmap
)
val
uri
=
saveImage
(
bitmap
)
if
(
uri
!=
null
)
{
if
(
uri
!=
null
)
{
...
@@ -671,6 +670,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -671,6 +670,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
drawDialog
.
dismiss
()
drawDialog
.
dismiss
()
}
}
}
image_close_drawing
.
setOnClickListener
{
image_close_drawing
.
setOnClickListener
{
drawDialog
.
dismiss
()
drawDialog
.
dismiss
()
}
}
...
@@ -836,14 +836,15 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -836,14 +836,15 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
private
fun
canWriteToExternalStorage
():
Boolean
{
private
fun
canWriteToExternalStorage
():
Boolean
{
return
AndroidPermissionsHelper
.
checkPermission
(
activity
!!
.
applicationContext
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
return
context
?.
let
{
AndroidPermissionsHelper
.
checkPermission
(
it
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
}
!!
}
}
private
fun
checkWritingPermission
()
{
private
fun
checkWritingPermission
()
{
AndroidPermissionsHelper
.
requestPermission
(
this
.
activity
!!
,
activity
?.
let
{
AndroidPermissionsHelper
.
requestPermission
(
it
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
AndroidPermissionsHelper
.
WRITE_EXTERNAL_STORAGE_CODE
)
AndroidPermissionsHelper
.
WRITE_EXTERNAL_STORAGE_CODE
)
Timber
.
e
(
"checkWritingPermission"
)
}
}
}
private
fun
setupSuggestionsView
()
{
private
fun
setupSuggestionsView
()
{
...
...
app/src/main/java/chat/rocket/android/widget/draw/CustomDrawView.kt
View file @
f46fef0f
...
@@ -65,8 +65,6 @@ class CustomDrawView(context: Context, attrs: AttributeSet) : View(context, attr
...
@@ -65,8 +65,6 @@ class CustomDrawView(context: Context, attrs: AttributeSet) : View(context, attr
val
lastKey
=
mUndonePaths
.
keys
.
last
()
val
lastKey
=
mUndonePaths
.
keys
.
last
()
addPath
(
lastKey
,
mUndonePaths
.
values
.
last
())
addPath
(
lastKey
,
mUndonePaths
.
values
.
last
())
mUndonePaths
.
remove
(
lastKey
)
mUndonePaths
.
remove
(
lastKey
)
if
(
mUndonePaths
.
isEmpty
())
{
}
invalidate
()
invalidate
()
}
}
...
...
app/src/main/java/chat/rocket/android/widget/draw/Line.kt
View file @
f46fef0f
...
@@ -4,28 +4,7 @@ import android.graphics.Path
...
@@ -4,28 +4,7 @@ import android.graphics.Path
import
java.io.Writer
import
java.io.Writer
import
java.security.InvalidParameterException
import
java.security.InvalidParameterException
class
Line
:
Action
{
class
Line
(
val
x
:
Float
,
val
y
:
Float
)
:
Action
{
val
x
:
Float
val
y
:
Float
constructor
(
data
:
String
)
{
if
(!
data
.
startsWith
(
"L"
))
throw
InvalidParameterException
(
"The Line data should start with 'L'."
)
try
{
val
xy
=
data
.
substring
(
1
).
split
(
","
.
toRegex
()).
dropLastWhile
(
String
::
isEmpty
).
toTypedArray
()
x
=
xy
[
0
].
trim
().
toFloat
()
y
=
xy
[
1
].
trim
().
toFloat
()
}
catch
(
ignored
:
Exception
)
{
throw
InvalidParameterException
(
"Error parsing the given Line data."
)
}
}
constructor
(
x
:
Float
,
y
:
Float
)
{
this
.
x
=
x
this
.
y
=
y
}
override
fun
perform
(
path
:
Path
)
{
override
fun
perform
(
path
:
Path
)
{
path
.
lineTo
(
x
,
y
)
path
.
lineTo
(
x
,
y
)
...
...
app/src/main/java/chat/rocket/android/widget/draw/Move.kt
View file @
f46fef0f
...
@@ -4,15 +4,7 @@ import android.graphics.Path
...
@@ -4,15 +4,7 @@ import android.graphics.Path
import
java.io.Writer
import
java.io.Writer
import
java.security.InvalidParameterException
import
java.security.InvalidParameterException
class
Move
:
Action
{
class
Move
(
val
x
:
Float
,
val
y
:
Float
)
:
Action
{
val
x
:
Float
val
y
:
Float
constructor
(
x
:
Float
,
y
:
Float
)
{
this
.
x
=
x
this
.
y
=
y
}
override
fun
perform
(
path
:
Path
)
{
override
fun
perform
(
path
:
Path
)
{
path
.
moveTo
(
x
,
y
)
path
.
moveTo
(
x
,
y
)
...
...
app/src/main/java/chat/rocket/android/widget/draw/PaintOptions.kt
View file @
f46fef0f
...
@@ -2,5 +2,4 @@ package chat.rocket.android.widget.draw
...
@@ -2,5 +2,4 @@ package chat.rocket.android.widget.draw
import
android.graphics.Color
import
android.graphics.Color
data class
PaintOptions
(
var
color
:
Int
=
Color
.
BLACK
,
var
strokeWidth
:
Float
=
8f
,
var
alpha
:
Int
=
255
)
{
data class
PaintOptions
(
var
color
:
Int
=
Color
.
BLACK
,
var
strokeWidth
:
Float
=
8f
,
var
alpha
:
Int
=
255
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/widget/draw/Quad.kt
View file @
f46fef0f
...
@@ -3,19 +3,7 @@ package chat.rocket.android.widget.draw
...
@@ -3,19 +3,7 @@ package chat.rocket.android.widget.draw
import
android.graphics.Path
import
android.graphics.Path
import
java.io.Writer
import
java.io.Writer
class
Quad
:
Action
{
class
Quad
(
val
x1
:
Float
,
val
y1
:
Float
,
val
x2
:
Float
,
val
y2
:
Float
)
:
Action
{
val
x1
:
Float
val
y1
:
Float
val
x2
:
Float
val
y2
:
Float
constructor
(
x1
:
Float
,
y1
:
Float
,
x2
:
Float
,
y2
:
Float
)
{
this
.
x1
=
x1
this
.
y1
=
y1
this
.
x2
=
x2
this
.
y2
=
y2
}
override
fun
perform
(
path
:
Path
)
{
override
fun
perform
(
path
:
Path
)
{
path
.
quadTo
(
x1
,
y1
,
x2
,
y2
)
path
.
quadTo
(
x1
,
y1
,
x2
,
y2
)
...
...
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