Removed unused welcome screen.
This commit is contained in:
parent
cdef682fe2
commit
abda0b1830
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
|
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
|
||||||
|
|
||||||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
||||||
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -51,76 +51,70 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
public class HomeActivity extends Activity
|
public class HomeActivity extends Activity {
|
||||||
{
|
|
||||||
private final static String ADD_BOOKMARK_PLACEHOLDER = "add_bookmark";
|
private final static String ADD_BOOKMARK_PLACEHOLDER = "add_bookmark";
|
||||||
|
|
||||||
private ListView listViewBookmarks;
|
private ListView listViewBookmarks;
|
||||||
private WebView webViewGetStarted;
|
|
||||||
|
|
||||||
private Button clearTextButton;
|
private Button clearTextButton;
|
||||||
private EditText superBarEditText;
|
private EditText superBarEditText;
|
||||||
private BookmarkArrayAdapter manualBookmarkAdapter;
|
private BookmarkArrayAdapter manualBookmarkAdapter;
|
||||||
private SeparatedListAdapter separatedListAdapter;
|
private SeparatedListAdapter separatedListAdapter;
|
||||||
|
|
||||||
private PlaceholderBookmark addBookmarkPlaceholder;
|
private PlaceholderBookmark addBookmarkPlaceholder;
|
||||||
|
|
||||||
private static final String TAG = "HomeActivity";
|
private static final String TAG = "HomeActivity";
|
||||||
|
|
||||||
private static final String PARAM_SUPERBAR_TEXT = "superbar_text";
|
private static final String PARAM_SUPERBAR_TEXT = "superbar_text";
|
||||||
|
|
||||||
private String sectionLabelBookmarks;
|
private String sectionLabelBookmarks;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
{
|
setTitle(R.string.title_home);
|
||||||
setTitle(R.string.title_home);
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.home);
|
setContentView(R.layout.home);
|
||||||
|
|
||||||
long heapSize = Runtime.getRuntime().maxMemory();
|
long heapSize = Runtime.getRuntime().maxMemory();
|
||||||
Log.i(TAG, "Max HeapSize: " + heapSize);
|
Log.i(TAG, "Max HeapSize: " + heapSize);
|
||||||
Log.i(TAG, "App data folder: " + getFilesDir().toString());
|
Log.i(TAG, "App data folder: " + getFilesDir().toString());
|
||||||
|
|
||||||
// load strings
|
// load strings
|
||||||
sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
|
sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
|
||||||
|
|
||||||
// create add bookmark/quick connect bookmark placeholder
|
// create add bookmark/quick connect bookmark placeholder
|
||||||
addBookmarkPlaceholder = new PlaceholderBookmark();
|
addBookmarkPlaceholder = new PlaceholderBookmark();
|
||||||
addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
|
addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
|
||||||
addBookmarkPlaceholder.setLabel(getResources().getString(R.string.list_placeholder_add_bookmark));
|
addBookmarkPlaceholder.setLabel(getResources().getString(R.string.list_placeholder_add_bookmark));
|
||||||
|
|
||||||
// check for passed .rdp file and open it in a new bookmark
|
// check for passed .rdp file and open it in a new bookmark
|
||||||
Intent caller = getIntent();
|
Intent caller = getIntent();
|
||||||
Uri callParameter = caller.getData();
|
Uri callParameter = caller.getData();
|
||||||
|
|
||||||
if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null)
|
if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null) {
|
||||||
{
|
|
||||||
String refStr = ConnectionReference.getFileReference(callParameter.getPath());
|
String refStr = ConnectionReference.getFileReference(callParameter.getPath());
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
||||||
|
|
||||||
Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
|
Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
|
||||||
bookmarkIntent.putExtras(bundle);
|
bookmarkIntent.putExtras(bundle);
|
||||||
startActivity(bookmarkIntent);
|
startActivity(bookmarkIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load views
|
// load views
|
||||||
clearTextButton = (Button) findViewById(R.id.clear_search_btn);
|
clearTextButton = (Button) findViewById(R.id.clear_search_btn);
|
||||||
superBarEditText = (EditText) findViewById(R.id.superBarEditText);
|
superBarEditText = (EditText) findViewById(R.id.superBarEditText);
|
||||||
|
|
||||||
listViewBookmarks = (ListView) findViewById(R.id.listViewBookmarks);
|
listViewBookmarks = (ListView) findViewById(R.id.listViewBookmarks);
|
||||||
webViewGetStarted = (WebView) findViewById(R.id.webViewWelcome);
|
|
||||||
|
|
||||||
String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "welcome.html" : "welcome_phone.html";
|
String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "welcome.html" : "welcome_phone.html";
|
||||||
webViewGetStarted.getSettings().setJavaScriptEnabled(true);
|
|
||||||
Locale def = Locale.getDefault();
|
Locale def = Locale.getDefault();
|
||||||
String prefix = def.getLanguage().toLowerCase(def);
|
String prefix = def.getLanguage().toLowerCase(def);
|
||||||
|
|
||||||
String base = "file:///android_asset/";
|
String base = "file:///android_asset/";
|
||||||
String dir = prefix + "_help_page/"
|
String dir = prefix + "_help_page/"
|
||||||
+ filename;
|
+ filename;
|
||||||
try {
|
try {
|
||||||
InputStream is = getAssets().open(dir);
|
InputStream is = getAssets().open(dir);
|
||||||
is.close();
|
is.close();
|
||||||
@ -128,164 +122,127 @@ public class HomeActivity extends Activity
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Missing localized asset " + dir, e);
|
Log.e(TAG, "Missing localized asset " + dir, e);
|
||||||
dir = "file:///android_asset/help_page/" + filename;
|
dir = "file:///android_asset/help_page/" + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
webViewGetStarted.loadUrl(dir);
|
// set listeners for the list view
|
||||||
|
|
||||||
// set listeners for the list view
|
|
||||||
listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
{
|
|
||||||
String curSection = separatedListAdapter.getSectionForPosition(position);
|
String curSection = separatedListAdapter.getSectionForPosition(position);
|
||||||
Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) + " in section " + curSection);
|
Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) + " in section " + curSection);
|
||||||
if(curSection == sectionLabelBookmarks)
|
if(curSection == sectionLabelBookmarks) {
|
||||||
{
|
String refStr = view.getTag().toString();
|
||||||
String refStr = view.getTag().toString();
|
|
||||||
if (ConnectionReference.isManualBookmarkReference(refStr) ||
|
if (ConnectionReference.isManualBookmarkReference(refStr) ||
|
||||||
ConnectionReference.isHostnameReference(refStr))
|
ConnectionReference.isHostnameReference(refStr)) {
|
||||||
{
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
||||||
|
|
||||||
|
Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
|
||||||
|
sessionIntent.putExtras(bundle);
|
||||||
|
startActivity(sessionIntent);
|
||||||
|
|
||||||
Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
|
|
||||||
sessionIntent.putExtras(bundle);
|
|
||||||
startActivity(sessionIntent);
|
|
||||||
|
|
||||||
// clear any search text
|
// clear any search text
|
||||||
superBarEditText.setText("");
|
superBarEditText.setText("");
|
||||||
superBarEditText.clearFocus();
|
superBarEditText.clearFocus();
|
||||||
}
|
} else if (ConnectionReference.isPlaceholderReference(refStr)) {
|
||||||
else if (ConnectionReference.isPlaceholderReference(refStr))
|
|
||||||
{
|
|
||||||
// is this the add bookmark placeholder?
|
// is this the add bookmark placeholder?
|
||||||
if (ConnectionReference.getPlaceholder(refStr).equals(ADD_BOOKMARK_PLACEHOLDER))
|
if (ConnectionReference.getPlaceholder(refStr).equals(ADD_BOOKMARK_PLACEHOLDER)) {
|
||||||
{
|
Intent bookmarkIntent = new Intent(view.getContext(), BookmarkActivity.class);
|
||||||
Intent bookmarkIntent = new Intent(view.getContext(), BookmarkActivity.class);
|
startActivity(bookmarkIntent);
|
||||||
startActivity(bookmarkIntent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
|
listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
// if the selected item is not a session item (tag == null) and not a quick connect entry
|
// if the selected item is not a session item (tag == null) and not a quick connect entry
|
||||||
// (not a hostname connection reference) inflate the context menu
|
// (not a hostname connection reference) inflate the context menu
|
||||||
View itemView = ((AdapterContextMenuInfo)menuInfo).targetView;
|
View itemView = ((AdapterContextMenuInfo)menuInfo).targetView;
|
||||||
String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
|
String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
|
||||||
if (refStr != null && !ConnectionReference.isHostnameReference(refStr) && !ConnectionReference.isPlaceholderReference(refStr))
|
if (refStr != null && !ConnectionReference.isHostnameReference(refStr) && !ConnectionReference.isPlaceholderReference(refStr)) {
|
||||||
{
|
|
||||||
getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
|
getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
|
||||||
menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
|
menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
|
superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
|
||||||
|
|
||||||
clearTextButton.setOnClickListener(new OnClickListener() {
|
clearTextButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
superBarEditText.setText("");
|
superBarEditText.setText("");
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
webViewGetStarted.setWebViewClient(new WebViewClient() {
|
|
||||||
@Override
|
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url)
|
|
||||||
{
|
|
||||||
if (url.endsWith("new_connection"))
|
|
||||||
{
|
|
||||||
Intent bookmarkIntent = new Intent(getApplicationContext(), BookmarkActivity.class);
|
|
||||||
startActivity(bookmarkIntent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSearchRequested() {
|
public boolean onSearchRequested() {
|
||||||
superBarEditText.requestFocus();
|
superBarEditText.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem aItem) {
|
public boolean onContextItemSelected(MenuItem aItem) {
|
||||||
|
|
||||||
// get connection reference
|
// get connection reference
|
||||||
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)aItem.getMenuInfo();
|
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)aItem.getMenuInfo();
|
||||||
String refStr = menuInfo.targetView.getTag().toString();
|
String refStr = menuInfo.targetView.getTag().toString();
|
||||||
|
|
||||||
// refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
|
// refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
|
||||||
int itemId = aItem.getItemId();
|
int itemId = aItem.getItemId();
|
||||||
if (itemId == R.id.bookmark_connect)
|
if (itemId == R.id.bookmark_connect) {
|
||||||
{
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
||||||
Intent sessionIntent = new Intent(this, SessionActivity.class);
|
Intent sessionIntent = new Intent(this, SessionActivity.class);
|
||||||
sessionIntent.putExtras(bundle);
|
sessionIntent.putExtras(bundle);
|
||||||
|
|
||||||
startActivity(sessionIntent);
|
startActivity(sessionIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (itemId == R.id.bookmark_edit) {
|
||||||
else if (itemId == R.id.bookmark_edit)
|
|
||||||
{
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
|
||||||
|
|
||||||
Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
|
Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
|
||||||
bookmarkIntent.putExtras(bundle);
|
bookmarkIntent.putExtras(bundle);
|
||||||
startActivity(bookmarkIntent);
|
startActivity(bookmarkIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (itemId == R.id.bookmark_delete) {
|
||||||
else if (itemId == R.id.bookmark_delete)
|
if(ConnectionReference.isManualBookmarkReference(refStr)) {
|
||||||
{
|
|
||||||
if(ConnectionReference.isManualBookmarkReference(refStr))
|
|
||||||
{
|
|
||||||
long id = ConnectionReference.getManualBookmarkId(refStr);
|
long id = ConnectionReference.getManualBookmarkId(refStr);
|
||||||
GlobalApp.getManualBookmarkGateway().delete(id);
|
GlobalApp.getManualBookmarkGateway().delete(id);
|
||||||
manualBookmarkAdapter.remove(id);
|
manualBookmarkAdapter.remove(id);
|
||||||
separatedListAdapter.notifyDataSetChanged();
|
separatedListAdapter.notifyDataSetChanged();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
assert false;
|
assert false;
|
||||||
}
|
}
|
||||||
|
|
||||||
showWelcomeScreenOrBookmarkList();
|
|
||||||
|
|
||||||
// clear super bar text
|
// clear super bar text
|
||||||
superBarEditText.setText("");
|
superBarEditText.setText("");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
Log.v(TAG, "HomeActivity.onResume");
|
Log.v(TAG, "HomeActivity.onResume");
|
||||||
|
|
||||||
// create bookmark cursor adapter
|
// create bookmark cursor adapter
|
||||||
manualBookmarkAdapter = new BookmarkArrayAdapter(this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
|
manualBookmarkAdapter = new BookmarkArrayAdapter(this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
|
||||||
|
|
||||||
// add add bookmark item to manual adapter
|
// add add bookmark item to manual adapter
|
||||||
manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
|
manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
|
||||||
|
|
||||||
// attach all adapters to the separatedListView adapter and assign it to the list view
|
// attach all adapters to the separatedListView adapter and assign it to the list view
|
||||||
separatedListAdapter = new SeparatedListAdapter(this);
|
separatedListAdapter = new SeparatedListAdapter(this);
|
||||||
separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
|
separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
|
||||||
listViewBookmarks.setAdapter(separatedListAdapter);
|
listViewBookmarks.setAdapter(separatedListAdapter);
|
||||||
|
|
||||||
// show welcome screen in case we have a first-time user
|
|
||||||
showWelcomeScreenOrBookmarkList();
|
|
||||||
|
|
||||||
// if we have a filter text entered cause an update to be caused here
|
// if we have a filter text entered cause an update to be caused here
|
||||||
String filter = superBarEditText.getText().toString();
|
String filter = superBarEditText.getText().toString();
|
||||||
if (filter.length() > 0)
|
if (filter.length() > 0)
|
||||||
@ -302,54 +259,46 @@ public class HomeActivity extends Activity
|
|||||||
separatedListAdapter = null;
|
separatedListAdapter = null;
|
||||||
manualBookmarkAdapter = null;
|
manualBookmarkAdapter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed()
|
public void onBackPressed() {
|
||||||
{
|
// if back was pressed - ask the user if he really wants to exit
|
||||||
// if back was pressed - ask the user if he really wants to exit
|
if (GlobalSettings.getAskOnExit()) {
|
||||||
if (GlobalSettings.getAskOnExit())
|
|
||||||
{
|
|
||||||
final CheckBox cb = new CheckBox(this);
|
final CheckBox cb = new CheckBox(this);
|
||||||
cb.setChecked(!GlobalSettings.getAskOnExit());
|
cb.setChecked(!GlobalSettings.getAskOnExit());
|
||||||
cb.setText(R.string.dlg_dont_show_again);
|
cb.setText(R.string.dlg_dont_show_again);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.dlg_title_exit)
|
builder.setTitle(R.string.dlg_title_exit)
|
||||||
.setMessage(R.string.dlg_msg_exit)
|
.setMessage(R.string.dlg_msg_exit)
|
||||||
.setView(cb)
|
.setView(cb)
|
||||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
{
|
GlobalSettings.setAskOnExit(!cb.isChecked());
|
||||||
GlobalSettings.setAskOnExit(!cb.isChecked());
|
finish();
|
||||||
finish();
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
{
|
GlobalSettings.setAskOnExit(!cb.isChecked());
|
||||||
GlobalSettings.setAskOnExit(!cb.isChecked());
|
dialog.dismiss();
|
||||||
dialog.dismiss();
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState)
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
{
|
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
|
outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRestoreInstanceState(Bundle inState)
|
protected void onRestoreInstanceState(Bundle inState) {
|
||||||
{
|
|
||||||
super.onRestoreInstanceState(inState);
|
super.onRestoreInstanceState(inState);
|
||||||
superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
|
superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
|
||||||
}
|
}
|
||||||
@ -366,45 +315,29 @@ public class HomeActivity extends Activity
|
|||||||
|
|
||||||
// refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
|
// refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
if (itemId == R.id.newBookmark)
|
if (itemId == R.id.newBookmark) {
|
||||||
{
|
|
||||||
Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
|
Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
|
||||||
startActivity(bookmarkIntent);
|
startActivity(bookmarkIntent);
|
||||||
}
|
} else if (itemId == R.id.appSettings) {
|
||||||
else if (itemId == R.id.appSettings)
|
|
||||||
{
|
|
||||||
Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
|
Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
|
||||||
startActivity(settingsIntent);
|
startActivity(settingsIntent);
|
||||||
}
|
} else if (itemId == R.id.help) {
|
||||||
else if (itemId == R.id.help)
|
|
||||||
{
|
|
||||||
Intent helpIntent = new Intent(this, HelpActivity.class);
|
Intent helpIntent = new Intent(this, HelpActivity.class);
|
||||||
startActivity(helpIntent);
|
startActivity(helpIntent);
|
||||||
}
|
} else if (itemId == R.id.about) {
|
||||||
else if (itemId == R.id.about)
|
|
||||||
{
|
|
||||||
Intent aboutIntent = new Intent(this, AboutActivity.class);
|
Intent aboutIntent = new Intent(this, AboutActivity.class);
|
||||||
startActivity(aboutIntent);
|
startActivity(aboutIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
private void showWelcomeScreenOrBookmarkList()
|
|
||||||
{
|
|
||||||
listViewBookmarks.setVisibility(View.VISIBLE);
|
|
||||||
webViewGetStarted.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SuperBarTextWatcher implements TextWatcher
|
private class SuperBarTextWatcher implements TextWatcher {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if(separatedListAdapter != null)
|
if(separatedListAdapter != null) {
|
||||||
{
|
|
||||||
String text = s.toString();
|
String text = s.toString();
|
||||||
if(text.length() > 0)
|
if(text.length() > 0) {
|
||||||
{
|
|
||||||
ArrayList<BookmarkBase> computers_list = GlobalApp.getQuickConnectHistoryGateway().findHistory(text);
|
ArrayList<BookmarkBase> computers_list = GlobalApp.getQuickConnectHistoryGateway().findHistory(text);
|
||||||
computers_list.addAll(GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(text));
|
computers_list.addAll(GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(text));
|
||||||
manualBookmarkAdapter.replaceItems(computers_list);
|
manualBookmarkAdapter.replaceItems(computers_list);
|
||||||
@ -412,13 +345,11 @@ public class HomeActivity extends Activity
|
|||||||
qcBm.setLabel(text);
|
qcBm.setLabel(text);
|
||||||
qcBm.setHostname(text);
|
qcBm.setHostname(text);
|
||||||
manualBookmarkAdapter.insert(qcBm, 0);
|
manualBookmarkAdapter.insert(qcBm, 0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
manualBookmarkAdapter.replaceItems(GlobalApp.getManualBookmarkGateway().findAll());
|
manualBookmarkAdapter.replaceItems(GlobalApp.getManualBookmarkGateway().findAll());
|
||||||
manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
|
manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
separatedListAdapter.notifyDataSetChanged();
|
separatedListAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,6 +360,6 @@ public class HomeActivity extends Activity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user