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.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 {// ww w . ja va 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 } 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.rong.xposed.headsoff.PerAppWhiteList.java
@Override @SuppressLint("WorldReadableFiles") @SuppressWarnings("deprecation") public void onClick(View v) { int id = v.getId(); if (id == R.id.btn_add) { String pattern = edtRegex.getText().toString(); boolean bClear = false; if (TextUtils.isEmpty(pattern)) { Toast.makeText(this, R.string.white_list_add_empty, Toast.LENGTH_LONG).show(); return; }/*from w ww . j ava 2 s .c o m*/ if (isRegexValid(pattern)) { if (mList.size() < SettingValues.WHITE_LIST_MAX) { if (checkIfExists(pattern)) { Toast.makeText(this, R.string.white_list_add_exists_already, Toast.LENGTH_LONG).show(); return; } mList.add(pattern); bClear = true; SharedPreferences prefs = getSharedPreferences(SettingValues.PREF_FILE, Context.MODE_WORLD_READABLE); SharedPreferences.Editor editor = prefs.edit(); String key = packageName + SettingValues.KEY_SUFFIX_WHITELIST_COUNT; editor.putInt(key, mList.size()); editor.apply(); key = packageName + SettingValues.KEY_SUFFIX_WHITELIST; editor.putStringSet(key, new HashSet<>(mList)); editor.apply(); mAdapter.notifyDataSetChanged(); checkShowEmptyListHint(); Toast.makeText(this, R.string.white_list_add_success, Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, getString(R.string.white_list_exceeded_limitation, SettingValues.WHITE_LIST_MAX), Toast.LENGTH_LONG).show(); } } else { Toast.makeText(this, R.string.white_list_invalid_regex_pattern, Toast.LENGTH_LONG).show(); edtRegex.requestFocus(); } if (bClear) { edtRegex.setText(""); testEdit.setText(""); if (testEdit.hasFocus()) testEdit.clearFocus(); } } }
From source file:com.entradahealth.entrada.android.app.personal.activities.job_list.JobListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; application = (EntradaApplication) EntradaApplication.getAppContext(); sp = getSharedPreferences("Entrada", Context.MODE_WORLD_READABLE); if (sp.getBoolean("SECURE_MSG", true)) getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); else// ww w.j a v a 2s .com getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); final JobListActivity thisActivity = this; //Custom view as action bar LayoutInflater mInflater = LayoutInflater.from(this); View mCustomView = mInflater.inflate(R.layout.acbar_job_list, null); tvAcTitle = (TextView) mCustomView.findViewById(R.id.tvAcTitle); ivInbox = (ImageView) mCustomView.findViewById(R.id.ivInbox); ivAddJob = (ImageView) mCustomView.findViewById(R.id.ivAddJob); ivSync = (ImageView) mCustomView.findViewById(R.id.ivSync); ivSchedule = (ImageView) mCustomView.findViewById(R.id.ivSchedule); tvAcTitle.setText(BundleKeys.title); //Sample icon badger on Action bar item badge = new BadgeView(this, ivInbox); if (BundleKeys.fromSecureMessaging || !application.isJobListEnabled()) { startActivity(new Intent(JobListActivity.this, SecureMessaging.class)); finish(); } ivInbox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent(JobListActivity.this, SecureMessaging.class)); finish(); } }); ivAddJob.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent addJobIntent = new Intent(JobListActivity.this, AddJobActivity.class); addJobIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(addJobIntent); finish(); } }); ivSync.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ns = new NetworkState(getApplicationContext()); isConnected = ns.isConnectingToInternet(); if (isConnected) { running = false; ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.entradahealth.entrada.android.app.personal.sync.SyncService" .equals(service.service.getClassName()) || "com.entradahealth.entrada.android.app.personal.sync.DictationUploadService" .equals(service.service.getClassName())) { running = true; } } if (!running) { etSearch.setText(null); if (!isFinishing()) { //retryUploads(); boolean canSync = true; try { List<Job> jobs = AndroidState.getInstance().getUserState() .getProvider(currentAccount).getJobs(); for (Job j : jobs) { if (j.isPending()) { canSync = false; UserState state = AndroidState.getInstance().getUserState(); Log.e("", "onOptionsItemSelected-syncMenuItem--" + j.id); DictationUploadService.startUpload(JobListActivity.this, state, currentAccount, j); } } } catch (Exception ex) { ACRA.getErrorReporter().handleSilentException(ex); canSync = false; } if (!canSync) { Toast.makeText(JobListActivity.this, "Please wait for all uploads to complete before syncing.", Toast.LENGTH_SHORT).show(); } else { rlSyncError.setVisibility(View.GONE); rlUpdated.setVisibility(View.INVISIBLE); tvUpdating.setVisibility(View.VISIBLE); Intent i = new Intent(JobListActivity.this, SyncService.class); startService(i); } isSyncing = true; BundleKeys.SYNC_FOR_ACC = currentAccount.getDisplayName(); //BundleKeys.SYNC_FOR_CLINIC = currentAccount.getClinicCode(); /*task1 = buildMinderTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task1.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { task1.execute(); }*/ } } else { if (!isResumed) Toast.makeText(JobListActivity.this, "Please wait for all uploads to complete before syncing.", Toast.LENGTH_SHORT) .show(); } isResumed = false; } else { rlSyncError.setVisibility(View.VISIBLE); rlUpdated.setVisibility(View.GONE); tvUpdating.setVisibility(View.GONE); } } }); ivSchedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(JobListActivity.this, ScheduleActivity.class)); finish(); } }); getActionBar().setCustomView(mCustomView); getActionBar().setDisplayShowCustomEnabled(true); //ActionBar ab = getActionBar(); //ab.setTitle(BundleKeys.title); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); registerReceiver(broadcastReceiver, new IntentFilter("CONNECTIVITY_CHANGED")); jobIds = new ArrayList<Long>(); BundleKeys.fromImageDisplay = false; BundleKeys.fromCaputreImages = false; BundleKeys.fromSecureMessaging = false; /*Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread paramThread, Throwable paramThrowable) { Log.e("Job-List-Activity","Uncaught-Exception"); System.exit(2); } });*/ setBehindContentView(R.layout.job_list_sliding_menu); tvListTitle = (TextView) findViewById(R.id.tvListTitle); tvListTitle.setText("Jobs"); lvSliding = (ListView) findViewById(R.id.lvSlidingMenu); lvSliding.setBackgroundColor(Color.parseColor("#262b38")); // Get screen width and set sliding width to 3/4 Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int req_width = width * 3 / 4; slidingMenu = getSlidingMenu(); slidingMenu.setFadeEnabled(true); slidingMenu.setFadeDegree(0.35f); slidingMenu.setBehindWidth(req_width); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); setContentView(R.layout.job_list); ivDrawer = (ImageView) findViewById(R.id.ivDrawer); ivDrawer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub slidingMenu.toggle(); // JobCountTask(); } }); rlUpdated = (RelativeLayout) findViewById(R.id.rlDateTime); rlSyncError = (RelativeLayout) findViewById(R.id.rlSyncError); rlSyncError.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.title_sync_error); builder.setMessage(R.string.msg_sync_error); builder.setPositiveButton("OK", null); dgSyncError = builder.create(); dgSyncError.show(); } }); tvDate = (TextView) findViewById(R.id.tvDate); tvTime = (TextView) findViewById(R.id.tvTime); tvUpdating = (TextView) findViewById(R.id.lblUpdating); tvSyncFailed = (TextView) findViewById(R.id.lblSyncError); handler = new Handler(); handler.postDelayed(runnable, BundleKeys.mins_to_sync * 60 * 1000); handler.postDelayed(runnable_logs, 5 * 60 * 1000); jobListView = (ListView) findViewById(R.id.jobListView); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); jobListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { // TODO: evaluate whether to save search text in // UserState to repopulate on back press. itemClicked = true; if (searchTask != null) { searchTask.cancel(true); } Log.d("", "-- Job ItemClick --"); List<Long> jobList = thisActivity.getJobIdList(); Preconditions.checkNotNull(jobList, "null List<Job> when adapter view clicked."); Job job = AndroidState.getInstance().getUserState().getProvider(currentAccount) .getJob(jobList.get(position)); if (job != null) { Preconditions.checkNotNull(job, "null item in List<Job> when adapter view clicked."); if (job.isFlagSet(Job.Flags.UPLOAD_COMPLETED) || job.isFlagSet(Job.Flags.UPLOAD_IN_PROGRESS) || (job.isFlagSet(Job.Flags.UPLOAD_PENDING) && BundleKeys.which == 6)) { Toast.makeText(thisActivity, "Cannot open a completed dictation.", Toast.LENGTH_SHORT) .show(); return; } else if (job.isFlagSet(Job.Flags.LOCALLY_DELETED)) { return; } Intent intent = new Intent(thisActivity, JobDisplayActivity.class); Bundle b = new Bundle(); if (!job.isFlagSet(Flags.HOLD)) job = job.setFlag(Flags.IS_FIRST); else job = job.clearFlag(Flags.IS_FIRST); try { AndroidState.getInstance().getUserState().getProvider(currentAccount).updateJob(job); } catch (DomainObjectWriteException e) { // TODO Auto-generated catch block e.printStackTrace(); } b.putBoolean("isFirst", true); b.putBoolean("isFromList", true); b.putBoolean("isNew", false); b.putLong(BundleKeys.SELECTED_JOB, job.id); b.putString(BundleKeys.SELECTED_JOB_ACCOUNT, currentAccount.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(b); thisActivity.startActivity(intent); thisActivity.finish(); } } }); jobListView.setMultiChoiceModeListener(new JobListMultiChoiceModeListener(this)); slidingMenu.setOnOpenListener(new OnOpenListener() { @Override public void onOpen() { // TODO Auto-generated method stub openSlide(); } }); lvSliding.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { // TODO Auto-generated method stub switch (pos) { case 1: //getActionBar().setTitle("Today's Jobs"); tvAcTitle.setText("Today's Jobs"); BundleKeys.title = "Today's Jobs"; BundleKeys.which = 1; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 2: //getActionBar().setTitle("Tomorrow's Jobs"); tvAcTitle.setText("Tomorrow's Jobs"); BundleKeys.which = 2; BundleKeys.title = "Tomorrow's Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 3: //getActionBar().setTitle("Stat Jobs"); tvAcTitle.setText("Stat Jobs"); BundleKeys.which = 3; BundleKeys.title = "Stat Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 4: //getActionBar().setTitle("All Jobs"); tvAcTitle.setText("All Jobs"); BundleKeys.which = 4; BundleKeys.title = "All Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 6: //getActionBar().setTitle("Hold Jobs"); tvAcTitle.setText("Hold Jobs"); BundleKeys.which = 5; BundleKeys.title = "Hold Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 7: //getActionBar().setTitle("Deleted Jobs"); tvAcTitle.setText("Deleted Jobs"); BundleKeys.which = 7; BundleKeys.title = "Deleted Jobs"; // Hide "Add Job" menu item //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(false); ivAddJob.setVisibility(View.GONE); jobListView.setChoiceMode(ListView.CHOICE_MODE_NONE); etSearch.setText(""); break; case 8: //getActionBar().setTitle("Completed Jobs"); tvAcTitle.setText("Completed Jobs"); BundleKeys.which = 6; BundleKeys.title = "Completed Jobs"; // Hide "Add Job" menu item //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(false); ivAddJob.setVisibility(View.GONE); jobListView.setChoiceMode(ListView.CHOICE_MODE_NONE); etSearch.setText(""); break; case 10: isSetting = true; //getActionBar().setTitle("Settings"); tvAcTitle.setText("Settings Jobs"); startActivity(new Intent(JobListActivity.this, EntradaSettings.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); finish(); break; case 11: // Check if there are any held jobs or any uploads in // progress boolean isHeld = true, isPending = true; try { List<Job> jobs = AndroidState.getInstance().getUserState().getProvider(currentAccount) .getJobs(); for (Job j : jobs) { if (j.isPending()) isPending = false; if (j.isFlagSet(Job.Flags.HOLD)) isHeld = false; } } catch (Exception ex) { ACRA.getErrorReporter().handleSilentException(ex); isPending = false; isHeld = false; } if (SyncService.isRunning()) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_upload_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } else if (isPending && isHeld) { Intent qIntent = new Intent(JobListActivity.this, ManageQueuesActivity.class); qIntent.putExtra("from_settings", false); qIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(qIntent); finish(); } else if (!isHeld) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_hold_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } else if (!isPending) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_upload_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } break; default: //getActionBar().setTitle("Today's Jobs"); tvAcTitle.setText("Today's Jobs"); BundleKeys.title = "Today's Jobs"; BundleKeys.which = 1; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); } Log.e(LOG_NAME, Integer.toString(BundleKeys.which) + " - " + BundleKeys.title); isSync = false; slidingMenu.toggle(true); /* * Log.e("isSetting", Boolean.toString(isSetting)); * if(BundleKeys.which != 8 && BundleKeys.which != 9 && * !isSetting) etSearch.setText(""); */ } }); rlSearch = (RelativeLayout) findViewById(R.id.rlSearch); etSearch = (EditText) findViewById(R.id.etSearch); etSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //launchSearchTask(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub try { Thread.sleep(200); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } launchSearchTask(); } }); GetResourcesTask task = new GetResourcesTask(); task.execute(); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdateManager.java
private void installPackage(final Context context, final byte[] apkContents, final UpdateListener listener) { final AsyncTask<Void, Void, File> task = new AsyncTask<Void, Void, File>() { volatile Exception exception; @SuppressLint("WorldReadableFiles") @Override/*from w w w . j a va 2s .co m*/ protected File doInBackground(Void... params) { try { if (Utilities.isNullOrEmpty(apkContents)) { throw new NullPointerException("apkContents"); } String tempFileName = "nextversion.apk"; File tempFile = context.getFileStreamPath(tempFileName); if (tempFile.exists()) { tempFile.delete(); } FileOutputStream fout = context.openFileOutput(tempFileName, Context.MODE_WORLD_READABLE); try { fout.write(apkContents); fout.flush(); } finally { try { fout.close(); } catch (Exception e) { // omit } } return tempFile; } catch (Exception e) { exception = e; Log.e("Couldn't save apk", e); return null; } } @Override protected void onPostExecute(File result) { if (exception == null) { try { Uri data = Uri.fromFile(result); String type = "application/vnd.android.package-archive"; Intent promptInstall = new Intent(Intent.ACTION_VIEW); promptInstall.setDataAndType(data, type); context.startActivity(promptInstall); if (listener != null) { listener.onUpdateCompleted(); } return; } catch (Exception e) { exception = e; } } if (listener == null) { Log.e("Update failed", exception); } else { listener.onUpdateFailed(exception); } } }; task.execute(); }
From source file:edu.umich.oasis.service.KVSSharedPrefs.java
@SuppressWarnings("deprecation") public KVSSharedPrefs(Sandbox sandbox, String owningPackage, String callingPackage, String storeName, int mode) { mContext = OASISApplication.getInstance(); mSandbox = sandbox;//from ww w.j av a2s . c o m mStoreName = storeName; mOwningPackage = mContext.checkPackageName(owningPackage); SharedPreferences sp = getPlatformSharedPrefs(storeName); mPrefs = NamespaceSharedPrefs.get(sp, TAINT_SET, TAINT); // Handle read and write permissions, as previously configured. boolean configReadPublic = mPrefs.getBoolean(CONFIG, CONFIG_PUBLIC_READABLE, false); boolean configWritePublic = mPrefs.getBoolean(CONFIG, CONFIG_PUBLIC_WRITABLE, false); if (localLOGD) { Log.d(TAG, String.format("Store '%s', owner '%s', caller '%s'", storeName, owningPackage, callingPackage)); } // Are we trying to load this package's prefs, or something else? boolean isSamePackage = Objects.equals(owningPackage, callingPackage); // Set the readable and writable flags for this object... isReadable = isSamePackage || configReadPublic; isWritable = isSamePackage || configWritePublic; // ...And set the flags that will be written on update. canReadPublic = (mode & Context.MODE_WORLD_READABLE) != 0; canWritePublic = (mode & Context.MODE_WORLD_WRITEABLE) != 0; isClosed = false; }
From source file:edu.umich.flowfence.service.KVSSharedPrefs.java
@SuppressWarnings("deprecation") public KVSSharedPrefs(Sandbox sandbox, String owningPackage, String callingPackage, String storeName, int mode) { mContext = FlowfenceApplication.getInstance(); mSandbox = sandbox;/*from w w w.j a va 2 s. c o m*/ mStoreName = storeName; mOwningPackage = mContext.checkPackageName(owningPackage); SharedPreferences sp = getPlatformSharedPrefs(storeName); mPrefs = NamespaceSharedPrefs.get(sp, TAINT_SET, TAINT); // Handle read and write permissions, as previously configured. boolean configReadPublic = mPrefs.getBoolean(CONFIG, CONFIG_PUBLIC_READABLE, false); boolean configWritePublic = mPrefs.getBoolean(CONFIG, CONFIG_PUBLIC_WRITABLE, false); if (localLOGD) { Log.d(TAG, String.format("Store '%s', owner '%s', caller '%s'", storeName, owningPackage, callingPackage)); } // Are we trying to load this package's prefs, or something else? boolean isSamePackage = Objects.equals(owningPackage, callingPackage); // Set the readable and writable flags for this object... isReadable = isSamePackage || configReadPublic; isWritable = isSamePackage || configWritePublic; // ...And set the flags that will be written on update. canReadPublic = (mode & Context.MODE_WORLD_READABLE) != 0; canWritePublic = (mode & Context.MODE_WORLD_WRITEABLE) != 0; isClosed = false; }
From source file:com.polyvi.xface.extension.camera.XCameraExt.java
private File createCaptureFile(int encodingType) { Context context = getContext(); String picName = ""; File photo = null;/* www. ja v a 2s. com*/ long time = Calendar.getInstance().getTimeInMillis(); if (mEncodingType == JPEG) { picName = String.valueOf(time) + ".jpg"; } else if (mEncodingType == PNG) { picName = String.valueOf(time) + ".png"; } else { throw new IllegalArgumentException("Invalid Encoding Type: " + mEncodingType); } photo = context.getFileStreamPath(picName); if (!photo.exists()) { try { FileOutputStream outStream = context.openFileOutput(picName, Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); outStream.close(); photo = context.getFileStreamPath(picName); } catch (FileNotFoundException e) { XLog.e(CLASS_NAME, "Create picture failed!"); } catch (IOException e) { XLog.e(CLASS_NAME, "Close picture fileStream failed!"); } } return photo; }
From source file:com.orange.ocara.ui.activity.BaseActivity.java
@SuppressWarnings("deprecation") private void viewFile(InputStream in, OutputStream out, File file, String pdfName) throws IOException { out = openFileOutput(file.getName(), Context.MODE_WORLD_READABLE); copyFile(in, out);//from w w w .j a v a 2 s . c o m in.close(); in = null; out.flush(); out.close(); out = null; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + getFilesDir() + File.separator + pdfName), "application/pdf"); startActivity(intent); }
From source file:com.rong.xposed.headsoff.PerAppWhiteList.java
@SuppressLint("WorldReadableFiles") @SuppressWarnings("deprecation") private List<String> getWhiteList(String pkg) { SharedPreferences prefs = getSharedPreferences(SettingValues.PREF_FILE, Context.MODE_WORLD_READABLE); String key = pkg + SettingValues.KEY_SUFFIX_WHITELIST_COUNT; int count = prefs.getInt(key, SettingValues.DEFAULT_WHITELIST_COUNT); if (count == 0) { return new ArrayList<>(); }/* w w w . j a va 2 s .c om*/ key = pkg + SettingValues.KEY_SUFFIX_WHITELIST; Set<String> set = prefs.getStringSet(key, null); if (set == null) return new ArrayList<>(); return new ArrayList<>(set); }
From source file:joshuamgoodwin.gmail.com.ohiolegalaidassistant.MainActivity.java
private void selectItem(String groupName, int groupPosition, int childPosition, String childName) { // update the main content by replacing fragments Fragment fragmentName = new Welcome(); ActionMenuItemView search = (ActionMenuItemView) findViewById(R.id.action_search); //search.setVisibility(View.INVISIBLE); String tag = "WELCOME"; Bundle bundle = new Bundle(); boolean welcomeVisible = false; // Welcome welcome = (Welcome)getFragmentManager().findFragmentByTag("WELCOME"); // if (welcome.isVisible()) welcomeVisible = true; if (groupName.equals("Calculators")) { if (childName.equals(getString(R.string.OWF_calculator))) { fragmentName = new OwfCalculator(); tag = "OWF_CALCULATOR"; } else if (childName.equals(getString(R.string.federal_poverty))) { fragmentName = new FplCalculatorController(); tag = "FPL_CALCULATOR"; } else if (childName.equals(getString(R.string.food_stamps))) { fragmentName = new FsCalculator(); tag = "FS_CALCULATOR"; } else if (childName.equals(getString(R.string.child_support))) { String url = "https://www.lawhelpinteractive.org/login_form?template_id=template.2014-06-05.4419790386&set_language=en"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url));//from ww w .j av a 2 s.c om startActivity(i); } else if (childName.equals(getString(R.string.APR))) { fragmentName = new APRCalculator(); tag = "APR"; } else if (childName.equals(getString(R.string.ACACalculator))) { fragmentName = new ACACalculator(); tag = "ACA"; } else if (childName.equals("Garnishment")) { fragmentName = new GarnishmentCalculator(); tag = "GARNISHMENT"; } else { fragmentName = new Welcome(); } } else if (groupName.equals("Court Dockets")) { tag = "WEBVIEW"; if (childName.equals(getString(R.string.edit_courts))) { fragmentName = new ShowCourtsFragment(); } else { CourtSitesDAO dao = new CourtSitesDAO(this); String address = dao.addressFromName(childName); bundle = new Bundle(); bundle.putString("address", address); fragmentName = new WebViewFragment(); fragmentName.setArguments(bundle); } } else if (groupName.equals("Rules")) { fragmentName = new RulesFragment(); //search.setVisibility(View.VISIBLE); tag = "RULES"; if (childName.equals("Federal Rules of Evidence")) { bundle.putString("ruleSet", "fre_by_rule"); } if (childName.equals("Federal Rules of Civil Procedure")) { bundle.putString("ruleSet", "federal_rules_cp"); } if (childName.equals("Ohio Rules of Civil Procedure")) { bundle.putString("ruleSet", "ohio_rules_cp"); } if (childName.equals("Ohio Rules of Evidence")) { bundle.putString("ruleSet", "ohio_rules_evidence"); } if (childName.equals("Ohio Rules of Juvenile Procedure")) { bundle.putString("ruleSet", "ohio_rules_juvenile"); } if (childName.equals("Ohio Rules of Appellate Procedure")) { bundle.putString("ruleSet", "ohio_appellate_rules"); } fragmentName.setArguments(bundle); } else if (groupName.equals("About")) { fragmentName = new AboutFragment(); tag = "ABOUT"; } else if (groupName.equals("License")) { fragmentName = new LicenseFragment(); tag = "LICENSE"; } else if (groupName.equals("Forms")) { if (childName.equals("Exemption List")) { CopyAssets("exemption.pdf"); } else if (childName.equals("Standards Help Sheet")) { CopyAssets("standards_help_sheet.pdf"); } else if (childName.equals("Edit/Add Forms")) { fragmentName = new ShowFormsFragment(); tag = "ADD FORMS"; } else { FormsDAO formsDao = new FormsDAO(this); String fileName = formsDao.addressFromName(childName); File file = new File(fileName); AssetManager am = getAssets(); InputStream in = null; OutputStream out = null; try { in = am.open(fileName); out = openFileOutput(file.getName(), Context.MODE_WORLD_READABLE); copyFile(in, out); in.close(); in = null; out.close(); out = null; } catch (Exception e) { Log.e("tag", e.getMessage()); } Intent intent = new Intent(Intent.ACTION_VIEW); String ext = formsDao.extensionFromName(childName); String type; if (ext.equals("doc") || ext.equals("docx")) { // Word document type = "application/msword"; } else if (ext.equals("pdf")) { // PDF file type = "application/pdf"; } else if (ext.equals("ppt") || ext.equals("pptx")) { // Powerpoint file type = "application/vnd.ms-powerpoint"; } else if (ext.equals("xls") || ext.equals("xlsx")) { // Excel file type = "application/vnd.ms-excel"; } else if (ext.equals("zip") || ext.equals("rar")) { // WAV audio file type = "application/x-wav"; } else if (ext.equals("rtf")) { // RTF file type = "application/rtf"; } else if (ext.equals("wav") || ext.equals("mp3")) { // WAV audio file type = "audio/x-wav"; } else if (ext.equals("gif")) { // GIF file type = "image/gif"; } else if (ext.equals("jpg") || ext.equals("jpeg") || ext.equals("png")) { // JPG file type = "image/jpeg"; } else if (ext.equals("txt")) { // Text file type = "text/plain"; } else if (ext.equals("3gp") || ext.equals("mpg") || ext.equals("mpeg") || ext.equals("mpe") || ext.equals("mp4") || ext.equals("avi")) { // Video files type = "video/*"; } else { //if you want you can also define the intent type for any other file //additionally use else clause below, to manage other unknown extensions //in this case, Android will show all applications installed on the device //so you can choose which application to use type = "*/*"; } intent.setDataAndType(Uri.parse("file://" + fileName), type); startActivity(intent); } } else if (groupName.equals("Negotiations")) { if (childName.equals(getString(R.string.add_negotiations))) { fragmentName = new ShowNegotiationsFragment(); tag = "Negotiations"; } } else { fragmentName = new Welcome(); } setFragment(fragmentName, tag); // update selected item and title, then close the drawer LinearLayout mDrawerContent = (LinearLayout) findViewById(R.id.left_drawer); mDrawerList.setItemChecked(childPosition, true); if (groupName.equals("About")) { setTitle("About"); } else if (groupName.equals("License")) { setTitle("License"); } else { setTitle(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition)); } mDrawerLayout.closeDrawer(mDrawerContent); }