FreeRDP
Loading...
Searching...
No Matches
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)
 
boolean onCreateOptionsMenu (Menu menu)
 
boolean onOptionsItemSelected (MenuItem item)
 

Protected Member Functions

void onResume ()
 
void onSaveInstanceState (Bundle outState)
 

Detailed Description

Definition at line 33 of file HomeActivity.java.

Member Function Documentation

◆ onCreate()

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

Definition at line 44 of file HomeActivity.java.

45 {
46 super.onCreate(savedInstanceState);
47 binding = HomeBinding.inflate(getLayoutInflater());
48 setContentView(binding.getRoot());
49
50 long heapSize = Runtime.getRuntime().maxMemory();
51 Log.i(TAG, "Max HeapSize: " + heapSize);
52 Log.i(TAG, "App data folder: " + getFilesDir().toString());
53
54 // check for passed .rdp file and open it in a new bookmark
55 Intent caller = getIntent();
56 Uri callParameter = caller.getData();
57
58 if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null)
59 {
60 String refStr = ConnectionReference.getFileReference(callParameter.getPath());
61 Bundle bundle = new Bundle();
62 bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
63
64 Intent bookmarkIntent =
65 new Intent(this.getApplicationContext(), BookmarkActivity.class);
66 bookmarkIntent.putExtras(bundle);
67 startActivity(bookmarkIntent);
68 }
69
70 viewModel = new ViewModelProvider(this).get(HomeViewModel.class);
71
72 bookmarkListAdapter = new BookmarkListAdapter();
73 bookmarkListAdapter.setCallbacks(new BookmarkListAdapter.Callbacks() {
74 @Override public void onItemClick(String refStr)
75 {
76 if (ConnectionReference.isBookmarkReference(refStr) ||
77 ConnectionReference.isHostnameReference(refStr))
78 {
79 Bundle bundle = new Bundle();
80 bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
81
82 Intent sessionIntent = new Intent(HomeActivity.this, SessionActivity.class);
83 sessionIntent.putExtras(bundle);
84 startActivity(sessionIntent);
85
86 if (searchView != null)
87 {
88 searchView.setQuery("", false);
89 searchView.setIconified(true);
90 }
91 if (searchMenuItem != null)
92 {
93 searchMenuItem.collapseActionView();
94 }
95 viewModel.loadBookmarks("");
96 }
97 }
98
99 @Override public void onDelete(long id)
100 {
101 viewModel.deleteBookmark(id);
102 }
103 });
104
105 binding.recyclerViewBookmarks.setLayoutManager(new LinearLayoutManager(this));
106 binding.recyclerViewBookmarks.setAdapter(bookmarkListAdapter);
107
108 viewModel.getBookmarks().observe(this,
109 bookmarks -> bookmarkListAdapter.setItems(bookmarks));
110
111 // restore search query after process death
112 if (savedInstanceState != null)
113 {
114 String query = savedInstanceState.getString(PARAM_SEARCH_QUERY);
115 if (query != null && !query.isEmpty() && viewModel.getCurrentQuery().isEmpty())
116 {
117 viewModel.loadBookmarks(query);
118 }
119 }
120
121 getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
122 @Override public void handleOnBackPressed()
123 {
124 if (ApplicationSettingsActivity.getAskOnExit(HomeActivity.this))
125 {
126 new AlertDialog.Builder(HomeActivity.this)
127 .setTitle(R.string.dlg_title_exit)
128 .setMessage(R.string.dlg_msg_exit)
129 .setPositiveButton(R.string.yes, (dialog, which) -> finish())
130 .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
131 .show();
132 }
133 else
134 {
135 finish();
136 }
137 }
138 });
139 }

◆ onCreateOptionsMenu()

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

Definition at line 154 of file HomeActivity.java.

155 {
156 MenuInflater inflater = getMenuInflater();
157 inflater.inflate(R.menu.home_menu, menu);
158 setupSearchView(menu);
159 return true;
160 }

◆ onOptionsItemSelected()

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

Definition at line 162 of file HomeActivity.java.

163 {
164 // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case
165 // here ..
166 int itemId = item.getItemId();
167 if (itemId == R.id.newBookmark)
168 {
169 Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
170 startActivity(bookmarkIntent);
171 }
172 else if (itemId == R.id.appSettings)
173 {
174 Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
175 startActivity(settingsIntent);
176 }
177 else if (itemId == R.id.help)
178 {
179 Intent helpIntent = new Intent(this, HelpActivity.class);
180 startActivity(helpIntent);
181 }
182 else if (itemId == R.id.about)
183 {
184 Intent aboutIntent = new Intent(this, AboutActivity.class);
185 startActivity(aboutIntent);
186 }
187
188 return true;
189 }

◆ onResume()

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

Definition at line 141 of file HomeActivity.java.

142 {
143 super.onResume();
144 Log.v(TAG, "HomeActivity.onResume");
145 viewModel.loadBookmarks(viewModel.getCurrentQuery());
146 }

◆ onSaveInstanceState()

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

Definition at line 148 of file HomeActivity.java.

149 {
150 super.onSaveInstanceState(outState);
151 outState.putString(PARAM_SEARCH_QUERY, viewModel.getCurrentQuery());
152 }

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