use of android.provider.SearchRecentSuggestions in project musicbrainz-android by jdamcd.
the class SearchActivity method saveQueryAsSuggestion.
private void saveQueryAsSuggestion() {
if (App.getUser().isSearchSuggestionsEnabled()) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SuggestionProvider.AUTHORITY, SuggestionProvider.MODE);
suggestions.saveRecentQuery(searchTerm, null);
}
}
use of android.provider.SearchRecentSuggestions in project musicbrainz-android by jdamcd.
the class SettingsActivity method clearSuggestionHistory.
private void clearSuggestionHistory() {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SuggestionProvider.AUTHORITY, SuggestionProvider.MODE);
suggestions.clearHistory();
Toast.makeText(this, R.string.toast_search_cleared, Toast.LENGTH_SHORT).show();
}
use of android.provider.SearchRecentSuggestions in project Talon-for-Twitter by klinker24.
the class DrawerActivity method logoutFromTwitter.
private void logoutFromTwitter() {
context.sendBroadcast(new Intent("com.klinker.android.STOP_PUSH_SERVICE"));
int currentAccount = sharedPrefs.getInt("current_account", 1);
boolean login1 = sharedPrefs.getBoolean("is_logged_in_1", false);
boolean login2 = sharedPrefs.getBoolean("is_logged_in_2", false);
// Delete the data for the logged out account
SharedPreferences.Editor e = sharedPrefs.edit();
e.remove("authentication_token_" + currentAccount);
e.remove("authentication_token_secret_" + currentAccount);
e.remove("is_logged_in_" + currentAccount);
e.remove("new_notification");
e.remove("new_retweets");
e.remove("new_favorites");
e.remove("new_follows");
e.remove("current_position_" + currentAccount);
e.remove("last_activity_refresh_" + currentAccount);
e.remove("original_activity_refresh_" + currentAccount);
e.remove("activity_follower_count_" + currentAccount);
e.remove("activity_latest_followers_" + currentAccount);
e.commit();
HomeDataSource homeSources = HomeDataSource.getInstance(context);
homeSources.deleteAllTweets(currentAccount);
MentionsDataSource mentionsSources = MentionsDataSource.getInstance(context);
mentionsSources.deleteAllTweets(currentAccount);
DMDataSource dmSource = DMDataSource.getInstance(context);
dmSource.deleteAllTweets(currentAccount);
FavoriteUsersDataSource favs = FavoriteUsersDataSource.getInstance(context);
favs.deleteAllUsers(currentAccount);
InteractionsDataSource inters = InteractionsDataSource.getInstance(context);
inters.deleteAllInteractions(currentAccount);
ActivityDataSource activity = ActivityDataSource.getInstance(context);
activity.deleteAll(currentAccount);
FavoriteTweetsDataSource favTweets = FavoriteTweetsDataSource.getInstance(context);
favTweets.deleteAllTweets(currentAccount);
try {
long account1List1 = sharedPrefs.getLong("account_" + currentAccount + "_list_1", 0l);
long account1List2 = sharedPrefs.getLong("account_" + currentAccount + "_list_2", 0l);
ListDataSource list = ListDataSource.getInstance(context);
list.deleteAllTweets(account1List1);
list.deleteAllTweets(account1List2);
} catch (Exception x) {
}
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
suggestions.clearHistory();
AppSettings.invalidate();
if (currentAccount == 1 && login2) {
e.putInt("current_account", 2).commit();
finish();
Intent next = new Intent(context, MainActivity.class);
startActivity(next);
} else if (currentAccount == 2 && login1) {
e.putInt("current_account", 1).commit();
finish();
Intent next = new Intent(context, MainActivity.class);
startActivity(next);
} else {
// only the one account
e.putInt("current_account", 1).commit();
finish();
Intent login = new Intent(context, LoginActivity.class);
startActivity(login);
}
}
use of android.provider.SearchRecentSuggestions in project Talon-for-Twitter by klinker24.
the class SearchedTrendsActivity method handleIntent.
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
searchQuery = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
if (searchQuery.contains("#")) {
suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
} else {
suggestions.saveRecentQuery(searchQuery, null);
}
if (searchQuery.contains("#")) {
// we want to add it to the userAutoComplete
HashtagDataSource source = HashtagDataSource.getInstance(context);
if (source != null) {
source.deleteTag(searchQuery.replaceAll("\"", ""));
source.createTag(searchQuery.replaceAll("\"", ""));
}
}
if (!searchQuery.contains("-RT")) {
searchQuery += " -RT";
}
String query = searchQuery;
doSearch(query);
}
}
use of android.provider.SearchRecentSuggestions in project Talon-for-Twitter by klinker24.
the class SearchPager method handleIntent.
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
searchQuery = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
if (searchQuery.contains("#")) {
suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
} else {
suggestions.saveRecentQuery(searchQuery, null);
}
searchQuery += " -RT";
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
String uriString = uri.toString();
if (uriString.contains("status/")) {
long id;
String replace = uriString.substring(uriString.indexOf("status")).replace("status/", "").replaceAll("photo/*", "");
if (replace.contains("/")) {
replace = replace.substring(0, replace.indexOf("/"));
} else if (replace.contains("?")) {
replace = replace.substring(0, replace.indexOf("?"));
}
try {
id = Long.parseLong(replace);
} catch (Exception e) {
id = 0l;
}
searchQuery = id + "";
onlyStatus = true;
} else if (!uriString.contains("q=") && !uriString.contains("screen_name%3D")) {
// going to try searching for users i guess
String name = uriString.substring(uriString.indexOf(".com/"));
name = name.replaceAll("/", "").replaceAll(".com", "");
searchQuery = name;
onlyProfile = true;
} else if (uriString.contains("q=")) {
try {
String search = uri.getQueryParameter("q");
if (search != null) {
searchQuery = search;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
if (searchQuery.contains("#")) {
suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
} else {
suggestions.saveRecentQuery(searchQuery, null);
}
searchQuery += " -RT";
} else {
searchQuery = "";
}
} catch (Exception e) {
}
} else {
try {
String search = uriString;
search = search.substring(search.indexOf("screen_name%3D") + 14);
search = search.substring(0, search.indexOf("%"));
if (search != null) {
searchQuery = search;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
if (searchQuery.contains("#")) {
suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
} else {
suggestions.saveRecentQuery(searchQuery, null);
}
searchQuery += " -RT";
} else {
searchQuery = "";
}
onlyProfile = true;
} catch (Exception e) {
}
}
}
}
Aggregations