List of usage examples for android.content Context MODE_WORLD_READABLE
int MODE_WORLD_READABLE
To view the source code for android.content Context MODE_WORLD_READABLE.
Click Source Link
From source file:com.afreire.plugins.video.VideoPlayer.java
private void copy(String fileFrom, String fileTo) throws IOException { // get file to be copied from assets //InputStream in = this.cordova.getActivity().getAssets().open(fileFrom); // The video is obtained from any location and not just assets. InputStream in = new FileInputStream(fileFrom); // get file where copied too, in internal storage. // must be MODE_WORLD_READABLE or Android can't play it FileOutputStream out = this.cordova.getActivity().openFileOutput(fileTo, Context.MODE_WORLD_READABLE); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len;/*from w ww.j a v a 2s. co m*/ while ((len = in.read(buf)) > 0) out.write(buf, 0, len); in.close(); out.close(); }
From source file:de.Maxr1998.xposed.maxlock.ui.settings.SettingsFragment.java
@SuppressLint("WorldReadableFiles") @Override/* w w w. j a va 2s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); //noinspection deprecation getPreferenceManager().setSharedPreferencesMode(Activity.MODE_WORLD_READABLE); addPreferencesFromResource(R.xml.preferences_main); PREFS = PreferenceManager.getDefaultSharedPreferences(getActivity()); PREFS_KEYS = getActivity().getSharedPreferences(Common.PREFS_KEY, Context.MODE_PRIVATE); //noinspection deprecation PREFS_THEME = getActivity().getSharedPreferences(Common.PREFS_THEME, Context.MODE_WORLD_READABLE); devicePolicyManager = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE); deviceAdmin = new ComponentName(getActivity(), UninstallProtectionReceiver.class); }
From source file:de.Maxr1998.xposed.maxlock.ui.SettingsActivity.java
@SuppressLint("WorldReadableFiles") @SuppressWarnings("deprecation") @Override//from ww w. jav a2s. co m public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.toolbar_menu, menu); SwitchCompat master_switch = (SwitchCompat) MenuItemCompat .getActionView(menu.findItem(R.id.toolbar_master_switch)); master_switch.setChecked(getSharedPreferences(Common.PREFS_PACKAGES, Context.MODE_WORLD_READABLE) .getBoolean(Common.MASTER_SWITCH_ON, false)); master_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @SuppressLint({ "CommitPrefEdits" }) @Override public void onCheckedChanged(CompoundButton button, boolean b) { getSharedPreferences(Common.PREFS_PACKAGES, Context.MODE_WORLD_READABLE).edit() .putBoolean(Common.MASTER_SWITCH_ON, b).commit(); } }); Fragment appsList = getSupportFragmentManager().findFragmentByTag("AppListFragment"); if (appsList != null && appsList.isVisible()) { menu.findItem(R.id.toolbar_info).setVisible(false); menu.findItem(R.id.toolbar_master_switch).setVisible(false); } Fragment guide = getSupportFragmentManager().findFragmentByTag("GuideFragment"); if (guide != null && guide.isVisible()) { menu.findItem(R.id.toolbar_info).setVisible(false); } return super.onCreateOptionsMenu(menu); }
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 w ww .j a v 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 } 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:br.ufrgs.urbosenti.test.TestManager.java
public TestManager(DeviceManager deviceManager, String filesName, Context context) throws IOException { super(deviceManager, COMPONENT_ID); this.deviceManager = deviceManager; FileOutputStream outputStream = context.openFileOutput("actionResults" + filesName + ".out", Context.MODE_WORLD_READABLE); //this.experimentalResults = new FileWriter(new File("actionResults" + filesName + ".out")); this.writer = outputStream; this.shudown = false; this.eventCount = 0; this.eventLimit = 1; this.interactionMode = 0; }
From source file:com.radadev.xkcd.Comics.java
public static final boolean setLastUpdate(Context context, Date date) { Editor editor = context.getSharedPreferences("info", Context.MODE_WORLD_READABLE).edit(); editor.putString(KEY_LAST_UPDATE, date.toGMTString()); return editor.commit(); }
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 {/*from w w w .ja v a 2 s . 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.xtensive.plugins.pdfviewer.PDFViewer.java
private void copy(InputStream in, String fileTo) throws IOException { // get file to be copied from assets //InputStream in = this.cordova.getActivity().getAssets().open(fileFrom); // get file where copied too, in internal storage. // must be MODE_WORLD_READABLE or Android can't play it FileOutputStream out = this.cordova.getActivity().openFileOutput(fileTo, Context.MODE_WORLD_READABLE); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len;/* w ww.ja va 2 s. c om*/ while ((len = in.read(buf)) > 0) out.write(buf, 0, len); in.close(); out.close(); }
From source file:biz.wiz.android.wallet.WalletApplication.java
private void initLogging() { final File logDir = getDir("log", Constants.TEST ? Context.MODE_WORLD_READABLE : MODE_PRIVATE); final File logFile = new File(logDir, "wallet.log"); final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); final PatternLayoutEncoder filePattern = new PatternLayoutEncoder(); filePattern.setContext(context);/* w w w.j a v a 2s. c om*/ filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n"); filePattern.start(); final RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>(); fileAppender.setContext(context); fileAppender.setFile(logFile.getAbsolutePath()); final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>(); rollingPolicy.setContext(context); rollingPolicy.setParent(fileAppender); rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/wallet.%d.log.gz"); rollingPolicy.setMaxHistory(7); rollingPolicy.start(); fileAppender.setEncoder(filePattern); fileAppender.setRollingPolicy(rollingPolicy); fileAppender.start(); final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder(); logcatTagPattern.setContext(context); logcatTagPattern.setPattern("%logger{0}"); logcatTagPattern.start(); final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder(); logcatPattern.setContext(context); logcatPattern.setPattern("[%thread] %msg%n"); logcatPattern.start(); final LogcatAppender logcatAppender = new LogcatAppender(); logcatAppender.setContext(context); logcatAppender.setTagEncoder(logcatTagPattern); logcatAppender.setEncoder(logcatPattern); logcatAppender.start(); final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME); log.addAppender(fileAppender); log.addAppender(logcatAppender); log.setLevel(Level.INFO); }
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 {// ww w . ja va2 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); }