List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key, boolean defaultValue)
From source file:biz.bokhorst.xprivacy.ActivityShare.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check privacy service client if (!PrivacyService.checkClient()) return;/*from w w w.ja va 2 s. c o m*/ // Get data int userId = Util.getUserId(Process.myUid()); final Bundle extras = getIntent().getExtras(); final String action = getIntent().getAction(); final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList) : new int[0]); final String restrictionName = (extras != null ? extras.getString(cRestriction) : null); int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1); if (action.equals(ACTION_EXPORT)) mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null); // License check if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) { if (!Util.isProEnabled() && Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); return; } } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) { if (Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); return; } } // Registration check if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) { finish(); return; } // Check whether we need a user interface if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false)) mInteractive = true; // Set layout setContentView(R.layout.sharelist); setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar)); // Reference controls final TextView tvDescription = (TextView) findViewById(R.id.tvDescription); final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle); final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle); final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction); RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear); RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull); RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand); RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand); final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate); final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear); final Button btnOk = (Button) findViewById(R.id.btnOk); final Button btnCancel = (Button) findViewById(R.id.btnCancel); // Set title if (action.equals(ACTION_TOGGLE)) { mActionId = R.string.menu_toggle; getSupportActionBar().setSubtitle(R.string.menu_toggle); } else if (action.equals(ACTION_IMPORT)) { mActionId = R.string.menu_import; getSupportActionBar().setSubtitle(R.string.menu_import); } else if (action.equals(ACTION_EXPORT)) { mActionId = R.string.menu_export; getSupportActionBar().setSubtitle(R.string.menu_export); } else if (action.equals(ACTION_FETCH)) { mActionId = R.string.menu_fetch; getSupportActionBar().setSubtitle(R.string.menu_fetch); } else if (action.equals(ACTION_SUBMIT)) { mActionId = R.string.menu_submit; getSupportActionBar().setSubtitle(R.string.menu_submit); } else { finish(); return; } // Get localized restriction name List<String> listRestrictionName = new ArrayList<String>( PrivacyManager.getRestrictions(this).navigableKeySet()); listRestrictionName.add(0, getString(R.string.menu_all)); // Build restriction adapter SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); saRestriction.addAll(listRestrictionName); // Setup restriction spinner int pos = 0; if (restrictionName != null) for (String restriction : PrivacyManager.getRestrictions(this).values()) { pos++; if (restrictionName.equals(restriction)) break; } spRestriction.setAdapter(saRestriction); spRestriction.setSelection(pos); // Build template adapter SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0", getString(R.string.title_default)); spAdapter.add(defaultName); for (int i = 1; i <= 4; i++) { String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i), getString(R.string.title_alternate) + " " + i); spAdapter.add(alternateName); } spTemplate.setAdapter(spAdapter); // Build application list AppListTask appListTask = new AppListTask(); appListTask.executeOnExecutor(mExecutor, uids); // Import/export filename if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) { // Check for availability of sharing intent Intent file = new Intent(Intent.ACTION_GET_CONTENT); file.setType("file/*"); boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file); // Get file name if (mFileName == null) if (action.equals(ACTION_EXPORT)) { String packageName = null; if (uids.length == 1) try { ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]); packageName = appInfo.getPackageName().get(0); } catch (Throwable ex) { Util.bug(null, ex); } mFileName = getFileName(this, hasIntent, packageName); } else mFileName = (hasIntent ? null : getFileName(this, false, null)); if (mFileName == null) fileChooser(); else showFileName(); if (action.equals(ACTION_IMPORT)) cbClear.setVisibility(View.VISIBLE); } else if (action.equals(ACTION_FETCH)) { tvDescription.setText(getBaseURL()); cbClear.setVisibility(View.VISIBLE); } else if (action.equals(ACTION_TOGGLE)) { tvDescription.setVisibility(View.GONE); spRestriction.setVisibility(View.VISIBLE); svToggle.setVisibility(View.VISIBLE); // Listen for radio button rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { btnOk.setEnabled(checkedId >= 0); spRestriction.setVisibility( checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE : View.VISIBLE); spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE); } }); boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true); rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE); rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE); if (choice == CHOICE_CLEAR) rbClear.setChecked(true); else if (choice == CHOICE_TEMPLATE) rbTemplateFull.setChecked(true); } else tvDescription.setText(getBaseURL()); if (mInteractive) { // Enable ok // (showFileName does this for export/import) if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH)) btnOk.setEnabled(true); // Listen for ok btnOk.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { btnOk.setEnabled(false); // Toggle if (action.equals(ACTION_TOGGLE)) { mRunning = true; for (int i = 0; i < rgToggle.getChildCount(); i++) ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false); int pos = spRestriction.getSelectedItemPosition(); String restrictionName = (pos == 0 ? null : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos - 1]); new ToggleTask().executeOnExecutor(mExecutor, restrictionName); // Import } else if (action.equals(ACTION_IMPORT)) { mRunning = true; cbClear.setEnabled(false); new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked()); } // Export else if (action.equals(ACTION_EXPORT)) { mRunning = true; new ExportTask().executeOnExecutor(mExecutor, new File(mFileName)); // Fetch } else if (action.equals(ACTION_FETCH)) { if (uids.length > 0) { mRunning = true; cbClear.setEnabled(false); new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked()); } } // Submit else if (action.equals(ACTION_SUBMIT)) { if (uids.length > 0) { if (uids.length <= cSubmitLimit) { mRunning = true; new SubmitTask().executeOnExecutor(mExecutor); } else { String message = getString(R.string.msg_limit, cSubmitLimit + 1); Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show(); btnOk.setEnabled(false); } } } } }); } else btnOk.setEnabled(false); // Listen for cancel btnCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { if (mRunning) { mAbort = true; Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show(); } else finish(); } }); }
From source file:com.aimfire.demo.CamcorderActivity.java
@Override protected void onNewIntent(Intent intent) { if (BuildConfig.DEBUG) Log.d(TAG, "onNewIntent"); /*/*from w w w . ja v a 2s .c om*/ * we will now set up the synchronization between two cameras */ Bundle extras = intent.getExtras(); if (extras == null) { if (BuildConfig.DEBUG) Log.e(TAG, "onNewIntent: wrong parameter"); FirebaseCrash.report(new Exception("CamcorderActivity onNewIntent: wrong parameter")); finish(); return; } mSyncTimeUs = extras.getLong(MainConsts.EXTRA_SYNCTIME, -1); /* * we could get here in two ways: 1) AimfireService completed sync with remote device. * 2) a switch from photo to video mode. if it is the latter, EXTRA_MSG is true */ mPvSwitching = extras.getBoolean(MainConsts.EXTRA_MSG, false); /* * originally we set the initiator to be the left device. now we will set left/right * based on user preference */ if (mPvSwitching) { mIsLeft = extras.getBoolean(MainConsts.EXTRA_ISLEFT); } /* * send parameters of our camera to remote. */ sendCamParams(); // CustomToast.show(getActivity(), // mIsLeft?getActivity().getString(R.string.left_camera_ready): // getActivity().getString(R.string.right_camera_ready), // Toast.LENGTH_SHORT); }
From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mProfileImageLoader = getApp().getProfileImageLoader(); mPreviewImageLoader = getApp().getPreviewImageLoader(); mContentHandle = TwitterManager.get().getContentHandle(getContentHandleBase(), getScreenName(), getLaneIdentifier(), getApp().getCurrentAccountKey()); View resultView = inflater.inflate(R.layout.lane, null); configureLaneWidth(resultView);/* www . java 2s .c o m*/ mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher); mListHeadingTextView = (TextView) resultView.findViewById(R.id.list_heading); mListHeadingHideImage = (ImageView) resultView.findViewById(R.id.list_hide); mListHeadingHideImage.setOnClickListener(mListHeadingHideImageOnClickListener); mMultipleTweetSelectionCallback = new MultipleTweetSelectionCallback(); mTweetFeedListAdapter = new TweetFeedListAdapter(inflater); mTweetFeedListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview); mTweetFeedListView.getRefreshableView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); mTweetFeedListView.getRefreshableView().setMultiChoiceModeListener(mMultipleTweetSelectionCallback); mTweetFeedListView.getRefreshableView().setOnScrollListener(mTweetFeedOnScrollListener); mTweetFeedListView.getRefreshableView().setAdapter(mTweetFeedListAdapter); mTweetFeedListView.setOnRefreshListener(mTweetFeedOnRefreshListener); mTweetFeedListView.setOnLastItemVisibleListener(mTweetFeedOnLastItemVisibleListener); mRefreshTimestampsHandler.removeCallbacks(mRefreshTimestampsTask); mRefreshTimestampsHandler.postDelayed(mRefreshTimestampsTask, REFRESH_TIMESTAMPS_INTERVAL); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeUpKeyDownReceiver, new IntentFilter("" + SystemEvent.VOLUME_UP_KEY_DOWN)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeDownKeyDownReceiver, new IntentFilter("" + SystemEvent.VOLUME_DOWN_KEY_DOWN)); if (savedInstanceState != null) { mTwitterStatusIdWhenRefreshed = savedInstanceState.containsKey("TwitterStatusIdWhenRefreshed") ? savedInstanceState.getLong("TwitterStatusIdWhenRefreshed") : 0L; mLastTwitterStatusIdSeen = savedInstanceState.containsKey("LastTwitterStatusIdSeen") ? savedInstanceState.getLong("LastTwitterStatusIdSeen") : 0L; mNewStatuses = savedInstanceState.getInt("NewStatuses", 0); mHidingListHeading = savedInstanceState.getBoolean("HidingListHeading", false); } configureInitialStatuses(); return resultView; }
From source file:ch.bfh.evoting.alljoyn.BusHandler.java
@Override public void handleMessage(Message msg) { Status status = null;/*from w w w . jav a2s .c o m*/ Intent intent; switch (msg.what) { case INIT: { doInit(); break; } case CREATE_GROUP: { Bundle data = msg.getData(); String groupName = data.getString("groupName"); String groupPassword = data.getString("groupPassword"); status = doCreateGroup(groupName, groupPassword); Log.d(TAG, "status of group creation " + status); switch (status) { case OK: LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("NetworkServiceStarted")); break; case ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED: LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("NetworkServiceStarted")); break; case INVALID_DATA: //invalid group name intent = new Intent("networkConnectionFailed"); intent.putExtra("error", 1); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break; case ALREADY_FINDING: //group name already exists intent = new Intent("networkConnectionFailed"); intent.putExtra("error", 2); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break; default: LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("networkConnectionFailed")); break; } break; } case DESTROY_GROUP: { status = doDestroyGroup((String) msg.obj); break; } case JOIN_GROUP: { Bundle data = msg.getData(); String groupName = data.getString("groupName"); String groupPassword = data.getString("groupPassword"); String saltShortDigest = data.getString("saltShortDigest"); status = doJoinGroup(groupName, groupPassword, saltShortDigest); Log.d(TAG, "status of group join " + status); switch (status) { case OK: LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("NetworkServiceStarted")); break; case ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED: LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("NetworkServiceStarted")); break; case INVALID_DATA: //invalid group name intent = new Intent("networkConnectionFailed"); intent.putExtra("error", 1); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break; case ALLJOYN_FINDADVERTISEDNAME_REPLY_FAILED: //group not found intent = new Intent("networkConnectionFailed"); intent.putExtra("error", 3); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break; case ALLJOYN_JOINSESSION_REPLY_FAILED: //group not joined intent = new Intent("networkConnectionFailed"); intent.putExtra("error", 4); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break; default: LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("networkConnectionFailed")); break; } break; } case LEAVE_GROUP: { status = doLeaveGroup((String) msg.obj); break; } case UNLOCK_GROUP: { status = doUnlockGroup((String) msg.obj); break; } case LOCK_GROUP: { status = doLockGroup((String) msg.obj); break; } case SET_PORT: { doSetPort((Short) msg.obj); break; } case JOIN_OR_CREATE: { status = doJoinOrCreate((String) msg.obj); break; } case PING: { Bundle data = msg.getData(); String groupName = data.getString("groupName"); String pingString = data.getString("pingString"); boolean encrypted = data.getBoolean("encrypted", true); Type type = (Type) data.getSerializable("type"); doPing(groupName, pingString, encrypted, type); break; } case REPROCESS_MESSAGE: { Bundle data = msg.getData(); AllJoynMessage message = (AllJoynMessage) data.getSerializable("message"); this.processMessage(message); break; } case DISCONNECT: { doDisconnect(); break; } default: break; } }
From source file:com.android.launcher2.Launcher.java
/** * Restores the previous state, if it exists. * * @param savedState The previous state. */// ww w. j ava 2 s . c o m private void restoreState(Bundle savedState) { if (savedState == null) { return; } State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal())); if (state == State.APPS_CUSTOMIZE) { mOnResumeState = State.APPS_CUSTOMIZE; } int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1); if (currentScreen > -1) { mWorkspace.setCurrentPage(currentScreen); } final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1); final int pendingAddScreen = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SCREEN, -1); if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) { mPendingAddInfo.container = pendingAddContainer; mPendingAddInfo.screen = pendingAddScreen; mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X); mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y); mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X); mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y); mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO); mWaitingForResult = true; mRestoring = true; } boolean renameFolder = savedState.getBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, false); if (renameFolder) { long id = savedState.getLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID); mFolderInfo = mModel.getFolderById(this, sFolders, id); mRestoring = true; } // Restore the AppsCustomize tab if (mAppsCustomizeTabHost != null) { String curTab = savedState.getString("apps_customize_currentTab"); if (curTab != null) { mAppsCustomizeTabHost .setContentTypeImmediate(mAppsCustomizeTabHost.getContentTypeForTabTag(curTab)); mAppsCustomizeContent.loadAssociatedPages(mAppsCustomizeContent.getCurrentPage()); } int currentIndex = savedState.getInt("apps_customize_currentIndex"); mAppsCustomizeContent.restorePageForIndex(currentIndex); } }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Trace.beginSection("onCreate()"); super.onCreate(savedInstanceState); if (RequestPermissionsActivity.startPermissionActivity(this) || RequestDesiredPermissionsActivity.startPermissionActivity(this)) { return;// ww w. ja va2 s.c om } final int previousScreenType = getIntent().getIntExtra(EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN); Logger.logScreenView(this, ScreenType.QUICK_CONTACT, previousScreenType); if (CompatUtils.isLollipopCompatible()) { getWindow().setStatusBarColor(Color.TRANSPARENT); } processIntent(getIntent()); // Show QuickContact in front of soft input getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); setContentView(R.layout.quickcontact_activity); mMaterialColorMapUtils = new MaterialColorMapUtils(getResources()); mScroller = (MultiShrinkScroller) findViewById(R.id.multiscroller); mContactCard = (ExpandingEntryCardView) findViewById(R.id.communication_card); mNoContactDetailsCard = (ExpandingEntryCardView) findViewById(R.id.no_contact_data_card); mRecentCard = (ExpandingEntryCardView) findViewById(R.id.recent_card); mAboutCard = (ExpandingEntryCardView) findViewById(R.id.about_card); mCollapsedSuggestionCardView = (CardView) findViewById(R.id.collapsed_suggestion_card); mExpandSuggestionCardView = (CardView) findViewById(R.id.expand_suggestion_card); mCollapasedSuggestionHeader = findViewById(R.id.collapsed_suggestion_header); mCollapsedSuggestionCardTitle = (TextView) findViewById(R.id.collapsed_suggestion_card_title); mExpandSuggestionCardTitle = (TextView) findViewById(R.id.expand_suggestion_card_title); mSuggestionSummaryPhoto = (ImageView) findViewById(R.id.suggestion_icon); mSuggestionForName = (TextView) findViewById(R.id.suggestion_for_name); mSuggestionContactsNumber = (TextView) findViewById(R.id.suggestion_for_contacts_number); mSuggestionList = (LinearLayout) findViewById(R.id.suggestion_list); mSuggestionsCancelButton = (Button) findViewById(R.id.cancel_button); mSuggestionsLinkButton = (Button) findViewById(R.id.link_button); if (savedInstanceState != null) { mIsSuggestionListCollapsed = savedInstanceState.getBoolean(KEY_IS_SUGGESTION_LIST_COLLAPSED, true); mPreviousContactId = savedInstanceState.getLong(KEY_PREVIOUS_CONTACT_ID); mSuggestionsShouldAutoSelected = savedInstanceState.getBoolean(KEY_SUGGESTIONS_AUTO_SELECTED, true); mSelectedAggregationIds = (TreeSet<Long>) savedInstanceState .getSerializable(KEY_SELECTED_SUGGESTION_CONTACTS); } else { mIsSuggestionListCollapsed = true; mSelectedAggregationIds.clear(); } if (mSelectedAggregationIds.isEmpty()) { disableLinkButton(); } else { enableLinkButton(); } mCollapasedSuggestionHeader.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mCollapsedSuggestionCardView.setVisibility(View.GONE); mExpandSuggestionCardView.setVisibility(View.VISIBLE); mIsSuggestionListCollapsed = false; mExpandSuggestionCardTitle.requestFocus(); mExpandSuggestionCardTitle.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } }); mSuggestionsCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mCollapsedSuggestionCardView.setVisibility(View.VISIBLE); mExpandSuggestionCardView.setVisibility(View.GONE); mIsSuggestionListCollapsed = true; } }); mNoContactDetailsCard.setOnClickListener(mEntryClickHandler); mContactCard.setOnClickListener(mEntryClickHandler); mContactCard.setExpandButtonText(getResources().getString(R.string.expanding_entry_card_view_see_all)); mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener); mRecentCard.setOnClickListener(mEntryClickHandler); mRecentCard.setTitle(getResources().getString(R.string.recent_card_title)); mAboutCard.setOnClickListener(mEntryClickHandler); mAboutCard.setOnCreateContextMenuListener(mEntryContextMenuListener); mPhotoView = (QuickContactImageView) findViewById(R.id.photo); final View transparentView = findViewById(R.id.transparent_view); if (mScroller != null) { transparentView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mScroller.scrollOffBottom(); } }); } // Allow a shadow to be shown under the toolbar. ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources()); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setActionBar(toolbar); getActionBar().setTitle(null); // Put a TextView with a known resource id into the ActionBar. This allows us to easily // find the correct TextView location & size later. toolbar.addView(getLayoutInflater().inflate(R.layout.quickcontact_title_placeholder, null)); mHasAlreadyBeenOpened = savedInstanceState != null; mIsEntranceAnimationFinished = mHasAlreadyBeenOpened; mWindowScrim = new ColorDrawable(SCRIM_COLOR); mWindowScrim.setAlpha(0); getWindow().setBackgroundDrawable(mWindowScrim); mScroller.initialize(mMultiShrinkScrollerListener, mExtraMode == MODE_FULLY_EXPANDED); // mScroller needs to perform asynchronous measurements after initalize(), therefore // we can't mark this as GONE. mScroller.setVisibility(View.INVISIBLE); setHeaderNameText(R.string.missing_name); mSelectAccountFragmentListener = (SelectAccountDialogFragmentListener) getFragmentManager() .findFragmentByTag(FRAGMENT_TAG_SELECT_ACCOUNT); if (mSelectAccountFragmentListener == null) { mSelectAccountFragmentListener = new SelectAccountDialogFragmentListener(); getFragmentManager().beginTransaction() .add(0, mSelectAccountFragmentListener, FRAGMENT_TAG_SELECT_ACCOUNT).commit(); mSelectAccountFragmentListener.setRetainInstance(true); } mSelectAccountFragmentListener.setQuickContactActivity(this); SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ true, new Runnable() { @Override public void run() { if (!mHasAlreadyBeenOpened) { // The initial scrim opacity must match the scrim opacity that would be // achieved by scrolling to the starting position. final float alphaRatio = mExtraMode == MODE_FULLY_EXPANDED ? 1 : mScroller.getStartingTransparentHeightRatio(); final int duration = getResources().getInteger(android.R.integer.config_shortAnimTime); final int desiredAlpha = (int) (0xFF * alphaRatio); ObjectAnimator o = ObjectAnimator.ofInt(mWindowScrim, "alpha", 0, desiredAlpha) .setDuration(duration); o.start(); } } }); if (savedInstanceState != null) { final int color = savedInstanceState.getInt(KEY_THEME_COLOR, 0); SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ false, new Runnable() { @Override public void run() { // Need to wait for the pre draw before setting the initial scroll // value. Prior to pre draw all scroll values are invalid. if (mHasAlreadyBeenOpened) { mScroller.setVisibility(View.VISIBLE); mScroller.setScroll(mScroller.getScrollNeededToBeFullScreen()); } // Need to wait for pre draw for setting the theme color. Setting the // header tint before the MultiShrinkScroller has been measured will // cause incorrect tinting calculations. if (color != 0) { setThemeColor(mMaterialColorMapUtils.calculatePrimaryAndSecondaryColor(color)); } } }); } Trace.endSection(); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void initActivityState(Bundle bundle) { Intent intent = getIntent();//from ww w .ja v a 2 s .c om if (bundle != null) { setIntent(getIntent().setAction(Intent.ACTION_VIEW)); String recipients = bundle.getString(RECIPIENTS); if (LogTag.VERBOSE) log("get mConversation by recipients " + recipients); mConversation = Conversation.get(this, ContactList.getByNumbers(recipients, false /* don't block */, true /* replace number */), false); addRecipientsListeners(); mSendDiscreetMode = bundle.getBoolean(KEY_EXIT_ON_SENT, false); mForwardMessageMode = bundle.getBoolean(KEY_FORWARDED_MESSAGE, false); if (mSendDiscreetMode) { mMsgListView.setVisibility(View.INVISIBLE); } mWorkingMessage.readStateFromBundle(bundle); return; } // If we have been passed a thread_id, use that to find our conversation. long threadId = intent.getLongExtra(THREAD_ID, 0); if (threadId > 0) { if (LogTag.VERBOSE) log("get mConversation by threadId " + threadId); mConversation = Conversation.get(this, threadId, false); } else { Uri intentData = intent.getData(); if (intentData != null) { // try to get a conversation based on the data URI passed to our intent. if (LogTag.VERBOSE) log("get mConversation by intentData " + intentData); mConversation = Conversation.get(this, intentData, false); mWorkingMessage.setText(getBody(intentData)); } else { // special intent extra parameter to specify the address String address = intent.getStringExtra("address"); if (!TextUtils.isEmpty(address)) { if (LogTag.VERBOSE) log("get mConversation by address " + address); mConversation = Conversation.get(this, ContactList.getByNumbers(address, false /* don't block */, true /* replace number */), false); } else { if (LogTag.VERBOSE) log("create new conversation"); mConversation = Conversation.createNew(this); } } } addRecipientsListeners(); updateThreadIdIfRunning(); mSendDiscreetMode = intent.getBooleanExtra(KEY_EXIT_ON_SENT, false); mForwardMessageMode = intent.getBooleanExtra(KEY_FORWARDED_MESSAGE, false); if (mSendDiscreetMode) { mMsgListView.setVisibility(View.INVISIBLE); } if (intent.hasExtra("sms_body")) { mWorkingMessage.setText(intent.getStringExtra("sms_body")); } mWorkingMessage.setSubject(intent.getStringExtra("subject"), false); }
From source file:com.android.soma.Launcher.java
/** * Restores the previous state, if it exists. * * @param savedState The previous state. *///from w ww . j a v a2 s . co m private void restoreState(Bundle savedState) { if (savedState == null) { return; } State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal())); if (state == State.APPS_CUSTOMIZE) { mOnResumeState = State.APPS_CUSTOMIZE; } int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, PagedView.INVALID_RESTORE_PAGE); if (currentScreen != PagedView.INVALID_RESTORE_PAGE) { mWorkspace.setRestorePage(currentScreen); } final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1); final long pendingAddScreen = savedState.getLong(RUNTIME_STATE_PENDING_ADD_SCREEN, -1); if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) { mPendingAddInfo.container = pendingAddContainer; mPendingAddInfo.screenId = pendingAddScreen; mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X); mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y); mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X); mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y); mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO); mWaitingForResult = true; mRestoring = true; } boolean renameFolder = savedState.getBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, false); if (renameFolder) { long id = savedState.getLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID); mFolderInfo = mModel.getFolderById(this, sFolders, id); mRestoring = true; } // Restore the AppsCustomize tab if (mAppsCustomizeTabHost != null) { String curTab = savedState.getString("apps_customize_currentTab"); if (curTab != null) { mAppsCustomizeTabHost .setContentTypeImmediate(mAppsCustomizeTabHost.getContentTypeForTabTag(curTab)); mAppsCustomizeContent.loadAssociatedPages(mAppsCustomizeContent.getCurrentPage()); } int currentIndex = savedState.getInt("apps_customize_currentIndex"); mAppsCustomizeContent.restorePageForIndex(currentIndex); } }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
/** Called when the activity is first created. */ @Override/*from w w w. j a va 2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // must be at the beginning of any activity that can be called from an // external intent try { Collect.createODKDirs(); } catch (RuntimeException e) { createErrorDialog(e.getMessage(), EXIT); return; } Log.i("Activity", "Created"); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mSharedPreferences .registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { compressImage = mSharedPreferences .getBoolean(PreferencesActivity.KEY_ENABLE_IMAGE_COMPRESSION, false); } }); setContentView(R.layout.form_entry); /* setTitle(getString(R.string.app_name) + " > " + getString(R.string.loading_form));*/ setTitle(getString(R.string.app_name)); Log.i("Entry", "Form"); mErrorMessage = null; //progressBar = (ProgressBar) findViewById(R.id.progress); //progressBar.setVisibility(ProgressBar.VISIBLE); //progressBar.setProgress(0); mBeenSwiped = false; mAlertDialog = null; mCurrentView = null; mInAnimation = null; mOutAnimation = null; mGestureDetector = new GestureDetector(this, this); mQuestionHolder = (LinearLayout) findViewById(R.id.questionholder); // get admin preference settings mAdminPreferences = getSharedPreferences(AdminPreferencesActivity.ADMIN_PREFERENCES, 0); mNextButton = (ImageButton) findViewById(R.id.form_forward_button); mNextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mBeenSwiped = true; showNextView(); } }); mBackButton = (ImageButton) findViewById(R.id.form_back_button); mBackButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mBeenSwiped = true; showPreviousView(); } }); needLocation = mSharedPreferences.getBoolean(PreferencesActivity.KEY_GPS_FIX, false); if (needLocation) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 5, this); } // Load JavaRosa modules. needed to restore forms. new XFormsModule().registerModule(); // needed to override rms property manager org.javarosa.core.services.PropertyManager.setPropertyManager(new PropertyManager(getApplicationContext())); String startingXPath = null; String waitingXPath = null; String instancePath = null; Boolean newForm = true; if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_FORMPATH)) { mFormPath = savedInstanceState.getString(KEY_FORMPATH); } if (savedInstanceState.containsKey(KEY_INSTANCEPATH)) { instancePath = savedInstanceState.getString(KEY_INSTANCEPATH); } if (savedInstanceState.containsKey(KEY_XPATH)) { startingXPath = savedInstanceState.getString(KEY_XPATH); Log.i(t, "startingXPath is: " + startingXPath); } if (savedInstanceState.containsKey(KEY_XPATH_WAITING_FOR_DATA)) { waitingXPath = savedInstanceState.getString(KEY_XPATH_WAITING_FOR_DATA); Log.i(t, "waitingXPath is: " + waitingXPath); } if (savedInstanceState.containsKey(NEWFORM)) { newForm = savedInstanceState.getBoolean(NEWFORM, true); } if (savedInstanceState.containsKey(KEY_ERROR)) { mErrorMessage = savedInstanceState.getString(KEY_ERROR); } } // If a parse error message is showing then nothing else is loaded // Dialogs mid form just disappear on rotation. if (mErrorMessage != null) { createErrorDialog(mErrorMessage, EXIT); return; } // Check to see if this is a screen flip or a new form load. Object data = getLastNonConfigurationInstance(); if (data instanceof FormLoaderTask) { mFormLoaderTask = (FormLoaderTask) data; } else if (data instanceof SaveToDiskTask) { mSaveToDiskTask = (SaveToDiskTask) data; } else if (data == null) { if (!newForm) { if (Collect.getInstance().getFormController() != null) { refreshCurrentView(); } else { Log.w(t, "Reloading form and restoring state."); // we need to launch the form loader to load the form // controller... mFormLoaderTask = new FormLoaderTask(instancePath, startingXPath, waitingXPath); Collect.getInstance().getActivityLogger().logAction(this, "formReloaded", mFormPath); // TODO: this doesn' work (dialog does not get removed): // showDialog(PROGRESS_DIALOG); // show dialog before we execute... Log.i("Loader", "Executing"); mFormLoaderTask.execute(mFormPath); } return; } // Not a restart from a screen orientation change (or other). Collect.getInstance().setFormController(null); CompatibilityUtils.invalidateOptionsMenu(this); Intent intent = getIntent(); if (intent != null) { Uri uri = intent.getData(); if (getContentResolver().getType(uri).equals(InstanceColumns.CONTENT_ITEM_TYPE)) { // get the formId and version for this instance... String jrFormId = null; String jrVersion = null; { Cursor instanceCursor = null; try { instanceCursor = getContentResolver().query(uri, null, null, null, null); if (instanceCursor.getCount() != 1) { this.createErrorDialog("Bad URI: " + uri, EXIT); return; } else { instanceCursor.moveToFirst(); instancePath = instanceCursor.getString( instanceCursor.getColumnIndex(InstanceColumns.INSTANCE_FILE_PATH)); Collect.getInstance().getActivityLogger().logAction(this, "instanceLoaded", instancePath); jrFormId = instanceCursor .getString(instanceCursor.getColumnIndex(InstanceColumns.JR_FORM_ID)); int idxJrVersion = instanceCursor.getColumnIndex(InstanceColumns.JR_VERSION); jrVersion = instanceCursor.isNull(idxJrVersion) ? null : instanceCursor.getString(idxJrVersion); } } finally { if (instanceCursor != null) { instanceCursor.close(); } } } String[] selectionArgs; String selection; if (jrVersion == null) { selectionArgs = new String[] { jrFormId }; selection = FormsColumns.JR_FORM_ID + "=? AND " + FormsColumns.JR_VERSION + " IS NULL"; } else { selectionArgs = new String[] { jrFormId, jrVersion }; selection = FormsColumns.JR_FORM_ID + "=? AND " + FormsColumns.JR_VERSION + "=?"; } { Cursor formCursor = null; try { formCursor = getContentResolver().query(FormsColumns.CONTENT_URI, null, selection, selectionArgs, null); if (formCursor.getCount() == 1) { formCursor.moveToFirst(); mFormPath = formCursor .getString(formCursor.getColumnIndex(FormsColumns.FORM_FILE_PATH)); } else if (formCursor.getCount() < 1) { this.createErrorDialog( getString(R.string.parent_form_not_present, jrFormId) + ((jrVersion == null) ? "" : "\n" + getString(R.string.version) + " " + jrVersion), EXIT); return; } else if (formCursor.getCount() > 1) { // still take the first entry, but warn that // there are multiple rows. // user will need to hand-edit the SQLite // database to fix it. formCursor.moveToFirst(); mFormPath = formCursor .getString(formCursor.getColumnIndex(FormsColumns.FORM_FILE_PATH)); this.createErrorDialog(getString(R.string.survey_multiple_forms_error), EXIT); return; } } finally { if (formCursor != null) { formCursor.close(); } } } } else if (getContentResolver().getType(uri).equals(FormsColumns.CONTENT_ITEM_TYPE)) { Cursor c = null; try { c = getContentResolver().query(uri, null, null, null, null); if (c.getCount() != 1) { this.createErrorDialog("Bad URI: " + uri, EXIT); return; } else { c.moveToFirst(); mFormPath = c.getString(c.getColumnIndex(FormsColumns.FORM_FILE_PATH)); // This is the fill-blank-form code path. // See if there is a savepoint for this form that // has never been // explicitly saved // by the user. If there is, open this savepoint // (resume this filled-in // form). // Savepoints for forms that were explicitly saved // will be recovered // when that // explicitly saved instance is edited via // edit-saved-form. final String filePrefix = mFormPath.substring(mFormPath.lastIndexOf('/') + 1, mFormPath.lastIndexOf('.')) + "_"; final String fileSuffix = ".xml.save"; File cacheDir = new File(Collect.CACHE_PATH); File[] files = cacheDir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { String name = pathname.getName(); return name.startsWith(filePrefix) && name.endsWith(fileSuffix); } }); // see if any of these savepoints are for a // filled-in form that has never been // explicitly saved by the user... for (int i = 0; i < files.length; ++i) { File candidate = files[i]; String instanceDirName = candidate.getName().substring(0, candidate.getName().length() - fileSuffix.length()); File instanceDir = new File( Collect.INSTANCES_PATH + File.separator + instanceDirName); File instanceFile = new File(instanceDir, instanceDirName + ".xml"); if (instanceDir.exists() && instanceDir.isDirectory() && !instanceFile.exists()) { // yes! -- use this savepoint file instancePath = instanceFile.getAbsolutePath(); break; } } } } finally { if (c != null) { c.close(); } } } else { Log.e(t, "unrecognized URI"); this.createErrorDialog("Unrecognized URI: " + uri, EXIT); return; } mFormLoaderTask = new FormLoaderTask(instancePath, null, null); Collect.getInstance().getActivityLogger().logAction(this, "formLoaded", mFormPath); showDialog(PROGRESS_DIALOG); // show dialog before we execute... Log.i("Loader", "Executing"); mFormLoaderTask.execute(mFormPath); } } }