use of android.provider.SearchRecentSuggestions in project Talon-for-Twitter by klinker24.
the class ProfilePager method getUser.
public void getUser() {
Thread getUser = new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
thisUser = twitter.showUser(screenName);
} catch (Exception e) {
thisUser = null;
}
if (thisUser != null) {
try {
FollowersDataSource.getInstance(context).createUser(thisUser, sharedPrefs.getInt("current_account", 1));
} catch (Exception e) {
// the user already exists. don't know if this is more efficient than querying the db or not.
}
final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
suggestions.saveRecentQuery("@" + thisUser.getScreenName(), null);
}
new GetActionBarInfo().execute();
}
});
getUser.setPriority(Thread.MAX_PRIORITY);
getUser.start();
}
use of android.provider.SearchRecentSuggestions in project ActionBarSherlock by JakeWharton.
the class Issue659 method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, Issue659SuggestionsProvider.AUTHORITY, Issue659SuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
Toast.makeText(this, "Search called with: " + query, Toast.LENGTH_SHORT).show();
}
}
use of android.provider.SearchRecentSuggestions in project Varis-Android by dkhmelenko.
the class MainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu_main, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView = null;
if (searchItem != null) {
mSearchView = (SearchView) searchItem.getActionView();
}
if (mSearchView != null) {
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
boolean submitProhibited = true;
if (query.length() > SEARCH_LIMIT) {
// save search query to history
SearchRecentSuggestions suggestionsProvider = new SearchRecentSuggestions(MainActivity.this, SearchHistoryProvider.AUTHORITY, SearchHistoryProvider.MODE);
suggestionsProvider.saveRecentQuery(query, null);
submitProhibited = false;
}
return submitProhibited;
}
@Override
public boolean onQueryTextChange(String newText) {
reloadSearchHistoryAdapter(newText);
return true;
}
});
mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionClick(int position) {
mSearchView.setQuery(mQueryItems.get(position), true);
return true;
}
@Override
public boolean onSuggestionSelect(int position) {
return true;
}
});
reloadSearchHistoryAdapter("");
// restore query if it was
if (!TextUtils.isEmpty(mSavedQuery)) {
mSearchView.setQuery(mSavedQuery, false);
mSearchView.setIconified(false);
}
}
return super.onCreateOptionsMenu(menu);
}
use of android.provider.SearchRecentSuggestions in project materialistic by hidroh.
the class SearchActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
if (getIntent().hasExtra(SearchManager.QUERY)) {
mQuery = getIntent().getStringExtra(SearchManager.QUERY);
}
super.onCreate(savedInstanceState);
if (!TextUtils.isEmpty(mQuery)) {
getSupportActionBar().setSubtitle(mQuery);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchRecentSuggestionsProvider.PROVIDER_AUTHORITY, SearchRecentSuggestionsProvider.MODE) {
@Override
public void saveRecentQuery(String queryString, String line2) {
truncateHistory(getContentResolver(), MAX_RECENT_SUGGESTIONS - 1);
super.saveRecentQuery(queryString, line2);
}
};
suggestions.saveRecentQuery(mQuery, null);
}
}
use of android.provider.SearchRecentSuggestions in project Talon-for-Twitter by klinker24.
the class PrefFragment method setUpMemManagementSettings.
public void setUpMemManagementSettings() {
final SharedPreferences sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
Preference clearSearch = findPreference("clear_searches");
clearSearch.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
suggestions.clearHistory();
return false;
}
});
Preference backup = findPreference("backup");
backup.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
new AlertDialog.Builder(context).setTitle(context.getResources().getString(R.string.backup_settings_dialog)).setMessage(context.getResources().getString(R.string.backup_settings_dialog_summary)).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
File des = new File(Environment.getExternalStorageDirectory() + "/Talon/backup.prefs");
IOUtils.saveSharedPreferencesToFile(des, context);
Toast.makeText(context, context.getResources().getString(R.string.backup_success), Toast.LENGTH_LONG).show();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}).create().show();
return false;
}
});
Preference restore = findPreference("restore");
restore.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
File des = new File(Environment.getExternalStorageDirectory() + "/Talon/backup.prefs");
String authenticationToken1 = sharedPrefs.getString("authentication_token_1", "none");
String authenticationTokenSecret1 = sharedPrefs.getString("authentication_token_secret_1", "none");
String myScreenName1 = sharedPrefs.getString("twitter_screen_name_1", "");
String myName1 = sharedPrefs.getString("twitter_users_name_1", "");
String myBackgroundUrl1 = sharedPrefs.getString("twitter_background_url_1", "");
String myProfilePicUrl1 = sharedPrefs.getString("profile_pic_url_1", "");
long lastTweetId1 = sharedPrefs.getLong("last_tweet_id_1", 0);
long secondLastTweetId1 = sharedPrefs.getLong("second_last_tweet_id_1", 0);
long lastMentionId1 = sharedPrefs.getLong("last_mention_id_1", 0);
long lastDMId1 = sharedPrefs.getLong("last_dm_id_1", 0);
long twitterId1 = sharedPrefs.getLong("twitter_id_1", 0);
boolean isloggedin1 = sharedPrefs.getBoolean("is_logged_in_1", false);
String authenticationToken2 = sharedPrefs.getString("authentication_token_2", "none");
String authenticationTokenSecret2 = sharedPrefs.getString("authentication_token_secret_2", "none");
String myScreenName2 = sharedPrefs.getString("twitter_screen_name_2", "");
String myName2 = sharedPrefs.getString("twitter_users_name_2", "");
String myBackgroundUrl2 = sharedPrefs.getString("twitter_background_url_2", "");
String myProfilePicUrl2 = sharedPrefs.getString("profile_pic_url_2", "");
long lastTweetId2 = sharedPrefs.getLong("last_tweet_id_2", 0);
long secondLastTweetId2 = sharedPrefs.getLong("second_last_tweet_id_2", 0);
long lastMentionId2 = sharedPrefs.getLong("last_mention_id_2", 0);
long lastDMId2 = sharedPrefs.getLong("last_dm_id_2", 0);
long twitterId2 = sharedPrefs.getLong("twitter_id_2", 0);
boolean isloggedin2 = sharedPrefs.getBoolean("is_logged_in_2", false);
IOUtils.loadSharedPreferencesFromFile(des, context);
Toast.makeText(context, context.getResources().getString(R.string.restore_success), Toast.LENGTH_LONG).show();
SharedPreferences.Editor e = sharedPrefs.edit();
e.putString("authentication_token_1", authenticationToken1);
e.putString("authentication_token_secret_1", authenticationTokenSecret1);
e.putString("twitter_screen_name_1", myScreenName1);
e.putString("twitter_users_name_1", myName1);
e.putString("twitter_background_url_1", myBackgroundUrl1);
e.putString("profile_pic_url_1", myProfilePicUrl1);
e.putString("favorite_user_names_1", "");
e.putLong("last_tweet_id_1", lastTweetId1);
e.putLong("second_last_tweet_id_1", secondLastTweetId1);
e.putLong("last_mention_id_1", lastMentionId1);
e.putLong("last_dm_id_1", lastDMId1);
e.putLong("twitter_id_1", twitterId1);
e.putBoolean("is_logged_in_1", isloggedin1);
e.putString("authentication_token_2", authenticationToken2);
e.putString("authentication_token_secret_2", authenticationTokenSecret2);
e.putString("twitter_screen_name_2", myScreenName2);
e.putString("twitter_users_name_2", myName2);
e.putString("twitter_background_url_2", myBackgroundUrl2);
e.putString("profile_pic_url_2", myProfilePicUrl2);
e.putString("favorite_user_names_2", "");
e.putLong("last_tweet_id_2", lastTweetId2);
e.putLong("second_last_tweet_id_2", secondLastTweetId2);
e.putLong("last_mention_id_2", lastMentionId2);
e.putLong("last_dm_id_2", lastDMId2);
e.putLong("twitter_id_2", twitterId2);
e.putBoolean("is_logged_in_2", isloggedin2);
e.remove("new_notifications");
e.remove("new_retweets");
e.remove("new_favorites");
e.remove("new_follows");
int currentAccount = sharedPrefs.getInt("current_account", 1);
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();
return false;
}
});
final Preference cache = findPreference("delete_cache");
long size = IOUtils.dirSize(context.getCacheDir());
cache.setSummary(getResources().getString(R.string.current_cache_size) + ": " + size / 1048576 + " MB");
cache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
new AlertDialog.Builder(context).setTitle(context.getResources().getString(R.string.cache_dialog)).setMessage(context.getResources().getString(R.string.cache_dialog_summary)).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
try {
new TrimCache(cache).execute();
} catch (Exception e) {
e.printStackTrace();
}
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}).create().show();
return false;
}
});
Preference trim = findPreference("trim_now");
trim.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
new AlertDialog.Builder(context).setTitle(context.getResources().getString(R.string.trim_dialog)).setMessage(context.getResources().getString(R.string.cache_dialog_summary)).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
try {
new TrimDatabase().execute();
} catch (Exception e) {
e.printStackTrace();
}
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}).create().show();
return false;
}
});
}
Aggregations