-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT MERGE] Using TextViewSizeAwareTouchListener with Text views (scaling refactor part 4) #210
[DO NOT MERGE] Using TextViewSizeAwareTouchListener with Text views (scaling refactor part 4) #210
Conversation
…er and added new listener to addText()
You can test the changes on this Pull Request by downloading the APK here. |
@@ -413,11 +415,20 @@ class PhotoEditor private constructor(builder: Builder) : | |||
when (viewType) { | |||
ViewType.TEXT -> { | |||
rootView = layoutInflater.inflate(R.layout.view_photo_editor_text, null) | |||
if (rootView.tvPhotoEditorText != null && mDefaultTextTypeface != null) { | |||
rootView.tvPhotoEditorText.gravity = Gravity.CENTER | |||
val txtTextView = rootView.tvPhotoEditorText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section in the when ()
clause is basically copied from the EMOJI
case except for the mDefaultTextTypeface
which is different from mDefaultEmojiTypeface
. Can possibly try and refactor further.
@@ -381,7 +383,7 @@ class PhotoEditor private constructor(builder: Builder) : | |||
* @param rootView rootview of image,text and emoji | |||
*/ | |||
private fun addViewToParent(rootView: View, viewType: ViewType, sourceUri: Uri? = null) { | |||
if (viewType != EMOJI) { | |||
if (viewType != EMOJI && viewType != TEXT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both EMOJI and TEXT view types use the same AutoResizeTextView
class instead of plain old TextView
so, we need to set a width/height
to start with (instead of wrap_content
), which will later on be adjusted on fontSize
accordingly.
} | ||
txtTextView.gravity = Gravity.CENTER | ||
// txtTextView.setLayerType(View.LAYER_TYPE_SOFTWARE, null) | ||
val maxHeight = parentView.height |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to change as we get #206 merged, and do the same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.onGestureControl = onGestureControl | ||
} | ||
|
||
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SimpleOnGestureListener
gives us the ability to listen to clicks in a distinguishable way mostly. Could simplify and listen to MOVE_UP
events given we're already processing them but, prefer to avoid false positives and rely on the platform mechanism for onClick()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used so we can show the Editor dialog when the user taps on an existing view of type TEXT
.
This one should be ready for review now @aforcier 🙇 |
Builds on top of #209.
Adding the new listener to be used with actual
TextView
s (already used for emoji at this point).In this type of view we also need to detect taps (through
GestureDetector
) so we can open the text editor dialog and fire up the keyboard for editing. 361f418To test:
Bonus test (to make sure other functionality is compatible):
testSticker()
inComposeLoopFrameActivity
, for example: