FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
com.freerdp.freerdpcore.presentation.HomeActivity Class Reference
Inheritance diagram for com.freerdp.freerdpcore.presentation.HomeActivity:
Collaboration diagram for com.freerdp.freerdpcore.presentation.HomeActivity:

Public Member Functions

void onCreate (Bundle savedInstanceState)
 
void onConfigurationChanged (Configuration newConfig)
 
boolean onSearchRequested ()
 
boolean onContextItemSelected (MenuItem aItem)
 
void onBackPressed ()
 
boolean onCreateOptionsMenu (Menu menu)
 
boolean onOptionsItemSelected (MenuItem item)
 

Protected Member Functions

void onResume ()
 
void onPause ()
 
void onSaveInstanceState (Bundle outState)
 
void onRestoreInstanceState (Bundle inState)
 

Detailed Description

Definition at line 49 of file HomeActivity.java.

Member Function Documentation

◆ onBackPressed()

void com.freerdp.freerdpcore.presentation.HomeActivity.onBackPressed ( )
inline

Definition at line 276 of file HomeActivity.java.

277 {
278 // if back was pressed - ask the user if he really wants to exit
279 if (ApplicationSettingsActivity.getAskOnExit(this))
280 {
281 final CheckBox cb = new CheckBox(this);
282 cb.setChecked(!ApplicationSettingsActivity.getAskOnExit(this));
283 cb.setText(R.string.dlg_dont_show_again);
284
285 AlertDialog.Builder builder = new AlertDialog.Builder(this);
286 builder.setTitle(R.string.dlg_title_exit)
287 .setMessage(R.string.dlg_msg_exit)
288 .setView(cb)
289 .setPositiveButton(R.string.yes,
290 new DialogInterface.OnClickListener() {
291 public void onClick(DialogInterface dialog, int which)
292 {
293 finish();
294 }
295 })
296 .setNegativeButton(R.string.no,
297 new DialogInterface.OnClickListener() {
298 public void onClick(DialogInterface dialog, int which)
299 {
300 dialog.dismiss();
301 }
302 })
303 .create()
304 .show();
305 }
306 else
307 {
308 super.onBackPressed();
309 }
310 }

◆ onConfigurationChanged()

void com.freerdp.freerdpcore.presentation.HomeActivity.onConfigurationChanged ( Configuration  newConfig)
inline

Definition at line 175 of file HomeActivity.java.

176 {
177 // ignore orientation/keyboard change
178 super.onConfigurationChanged(newConfig);
179 mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
180 View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
181 }

◆ onContextItemSelected()

boolean com.freerdp.freerdpcore.presentation.HomeActivity.onContextItemSelected ( MenuItem  aItem)
inline

Definition at line 189 of file HomeActivity.java.

190 {
191
192 // get connection reference
193 AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)aItem.getMenuInfo();
194 String refStr = menuInfo.targetView.getTag().toString();
195
196 // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case
197 // here ..
198 int itemId = aItem.getItemId();
199 if (itemId == R.id.bookmark_connect)
200 {
201 Bundle bundle = new Bundle();
202 bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
203 Intent sessionIntent = new Intent(this, SessionActivity.class);
204 sessionIntent.putExtras(bundle);
205
206 startActivity(sessionIntent);
207 return true;
208 }
209 else if (itemId == R.id.bookmark_edit)
210 {
211 Bundle bundle = new Bundle();
212 bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
213
214 Intent bookmarkIntent =
215 new Intent(this.getApplicationContext(), BookmarkActivity.class);
216 bookmarkIntent.putExtras(bundle);
217 startActivity(bookmarkIntent);
218 return true;
219 }
220 else if (itemId == R.id.bookmark_delete)
221 {
222 if (ConnectionReference.isManualBookmarkReference(refStr))
223 {
224 long id = ConnectionReference.getManualBookmarkId(refStr);
225 GlobalApp.getManualBookmarkGateway().delete(id);
226 manualBookmarkAdapter.remove(id);
227 separatedListAdapter.notifyDataSetChanged();
228 }
229 else
230 {
231 assert false;
232 }
233
234 // clear super bar text
235 superBarEditText.setText("");
236 return true;
237 }
238
239 return false;
240 }

◆ onCreate()

void com.freerdp.freerdpcore.presentation.HomeActivity.onCreate ( Bundle  savedInstanceState)
inline

Definition at line 64 of file HomeActivity.java.

65 {
66 setTitle(R.string.title_home);
67 super.onCreate(savedInstanceState);
68 setContentView(R.layout.home);
69
70 mDecor = getWindow().getDecorView();
71 mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
72 View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
73
74 long heapSize = Runtime.getRuntime().maxMemory();
75 Log.i(TAG, "Max HeapSize: " + heapSize);
76 Log.i(TAG, "App data folder: " + getFilesDir().toString());
77
78 // load strings
79 sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
80
81 // create add bookmark/quick connect bookmark placeholder
82 addBookmarkPlaceholder = new PlaceholderBookmark();
83 addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
84 addBookmarkPlaceholder.setLabel(
85 getResources().getString(R.string.list_placeholder_add_bookmark));
86
87 // check for passed .rdp file and open it in a new bookmark
88 Intent caller = getIntent();
89 Uri callParameter = caller.getData();
90
91 if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null)
92 {
93 String refStr = ConnectionReference.getFileReference(callParameter.getPath());
94 Bundle bundle = new Bundle();
95 bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
96
97 Intent bookmarkIntent =
98 new Intent(this.getApplicationContext(), BookmarkActivity.class);
99 bookmarkIntent.putExtras(bundle);
100 startActivity(bookmarkIntent);
101 }
102
103 // load views
104 clearTextButton = findViewById(R.id.clear_search_btn);
105 superBarEditText = findViewById(R.id.superBarEditText);
106
107 listViewBookmarks = findViewById(R.id.listViewBookmarks);
108
109 // set listeners for the list view
110 listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
111 public void onItemClick(AdapterView<?> parent, View view, int position, long id)
112 {
113 String curSection = separatedListAdapter.getSectionForPosition(position);
114 Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) +
115 " in section " + curSection);
116 if (curSection.equals(sectionLabelBookmarks))
117 {
118 String refStr = view.getTag().toString();
119 if (ConnectionReference.isManualBookmarkReference(refStr) ||
120 ConnectionReference.isHostnameReference(refStr))
121 {
122 Bundle bundle = new Bundle();
123 bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
124
125 Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
126 sessionIntent.putExtras(bundle);
127 startActivity(sessionIntent);
128
129 // clear any search text
130 superBarEditText.setText("");
131 superBarEditText.clearFocus();
132 }
133 else if (ConnectionReference.isPlaceholderReference(refStr))
134 {
135 // is this the add bookmark placeholder?
136 if (ConnectionReference.getPlaceholder(refStr).equals(
137 ADD_BOOKMARK_PLACEHOLDER))
138 {
139 Intent bookmarkIntent =
140 new Intent(view.getContext(), BookmarkActivity.class);
141 startActivity(bookmarkIntent);
142 }
143 }
144 }
145 }
146 });
147
148 listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
149 @Override
150 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
151 {
152 // if the selected item is not a session item (tag == null) and not a quick connect
153 // entry (not a hostname connection reference) inflate the context menu
154 View itemView = ((AdapterContextMenuInfo)menuInfo).targetView;
155 String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
156 if (refStr != null && !ConnectionReference.isHostnameReference(refStr) &&
157 !ConnectionReference.isPlaceholderReference(refStr))
158 {
159 getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
160 menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
161 }
162 }
163 });
164
165 superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
166
167 clearTextButton.setOnClickListener(new OnClickListener() {
168 @Override public void onClick(View v)
169 {
170 superBarEditText.setText("");
171 }
172 });
173 }

◆ onCreateOptionsMenu()

boolean com.freerdp.freerdpcore.presentation.HomeActivity.onCreateOptionsMenu ( Menu  menu)
inline

Definition at line 324 of file HomeActivity.java.

325 {
326 MenuInflater inflater = getMenuInflater();
327 inflater.inflate(R.menu.home_menu, menu);
328 return true;
329 }

◆ onOptionsItemSelected()

boolean com.freerdp.freerdpcore.presentation.HomeActivity.onOptionsItemSelected ( MenuItem  item)
inline

Definition at line 331 of file HomeActivity.java.

332 {
333
334 // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case
335 // here ..
336 int itemId = item.getItemId();
337 if (itemId == R.id.newBookmark)
338 {
339 Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
340 startActivity(bookmarkIntent);
341 }
342 else if (itemId == R.id.appSettings)
343 {
344 Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
345 startActivity(settingsIntent);
346 }
347 else if (itemId == R.id.help)
348 {
349 Intent helpIntent = new Intent(this, HelpActivity.class);
350 startActivity(helpIntent);
351 }
352 else if (itemId == R.id.about)
353 {
354 Intent aboutIntent = new Intent(this, AboutActivity.class);
355 startActivity(aboutIntent);
356 }
357
358 return true;
359 }

◆ onPause()

void com.freerdp.freerdpcore.presentation.HomeActivity.onPause ( )
inlineprotected

Definition at line 265 of file HomeActivity.java.

266 {
267 super.onPause();
268 Log.v(TAG, "HomeActivity.onPause");
269
270 // reset adapters
271 listViewBookmarks.setAdapter(null);
272 separatedListAdapter = null;
273 manualBookmarkAdapter = null;
274 }

◆ onRestoreInstanceState()

void com.freerdp.freerdpcore.presentation.HomeActivity.onRestoreInstanceState ( Bundle  inState)
inlineprotected

Definition at line 318 of file HomeActivity.java.

319 {
320 super.onRestoreInstanceState(inState);
321 superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
322 }

◆ onResume()

void com.freerdp.freerdpcore.presentation.HomeActivity.onResume ( )
inlineprotected

Definition at line 242 of file HomeActivity.java.

243 {
244 super.onResume();
245 Log.v(TAG, "HomeActivity.onResume");
246
247 // create bookmark cursor adapter
248 manualBookmarkAdapter = new BookmarkArrayAdapter(
249 this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
250
251 // add add bookmark item to manual adapter
252 manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
253
254 // attach all adapters to the separatedListView adapter and assign it to the list view
255 separatedListAdapter = new SeparatedListAdapter(this);
256 separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
257 listViewBookmarks.setAdapter(separatedListAdapter);
258
259 // if we have a filter text entered cause an update to be caused here
260 String filter = superBarEditText.getText().toString();
261 if (filter.length() > 0)
262 superBarEditText.setText(filter);
263 }

◆ onSaveInstanceState()

void com.freerdp.freerdpcore.presentation.HomeActivity.onSaveInstanceState ( Bundle  outState)
inlineprotected

Definition at line 312 of file HomeActivity.java.

313 {
314 super.onSaveInstanceState(outState);
315 outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
316 }

◆ onSearchRequested()

boolean com.freerdp.freerdpcore.presentation.HomeActivity.onSearchRequested ( )
inline

Definition at line 183 of file HomeActivity.java.

184 {
185 superBarEditText.requestFocus();
186 return true;
187 }

The documentation for this class was generated from the following file: