List of usage examples for android.os Bundle getStringArray
@Nullable
public String[] getStringArray(@Nullable String key)
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ???/* ww w . ja va 2s .c o m*/ * * @param savedInstanceState Bundle */ private void loadActivitySavedData(Bundle savedInstanceState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { String fieldName = f.getName(); @SuppressWarnings("rawtypes") Class cls = f.getType(); if (cls == int.class || cls == Integer.class) { f.setInt(this, savedInstanceState.getInt(fieldName)); } else if (String.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getString(fieldName)); } else if (Serializable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getSerializable(fieldName)); } else if (cls == long.class || cls == Long.class) { f.setLong(this, savedInstanceState.getLong(fieldName)); } else if (cls == short.class || cls == Short.class) { f.setShort(this, savedInstanceState.getShort(fieldName)); } else if (cls == boolean.class || cls == Boolean.class) { f.setBoolean(this, savedInstanceState.getBoolean(fieldName)); } else if (cls == byte.class || cls == Byte.class) { f.setByte(this, savedInstanceState.getByte(fieldName)); } else if (cls == char.class || cls == Character.class) { f.setChar(this, savedInstanceState.getChar(fieldName)); } else if (CharSequence.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getCharSequence(fieldName)); } else if (cls == float.class || cls == Float.class) { f.setFloat(this, savedInstanceState.getFloat(fieldName)); } else if (cls == double.class || cls == Double.class) { f.setDouble(this, savedInstanceState.getDouble(fieldName)); } else if (String[].class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getStringArray(fieldName)); } else if (Parcelable.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getParcelable(fieldName)); } else if (Bundle.class.isAssignableFrom(cls)) { f.set(this, savedInstanceState.getBundle(fieldName)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } }
From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java
/** * Called when the application gets started. *///ww w . j ava 2 s .c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initialize our ability to switch to fullscreen. decorView = getWindow().getDecorView(); decorView.setOnSystemUiVisibilityChangeListener(this); // Set the Activity title that will be displayed on the ActionBar (among other places). setTitle(R.string.action_bar_title); /* * Navigation Drawer setup */ navigationDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Extend the ActionBarDrawerToggle class actionBarDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ navigationDrawerLayout, /* DrawerLayout object */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { /** Called when a drawer has settled in a completely closed state. */ @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); //getActionBar().setTitle(actionBarTitle); } /** Called when a drawer has settled in a completely open state. */ @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); //getActionBar().setTitle(navigationDrawerTitle); } }; navigationDrawerLayout.setDrawerListener(actionBarDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // Find the Book buttons that we will be updating with the names of the displayed books drawerBookButton = new Button[Governor.N_PANELS]; drawerBookButton[0] = (Button) findViewById(R.id.drawer_book_title_1_button); drawerBookButton[1] = (Button) findViewById(R.id.drawer_book_title_2_button); drawerHideOrReappearPanelButton = (Button) findViewById(R.id.drawer_hide_panel_button); // Restore the buttons text after runtime change if (savedInstanceState != null) { drawerBookButtonText = savedInstanceState.getStringArray("nps_drawerBookButtonText"); restoreBookNamesInDrawer(drawerBookButtonText); } if (drawerBookButtonText == null) { drawerBookButtonText = new String[Governor.N_PANELS]; } /* end of Navigation Drawer setup */ if (savedInstanceState != null) { // When trying to use "getString(R.string.nonPersistentState_panelCount)" as key, the value is // just NOT retrieved. The same if the key is too long, e.g. "nonPersistentState_panelCount". fullscreenMode = savedInstanceState.getBoolean("nps_fullscreenMode", false); } debugContext = getBaseContext(); // Fullscreen: Reactivate if it was active before. if (fullscreenMode) { activateFullscreen(true); } // Load the Governor and panels from persistent state if needed. loadGovernorAndPanelsIfNeeded(true); doNotLoadGovernorThisTimeInOnResume = true; }
From source file:org.kontalk.service.msgcenter.MessageCenterService.java
private void sendMessage(Bundle data) { if (!isRosterLoaded()) { Log.d(TAG, "roster not loaded yet, not sending message"); return;/*from w w w .j a va 2 s . co m*/ } boolean retrying = data.getBoolean("org.kontalk.message.retrying"); final String groupJid = data.getString("org.kontalk.message.group.jid"); String to; // used for verifying isPaused() String convJid; String[] toGroup; GroupController group = null; if (groupJid != null) { toGroup = data.getStringArray("org.kontalk.message.to"); // TODO this should be discovered first to = XmppStringUtils.completeJidFrom("multicast", mConnection.getServiceName()); convJid = groupJid; // TODO take type from data group = GroupControllerFactory.createController(KontalkGroupController.GROUP_TYPE, mConnection, this); // check if we can send messages even with some members with no subscriptipn if (!group.canSendWithNoSubscription()) { for (String jid : toGroup) { if (!isAuthorized(jid)) { Log.i(TAG, "not subscribed to " + jid + ", not sending group message"); return; } } } } else { to = data.getString("org.kontalk.message.to"); toGroup = new String[] { to }; convJid = to; } if (group == null && !isAuthorized(to)) { Log.i(TAG, "not subscribed to " + to + ", not sending message"); // warn user: message will not be sent if (!retrying && MessagingNotification.isPaused(to)) { Toast.makeText(this, R.string.warn_not_subscribed, Toast.LENGTH_LONG).show(); } return; } PersonalKey key; try { key = ((Kontalk) getApplicationContext()).getPersonalKey(); } catch (Exception pgpe) { Log.w(TAG, "no personal key available - not allowed to send messages"); // warn user: message will not be sent if (MessagingNotification.isPaused(convJid)) { Toast.makeText(this, R.string.warn_no_personal_key, Toast.LENGTH_LONG).show(); } return; } // check if message is already pending final long msgId = data.getLong("org.kontalk.message.msgId"); if (mWaitingReceipt.containsValue(msgId)) { Log.v(TAG, "message already queued and waiting - dropping"); return; } final String id = data.getString("org.kontalk.message.packetId"); final boolean encrypt = data.getBoolean("org.kontalk.message.encrypt"); final String mime = data.getString("org.kontalk.message.mime"); String _mediaUri = data.getString("org.kontalk.message.media.uri"); if (_mediaUri != null) { // take the first available upload service :) IUploadService uploadService = getUploadService(); if (uploadService != null) { Uri preMediaUri = Uri.parse(_mediaUri); final String previewPath = data.getString("org.kontalk.message.preview.path"); long fileLength; try { // encrypt the file if necessary if (encrypt) { InputStream in = getContentResolver().openInputStream(preMediaUri); File encrypted = MessageUtils.encryptFile(this, in, toGroup); fileLength = encrypted.length(); preMediaUri = Uri.fromFile(encrypted); } else { fileLength = MediaStorage.getLength(this, preMediaUri); } } catch (Exception e) { Log.w(TAG, "error preprocessing media: " + preMediaUri, e); // simulate upload error UploadService.errorNotification(this, getString(R.string.notify_ticker_upload_error), getString(R.string.notify_text_upload_error)); return; } final Uri mediaUri = preMediaUri; // build a filename String filename = CompositeMessage.getFilename(mime, new Date()); if (filename == null) filename = MediaStorage.UNKNOWN_FILENAME; // media message - start upload service final String uploadTo = to; final String[] uploadGroupTo = toGroup; uploadService.getPostUrl(filename, fileLength, mime, new IUploadService.UrlCallback() { @Override public void callback(String putUrl, String getUrl) { // start upload intent service Intent i = new Intent(MessageCenterService.this, UploadService.class); i.setData(mediaUri); i.setAction(UploadService.ACTION_UPLOAD); i.putExtra(UploadService.EXTRA_POST_URL, putUrl); i.putExtra(UploadService.EXTRA_GET_URL, getUrl); i.putExtra(UploadService.EXTRA_DATABASE_ID, msgId); i.putExtra(UploadService.EXTRA_MESSAGE_ID, id); i.putExtra(UploadService.EXTRA_MIME, mime); // this will be used only for out of band data i.putExtra(UploadService.EXTRA_ENCRYPT, encrypt); i.putExtra(UploadService.EXTRA_PREVIEW_PATH, previewPath); // delete original (actually it's the encrypted temp file) if we already encrypted it i.putExtra(UploadService.EXTRA_DELETE_ORIGINAL, encrypt); i.putExtra(UploadService.EXTRA_USER, groupJid != null ? uploadGroupTo : uploadTo); if (groupJid != null) i.putExtra(UploadService.EXTRA_GROUP, groupJid); startService(i); } }); } else { // TODO warn user about this problem Log.w(TAG, "no upload service - this shouldn't happen!"); } } else { // hold on to message center while we send the message mIdleHandler.hold(false); Stanza m, originalStanza; // pre-process message for group delivery GroupCommand groupCommand = null; if (group != null) { int groupCommandId = data.getInt("org.kontalk.message.group.command", 0); switch (groupCommandId) { case GROUP_COMMAND_PART: groupCommand = group.part(); ((PartCommand) groupCommand).setDatabaseId(msgId); // FIXME careful to this, might need abstraction groupCommand.setMembers(toGroup); groupCommand.setGroupJid(groupJid); break; case GROUP_COMMAND_CREATE: { String subject = data.getString("org.kontalk.message.group.subject"); groupCommand = group.createGroup(); ((CreateGroupCommand) groupCommand).setSubject(subject); groupCommand.setMembers(toGroup); groupCommand.setGroupJid(groupJid); break; } case GROUP_COMMAND_SUBJECT: { String subject = data.getString("org.kontalk.message.group.subject"); groupCommand = group.setSubject(); ((SetSubjectCommand) groupCommand).setSubject(subject); // FIXME careful to this, might need abstraction groupCommand.setMembers(toGroup); groupCommand.setGroupJid(groupJid); break; } case GROUP_COMMAND_MEMBERS: { String subject = data.getString("org.kontalk.message.group.subject"); String[] added = data.getStringArray("org.kontalk.message.group.add"); String[] removed = data.getStringArray("org.kontalk.message.group.remove"); groupCommand = group.addRemoveMembers(); ((AddRemoveMembersCommand) groupCommand).setSubject(subject); ((AddRemoveMembersCommand) groupCommand).setAddedMembers(added); ((AddRemoveMembersCommand) groupCommand).setRemovedMembers(removed); groupCommand.setMembers(toGroup); groupCommand.setGroupJid(groupJid); break; } default: groupCommand = group.info(); // FIXME careful to this, might need abstraction groupCommand.setMembers(toGroup); groupCommand.setGroupJid(groupJid); } m = group.beforeEncryption(groupCommand, null); } else { // message stanza m = new org.jivesoftware.smack.packet.Message(); } originalStanza = m; boolean isMessage = (m instanceof org.jivesoftware.smack.packet.Message); if (to != null) m.setTo(to); // set message id m.setStanzaId(id); if (msgId > 0) mWaitingReceipt.put(id, msgId); // message server id String serverId = isMessage ? data.getString("org.kontalk.message.ack") : null; boolean ackRequest = isMessage && !data.getBoolean("org.kontalk.message.standalone", false) && group == null; if (isMessage) { org.jivesoftware.smack.packet.Message msg = (org.jivesoftware.smack.packet.Message) m; msg.setType(org.jivesoftware.smack.packet.Message.Type.chat); String body = data.getString("org.kontalk.message.body"); if (body != null) msg.setBody(body); String fetchUrl = data.getString("org.kontalk.message.fetch.url"); // generate preview if needed String _previewUri = data.getString("org.kontalk.message.preview.uri"); String previewFilename = data.getString("org.kontalk.message.preview.path"); if (_previewUri != null && previewFilename != null) { File previewPath = new File(previewFilename); if (!previewPath.isFile()) { Uri previewUri = Uri.parse(_previewUri); try { MediaStorage.cacheThumbnail(this, previewUri, previewPath, true); } catch (Exception e) { Log.w(TAG, "unable to generate preview for media", e); } } m.addExtension(new BitsOfBinary(MediaStorage.THUMBNAIL_MIME_NETWORK, previewPath)); } // add download url if present if (fetchUrl != null) { // in this case we will need the length too long length = data.getLong("org.kontalk.message.length"); m.addExtension(new OutOfBandData(fetchUrl, mime, length, encrypt)); } if (encrypt) { byte[] toMessage = null; try { Coder coder = Keyring.getEncryptCoder(this, mServer, key, toGroup); if (coder != null) { // no extensions, create a simple text version to save space if (m.getExtensions().size() == 0) { toMessage = coder.encryptText(body); } // some extension, encrypt whole stanza just to be sure else { toMessage = coder.encryptStanza(m.toXML()); } org.jivesoftware.smack.packet.Message encMsg = new org.jivesoftware.smack.packet.Message( m.getTo(), ((org.jivesoftware.smack.packet.Message) m).getType()); encMsg.setBody(getString(R.string.text_encrypted)); encMsg.setStanzaId(m.getStanzaId()); encMsg.addExtension(new E2EEncryption(toMessage)); // save the unencrypted stanza for later originalStanza = m; m = encMsg; } } // FIXME there is some very ugly code here // FIXME notify just once per session (store in Kontalk instance?) catch (IllegalArgumentException noPublicKey) { // warn user: message will be not sent if (MessagingNotification.isPaused(convJid)) { Toast.makeText(this, R.string.warn_no_public_key, Toast.LENGTH_LONG).show(); } } catch (GeneralSecurityException e) { // warn user: message will not be sent if (MessagingNotification.isPaused(convJid)) { Toast.makeText(this, R.string.warn_encryption_failed, Toast.LENGTH_LONG).show(); } } if (toMessage == null) { // message was not encrypted for some reason, mark it pending user review ContentValues values = new ContentValues(1); values.put(Messages.STATUS, Messages.STATUS_PENDING); getContentResolver().update(ContentUris.withAppendedId(Messages.CONTENT_URI, msgId), values, null, null); // do not send the message if (msgId > 0) mWaitingReceipt.remove(id); mIdleHandler.release(); return; } } } // post-process for group delivery if (group != null) { m = group.afterEncryption(groupCommand, m, originalStanza); } if (isMessage) { // received receipt if (serverId != null) { m.addExtension(new DeliveryReceipt(serverId)); } else { ChatState chatState; try { chatState = ChatState.valueOf(data.getString("org.kontalk.message.chatState")); // add chat state if message is not a received receipt m.addExtension(new ChatStateExtension(chatState)); } catch (Exception ignored) { } // standalone: no receipt if (ackRequest) DeliveryReceiptRequest.addTo((org.jivesoftware.smack.packet.Message) m); } } sendPacket(m); // no ack request, release message center immediately if (!ackRequest) mIdleHandler.release(); } }
From source file:net.reichholf.dreamdroid.fragment.TimerEditFragment.java
@SuppressWarnings("unchecked") @Override/*w w w. j ava 2 s .com*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.timer_edit, container, false); mName = (EditText) view.findViewById(R.id.EditTextTitle); mDescription = (EditText) view.findViewById(R.id.EditTextDescription); mEnabled = (CheckBox) view.findViewById(R.id.CheckBoxEnabled); mZap = (CheckBox) view.findViewById(R.id.CheckBoxZap); mAfterevent = (Spinner) view.findViewById(R.id.SpinnerAfterEvent); mLocation = (Spinner) view.findViewById(R.id.SpinnerLocation); mStartDate = (TextView) view.findViewById(R.id.TextViewBeginDate); mStartTime = (TextView) view.findViewById(R.id.TextViewBeginTime); mEndDate = (TextView) view.findViewById(R.id.TextViewEndDate); mEndTime = (TextView) view.findViewById(R.id.TextViewEndTime); mRepeatings = (TextView) view.findViewById(R.id.TextViewRepeated); mService = (TextView) view.findViewById(R.id.TextViewService); mTags = (TextView) view.findViewById(R.id.TextViewTags); // onClickListeners registerOnClickListener(mService, Statics.ITEM_PICK_SERVICE); registerOnClickListener(mStartDate, Statics.ITEM_PICK_BEGIN_DATE); registerOnClickListener(mStartTime, Statics.ITEM_PICK_BEGIN_TIME); registerOnClickListener(mEndDate, Statics.ITEM_PICK_END_DATE); registerOnClickListener(mEndTime, Statics.ITEM_PICK_END_TIME); registerOnClickListener(mRepeatings, Statics.ITEM_PICK_REPEATED); registerOnClickListener(mTags, Statics.ITEM_PICK_TAGS); mAfterevent.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { mTimer.put(Timer.KEY_AFTER_EVENT, Integer.valueOf(position).toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { // Auto is the default mAfterevent.setSelection(Timer.Afterevents.AUTO.intValue()); } }); mLocation.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { mTimer.put(Timer.KEY_LOCATION, DreamDroid.getLocations().get(position)); } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO implement some nothing-selected-handler for locations } }); // Initialize if savedInstanceState won't and instance was not retained if (savedInstanceState == null && mTimer == null && mTimerOld == null) { HashMap<String, Object> map = (HashMap<String, Object>) getArguments().get(sData); ExtendedHashMap data = new ExtendedHashMap(); data.putAll(map); mTimer = new ExtendedHashMap(); mTimer.putAll((HashMap<String, Object>) data.get("timer")); if (Intent.ACTION_EDIT.equals(getArguments().get("action"))) { mTimerOld = mTimer.clone(); } else { mTimerOld = null; } mSelectedTags = new ArrayList<>(); if (DreamDroid.getLocations().size() == 0 || DreamDroid.getTags().size() == 0) { mGetLocationsAndTagsTask = new GetLocationsAndTagsTask(); mGetLocationsAndTagsTask.execute(); } else { reload(); } } else if (savedInstanceState != null) { mTimer = savedInstanceState.getParcelable("timer"); mTimerOld = savedInstanceState.getParcelable("timerOld"); mSelectedTags = new ArrayList<>(Arrays.asList(savedInstanceState.getStringArray("selectedTags"))); if (mTimer != null) { reload(); } } else { reload(); } registerFab(R.id.fab_save, view, new View.OnClickListener() { @Override public void onClick(View v) { onItemSelected(Statics.ITEM_SAVE); } }); return view; }
From source file:cgeo.geocaching.cgeocaches.java
@Override public Loader<SearchResult> onCreateLoader(int type, Bundle extras) { if (type >= CacheListLoaderType.values().length) { throw new IllegalArgumentException("invalid loader type " + type); }// ww w . jav a 2 s . co m CacheListLoaderType enumType = CacheListLoaderType.values()[type]; AbstractSearchLoader loader = null; switch (enumType) { case OFFLINE: listId = Settings.getLastList(); if (listId <= StoredList.TEMPORARY_LIST_ID) { listId = StoredList.STANDARD_LIST_ID; title = res.getString(R.string.stored_caches_button); } else { final StoredList list = cgData.getList(listId); // list.id may be different if listId was not valid listId = list.id; title = list.title; } loader = new OfflineGeocacheListLoader(this.getBaseContext(), coords, listId); break; case HISTORY: title = res.getString(R.string.caches_history); loader = new HistoryGeocacheListLoader(app, coords); break; case NEAREST: title = res.getString(R.string.caches_nearby); loader = new CoordsGeocacheListLoader(app, coords); break; case COORDINATE: title = coords.toString(); loader = new CoordsGeocacheListLoader(app, coords); break; case KEYWORD: final String keyword = extras.getString(Intents.EXTRA_KEYWORD); title = keyword; loader = new KeywordGeocacheListLoader(app, keyword); break; case ADDRESS: final String address = extras.getString(Intents.EXTRA_ADDRESS); if (StringUtils.isNotBlank(address)) { title = address; } else { title = coords.toString(); } if (coords != null) { loader = new CoordsGeocacheListLoader(app, coords); } else { loader = new AddressGeocacheListLoader(app, address); } break; case USERNAME: final String username = extras.getString(Intents.EXTRA_USERNAME); title = username; loader = new UsernameGeocacheListLoader(app, username); break; case OWNER: final String ownerName = extras.getString(Intents.EXTRA_USERNAME); title = ownerName; loader = new OwnerGeocacheListLoader(app, ownerName); break; case MAP: //TODO Build Nullloader title = res.getString(R.string.map_map); search = (SearchResult) extras.get(Intents.EXTRA_SEARCH); replaceCacheListFromSearch(); loadCachesHandler.sendMessage(Message.obtain()); break; case REMOVE_FROM_HISTORY: title = res.getString(R.string.caches_history); loader = new RemoveFromHistoryLoader(app, extras.getStringArray(Intents.EXTRA_CACHELIST), coords); break; case NEXT_PAGE: loader = new NextPageGeocacheListLoader(app, search); break; } setTitle(title); showProgress(true); showFooterLoadingCaches(); if (loader != null) { loader.setRecaptchaHandler(new SearchHandler(this, res, loader)); } return loader; }
From source file:com.androidaq.AndroiDAQAdapter.java
public void setUIStates(Bundle bundle) { isOutputCh = bundle.getBooleanArray("isInput"); isDigCh = bundle.getBooleanArray("isDig"); outputState = bundle.getBooleanArray("outputState"); desiredFreq = bundle.getStringArray("desiredFreqs"); desiredDuty = bundle.getStringArray("desiredDutys"); }
From source file:csh.cryptonite.Cryptonite.java
/** Called when the activity is first created. */ @Override//ww w. j a va2s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); getResources(); if (!hasJni) { jniFail(); return; } mDataSource = new VolumesDataSource(this); mDataSource.open(); encfsVersion = "EncFS " + jniEncFSVersion(); opensslVersion = jniOpenSSLVersion(); bcWallet = jniBcWallet(); textOut = encfsVersion + "\n" + opensslVersion + "\nBC donations: " + bcWallet; Log.v(TAG, encfsVersion + " " + opensslVersion); updateDecryptDelayed = false; SharedPreferences prefs = getBaseContext().getSharedPreferences(ACCOUNT_PREFS_NAME, 0); setupReadDirs(prefs.getBoolean("cb_extcache", false)); StorageManager.INSTANCE.initLocalStorage(this); if (!externalStorageIsWritable() || !ShellUtils.supportsFuse()) { mountInfo = getString(R.string.mount_info_unsupported); } else { mountInfo = getString(R.string.mount_info); DirectorySettings.INSTANCE.mntDir = prefs.getString("txt_mntpoint", Cryptonite.defaultMntDir()); File mntDirF = new File(DirectorySettings.INSTANCE.mntDir); if (!mntDirF.exists()) { mntDirF.mkdirs(); } } DirectorySettings.INSTANCE.binDirPath = getFilesDir().getParentFile().getPath(); DirectorySettings.INSTANCE.encFSBin = DirectorySettings.INSTANCE.binDirPath + "/encfs"; hasFuse = ShellUtils.supportsFuse(); /* Running from Instrumentation? */ if (getIntent() != null) { mInstrumentation = getIntent().getBooleanExtra("csh.cryptonite.instrumentation", false); } else { mInstrumentation = false; } if (needsEncFSBinary()) { ProgressDialogFragment.showDialog(this, R.string.copying_bins, "copyingBins"); new Thread(new Runnable() { public void run() { cpBin("encfs"); cpBin("truecrypt"); runOnUiThread(new Runnable() { public void run() { ProgressDialogFragment.dismissDialog(Cryptonite.this, "copyingBins"); setEncFSBinaryVersion(); } }); } }).start(); } mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabsAdapter.addTab(mTabHost.newTabSpec(DBTAB_TAG).setIndicator(getString(R.string.dropbox_tabtitle)), DropboxFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(LOCALTAB_TAG).setIndicator(getString(R.string.local_tabtitle)), LocalFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(EXPERTTAB_TAG).setIndicator(getString(R.string.expert_tabtitle)), ExpertFragment.class, null); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); opMode = savedInstanceState.getInt("opMode"); if (savedInstanceState.getString("currentReturnPath") != null) { currentReturnPath = savedInstanceState.getString("currentReturnPath"); } if (savedInstanceState.getString("currentDialogStartPath") != null) { currentDialogStartPath = savedInstanceState.getString("currentDialogStartPath"); } if (savedInstanceState.getString("currentDialogRoot") != null) { currentDialogRoot = savedInstanceState.getString("currentDialogRoot"); } if (savedInstanceState.getString("currentDialogLabel") != null) { currentDialogLabel = savedInstanceState.getString("currentDialogLabel"); } if (savedInstanceState.getString("currentDialogButtonLabel") != null) { currentDialogButtonLabel = savedInstanceState.getString("currentDialogButtonLabel"); } if (savedInstanceState.getString("currentDialogRootName") != null) { currentDialogRootName = savedInstanceState.getString("currentDialogRootName"); } if (savedInstanceState.getString("currentOpenPath") != null) { currentOpenPath = savedInstanceState.getString("currentOpenPath"); } if (savedInstanceState.getString("currentUploadTargetPath") != null) { currentUploadTargetPath = savedInstanceState.getString("currentUploadTargetPath"); } if (savedInstanceState.getString("encfsBrowseRoot") != null) { encfsBrowseRoot = savedInstanceState.getString("encfsBrowseRoot"); } if (savedInstanceState.getString("currentConfigFile") != null) { currentConfigFile = savedInstanceState.getString("currentConfigFile"); } if (savedInstanceState.getStringArray("currentReturnPathList") != null) { currentReturnPathList = savedInstanceState.getStringArray("currentReturnPathList"); } if (savedInstanceState.getInt("currentDialogMode") != 0) { currentDialogMode = savedInstanceState.getInt("currentDialogMode"); } disclaimerShown = savedInstanceState.getBoolean("disclaimerShown"); if (currentReturnPath != null && currentDialogStartPath != null) { DirectorySettings.INSTANCE.currentBrowsePath = currentReturnPath; DirectorySettings.INSTANCE.currentBrowseStartPath = currentDialogStartPath; } int storageType = savedInstanceState.getInt("storageType"); if (storageType != Storage.STOR_UNDEFINED) { StorageManager.INSTANCE.initEncFSStorage(this, storageType); if (savedInstanceState.getString("encFSPath") != null) { StorageManager.INSTANCE.setEncFSPath(savedInstanceState.getString("encFSPath")); } } } String oAuth2AccessToken = getOAuth2AccessToken(); if (oAuth2AccessToken != null) { if (prefs.getBoolean("dbDecided", false)) { setSession(prefs.getBoolean("cb_appfolder", false), false); updateDecryptButtons(); } } if (DropboxInterface.INSTANCE.getDBApi() != null && DropboxInterface.INSTANCE.getDBApi().getSession() != null) { mLoggedIn = DropboxInterface.INSTANCE.getDBApi().getSession().isLinked(); } else { mLoggedIn = false; } if (!mInstrumentation && !prefs.getBoolean("cb_norris", false) && !disclaimerShown) { AlertDialog.Builder builder = new AlertDialog.Builder(Cryptonite.this); builder.setIcon(R.drawable.ic_launcher_cryptonite).setTitle(R.string.disclaimer) .setMessage(R.string.no_warranty) .setPositiveButton(R.string.understand, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { disclaimerShown = true; } }); AlertDialog dialog = builder.create(); dialog.show(); } }
From source file:com.tct.mail.compose.ComposeActivity.java
private void addAddressFromData(RecipientEditTextView view, Intent data) { //[FEATURE]-Mod-BEGIN by TSCD.chao zhang,04/22/2014,fix email crash during press back key during choosing nothing in Contacts. if (data == null) { return;/*from w w w .jav a 2s. c om*/ } //[FEATURE]-Mod-END by TSCD.chao zhang Bundle b = data.getExtras(); Bundle choiceSet = b.getBundle("result"); Set<String> set = choiceSet.keySet(); Iterator<String> i = set.iterator(); //TS: junwei-xu 2016-01-25 EMAIL BUGFIX-1496954 MOD_S String itemName, itemAddress; Rfc822Token token; // TS: zhaotianyong 2015-02-28 EMAIL BUGFIX-926303 ADD_S int recipientsCounts = 0; // TS: zhaotianyong 2015-02-28 EMAIL BUGFIX-926303 ADD_E while (i.hasNext()) { // TS: zhaotianyong 2015-02-28 EMAIL BUGFIX-926303 ADD_S recipientsCounts++; if (recipientsCounts > RECIPIENT_MAX_NUMBER) { Utility.showToast(this, this.getString(R.string.not_add_more_recipients, RECIPIENT_MAX_NUMBER)); return; } // TS: zhaotianyong 2015-02-28 EMAIL BUGFIX-926303 ADD_E String key = i.next(); String[] emails = choiceSet.getStringArray(key); itemName = emails[EMAIL_NAME_INDEX]; itemAddress = emails[EMAIL_ADDRESS_INDEX]; //TS: rong-tang 2016-03-28 EMAIL BUGFIX-1863457 MOD_S itemName = Rfc822Validator.fixInvalidName(itemName); //TS: rong-tang 2016-03-28 EMAIL BUGFIX-1863457 MOD_E token = new Rfc822Token(itemName, itemAddress, null); addAddressToList(token.toString(), view); } //TS: junwei-xu 2016-01-25 EMAIL BUGFIX-1496954 MOD_E }
From source file:org.opendatakit.survey.activities.MainMenuActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // android.os.Debug.waitForDebugger(); submenuPage = getIntentExtras().getString("_sync_state"); try {/*w w w . j a v a 2 s.c om*/ // ensure that we have a BackgroundTaskFragment... // create it programmatically because if we place it in the // layout XML, it will be recreated with each screen rotation // and we don't want that!!! mPropertyManager = new PropertyManager(this); // must be at the beginning of any activity that can be called from an // external intent setAppName(ODKFileUtils.getOdkDefaultAppName()); Uri uri = getIntent().getData(); Uri formUri = null; if (uri != null) { // initialize to the URI, then we will customize further based upon the // savedInstanceState... final Uri uriFormsProvider = FormsProviderAPI.CONTENT_URI; final Uri uriWebView = UrlUtils.getWebViewContentUri(this); if (uri.getScheme().equalsIgnoreCase(uriFormsProvider.getScheme()) && uri.getAuthority().equalsIgnoreCase(uriFormsProvider.getAuthority())) { List<String> segments = uri.getPathSegments(); if (segments != null && segments.size() == 1) { String appName = segments.get(0); setAppName(appName); } else if (segments != null && segments.size() >= 2) { String appName = segments.get(0); setAppName(appName); String tableId = segments.get(1); String formId = (segments.size() > 2) ? segments.get(2) : null; formUri = Uri.withAppendedPath(Uri.withAppendedPath( Uri.withAppendedPath(FormsProviderAPI.CONTENT_URI, appName), tableId), formId); } else { createErrorDialog(getString(R.string.invalid_uri_expecting_n_segments, uri.toString(), 2), EXIT); return; } } else if (uri.getScheme().equals(uriWebView.getScheme()) && uri.getAuthority().equals(uriWebView.getAuthority()) && uri.getPort() == uriWebView.getPort()) { List<String> segments = uri.getPathSegments(); if (segments != null && segments.size() == 1) { String appName = segments.get(0); setAppName(appName); } else { createErrorDialog(getString(R.string.invalid_uri_expecting_one_segment, uri.toString()), EXIT); return; } } else { createErrorDialog(getString(R.string.unrecognized_uri, uri.toString(), uriWebView.toString(), uriFormsProvider.toString()), EXIT); return; } } if (savedInstanceState != null) { // if appName is explicitly set, use it... setAppName(savedInstanceState.containsKey(IntentConsts.INTENT_KEY_APP_NAME) ? savedInstanceState.getString(IntentConsts.INTENT_KEY_APP_NAME) : getAppName()); if (savedInstanceState.containsKey(CONFLICT_TABLES)) { mConflictTables = savedInstanceState.getBundle(CONFLICT_TABLES); } } try { String appName = getAppName(); if (appName != null && appName.length() != 0) { ODKFileUtils.verifyExternalStorageAvailability(); ODKFileUtils.assertDirectoryStructure(appName); } } catch (RuntimeException e) { createErrorDialog(e.getMessage(), EXIT); return; } WebLogger.getLogger(getAppName()).i(t, "Starting up, creating directories"); if (savedInstanceState != null) { // if we are restoring, assume that initialization has already occurred. dispatchStringWaitingForData = savedInstanceState.containsKey(DISPATCH_STRING_WAITING_FOR_DATA) ? savedInstanceState.getString(DISPATCH_STRING_WAITING_FOR_DATA) : null; actionWaitingForData = savedInstanceState.containsKey(ACTION_WAITING_FOR_DATA) ? savedInstanceState.getString(ACTION_WAITING_FOR_DATA) : null; currentFragment = ScreenList.valueOf(savedInstanceState.containsKey(CURRENT_FRAGMENT) ? savedInstanceState.getString(CURRENT_FRAGMENT) : currentFragment.name()); if (savedInstanceState.containsKey(FORM_URI)) { FormIdStruct newForm = FormIdStruct.retrieveFormIdStruct(getContentResolver(), Uri.parse(savedInstanceState.getString(FORM_URI))); if (newForm != null) { setAppName(newForm.appName); setCurrentForm(newForm); } } setInstanceId( savedInstanceState.containsKey(INSTANCE_ID) ? savedInstanceState.getString(INSTANCE_ID) : getInstanceId()); setUploadTableId(savedInstanceState.containsKey(UPLOAD_TABLE_ID) ? savedInstanceState.getString(UPLOAD_TABLE_ID) : getUploadTableId()); String tmpScreenPath = savedInstanceState.containsKey(SCREEN_PATH) ? savedInstanceState.getString(SCREEN_PATH) : getScreenPath(); String tmpControllerState = savedInstanceState.containsKey(CONTROLLER_STATE) ? savedInstanceState.getString(CONTROLLER_STATE) : getControllerState(); setSectionScreenState(tmpScreenPath, tmpControllerState); setAuxillaryHash(savedInstanceState.containsKey(AUXILLARY_HASH) ? savedInstanceState.getString(AUXILLARY_HASH) : getAuxillaryHash()); if (savedInstanceState.containsKey(SESSION_VARIABLES)) { sessionVariables = savedInstanceState.getBundle(SESSION_VARIABLES); } if (savedInstanceState.containsKey(SECTION_STATE_SCREEN_HISTORY)) { sectionStateScreenHistory = savedInstanceState .getParcelableArrayList(SECTION_STATE_SCREEN_HISTORY); } if (savedInstanceState.containsKey(QUEUED_ACTIONS)) { String[] actionOutcomesArray = savedInstanceState.getStringArray(QUEUED_ACTIONS); queuedActions.clear(); queuedActions.addAll(Arrays.asList(actionOutcomesArray)); } if (savedInstanceState != null && savedInstanceState.containsKey(RESPONSE_JSON)) { String[] pendingResponseJSON = savedInstanceState.getStringArray(RESPONSE_JSON); queueResponseJSON.addAll(Arrays.asList(pendingResponseJSON)); } } else if (formUri != null) { // request specifies a specific formUri -- try to open that FormIdStruct newForm = FormIdStruct.retrieveFormIdStruct(getContentResolver(), formUri); if (newForm == null) { // can't find it -- launch the initialization dialog to hopefully // discover it. WebLogger.getLogger(getAppName()).i(t, "onCreate -- calling setRunInitializationTask"); ((Survey) getApplication()).setRunInitializationTask(getAppName()); currentFragment = ScreenList.WEBKIT; } else { transitionToFormHelper(uri, newForm); } } } catch (Exception e) { createErrorDialog(e.getMessage(), EXIT); } finally { setContentView(R.layout.main_screen); ActionBar actionBar = getActionBar(); actionBar.show(); } }
From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java
@SuppressLint("DefaultLocale") private void loadExtraDataParms(Intent in) { Bundle bundle = in.getExtras(); if (bundle != null) { tabHost.setCurrentTab(1);/* w ww.ja v a 2 s.co m*/ String sid = "External Application"; if (bundle.containsKey(SMBSYNC_SCHEDULER_ID)) { if (bundle.get(SMBSYNC_SCHEDULER_ID).getClass().getSimpleName().equals("String")) { sid = bundle.getString(SMBSYNC_SCHEDULER_ID); } } util.addLogMsg("I", String.format(mContext.getString(R.string.msgs_extra_data_startup_by), sid)); if (bundle.containsKey(SMBSYNC_EXTRA_PARM_STARTUP_PARMS)) { if (bundle.get(SMBSYNC_EXTRA_PARM_STARTUP_PARMS).getClass().getSimpleName().equals("String")) { String op = bundle.getString(SMBSYNC_EXTRA_PARM_STARTUP_PARMS).replaceAll("\"", "") .replaceAll("\'", ""); // Log.v("","op="+op); boolean[] opa = new boolean[] { false, false, false }; boolean error = false; extraValueSyncProfList = null; String[] op_str_array = op.split(","); if (op_str_array.length < 3) { error = true; util.addLogMsg("W", String.format( mContext.getString(R.string.msgs_extra_data_startup_parms_length_error), op)); } else { for (int i = 0; i < 3; i++) { if (op_str_array[i].toLowerCase().equals("false")) { opa[i] = false; } else if (op_str_array[i].toLowerCase().equals("true")) { opa[i] = true; } else { error = true; util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_startup_parms_value_error), op_str_array[i])); break; } } if (op_str_array.length > 3) { extraValueSyncProfList = new String[op_str_array.length - 3]; for (int i = 0; i < op_str_array.length - 3; i++) extraValueSyncProfList[i] = op_str_array[i + 3]; } } if (!error) { isExtraSpecAutoStart = isExtraSpecAutoTerm = isExtraSpecBgExec = true; extraValueAutoStart = opa[0]; util.addLogMsg("I", "AutoStart=" + extraValueAutoStart); if (isExtraSpecAutoStart && extraValueAutoStart) { extraValueAutoTerm = opa[1]; util.addLogMsg("I", "AutoTerm=" + extraValueAutoTerm); extraValueBgExec = opa[2]; util.addLogMsg("I", "Background=" + extraValueBgExec); } else { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_auto_start_not_specified), "AutoTerm")); util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_auto_start_not_specified), "Background")); } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_START)) { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_startup_parms_specified), SMBSYNC_EXTRA_PARM_AUTO_START)); } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_TERM)) { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_startup_parms_specified), SMBSYNC_EXTRA_PARM_AUTO_TERM)); } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION)) { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_startup_parms_specified), SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION)); } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_SYNC_PROFILE)) { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_startup_parms_specified), SMBSYNC_EXTRA_PARM_SYNC_PROFILE)); } } } else { util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_startup_parms_type_error)); } } else { if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_START)) { if (bundle.get(SMBSYNC_EXTRA_PARM_AUTO_START).getClass().getSimpleName().equals("Boolean")) { isExtraSpecAutoStart = true; extraValueAutoStart = bundle.getBoolean(SMBSYNC_EXTRA_PARM_AUTO_START); util.addLogMsg("I", "AutoStart=" + extraValueAutoStart); } else { util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_auto_start_not_boolean)); } } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_AUTO_TERM)) { if (bundle.get(SMBSYNC_EXTRA_PARM_AUTO_TERM).getClass().getSimpleName().equals("Boolean")) { if (isExtraSpecAutoStart) { isExtraSpecAutoTerm = true; extraValueAutoTerm = bundle.getBoolean(SMBSYNC_EXTRA_PARM_AUTO_TERM); util.addLogMsg("I", "AutoTerm=" + extraValueAutoTerm); } else { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_auto_start_not_specified), "AutoTerm")); } } else { util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_auto_term_not_boolean)); } } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION)) { if (bundle.get(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION).getClass().getSimpleName() .equals("Boolean")) { if (isExtraSpecAutoStart) { isExtraSpecBgExec = true; extraValueBgExec = bundle.getBoolean(SMBSYNC_EXTRA_PARM_BACKGROUND_EXECUTION); util.addLogMsg("I", "Background=" + extraValueBgExec); } else { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_auto_start_not_specified), "Background")); } } else { util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_back_ground_not_boolean)); } } if (bundle.containsKey(SMBSYNC_EXTRA_PARM_SYNC_PROFILE)) { if (isExtraSpecAutoStart) { if (bundle.get(SMBSYNC_EXTRA_PARM_SYNC_PROFILE).getClass().getSimpleName() .equals("String[]")) { extraValueSyncProfList = bundle.getStringArray(SMBSYNC_EXTRA_PARM_SYNC_PROFILE); } else { util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_sync_profile_type_error)); } } else { util.addLogMsg("W", String.format( mContext.getString( R.string.msgs_extra_data_ignored_auto_start_not_specified), "SyncProfile")); } } if (isExtraSpecAutoStart) { if (!isExtraSpecAutoTerm) { isExtraSpecAutoTerm = true; extraValueAutoTerm = false; util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_assumed_auto_term_disabled)); util.addLogMsg("I", "AutoTerm=" + extraValueAutoTerm); } if (!isExtraSpecBgExec) { isExtraSpecBgExec = true; extraValueBgExec = false; util.addLogMsg("W", mContext.getString(R.string.msgs_extra_data_assumed_bg_exec_disabled)); util.addLogMsg("I", "Background=" + extraValueBgExec); } } } } }