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.klinker.android.twitter.ui.drawer_activities.discover.trends.SearchedTrendsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down); try {/* ww w. jav a 2s .c o m*/ ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); settings = AppSettings.getInstance(this); if (settings.advanceWindowed) { setUpWindow(); } Utils.setUpPopupTheme(context, settings); actionBar = getActionBar(); actionBar.setTitle(getResources().getString(R.string.search)); setContentView(R.layout.ptr_list_layout); mPullToRefreshLayout = (FullScreenSwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); mPullToRefreshLayout.setOnRefreshListener(new FullScreenSwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { onRefreshStarted(); } }); if (settings.addonTheme) { mPullToRefreshLayout.setColorScheme(settings.accentInt, SwipeProgressBar.COLOR2, settings.accentInt, SwipeProgressBar.COLOR3); } else { if (settings.theme != AppSettings.THEME_LIGHT) { mPullToRefreshLayout.setColorScheme(context.getResources().getColor(R.color.app_color), SwipeProgressBar.COLOR2, context.getResources().getColor(R.color.app_color), SwipeProgressBar.COLOR3); } else { mPullToRefreshLayout.setColorScheme(context.getResources().getColor(R.color.app_color), getResources().getColor(R.color.light_ptr_1), context.getResources().getColor(R.color.app_color), getResources().getColor(R.color.light_ptr_2)); } } listView = (AsyncListView) findViewById(R.id.listView); BitmapLruCache cache = App.getInstance(context).getBitmapCache(); ArrayListLoader loader = new ArrayListLoader(cache, context); ItemManager.Builder builder = new ItemManager.Builder(loader); builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50); builder.setThreadPoolSize(4); listView.setItemManager(builder.build()); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { final int lastItem = firstVisibleItem + visibleItemCount; if (lastItem == totalItemCount && canRefresh) { getMore(); } } }); spinner = (LinearLayout) findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { } handleIntent(getIntent()); Utils.setActionBar(context); }
From source file:com.klinker.android.twitter.services.TalonPullNotificationService.java
@Override public void onCreate() { super.onCreate(); if (TalonPullNotificationService.isRunning) { stopSelf();/*from w w w.j a v a2 s. c o m*/ return; } TalonPullNotificationService.isRunning = true; settings = AppSettings.getInstance(this); mCache = App.getInstance(this).getBitmapCache(); sharedPreferences = getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); pullUnread = sharedPreferences.getInt("pull_unread", 0); Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); Intent stop = new Intent(this, StopPull.class); PendingIntent stopPending = PendingIntent.getService(this, 0, stop, 0); Intent popup = new Intent(this, RedirectToPopup.class); popup.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); popup.putExtra("from_notification", true); PendingIntent popupPending = PendingIntent.getActivity(this, 0, popup, 0); Intent compose = new Intent(this, WidgetCompose.class); popup.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent composePending = PendingIntent.getActivity(this, 0, compose, 0); String text; int count = 0; if (sharedPreferences.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPreferences.getBoolean("is_logged_in_2", false)) { count++; } boolean multAcc = false; if (count == 2) { multAcc = true; } if (settings.liveStreaming && settings.timelineNot) { text = getResources().getString(R.string.new_tweets_upper) + ": " + pullUnread; } else { text = getResources().getString(R.string.listening_for_mentions) + "..."; } mBuilder = new NotificationCompat.Builder(this).setSmallIcon(android.R.color.transparent) .setContentTitle(getResources().getString(R.string.talon_pull) + (multAcc ? " - @" + settings.myScreenName : "")) .setContentText(text).setOngoing(true) .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_stat_icon)); if (getApplicationContext().getResources().getBoolean(R.bool.expNotifications)) { mBuilder.addAction(R.drawable.ic_cancel_dark, getApplicationContext().getResources().getString(R.string.stop), stopPending); mBuilder.addAction(R.drawable.ic_popup, getResources().getString(R.string.popup), popupPending); mBuilder.addAction(R.drawable.ic_send_dark, getResources().getString(R.string.tweet), composePending); } try { mBuilder.setWhen(0); } catch (Exception e) { } mBuilder.setContentIntent(pendingIntent); // priority flag is only available on api level 16 and above if (getResources().getBoolean(R.bool.expNotifications)) { mBuilder.setPriority(Notification.PRIORITY_MIN); } mContext = getApplicationContext(); IntentFilter filter = new IntentFilter(); filter.addAction("com.klinker.android.twitter.STOP_PUSH"); registerReceiver(stopPush, filter); filter = new IntentFilter(); filter.addAction("com.klinker.android.twitter.START_PUSH"); registerReceiver(startPush, filter); filter = new IntentFilter(); filter.addAction("com.klinker.android.twitter.STOP_PUSH_SERVICE"); registerReceiver(stopService, filter); if (settings.liveStreaming && settings.timelineNot) { filter = new IntentFilter(); filter.addAction("com.klinker.android.twitter.UPDATE_NOTIF"); registerReceiver(updateNotification, filter); filter = new IntentFilter(); filter.addAction("com.klinker.android.twitter.NEW_TWEET"); registerReceiver(updateNotification, filter); filter = new IntentFilter(); filter.addAction("com.klinker.android.twitter.CLEAR_PULL_UNREAD"); registerReceiver(clearPullUnread, filter); } Thread start = new Thread(new Runnable() { @Override public void run() { // get the ids of everyone you follow try { Log.v("getting_ids", "started getting ids, mine: " + settings.myId); Twitter twitter = Utils.getTwitter(mContext, settings); long currCursor = -1; IDs idObject; int rep = 0; do { idObject = twitter.getFriendsIDs(settings.myId, currCursor); long[] lIds = idObject.getIDs(); ids = new ArrayList<Long>(); for (int i = 0; i < lIds.length; i++) { ids.add(lIds[i]); } rep++; } while ((currCursor = idObject.getNextCursor()) != 0 && rep < 3); ids.add(settings.myId); idsLoaded = true; startForeground(FOREGROUND_SERVICE_ID, mBuilder.build()); mContext.sendBroadcast(new Intent("com.klinker.android.twitter.START_PUSH")); } catch (Exception e) { e.printStackTrace(); TalonPullNotificationService.isRunning = false; pullUnread = 0; Thread stop = new Thread(new Runnable() { @Override public void run() { TalonPullNotificationService.shuttingDown = true; try { //pushStream.removeListener(userStream); } catch (Exception x) { } try { pushStream.cleanUp(); pushStream.shutdown(); Log.v("twitter_stream_push", "stopping push notifications"); } catch (Exception e) { // it isn't running e.printStackTrace(); // try twice to shut it down i guess try { Thread.sleep(2000); pushStream.cleanUp(); pushStream.shutdown(); Log.v("twitter_stream_push", "stopping push notifications"); } catch (Exception x) { // it isn't running x.printStackTrace(); } } TalonPullNotificationService.shuttingDown = false; } }); stop.setPriority(Thread.MAX_PRIORITY); stop.start(); stopSelf(); } catch (OutOfMemoryError e) { TalonPullNotificationService.isRunning = false; Thread stop = new Thread(new Runnable() { @Override public void run() { TalonPullNotificationService.shuttingDown = true; try { //pushStream.removeListener(userStream); } catch (Exception x) { } try { pushStream.cleanUp(); pushStream.shutdown(); Log.v("twitter_stream_push", "stopping push notifications"); } catch (Exception e) { // it isn't running e.printStackTrace(); // try twice to shut it down i guess try { Thread.sleep(2000); pushStream.cleanUp(); pushStream.shutdown(); Log.v("twitter_stream_push", "stopping push notifications"); } catch (Exception x) { // it isn't running x.printStackTrace(); } } TalonPullNotificationService.shuttingDown = false; } }); stop.setPriority(Thread.MAX_PRIORITY); stop.start(); pullUnread = 0; stopSelf(); } } }); start.setPriority(Thread.MAX_PRIORITY - 1); start.start(); }
From source file:com.radadev.xkcd.Comics.java
public static final Date getLastUpdate(Context context) { SharedPreferences info = context.getSharedPreferences("info", Context.MODE_WORLD_WRITEABLE); String dateString = info.getString(KEY_LAST_UPDATE, null); return (dateString != null) ? new Date(dateString) : null; }
From source file:com.klinker.android.twitter.ui.profile_viewer.ProfilePager.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down); mCache = App.getInstance(this).getBitmapCache(); context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); settings = AppSettings.getInstance(this); try {/*from www .jav a2 s .co m*/ ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } if (getIntent().getBooleanExtra("from_widget", false) || ((settings.advanceWindowed && !getIntent().getBooleanExtra("long_click", false)) || !settings.advanceWindowed && getIntent().getBooleanExtra("long_click", false))) { setUpWindow(); } setUpTheme(); int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } getFromIntent(); setContentView(R.layout.tweet_pager); ViewPager pager = (ViewPager) findViewById(R.id.pager); ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter(getFragmentManager(), context, name, screenName, proPic, tweetId, isRetweet, isMyProfile); pager.setAdapter(mPagerAdapter); pager.setOffscreenPageLimit(3); if (settings.addonTheme) { PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); strip.setBackgroundColor(settings.pagerTitleInt); if (!settings.showTitleStrip) { strip.setVisibility(View.GONE); } } Utils.setActionBar(context, !settings.advanceWindowed); // set it to the profile pager.setCurrentItem(1); }
From source file:com.klinker.android.twitter.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainActivity.sendHandler = new Handler(); context = this; sContext = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); DrawerActivity.settings = AppSettings.getInstance(context); try {/* w w w . j a va2s . c o m*/ requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); } catch (Exception e) { } sharedPrefs.edit().putBoolean("refresh_me", getIntent().getBooleanExtra("from_notification", false)) .commit(); setUpTheme(); setUpWindow(); setContentView(R.layout.main_activity); mViewPager = (ViewPager) findViewById(R.id.pager); setUpDrawer(0, getResources().getString(R.string.timeline)); MainActivity.sendLayout = (LinearLayout) findViewById(R.id.send_layout); MainActivity.sendHandler.postDelayed(showSend, 1000); MainActivity.sendButton = (ImageButton) findViewById(R.id.send_button); MainActivity.sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent compose = new Intent(context, ComposeActivity.class); startActivity(compose); } }); actionBar = getActionBar(); actionBar.setTitle(getResources().getString(R.string.timeline)); if (!settings.isTwitterLoggedIn) { Intent login = new Intent(context, LoginActivity.class); startActivity(login); } /*else if (!sharedPrefs.getBoolean("setup_v_two", false) && !PreferenceManager.getDefaultSharedPreferences(context).getBoolean("setup_v_two", false)) { Intent setupV2 = new Intent(context, Version2Setup.class); startActivity(setupV2); }*/ mSectionsPagerAdapter = new TimelinePagerAdapter(getFragmentManager(), context, sharedPrefs, getIntent().getBooleanExtra("from_launcher", false)); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER); mViewPager.setCurrentItem(mSectionsPagerAdapter.getCount() - 3); if (getIntent().getBooleanExtra("from_launcher", false)) { actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(getIntent().getIntExtra("launcher_page", 0))); } mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrollStateChanged(int state) { } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (!actionBar.isShowing()) { actionBar.show(); if (translucent) { statusBar.setVisibility(View.VISIBLE); } } MainActivity.sendHandler.post(showSend); } public void onPageSelected(int position) { String title = "" + mSectionsPagerAdapter.getPageTitle(position); if (title.equals(getResources().getString(R.string.mentions))) { MainDrawerArrayAdapter.current = 1; } else if (title.equals(getResources().getString(R.string.direct_messages))) { MainDrawerArrayAdapter.current = 2; } else if (title.equals(getResources().getString(R.string.timeline))) { MainDrawerArrayAdapter.current = 0; } else { MainDrawerArrayAdapter.current = -1; } drawerList.invalidateViews(); actionBar.setTitle(title); } }); mViewPager.setOffscreenPageLimit(4); if (getIntent().getBooleanExtra("tutorial", false) && !sharedPrefs.getBoolean("done_tutorial", false)) { getIntent().putExtra("tutorial", false); sharedPrefs.edit().putBoolean("done_tutorial", true).commit(); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "close drawer"); mDrawerLayout.closeDrawer(Gravity.LEFT); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_CLOSE_DRAWER)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "open drawer"); mDrawerLayout.openDrawer(Gravity.LEFT); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_OPEN_DRAWER)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "page left"); mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, true); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_PAGE_LEFT)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "page right"); mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_PAGE_RIGHT)); startActivity(new Intent(context, TutorialActivity.class)); overridePendingTransition(0, 0); } setLauncherPage(); if (getIntent().getBooleanExtra("from_drawer", false)) { mViewPager.setCurrentItem(getIntent().getIntExtra("page_to_open", 3)); } }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void saved() { ////////S-A-V-E-D/////////// LinearLayout SavedParent = (LinearLayout) V.findViewById(R.id.group_pinned); LayoutInflater inflater = getActivity().getLayoutInflater(); //If there are no pinned alarms if (touchSaveIndex(0) < 1) { View Saved = inflater.inflate(R.layout.saved_item, null); Saved.setOnClickListener(this); ((TextView) Saved.findViewById(R.id.savedLabel)).setText("No Pinned Alarms"); ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setEnabled(false); ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); LinearLayout.LayoutParams sparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); SavedParent.setLayoutParams(sparams); SavedParent.addView(Saved);//from w ww .j a v a 2s . c o m } else { for (int i = 1; i <= touchSaveIndex(0); i++) { // View Saved = new View(getApplicationContext()); View Saved = inflater.inflate(R.layout.saved_item, null); Saved.setOnClickListener(this); SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); Location location = new Location("POINT_LOCATION"); location.setLatitude(0); location.setLongitude(0); String address = "No Pinned Alarms"; if (prefs.contains(SAVED_LATITUDE_KEY + i)) { location.setLatitude(prefs.getFloat(SAVED_LATITUDE_KEY + i, 0)); } if (prefs.contains(SAVED_LONGITUDE_KEY + i)) { location.setLongitude(prefs.getFloat(SAVED_LONGITUDE_KEY + i, 0)); } if (prefs.contains(SAVED_ADDRESS_KEY + i)) { address = (prefs.getString(SAVED_ADDRESS_KEY + i, "")); } CharSequence name; if (!address.equals("")) { name = address; ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDDFFFFFF); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setTag(i); ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); } else { name = "Error"; ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setEnabled(false); } ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); ((TextView) Saved.findViewById(R.id.savedLabel)).setText(name); ((TextView) Saved.findViewById(R.id.savedLabel)).setTextSize(14); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); SavedParent.setLayoutParams(params); SavedParent.addView(Saved); } } }
From source file:org.cirrus.mobi.pegel.PegelFragmentsActivity.java
private Dialog createNotFoundDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.pegelNotFound).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //delete preferences SharedPreferences settings = getSharedPreferences("prefs", Context.MODE_WORLD_WRITEABLE); SharedPreferences.Editor edit = settings.edit(); edit.clear();/*from w ww .j a v a2 s.co m*/ edit.commit(); //clear selection, remove fragments Intent i = new Intent(PegelFragmentsActivity.this, PegelFragmentsActivity.class); startActivity(i); } }); return builder.create(); }
From source file:com.klinker.android.twitter.ui.compose.Compose.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); countHandler = new Handler(); settings = AppSettings.getInstance(this); context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); try {//from www . jav a 2 s . c o m ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } currentAccount = sharedPrefs.getInt("current_account", 1); mLocationClient = new LocationClient(context, this, this); mLocationClient.connect(); Utils.setUpPopupTheme(context, settings); setUpWindow(); setUpLayout(); setUpActionBar(); setUpReplyText(); if (reply.getText().toString().contains(" RT @")) { reply.setSelection(0); } //Utils.setActionBar(context, false); if (getIntent().getBooleanExtra("start_attach", false)) { attachButton.performClick(); //overflow.performClick(); } if (notiId != 0) { HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to); replyTo.setText(replyText); TextUtils.linkifyText(context, replyTo, null, true, "", true); replyTo.setVisibility(View.VISIBLE); } new Handler().postDelayed(new Runnable() { @Override public void run() { String text = reply.getText().toString(); try { if (!android.text.TextUtils.isEmpty(text) && !text.startsWith(" RT @")) { //text = text.replaceAll(" ", " "); reply.setText(text); reply.setSelection(text.length()); if (!text.endsWith(" ")) { reply.append(" "); } } } catch (Exception e) { } } }, 250); }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); countHandler = new Handler(); settings = AppSettings.getInstance(this); context = this; sharedPrefs = context.getSharedPreferences("com.daiv.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); try {//from ww w.j av a 2 s . c om ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } currentAccount = sharedPrefs.getInt("current_account", 1); buildGoogleApiClient(); Utils.setUpPopupTheme(context, settings); setUpWindow(); setUpLayout(); setUpActionBar(); setUpReplyText(); if (reply.getText().toString().contains(" RT @") || reply.getText().toString().contains("/status/")) { reply.setSelection(0); } if (getIntent().getBooleanExtra("start_attach", false)) { attachButton.performClick(); //overflow.performClick(); } if (notiId != 0) { HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to); replyTo.setText(replyText); TextUtils.linkifyText(context, replyTo, null, true, "", true); replyTo.setVisibility(View.VISIBLE); } new Handler().postDelayed(new Runnable() { @Override public void run() { String text = reply.getText().toString(); try { if (!android.text.TextUtils.isEmpty(text) && !(text.startsWith(" RT @") || text.contains("/status/"))) { //text = text.replaceAll(" ", " "); reply.setText(text); reply.setSelection(text.length()); if (!text.endsWith(" ")) { reply.append(" "); } } } catch (Exception e) { } } }, 250); }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void setSaved(int index) { SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); SharedPreferences.Editor prefsEditor = prefs.edit(); Location location = new Location("POINT_LOCATION"); location.setLatitude(0);//from w w w . j a va 2 s .c o m location.setLongitude(0); int setRad = 0; String setAddress = ""; if (prefs.contains(POINT_LATITUDE_KEY + index)) { location.setLatitude(prefs.getFloat(POINT_LATITUDE_KEY + index, 0)); } if (prefs.contains(POINT_LONGITUDE_KEY + index)) { location.setLongitude(prefs.getFloat(POINT_LONGITUDE_KEY + index, 0)); } if (prefs.contains(POINT_RADIUS_KEY + index)) { setRad = prefs.getInt(POINT_RADIUS_KEY + index, 0); } if (prefs.contains(POINT_ADDRESS_KEY + index)) { setAddress = prefs.getString(POINT_ADDRESS_KEY + index, ""); } touchSaveIndex(1); float setLat = (float) location.getLatitude(); float setLong = (float) location.getLongitude(); prefsEditor.putFloat(SAVED_LATITUDE_KEY + touchSaveIndex(0), setLat); prefsEditor.putFloat(SAVED_LONGITUDE_KEY + touchSaveIndex(0), setLong); prefsEditor.putInt(SAVED_RADIUS_KEY + touchSaveIndex(0), setRad); prefsEditor.putString(SAVED_ADDRESS_KEY + touchSaveIndex(0), setAddress); prefsEditor.commit(); }