List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key, boolean defaultValue)
From source file:com.amaze.filemanager.fragments.Main.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(false);//w ww . j av a2 s. c om //MAIN_ACTIVITY = (MainActivity) getActivity(); initNoFileLayout(); utils = new Futils(); String x = PreferenceUtils.getSelectionColor(skin); skinselection = Color.parseColor(x); color = PreferenceUtils.calculatevalues(x); ColorMatrix colorMatrix = new ColorMatrix(PreferenceUtils.calculatefilter(color)); colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix); ROOT_MODE = Sp.getBoolean("rootmode", false); SHOW_HIDDEN = Sp.getBoolean("showHidden", false); COLORISE_ICONS = Sp.getBoolean("coloriseIcons", true); folder = res.getDrawable(R.drawable.ic_grid_folder_new); getSortModes(); DARK_IMAGE = res.getDrawable(R.drawable.ic_doc_image_dark); DARK_VIDEO = res.getDrawable(R.drawable.ic_doc_video_dark); this.setRetainInstance(false); f = new HFile(HFile.UNKNOWN, CURRENT_PATH); f.generateMode(getActivity()); MAIN_ACTIVITY.initiatebbar(); IS_LIST = savedInstanceState != null ? savedInstanceState.getBoolean("IS_LIST", IS_LIST) : IS_LIST; ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST); if (theme1 == 1) { listView.setBackgroundDrawable( new ColorDrawable(getResources().getColor(R.color.holo_dark_background))); } else { if (IS_LIST) listView.setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.background_light))); } listView.setHasFixedSize(true); columns = Integer.parseInt(Sp.getString("columns", "-1")); if (IS_LIST) { mLayoutManager = new LinearLayoutManager(getActivity()); listView.setLayoutManager(mLayoutManager); } else { if (columns == -1 || columns == 0) mLayoutManagerGrid = new GridLayoutManager(getActivity(), 3); else mLayoutManagerGrid = new GridLayoutManager(getActivity(), columns); listView.setLayoutManager(mLayoutManagerGrid); } // use a linear layout manager footerView = getActivity().getLayoutInflater().inflate(R.layout.divider, null); dividerItemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false, SHOW_DIVIDERS); listView.addItemDecoration(dividerItemDecoration); mSwipeRefreshLayout.setColorSchemeColors(Color.parseColor(fabSkin)); DefaultItemAnimator animator = new DefaultItemAnimator(); listView.setItemAnimator(animator); mToolbarContainer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if ((columns == 0 || columns == -1)) { int screen_width = listView.getWidth(); int dptopx = dpToPx(115); columns = screen_width / dptopx; if (columns == 0 || columns == -1) columns = 3; if (!IS_LIST) mLayoutManagerGrid.setSpanCount(columns); } if (savedInstanceState != null && !IS_LIST) retrieveFromSavedInstance(savedInstanceState); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { mToolbarContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { mToolbarContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); if (savedInstanceState == null) { loadlist(CURRENT_PATH, false, openMode); } else { if (IS_LIST) retrieveFromSavedInstance(savedInstanceState); } }
From source file:com.android.settings.applications.CanBeOnSdCardChecker.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);//www . java 2 s.c o m mApplicationsState = ApplicationsState.getInstance(getActivity().getApplication()); Intent intent = getActivity().getIntent(); String action = intent.getAction(); int defaultListType = LIST_TYPE_DOWNLOADED; String className = getArguments() != null ? getArguments().getString("classname") : null; if (className == null) { className = intent.getComponent().getClassName(); } if (className.equals(RunningServicesActivity.class.getName()) || className.endsWith(".RunningServices")) { defaultListType = LIST_TYPE_RUNNING; } else if (className.equals(StorageUseActivity.class.getName()) || Intent.ACTION_MANAGE_PACKAGE_STORAGE.equals(action) || className.endsWith(".StorageUse")) { mSortOrder = SORT_ORDER_SIZE; defaultListType = LIST_TYPE_ALL; } else if (Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS.equals(action)) { // Select the all-apps list, with the default sorting defaultListType = LIST_TYPE_ALL; } if (savedInstanceState != null) { mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder); int tmp = savedInstanceState.getInt(EXTRA_DEFAULT_LIST_TYPE, -1); if (tmp != -1) defaultListType = tmp; mShowBackground = savedInstanceState.getBoolean(EXTRA_SHOW_BACKGROUND, false); } mDefaultListType = defaultListType; final Intent containerIntent = new Intent().setComponent(StorageMeasurement.DEFAULT_CONTAINER_COMPONENT); getActivity().bindService(containerIntent, mContainerConnection, Context.BIND_AUTO_CREATE); mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value); mComputingSizeStr = getActivity().getText(R.string.computing_size); TabInfo tab = new TabInfo(this, mApplicationsState, getActivity().getString(R.string.filter_apps_third_party), LIST_TYPE_DOWNLOADED, this, savedInstanceState); mTabs.add(tab); if (!Environment.isExternalStorageEmulated()) { tab = new TabInfo(this, mApplicationsState, getActivity().getString(R.string.filter_apps_onsdcard), LIST_TYPE_SDCARD, this, savedInstanceState); mTabs.add(tab); } tab = new TabInfo(this, mApplicationsState, getActivity().getString(R.string.filter_apps_running), LIST_TYPE_RUNNING, this, savedInstanceState); mTabs.add(tab); tab = new TabInfo(this, mApplicationsState, getActivity().getString(R.string.filter_apps_all), LIST_TYPE_ALL, this, savedInstanceState); mTabs.add(tab); tab = new TabInfo(this, mApplicationsState, getActivity().getString(R.string.filter_apps_disabled), LIST_TYPE_DISABLED, this, savedInstanceState); mTabs.add(tab); mNumTabs = mTabs.size(); }
From source file:com.android.mail.ui.FolderListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { setInstanceFromBundle(getArguments()); final View rootView = inflater.inflate(R.layout.folder_list, container, false); mListView = (ListView) rootView.findViewById(android.R.id.list); mListView.setEmptyView(null);/*from ww w.j ava 2 s.co m*/ mListView.setDivider(null); addListHeader(inflater, rootView, mListView); if (savedState != null && savedState.containsKey(BUNDLE_LIST_STATE)) { mListView.onRestoreInstanceState(savedState.getParcelable(BUNDLE_LIST_STATE)); } if (savedState != null && savedState.containsKey(BUNDLE_SELECTED_FOLDER)) { mSelectedFolderUri = new FolderUri(Uri.parse(savedState.getString(BUNDLE_SELECTED_FOLDER))); mSelectedDrawerItemCategory = savedState.getInt(BUNDLE_SELECTED_ITEM_TYPE); mSelectedFolderType = savedState.getInt(BUNDLE_SELECTED_TYPE); } else if (mParentFolder != null) { mSelectedFolderUri = mParentFolder.folderUri; // No selected folder type required for hierarchical lists. } if (savedState != null) { mInboxPresent = savedState.getBoolean(BUNDLE_INBOX_PRESENT, true); } else { mInboxPresent = true; } mMiniDrawerView = (MiniDrawerView) rootView.findViewById(R.id.mini_drawer); // Create default animator listeners mMiniDrawerFadeOutListener = new FadeAnimatorListener(mMiniDrawerView, true /* fadeOut */); mListViewFadeOutListener = new FadeAnimatorListener(mListView, true /* fadeOut */); mMiniDrawerFadeInListener = new FadeAnimatorListener(mMiniDrawerView, false /* fadeOut */); mListViewFadeInListener = new FadeAnimatorListener(mListView, false /* fadeOut */); return rootView; }
From source file:com.sonetel.ui.dialpad.DialerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dialer_digit, container, false); // Store the backgrounds objects that will be in use later /*/*from ww w . j a va2s . c o m*/ Resources r = getResources(); digitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active); digitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield_normal); */ // Store some object that could be useful later digits = (DigitsEditText) v.findViewById(R.id.digitsText); dialPad = (Dialpad) v.findViewById(R.id.dialPad); callBar = (DialerCallBar) v.findViewById(R.id.dialerCallBar); autoCompleteList = (ListView) v.findViewById(R.id.autoCompleteList); accountChooserButton = (AccountChooserButton) v.findViewById(R.id.accountChooserButton); dialerLayout = (DialerLayout) v.findViewById(R.id.top_digit_dialer); countryView = (ImageView) v.findViewById(R.id.imageView1); countryName = (TextView) v.findViewById(R.id.textView1); //switchTextView = (ImageButton) v.findViewById(R.id.switchTextView); // isTablet = Compatibility.isTabletScreen(getActivity()); // Digits field setup if (savedInstanceState != null) { isDigit = savedInstanceState.getBoolean(TEXT_MODE_KEY, isDigit); } digits.setOnEditorActionListener(keyboardActionListener); // Layout dialerLayout.setForceNoList(mDualPane); // Account chooser button setup accountChooserButton.setShowExternals(true); accountChooserButton.setOnAccountChangeListener(accountButtonChangeListener); // Dialpad dialPad.setOnDialKeyListener(this); // We only need to add the autocomplete list if we autoCompleteList.setAdapter(autoCompleteAdapter); autoCompleteList.setOnItemClickListener(autoCompleteListItemListener); autoCompleteList.setFastScrollEnabled(true); // Bottom bar setup callBar.setOnDialActionListener(this); callBar.setVideoEnabled(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_VIDEO)); //switchTextView.setVisibility(Compatibility.isCompatible(11) ? View.GONE : View.VISIBLE); // Init other buttons initButtons(v); // Ensure that current mode (text/digit) is applied setTextDialing(!isDigit, true); // Apply third party theme if any applyTheme(v); v.setOnKeyListener(this); //<<<<<<< .mine // updateRegistrations(); //======= applyTextToAutoComplete(); //>>>>>>> .r1897 return v; }
From source file:com.android.calendar.EventInfoFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mReminderChangeListener = new OnItemSelectedListener() { @Override/*from ww w . ja va 2s .c om*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Integer prevValue = (Integer) parent.getTag(); if (prevValue == null || prevValue != position) { parent.setTag(position); mUserModifiedReminders = true; } } @Override public void onNothingSelected(AdapterView<?> parent) { // do nothing } }; if (savedInstanceState != null) { mIsDialog = savedInstanceState.getBoolean(BUNDLE_KEY_IS_DIALOG, false); mWindowStyle = savedInstanceState.getInt(BUNDLE_KEY_WINDOW_STYLE, DIALOG_WINDOW_STYLE); } if (mIsDialog) { applyDialogParams(); } final FragmentActivity activity = getActivity(); mContext = activity; mColorPickerDialog = (EventColorPickerDialog) activity.getSupportFragmentManager() .findFragmentByTag(COLOR_PICKER_DIALOG_TAG); if (mColorPickerDialog != null) { mColorPickerDialog.setOnColorSelectedListener(this); } }
From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_stats); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mScrollView = (ObservableScrollView) findViewById(R.id.game_scroll_view); mScrollView.addCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); }//w ww. ja va2s. c o m mScrollViewChild = findViewById(R.id.game_scroll_view_child); mDetailsContainer = findViewById(R.id.game_details_container); mDetailsContainer.setAlpha(0); mDetailsContainer.setY(1200); mHeaderBox = findViewById(R.id.header_game); mGameViewContainer = findViewById(R.id.game_photo_container); mGameImageView = (ImageView) findViewById(R.id.game_photo); mGameTimeView = (TextView) findViewById(R.id.game_time_view); mGameScoreViewLeft = (TextView) findViewById(R.id.game_score_view_left); mGameScoreViewRight = (TextView) findViewById(R.id.game_score_view_right); tickerLayout = (LinearLayout) findViewById(R.id.sidedrawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mTitle = (TextView) findViewById(R.id.header_title); mSubtitle = (TextView) findViewById(R.id.header_subtitle); mUpdateProgressBar = (ProgressBar) findViewById(R.id.header_progressbar); mapView = (ImageView) findViewById(R.id.game_map_view); mHasPhoto = true; mGameImageView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); Picasso.with(this).load(R.drawable.drawable_dota_bg_dire_ancient).config(Bitmap.Config.ARGB_8888) .resize(Math.round(displayMetrics.widthPixels * PHOTO_ASPECT_RATIO * 2 / 3), displayMetrics.widthPixels * 2 / 3) .transform(new CropImageTransform(displayMetrics.heightPixels, displayMetrics.widthPixels)) .into(mGameImageView); setBundleContents(); initMapView(); mPresenter = new LiveStatsPresenter(this); mLiveTickerAdapter = new LiveTickerAdapter(this, R.layout.sidedrawer_list_item); if (savedInstanceState != null) { mLiveTickerAdapter.onRestoreInstanceState(savedInstanceState); gameCompleted = savedInstanceState.getBoolean(KEY_GAME_COMPLETE, false); } mDrawerListView = (ListView) findViewById(R.id.sidedrawer_items_list); mDrawerListView.setAdapter(mLiveTickerAdapter); mUpdateProgressAnim = new ProgressBarAnimation(mUpdateProgressBar, 2000, 0); mUpdateProgressAnim.setDuration(GAME_UPDATE_INTERVAL); mUpdateProgressAnim.setInterpolator(new LinearInterpolator()); if (!PrefUtils.hasLiveDrawerBeenShown(this)) { mDrawerLayout.openDrawer(Gravity.END); Toast.makeText(this, "Match events are shown in the right drawer", Toast.LENGTH_SHORT).show(); PrefUtils.setLiveDrawerShown(this); } }
From source file:android.support.v17.leanback.app.BrowseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getChildFragmentManager().findFragmentById(R.id.scale_frame) == null) { mHeadersFragment = new HeadersFragment(); createMainFragment(mAdapter, mSelectedPosition); FragmentTransaction ft = getChildFragmentManager().beginTransaction().replace(R.id.browse_headers_dock, mHeadersFragment);/*from w w w . j a v a 2 s.c om*/ if (mMainFragment != null) { ft.replace(R.id.scale_frame, mMainFragment); } else { // Empty adapter used to guard against lazy adapter loading. When this // fragment is instantiated, mAdapter might not have the data or might not // have been set. In either of those cases mFragmentAdapter will be null. // This way we can maintain the invariant that mMainFragmentAdapter is never // null and it avoids doing null checks all over the code. mMainFragmentAdapter = new MainFragmentAdapter(null); mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl()); } ft.commit(); } else { mHeadersFragment = (HeadersFragment) getChildFragmentManager() .findFragmentById(R.id.browse_headers_dock); mMainFragment = getChildFragmentManager().findFragmentById(R.id.scale_frame); mMainFragmentAdapter = ((MainFragmentAdapterProvider) mMainFragment).getMainFragmentAdapter(); mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl()); mIsPageRow = savedInstanceState != null ? savedInstanceState.getBoolean(IS_PAGE_ROW, false) : false; mSelectedPosition = savedInstanceState != null ? savedInstanceState.getInt(CURRENT_SELECTED_POSITION, 0) : 0; if (!mIsPageRow) { if (mMainFragment instanceof MainFragmentRowsAdapterProvider) { mMainFragmentRowsAdapter = ((MainFragmentRowsAdapterProvider) mMainFragment) .getMainFragmentRowsAdapter(); } else { mMainFragmentRowsAdapter = null; } } else { mMainFragmentRowsAdapter = null; } } mHeadersFragment.setHeadersGone(!mCanShowHeaders); if (mHeaderPresenterSelector != null) { mHeadersFragment.setPresenterSelector(mHeaderPresenterSelector); } mHeadersFragment.setAdapter(mAdapter); mHeadersFragment.setOnHeaderViewSelectedListener(mHeaderViewSelectedListener); mHeadersFragment.setOnHeaderClickedListener(mHeaderClickedListener); View root = inflater.inflate(R.layout.lb_browse_fragment, container, false); getProgressBarManager().setRootView((ViewGroup) root); mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame); mBrowseFrame.setOnChildFocusListener(mOnChildFocusListener); mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener); installTitleView(inflater, mBrowseFrame, savedInstanceState); mScaleFrameLayout = (ScaleFrameLayout) root.findViewById(R.id.scale_frame); mScaleFrameLayout.setPivotX(0); mScaleFrameLayout.setPivotY(mContainerListAlignTop); setupMainFragment(); if (mBrandColorSet) { mHeadersFragment.setBackgroundColor(mBrandColor); } mSceneWithHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { showHeaders(true); } }); mSceneWithoutHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { showHeaders(false); } }); mSceneAfterEntranceTransition = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { setEntranceTransitionEndState(); } }); return root; }
From source file:android.support.v17.leanback.app.BrowseSupportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getChildFragmentManager().findFragmentById(R.id.scale_frame) == null) { mHeadersSupportFragment = new HeadersSupportFragment(); createMainFragment(mAdapter, mSelectedPosition); FragmentTransaction ft = getChildFragmentManager().beginTransaction().replace(R.id.browse_headers_dock, mHeadersSupportFragment); if (mMainFragment != null) { ft.replace(R.id.scale_frame, mMainFragment); } else {//w w w . j a v a 2 s . c om // Empty adapter used to guard against lazy adapter loading. When this // fragment is instantiated, mAdapter might not have the data or might not // have been set. In either of those cases mFragmentAdapter will be null. // This way we can maintain the invariant that mMainFragmentAdapter is never // null and it avoids doing null checks all over the code. mMainFragmentAdapter = new MainFragmentAdapter(null); mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl()); } ft.commit(); } else { mHeadersSupportFragment = (HeadersSupportFragment) getChildFragmentManager() .findFragmentById(R.id.browse_headers_dock); mMainFragment = getChildFragmentManager().findFragmentById(R.id.scale_frame); mMainFragmentAdapter = ((MainFragmentAdapterProvider) mMainFragment).getMainFragmentAdapter(); mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl()); mIsPageRow = savedInstanceState != null ? savedInstanceState.getBoolean(IS_PAGE_ROW, false) : false; mSelectedPosition = savedInstanceState != null ? savedInstanceState.getInt(CURRENT_SELECTED_POSITION, 0) : 0; if (!mIsPageRow) { if (mMainFragment instanceof MainFragmentRowsAdapterProvider) { mMainFragmentRowsAdapter = ((MainFragmentRowsAdapterProvider) mMainFragment) .getMainFragmentRowsAdapter(); } else { mMainFragmentRowsAdapter = null; } } else { mMainFragmentRowsAdapter = null; } } mHeadersSupportFragment.setHeadersGone(!mCanShowHeaders); if (mHeaderPresenterSelector != null) { mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector); } mHeadersSupportFragment.setAdapter(mAdapter); mHeadersSupportFragment.setOnHeaderViewSelectedListener(mHeaderViewSelectedListener); mHeadersSupportFragment.setOnHeaderClickedListener(mHeaderClickedListener); View root = inflater.inflate(R.layout.lb_browse_fragment, container, false); getProgressBarManager().setRootView((ViewGroup) root); mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame); mBrowseFrame.setOnChildFocusListener(mOnChildFocusListener); mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener); installTitleView(inflater, mBrowseFrame, savedInstanceState); mScaleFrameLayout = (ScaleFrameLayout) root.findViewById(R.id.scale_frame); mScaleFrameLayout.setPivotX(0); mScaleFrameLayout.setPivotY(mContainerListAlignTop); setupMainFragment(); if (mBrandColorSet) { mHeadersSupportFragment.setBackgroundColor(mBrandColor); } mSceneWithHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { showHeaders(true); } }); mSceneWithoutHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { showHeaders(false); } }); mSceneAfterEntranceTransition = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { setEntranceTransitionEndState(); } }); return root; }
From source file:org.thoughtland.xlocation.ActivityShare.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check privacy service client if (!PrivacyService.checkClient()) return;//from w w w . j a v a2s .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); // 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; setTitle(R.string.menu_toggle); } else if (action.equals(ACTION_IMPORT)) { mActionId = R.string.menu_import; setTitle(R.string.menu_import); } else if (action.equals(ACTION_EXPORT)) { mActionId = R.string.menu_export; setTitle(R.string.menu_export); } else if (action.equals(ACTION_FETCH)) { mActionId = R.string.menu_fetch; setTitle(R.string.menu_fetch); } else if (action.equals(ACTION_SUBMIT)) { mActionId = R.string.menu_submit; setTitle(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); spAdapter.add(getString(R.string.title_default)); for (int i = 1; i <= 4; i++) spAdapter.add(getString(R.string.title_alternate) + " " + i); 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.setText(R.string.menu_toggle); 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(); } }); }