List of usage examples for android.content Context MODE_WORLD_WRITEABLE
int MODE_WORLD_WRITEABLE
To view the source code for android.content Context MODE_WORLD_WRITEABLE.
Click Source Link
From source file:com.daiv.android.twitter.utils.NotificationUtils.java
public static String[] getTitle(int[] unreadCount, Context context, int currentAccount) { String text = ""; String name = null;/*from w ww . j a v a2s . com*/ String names = ""; int homeTweets = unreadCount[0]; int mentionsTweets = unreadCount[1]; int dmTweets = unreadCount[2]; // they only have a new mention if (mentionsTweets == 1 && homeTweets == 0 && dmTweets == 0) { MentionsDataSource mentions = MentionsDataSource.getInstance(context); name = mentions.getNewestName(currentAccount); String n = mentions.getNewestNames(currentAccount); SharedPreferences sharedPrefs = context.getSharedPreferences( "com.daiv.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); for (String s : n.split(" ")) { if (!s.equals("") && !sharedPrefs.getString("twitter_screen_name_" + currentAccount, "").equals(s) && !s.equals(name)) { names += "@" + s + " "; } } text = context.getResources().getString(R.string.mentioned_by) + " @" + name; // if they are muted, and you don't want them to show muted mentions // then just quit if (sharedPrefs.getString("muted_users", "").contains(name) && !sharedPrefs.getBoolean("show_muted_mentions", false)) { return null; } } else if (homeTweets == 0 && mentionsTweets == 0 && dmTweets == 1) { // they have 1 new direct message DMDataSource dm = DMDataSource.getInstance(context); name = dm.getNewestName(currentAccount); text = context.getResources().getString(R.string.message_from) + " @" + name; } else { // other cases we will just put Test text = context.getResources().getString(R.string.app_name); } return new String[] { text, name, names }; }
From source file:piuk.blockchain.android.WalletApplication.java
public void deleteBitcoinJLocalData() { try {//w ww.j av a 2 s .c om //Delete the wallet file File bitcoinJFile = getFileStreamPath(Constants.WALLET_FILENAME_PROTOBUF); if (bitcoinJFile.exists()) { bitcoinJFile.delete(); } } catch (Exception e) { e.printStackTrace(); } try { //Clear the blockchain file (we need to rescan) File blockChainFile = new File( getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); if (blockChainFile.exists()) blockChainFile.delete(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private Location retrieveSaved(int index) { SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); Location location = new Location("POINT_LOCATION"); location.setLatitude(0);/*from www . j a v a 2s. co m*/ location.setLongitude(0); if (prefs.contains(SAVED_LATITUDE_KEY + index)) { location.setLatitude(prefs.getFloat(SAVED_LATITUDE_KEY + index, 0)); } if (prefs.contains(SAVED_LONGITUDE_KEY + index)) { location.setLongitude(prefs.getFloat(SAVED_LONGITUDE_KEY + index, 0)); } return location; }
From source file:com.klinker.android.twitter.utils.NotificationUtils.java
public static int[] getUnreads(Context context) { SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); int currentAccount = sharedPrefs.getInt("current_account", 1); HomeDataSource data = HomeDataSource.getInstance(context); int homeTweets = data.getUnreadCount(currentAccount); MentionsDataSource mentions = MentionsDataSource.getInstance(context); int mentionsTweets = mentions.getUnreadCount(currentAccount); int dmTweets = sharedPrefs.getInt("dm_unread_" + currentAccount, 0); return new int[] { homeTweets, mentionsTweets, dmTweets }; }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void cleanup(int tag) { SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.remove(SAVED_LATITUDE_KEY + tag); prefsEditor.remove(SAVED_LONGITUDE_KEY + tag); prefsEditor.remove(SAVED_RADIUS_KEY + tag); prefsEditor.remove(SAVED_ADDRESS_KEY + tag); for (int i = tag; i < touchSaveIndex(0); i++) { prefsEditor.putFloat(SAVED_LATITUDE_KEY + i, prefs.getFloat(SAVED_LATITUDE_KEY + (i + 1), 0)); prefsEditor.putFloat(SAVED_LONGITUDE_KEY + i, prefs.getFloat(SAVED_LONGITUDE_KEY + (i + 1), 0)); prefsEditor.putString(SAVED_ADDRESS_KEY + i, prefs.getString(SAVED_ADDRESS_KEY + (i + 1), "")); }/*from w ww.j av a 2s . com*/ prefsEditor.remove(SAVED_LATITUDE_KEY + touchSaveIndex(0)); prefsEditor.remove(SAVED_LONGITUDE_KEY + touchSaveIndex(0)); prefsEditor.remove(SAVED_ADDRESS_KEY + touchSaveIndex(0)); prefsEditor.commit(); }
From source file:com.klinker.android.twitter.utils.NotificationUtils.java
public static String[] getTitle(int[] unreadCount, Context context, int currentAccount) { String text = ""; String name = null;//w w w . j ava 2 s . com String names = ""; int homeTweets = unreadCount[0]; int mentionsTweets = unreadCount[1]; int dmTweets = unreadCount[2]; // they only have a new mention if (mentionsTweets == 1 && homeTweets == 0 && dmTweets == 0) { MentionsDataSource mentions = MentionsDataSource.getInstance(context); name = mentions.getNewestName(currentAccount); String n = mentions.getNewestNames(currentAccount); SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); for (String s : n.split(" ")) { if (!s.equals("") && !sharedPrefs.getString("twitter_screen_name_" + currentAccount, "").equals(s) && !s.equals(name)) { names += "@" + s + " "; } } text = context.getResources().getString(R.string.mentioned_by) + " @" + name; // if they are muted, and you don't want them to show muted mentions // then just quit if (sharedPrefs.getString("muted_users", "").contains(name) && !sharedPrefs.getBoolean("show_muted_mentions", false)) { return null; } } else if (homeTweets == 0 && mentionsTweets == 0 && dmTweets == 1) { // they have 1 new direct message DMDataSource dm = DMDataSource.getInstance(context); name = dm.getNewestName(currentAccount); text = context.getResources().getString(R.string.message_from) + " @" + name; } else { // other cases we will just put talon text = context.getResources().getString(R.string.app_name); } return new String[] { text, name, names }; }
From source file:com.klinker.android.twitter.ui.MainActivity.java
@Override public void onStart() { super.onStart(); MainActivity.isPopup = false;// ww w. jav a 2s . c o m Log.v("talon_starting", "main activity starting"); sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); // check for night mode switching int theme = AppSettings.getCurrentTheme(sharedPrefs); if (!getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY) || sharedPrefs.getBoolean("launcher_frag_switch", false) || (theme != settings.theme && !settings.addonTheme)) { sharedPrefs.edit().putBoolean("launcher_frag_switch", false).putBoolean("dont_refresh", true).commit(); AppSettings.invalidate(); Log.v("talon_theme", "no action bar overlay found, recreating"); finish(); overridePendingTransition(0, 0); startActivity(getRestartIntent()); overridePendingTransition(0, 0); MainActivity.caughtstarting = true; // return so that it doesn't start the background refresh, that is what caused the dups. sharedPrefs.edit().putBoolean("dont_refresh_on_start", true).commit(); return; } else { sharedPrefs.edit().putBoolean("dont_refresh", false).putBoolean("should_refresh", true).commit(); } if (DrawerActivity.settings.pushNotifications) { if (!TalonPullNotificationService.isRunning) { context.startService(new Intent(context, TalonPullNotificationService.class)); } } else { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); } // cancel the alarm to start the catchup service AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pendingIntent = PendingIntent.getService(context, 236, new Intent(context, CatchupPull.class), 0); am.cancel(pendingIntent); // cancel the old one, then start the new one in 1 min // clear the pull unread sharedPrefs.edit().putInt("pull_unread", 0).commit(); UpdateUtils.checkUpdate(this); /*new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } NotificationUtils.refreshNotification(context); } }).start();*/ }
From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java
public void notifyServiceComplete() { //Set the boolean in cache to state true i.e. the service is complete. SharedPreferences afterServiceCompletion = getApplicationContext() .getSharedPreferences("AFTER_SERVICE_COMPLETED", Context.MODE_WORLD_WRITEABLE); SharedPreferences.Editor afterServiceCompletionEditor = afterServiceCompletion.edit(); afterServiceCompletionEditor.putBoolean("AFTER_SERVICE_COMPLETED", true); afterServiceCompletionEditor.commit(); //Notify the User that the download service has been completed int mNotificationId = 235; NotificationCompat.Builder mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Data AerO2") .setContentText("Smog Data Download Complete"); NotificationManager mNotifyMgr = (NotificationManager) this.getSystemService(this.NOTIFICATION_SERVICE); Intent resultIntent = new Intent(this, SmogMapActivity.class); //What to do if the notification is clicked?? PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotifyMgr.notify(mNotificationId, mBuilder.build()); /*// w ww . ja v a 2 s. com Once the service is complete notify the system that service isn't completed so that it doesn't refresh the activity over and over again. sorry this might seen a bit wiered but this is how it works. */ SharedPreferences serviceStatus = getApplicationContext().getSharedPreferences("SERVICE_COMPLETED", Context.MODE_WORLD_WRITEABLE); SharedPreferences.Editor serviceStatusEdit = serviceStatus.edit(); serviceStatusEdit.putBoolean("SERVICE_COMPLETED", false); serviceStatusEdit.commit(); }
From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java
protected void showSplashScreen() { SharedPreferences afterServiceCompletion = getApplicationContext() .getSharedPreferences("AFTER_SERVICE_COMPLETED", Context.MODE_WORLD_WRITEABLE); SharedPreferences afterPermissionGranted = getApplicationContext() .getSharedPreferences("AFTER_PERMISSION_GRANTED", Context.MODE_WORLD_WRITEABLE); boolean serviceJustCompleted = afterServiceCompletion.getBoolean("AFTER_SERVICE_COMPLETED", false); splashScreen = new Dialog(this, R.style.SplashScreen); permissionJustGranted = afterPermissionGranted.getBoolean("AFTER_PERMISSION_GRANTED", false); if (!serviceJustCompleted && !permissionJustGranted) { // View splashIcon=(View) findViewById(R.id.splash_icon); // View splashText=(View) findViewById(R.id.splash_text); // splashIcon.setVisibility(View.GONE); // splashText.setVisibility(View.GONE); splashScreen.setContentView(R.layout.splash_screen); splashScreen.setCancelable(false); splashScreen.show();/* ww w .j av a 2 s. com*/ } else if (serviceJustCompleted) { SharedPreferences.Editor afterServiceCompletionEditor = afterServiceCompletion.edit(); afterServiceCompletionEditor.putBoolean("AFTER_SERVICE_COMPLETED", false); afterServiceCompletionEditor.commit(); splashScreen.setCancelable(false); splashScreen.show(); } else if (permissionJustGranted) { removeSplashScreen(); } }
From source file:com.klinker.android.twitter.ui.tweet_viewer.TweetPager.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed();//from w w w. j a va 2 s. co m return true; case R.id.menu_delete_tweet: new DeleteTweet().execute(); getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE).edit() .putBoolean("just_muted", true).commit(); return true; case R.id.menu_share: String text1 = tweet; text1 = "@" + screenName + ": " + text1 + "\n\n" + "https://twitter.com/" + screenName + "/status/" + tweetId; Log.v("my_text_on_share", text1); Intent share = new Intent(Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(Intent.EXTRA_TEXT, text1); startActivity(share); return true; case R.id.menu_copy_text: ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("tweet_text", tweet); clipboard.setPrimaryClip(clip); return true; /*case R.id.menu_open_web: Uri weburi; try { weburi = Uri.parse(otherLinks[0]); } catch (Exception e) { weburi = Uri.parse(webpage); } Intent launchBrowser = new Intent(Intent.ACTION_VIEW, weburi); startActivity(launchBrowser); return true;*/ case R.id.menu_save_image: new Thread(new Runnable() { @Override public void run() { Looper.prepare(); try { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_icon) .setTicker(getResources().getString(R.string.downloading) + "...") .setContentTitle(getResources().getString(R.string.app_name)) .setContentText(getResources().getString(R.string.saving_picture) + "...") .setProgress(100, 100, true).setLargeIcon(BitmapFactory .decodeResource(context.getResources(), R.drawable.ic_action_save)); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(6, mBuilder.build()); String url = webpage; if (webpage.contains("insta")) { url = url.substring(0, url.length() - 1) + "l"; } URL mUrl = new URL(url); Bitmap bitmap = BitmapFactory.decodeStream(mUrl.openConnection().getInputStream()); Random generator = new Random(); int n = 1000000; n = generator.nextInt(n); String fname = "Image-" + n; Uri uri = IOUtils.saveImage(bitmap, fname, context); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/*"); PendingIntent pending = PendingIntent.getActivity(context, 91, intent, 0); mBuilder = new NotificationCompat.Builder(context).setContentIntent(pending) .setSmallIcon(R.drawable.ic_stat_icon) .setTicker(getResources().getString(R.string.saved_picture) + "...") .setContentTitle(getResources().getString(R.string.app_name)) .setContentText(getResources().getString(R.string.saved_picture) + "!") .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_save)); mNotificationManager.notify(6, mBuilder.build()); } catch (Exception e) { e.printStackTrace(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_icon) .setTicker(getResources().getString(R.string.error) + "...") .setContentTitle(getResources().getString(R.string.app_name)) .setContentText(getResources().getString(R.string.error) + "...") .setProgress(100, 100, true).setLargeIcon(BitmapFactory .decodeResource(context.getResources(), R.drawable.ic_action_save)); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(6, mBuilder.build()); } } }).start(); return true; case R.id.menu_quote: String text = tweet; if (!settings.preferRT) { text = "\"@" + screenName + ": " + text + "\" "; } else { text = " RT @" + screenName + ": " + text; } Intent quote = new Intent(context, ComposeActivity.class); quote.putExtra("user", text); quote.putExtra("id", tweetId); startActivity(quote); return true; case R.id.menu_spam: new MarkSpam().execute(); getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE).edit() .putBoolean("just_muted", true).commit(); return super.onOptionsItemSelected(item); /*case R.id.menu_mute_hashtags: if (!hashtags[0].equals("")) { ArrayList<String> tags = new ArrayList<String>(); if (hashtags != null) { for (String s : hashtags) { if (!s.equals("")) { tags.add("#" + s); } } } final CharSequence[] fItems = new CharSequence[tags.size()]; for (int i = 0; i < tags.size(); i++) { fItems[i] = tags.get(i); } final SharedPreferences sharedPreferences = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); if (fItems.length > 1) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setItems(fItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { String touched = fItems[item] + ""; Toast.makeText(context, getResources().getString(R.string.muted) + " " + touched, Toast.LENGTH_SHORT).show(); touched = touched.replace("#", "") + " "; String current = sharedPreferences.getString("muted_hashtags", ""); sharedPreferences.edit().putString("muted_hashtags", current + touched).commit(); sharedPreferences.edit().putBoolean("refresh_me", true).commit(); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); } else { String touched = fItems[0] + ""; Toast.makeText(context, getResources().getString(R.string.muted) + " " + touched, Toast.LENGTH_SHORT).show(); touched = touched.replace("#", "") + " "; String current = sharedPreferences.getString("muted_hashtags", ""); sharedPreferences.edit().putString("muted_hashtags", current + touched).commit(); sharedPreferences.edit().putBoolean("refresh_me", true).commit(); } } else { Toast.makeText(context, getResources().getString(R.string.no_hashtags), Toast.LENGTH_SHORT).show(); } PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("just_muted", true).commit(); return super.onOptionsItemSelected(item); case R.id.menu_share_links: if (!otherLinks[0].equals("")) { ArrayList<String> urls = new ArrayList<String>(); if (otherLinks != null) { for (String s : otherLinks) { if (!s.equals("")) { urls.add(s); } } } final CharSequence[] fItems = new CharSequence[urls.size()]; for (int i = 0; i < urls.size(); i++) { fItems[i] = urls.get(i); } if (fItems.length > 1) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setItems(fItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { String touched = fItems[item] + ""; Intent intent=new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_TEXT, touched); context.startActivity(Intent.createChooser(intent, context.getResources().getString(R.string.menu_share))); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); } else { String touched = fItems[0] + ""; Intent intent=new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_TEXT, touched); context.startActivity(Intent.createChooser(intent, context.getResources().getString(R.string.menu_share))); } } else { Toast.makeText(context, getResources().getString(R.string.no_links), Toast.LENGTH_SHORT).show(); } return super.onOptionsItemSelected(item);*/ case R.id.menu_translate: try { String query = tweet.replaceAll(" ", "+"); String url = "http://translate.google.com/#auto|en|" + tweet; Uri uri = Uri.parse(url); Intent browser = new Intent(Intent.ACTION_VIEW, uri); browser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(browser); } catch (Exception e) { } return true; default: return super.onOptionsItemSelected(item); } }