Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
keyboard
LatinIME
Commits
717a8f50
Commit
717a8f50
authored
13 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Use dedicated layout for "touch to save word" feature
Change-Id: Ie8c948476740a645d8b2d9a9d821236941d27adf
parent
7fb04fe0
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
java/res/layout/candidates_strip.xml
+82
-49
82 additions, 49 deletions
java/res/layout/candidates_strip.xml
java/src/com/android/inputmethod/latin/CandidateView.java
+21
-12
21 additions, 12 deletions
java/src/com/android/inputmethod/latin/CandidateView.java
with
103 additions
and
61 deletions
java/res/layout/candidates_strip.xml
+
82
−
49
View file @
717a8f50
...
...
@@ -22,42 +22,10 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:latin=
"http://schemas.android.com/apk/res/com.android.inputmethod.latin"
>
<RelativeLayout
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<include
android:id=
"@+id/word_left"
layout=
"@layout/candidate_word"
/>
<include
android:id=
"@+id/info_left"
layout=
"@layout/candidate_info"
/>
</RelativeLayout>
<include
layout=
"@layout/candidate_divider"
/>
<RelativeLayout
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<include
android:id=
"@+id/word_center"
layout=
"@layout/candidate_word"
/>
<include
android:id=
"@+id/info_center"
layout=
"@layout/candidate_info"
/>
</RelativeLayout>
<include
layout=
"@layout/candidate_divider"
/>
<LinearLayout
android:orientation=
"horizontal"
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:id=
"@+id/candidates_strip"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
>
<RelativeLayout
android:layout_weight=
"1.0"
...
...
@@ -66,24 +34,89 @@
android:gravity=
"center"
>
<include
android:id=
"@+id/word_
righ
t"
android:id=
"@+id/word_
lef
t"
layout=
"@layout/candidate_word"
/>
<include
android:id=
"@+id/info_
righ
t"
android:id=
"@+id/info_
lef
t"
layout=
"@layout/candidate_info"
/>
</RelativeLayout>
<!-- Image drawables are set in CandidateView constructor -->
<ImageButton
android:id=
"@+id/expand_candidates_pane"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
style=
"?attr/suggestionsStripBackgroundStyle"
/>
<ImageButton
android:id=
"@+id/close_candidates_pane"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
style=
"?attr/suggestionsStripBackgroundStyle"
/>
<include
layout=
"@layout/candidate_divider"
/>
<RelativeLayout
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<include
android:id=
"@+id/word_center"
layout=
"@layout/candidate_word"
/>
<include
android:id=
"@+id/info_center"
layout=
"@layout/candidate_info"
/>
</RelativeLayout>
<include
layout=
"@layout/candidate_divider"
/>
<LinearLayout
android:orientation=
"horizontal"
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
>
<RelativeLayout
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<include
android:id=
"@+id/word_right"
layout=
"@layout/candidate_word"
/>
<include
android:id=
"@+id/info_right"
layout=
"@layout/candidate_info"
/>
</RelativeLayout>
<!-- Image drawables are set in CandidateView constructor -->
<ImageButton
android:id=
"@+id/expand_candidates_pane"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
style=
"?attr/suggestionsStripBackgroundStyle"
/>
<ImageButton
android:id=
"@+id/close_candidates_pane"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
style=
"?attr/suggestionsStripBackgroundStyle"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id=
"@+id/touch_to_save"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:visibility=
"gone"
>
<Button
android:id=
"@+id/word_to_save"
android:layout_weight=
"1.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:textSize=
"@dimen/candidate_text_size"
android:singleLine=
"true"
android:ellipsize=
"middle"
style=
"?attr/suggestionBackgroundStyle"
/>
<include
layout=
"@layout/candidate_divider"
/>
<TextView
android:layout_weight=
"2.0"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:gravity=
"left|center_vertical"
android:text=
"@string/hint_add_to_dictionary"
android:textSize=
"@dimen/candidate_text_size"
android:background=
"@null"
/>
</LinearLayout>
</merge>
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/CandidateView.java
+
21
−
12
View file @
717a8f50
...
...
@@ -66,6 +66,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private
static
final
boolean
DBG
=
LatinImeLogger
.
sDBG
;
private
final
View
mCandidatesStrip
;
private
static
final
int
NUM_CANDIDATES_IN_STRIP
=
3
;
private
final
ImageView
mExpandCandidatesPane
;
private
final
ImageView
mCloseCandidatesPane
;
...
...
@@ -88,6 +89,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private
final
PopupWindow
mPreviewPopup
;
private
final
TextView
mPreviewText
;
private
final
View
mTouchToSave
;
private
final
TextView
mWordToSave
;
private
Listener
mListener
;
private
SuggestedWords
mSuggestions
=
SuggestedWords
.
EMPTY
;
private
boolean
mShowingAutoCorrectionInverted
;
...
...
@@ -178,6 +182,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mPreviewPopup
.
setContentView
(
mPreviewText
);
mPreviewPopup
.
setBackgroundDrawable
(
null
);
mCandidatesStrip
=
findViewById
(
R
.
id
.
candidates_strip
);
mCandidateStripHeight
=
res
.
getDimensionPixelOffset
(
R
.
dimen
.
candidate_strip_height
);
for
(
int
i
=
0
;
i
<
MAX_SUGGESTIONS
;
i
++)
{
final
TextView
word
,
info
;
...
...
@@ -213,6 +218,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
}
mTouchToSave
=
findViewById
(
R
.
id
.
touch_to_save
);
mWordToSave
=
(
TextView
)
findViewById
(
R
.
id
.
word_to_save
);
mWordToSave
.
setOnClickListener
(
this
);
final
TypedArray
a
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
CandidateView
,
defStyle
,
R
.
style
.
CandidateViewStyle
);
mAutoCorrectHighlight
=
a
.
getInt
(
R
.
styleable
.
CandidateView_autoCorrectHighlight
,
0
);
...
...
@@ -448,14 +457,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
public
void
showAddToDictionaryHint
(
CharSequence
word
)
{
SuggestedWords
.
Builder
builder
=
new
SuggestedWords
.
Builder
()
.
addWord
(
word
)
.
addWord
(
getContext
().
getText
(
R
.
string
.
hint_add_to_dictionary
));
setSuggestions
(
builder
.
build
());
mWordToSave
.
setText
(
word
);
mShowingAddToDictionary
=
true
;
// Disable R.string.hint_add_to_dictionary button
TextView
tv
=
mWords
.
get
(
1
);
tv
.
setClickable
(
false
);
mCandidatesStrip
.
setVisibility
(
View
.
GONE
);
mTouchToSave
.
setVisibility
(
View
.
VISIBLE
);
}
public
boolean
dismissAddToDictionaryHint
()
{
...
...
@@ -475,6 +480,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mWords
.
get
(
i
).
setText
(
null
);
mInfos
.
get
(
i
).
setVisibility
(
View
.
GONE
);
}
mTouchToSave
.
setVisibility
(
View
.
GONE
);
mCandidatesStrip
.
setVisibility
(
View
.
VISIBLE
);
mCandidatesPane
.
removeAllViews
();
}
...
...
@@ -530,6 +537,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
@Override
public
void
onClick
(
View
view
)
{
if
(
view
==
mWordToSave
)
{
addToDictionary
(((
TextView
)
view
).
getText
());
clear
();
return
;
}
final
Object
tag
=
view
.
getTag
();
if
(!(
tag
instanceof
Integer
))
return
;
...
...
@@ -538,11 +551,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
return
;
final
CharSequence
word
=
mSuggestions
.
getWord
(
index
);
if
(
mShowingAddToDictionary
&&
index
==
0
)
{
addToDictionary
(
word
);
}
else
{
mListener
.
pickSuggestionManually
(
index
,
word
);
}
mListener
.
pickSuggestionManually
(
index
,
word
);
// Because some punctuation letters are not treated as word separator depending on locale,
// {@link #setSuggestions} might not be called and candidates pane left opened.
closeCandidatesPane
();
...
...
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