Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
briar
briar
Commits
ff76900d
Commit
ff76900d
authored
6 years ago
by
Torsten Grote
Browse files
Options
Downloads
Plain Diff
Merge branch '1609-trimmed-text-length' into 'master'
Use trimmed length when deciding whether text is empty Closes
#1609
See merge request
!1153
parents
53fe3e15
7d62ae5f
No related branches found
No related tags found
1 merge request
!1153
Use trimmed length when deciding whether text is empty
Pipeline
#3657
passed
6 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/main/java/org/briarproject/briar/android/view/EmojiTextInputView.java
+21
-7
21 additions, 7 deletions
...g/briarproject/briar/android/view/EmojiTextInputView.java
with
21 additions
and
7 deletions
briar-android/src/main/java/org/briarproject/briar/android/view/EmojiTextInputView.java
+
21
−
7
View file @
ff76900d
...
@@ -28,6 +28,7 @@ import static android.content.Context.LAYOUT_INFLATER_SERVICE;
...
@@ -28,6 +28,7 @@ import static android.content.Context.LAYOUT_INFLATER_SERVICE;
import
static
android
.
view
.
KeyEvent
.
KEYCODE_ENTER
;
import
static
android
.
view
.
KeyEvent
.
KEYCODE_ENTER
;
import
static
android
.
view
.
inputmethod
.
EditorInfo
.
IME_ACTION_SEND
;
import
static
android
.
view
.
inputmethod
.
EditorInfo
.
IME_ACTION_SEND
;
import
static
android
.
view
.
inputmethod
.
InputMethodManager
.
SHOW_IMPLICIT
;
import
static
android
.
view
.
inputmethod
.
InputMethodManager
.
SHOW_IMPLICIT
;
import
static
java
.
lang
.
Character
.
isWhitespace
;
import
static
java
.
util
.
Objects
.
requireNonNull
;
import
static
java
.
util
.
Objects
.
requireNonNull
;
import
static
org
.
briarproject
.
bramble
.
util
.
StringUtils
.
utf8IsTooLong
;
import
static
org
.
briarproject
.
bramble
.
util
.
StringUtils
.
utf8IsTooLong
;
...
@@ -125,19 +126,31 @@ public class EmojiTextInputView extends KeyboardAwareLinearLayout implements
...
@@ -125,19 +126,31 @@ public class EmojiTextInputView extends KeyboardAwareLinearLayout implements
@Override
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
int
count
)
{
// Need to start at position 0 to change empty
if
(
emptyTextAllowed
||
listener
==
null
)
return
;
if
(
start
!=
0
||
emptyTextAllowed
||
listener
==
null
)
return
;
// Work out whether the trimmed text has become empty or non-empty
if
(
s
.
length
()
==
0
)
{
if
(
isEmpty
)
{
if
(!
isEmpty
)
{
// We only need to check the characters that were added
if
(
countLeadingWhitespace
(
s
,
start
,
count
)
<
count
)
{
isEmpty
=
false
;
listener
.
onTextIsEmptyChanged
(
false
);
}
}
else
if
(
before
>
0
)
{
// Characters have been removed or replaced - check from the start
int
length
=
s
.
length
();
if
(
countLeadingWhitespace
(
s
,
0
,
length
)
==
length
)
{
isEmpty
=
true
;
isEmpty
=
true
;
listener
.
onTextIsEmptyChanged
(
true
);
listener
.
onTextIsEmptyChanged
(
true
);
}
}
}
else
if
(
isEmpty
)
{
isEmpty
=
false
;
listener
.
onTextIsEmptyChanged
(
false
);
}
}
}
}
private
int
countLeadingWhitespace
(
CharSequence
s
,
int
off
,
int
len
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(!
isWhitespace
(
s
.
charAt
(
off
+
i
)))
return
i
;
}
return
len
;
}
@Override
@Override
public
void
afterTextChanged
(
Editable
s
)
{
public
void
afterTextChanged
(
Editable
s
)
{
}
}
...
@@ -242,6 +255,7 @@ public class EmojiTextInputView extends KeyboardAwareLinearLayout implements
...
@@ -242,6 +255,7 @@ public class EmojiTextInputView extends KeyboardAwareLinearLayout implements
interface
TextInputListener
{
interface
TextInputListener
{
void
onTextIsEmptyChanged
(
boolean
isEmpty
);
void
onTextIsEmptyChanged
(
boolean
isEmpty
);
void
onSendEvent
();
void
onSendEvent
();
}
}
...
...
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