@@ -27,6 +27,10 @@ public class CandidatesView extends LinearLayout
2727 set to [GONE] when there are less than [NUM_CANDIDATES] suggestions. */
2828 TextView [] _item_views = new TextView [NUM_CANDIDATES ];
2929
30+ /** Optional view showing a message to the user. Visible when no candidates
31+ are shown. Might be [null]. */
32+ View _status_no_dict = null ; // Dictionary not installed
33+
3034 public CandidatesView (Context context , AttributeSet attrs )
3135 {
3236 super (context , attrs );
@@ -63,6 +67,36 @@ public void set_candidates(List<String> suggestions)
6367 }
6468 }
6569
70+ /** Refresh the status messages after a configuration refresh. The status
71+ message indicates whether the dictionaries should be installed. */
72+ public void refresh_status ()
73+ {
74+ set_candidates (Suggestions .NO_SUGGESTIONS );
75+ _status_no_dict = inflate_and_show (_status_no_dict ,
76+ (_config .current_dictionary == null ),
77+ R .layout .candidates_status_no_dict );
78+ }
79+
80+ /** Show or hide a status view and inflate it if needed. */
81+ View inflate_and_show (View v , boolean show , int layout_id )
82+ {
83+ if (!show )
84+ {
85+ if (v != null )
86+ v .setVisibility (View .GONE );
87+ }
88+ else
89+ {
90+ if (v == null )
91+ {
92+ v = View .inflate (getContext (), layout_id , null );
93+ addView (v );
94+ }
95+ v .setVisibility (View .VISIBLE );
96+ }
97+ return v ;
98+ }
99+
66100 private void setup_item_view (final int item_index , int item_id )
67101 {
68102 TextView v = (TextView )findViewById (item_id );
@@ -80,6 +114,7 @@ public void onClick(View _v)
80114 _item_views [item_index ] = v ;
81115 }
82116
117+ /** Whether the candidates view should be shown for a given editor. */
83118 public static boolean should_show (EditorInfo info )
84119 {
85120 int variation = info .inputType & InputType .TYPE_MASK_VARIATION ;
0 commit comments