List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getActivity().getApplicationContext(); ConnectivityManager connManager = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); mNetworkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); prefs = new DVBViewerPreferences(getActivity()); showFavs = prefs.getPrefs().getBoolean(DVBViewerPreferences.KEY_CHANNELS_USE_FAVS, false); showNowPlaying = prefs.getPrefs().getBoolean(DVBViewerPreferences.KEY_CHANNELS_SHOW_NOW_PLAYING, true); showNowPlayingWifi = prefs.getPrefs() .getBoolean(DVBViewerPreferences.KEY_CHANNELS_SHOW_NOW_PLAYING_WIFI_ONLY, true); mAdapter = new ChannelAdapter(getActivity()); if (getArguments() != null) { if (getArguments().containsKey(ChannelList.KEY_HAS_OPTIONMENU)) { hasOptionsMenu = getArguments().getBoolean(KEY_HAS_OPTIONMENU); }//from www .j a v a2 s . c om } if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_SELECTED_POSITION)) { selectedPosition = savedInstanceState.getInt(KEY_SELECTED_POSITION); } } else { selectedPosition = getActivity().getIntent().getIntExtra(KEY_SELECTED_POSITION, selectedPosition); } setHasOptionsMenu(hasOptionsMenu); }
From source file:co.taqat.call.assistant.AssistantActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }/*from www. j av a 2s .c o m*/ setContentView(R.layout.assistant); initUI(); if (getIntent().getBooleanExtra("LinkPhoneNumber", false)) { isLink = true; //if (getIntent().getBooleanExtra("FromPref",false)){ // fromPref = true; //displayCreateAccount(); } else { firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) ? AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.WELCOME; if (findViewById(R.id.fragment_container) != null) { if (savedInstanceState == null) { display(firstFragment); } else { currentFragment = (AssistantFragmentsEnum) savedInstanceState .getSerializable("CurrentFragment"); } } } if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) { echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller"); } else { echoCancellerAlreadyDone = false; } mPrefs = LinphonePreferences.instance(); status.enableSideMenu(false); accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl()); accountCreator.setDomain(getResources().getString(R.string.default_domain)); accountCreator.setListener(this); countryListAdapter = new CountryListAdapter(getApplicationContext()); mListener = new LinphoneCoreListenerBase() { @Override public void configuringStatus(LinphoneCore lc, final LinphoneCore.RemoteProvisioningState state, String message) { if (progress != null) progress.dismiss(); if (state == LinphoneCore.RemoteProvisioningState.ConfiguringSuccessful) { goToLinphoneActivity(); } else if (state == LinphoneCore.RemoteProvisioningState.ConfiguringFailed) { Toast.makeText(AssistantActivity.instance(), getString(R.string.remote_provisioning_failure), Toast.LENGTH_LONG).show(); } } @Override public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state, String smessage) { if (remoteProvisioningInProgress) { if (progress != null) progress.dismiss(); if (state == RegistrationState.RegistrationOk) { remoteProvisioningInProgress = false; success(); } } else if (accountCreated && !newAccount) { if (address != null && address.asString().equals(cfg.getAddress().asString())) { if (state == RegistrationState.RegistrationOk) { if (progress != null) progress.dismiss(); if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { accountCreator.isAccountUsed(); } } else if (state == RegistrationState.RegistrationFailed) { if (progress != null) progress.dismiss(); if (dialog == null || !dialog.isShowing()) { dialog = createErrorDialog(cfg, smessage); dialog.show(); } } else if (!(state == RegistrationState.RegistrationProgress)) { if (progress != null) progress.dismiss(); } } } } }; instance = this; }
From source file:com.ntsync.android.sync.syncadapter.SyncAdapter.java
private void performSync(Account account, Bundle extras, SyncResult syncResult, AccountSyncResult appSyncResult) { String authtoken = null;/* w w w . j a v a 2 s . c om*/ try { long contactSyncMarker = getContactSyncMarker(account); long contactGroupMarker = getContactGroupSyncMarker(account); SyncAnchor syncAnchor = new SyncAnchor(); if (contactSyncMarker == 0) { // By default, contacts from a 3rd party provider are hidden // in the contacts list. ContactManager.setAccountContactsVisibility(mContext, account, true); // Add Default Group, otherwise group selection is not // visible // in the default editor. ContactManager.ensureSampleGroupExists(mContext, account); } authtoken = NetworkUtilities.blockingGetAuthToken(mAccountManager, account, null); if (authtoken == null) { syncResult.stats.numIoExceptions++; appSyncResult.setState(SyncResultState.AUTH_FAILED); return; } boolean getRestrictions = extras != null ? extras.containsKey(Constants.PARAM_GETRESTRICTIONS) : false; Restrictions restr = SyncUtils.getRestrictions(account, mAccountManager); if (restr == null || getRestrictions) { Restrictions oldRestr = restr; restr = NetworkUtilities.getRestrictions(mContext, account, authtoken, mAccountManager); processRestrictions(oldRestr, restr, account); // Return-Value is not processed because we don't have to // restart for a full sync because all relevant data values will // be read after here. } PrivateKeyState readyState = ClientKeyHelper.isReadyForSync(mContext, account, mAccountManager, authtoken); boolean retryLater = false; switch (readyState) { case AUTH_FAILED: retryLater = true; appSyncResult.setState(SyncResultState.AUTH_FAILED); break; case CHECK_FAILED: // Retry later -> delay sync retryLater = true; appSyncResult.setState(SyncResultState.SERVER_ERROR); break; case NETWORK_ERROR: appSyncResult.setState(SyncResultState.NETWORK_ERROR); appSyncResult.setErrorMsg(readyState.getErrorMsg()); retryLater = true; break; case MISSING_KEY: sendMissingKey(account, authtoken, readyState.getCurrSalt()); appSyncResult.setState(SyncResultState.MISSING_KEY); return; default: clearMissingKeyNotification(account); break; } if (retryLater) { syncResult.delayUntil = SYNC_RETRY_DELAY; syncResult.fullSyncRequested = true; return; } SecretKey privKey = ClientKeyHelper.getOrCreatePrivateKey(account, mAccountManager); authtoken = checkIfSaltSaved(account, authtoken); if (authtoken == null) { syncResult.stats.numIoExceptions++; appSyncResult.setState(SyncResultState.AUTH_FAILED); return; } // Update ClientMod if not already set. ContactManager.updateClientModDate(mContext, account); // Get local Dirty Groups List<ContactGroup> dirtyGroups = ContactManager.getDirtyGroups(mContext, account, restr); boolean syncContacts = true; if (!dirtyGroups.isEmpty()) { // sync only Groups if some new groups are available, to // make // sure, that ids are available for (ContactGroup contactGroup : dirtyGroups) { if (contactGroup.getSourceId() == null) { syncContacts = false; break; } } } syncAnchor.setAnchor(ContactConstants.TYPE_CONTACTGROUP, contactGroupMarker); List<RawContact> dirtyContacts = null; Map<Long, String> newIdMap = null; if (syncContacts) { // Get local Dirty contacts dirtyContacts = ContactManager.getDirtyContacts(mContext, account, restr, new SyncRestConflictHandler(account.name)); newIdMap = ContactManager.getNewIdMap(mContext, account); syncAnchor.setAnchor(ContactConstants.TYPE_CONTACT, contactSyncMarker); } // Send the dirty contacts to the server, and retrieve the // server-side changes String saltStr = ClientKeyHelper.getSalt(account, mAccountManager); boolean explizitPhotoSave = getExplicitSavePhoto(account); SyncResponse result = NetworkUtilities.syncContacts(account, authtoken, syncAnchor, dirtyContacts, dirtyGroups, privKey, mAccountManager, mContext, syncResult, saltStr, newIdMap, restr, explizitPhotoSave); if (result.newGroupIdMap != null && !result.newGroupIdMap.isEmpty()) { if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Calling contactManager's set new GroupIds. Count Updates:" + result.newGroupIdMap.size()); } ContactManager.saveGroupIds(mContext, account.name, result.newGroupIdMap); } if (result.newContactIdMap != null && !result.newContactIdMap.isEmpty()) { if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Calling contactManager's set new ContactIds. Count Updates:" + result.newContactIdMap.size()); } ContactManager.saveContactIds(mContext, account.name, result.newContactIdMap); } Set<Long> updatedGroupIds = null; if (result.serverGroups != null && !result.serverGroups.isEmpty()) { // Update the local groups database with the changes. if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Calling contactManager's update groups. Count Updates:" + result.serverGroups.size()); } updatedGroupIds = ContactManager.updateGroups(mContext, account.name, result.serverGroups); } Set<Long> updatedContactIds = null; if (result.serverContacts != null && !result.serverContacts.isEmpty()) { // Update the local contacts database with the changes. if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Calling contactManager's update contacts. Count Updates:" + result.serverContacts.size()); } updatedContactIds = ContactManager.updateContacts(mContext, account.name, result.serverContacts, true, restr); } SyncAnchor newSyncAnchor = result.newServerAnchor; if (newSyncAnchor != null) { setContactSyncMarker(account, newSyncAnchor.getAnchor(ContactConstants.TYPE_CONTACT)); setContactGroupSyncMarker(account, newSyncAnchor.getAnchor(ContactConstants.TYPE_CONTACTGROUP)); } if (result.syncstate != null) { switch (result.syncstate) { case INVALID_KEY: // Reset Key-Info && do FullSync mAccountManager.invalidateAuthToken(Constants.ACCOUNT_TYPE, authtoken); ClientKeyHelper.clearPrivateKeyData(account, mAccountManager); ContactManager.setDirtyFlag(mContext, account); setContactSyncMarker(account, FULLSYNC_MARKER); setContactGroupSyncMarker(account, FULLSYNC_MARKER); syncResult.fullSyncRequested = true; appSyncResult.setState(SyncResultState.SUCCESS); return; case FORCE_FULLSYNC: ContactManager.setDirtyFlag(mContext, account); setContactSyncMarker(account, FULLSYNC_MARKER); setContactGroupSyncMarker(account, FULLSYNC_MARKER); syncResult.fullSyncRequested = true; appSyncResult.setState(SyncResultState.SUCCESS); return; default: LogHelper.logI(TAG, "Ignoring unknown SyncState:" + result.syncstate); break; } } boolean resync = processRestrictions(restr, result.restrictions, account); if (resync) { ContactManager.setDirtyFlag(mContext, account); syncResult.fullSyncRequested = true; appSyncResult.setState(SyncResultState.SUCCESS); return; } if (!dirtyGroups.isEmpty()) { ContactManager.clearGroupSyncFlags(mContext, dirtyGroups, result.newGroupIdMap, updatedGroupIds); } if (dirtyContacts != null && !dirtyContacts.isEmpty()) { ContactManager.clearSyncFlags(mContext, dirtyContacts, account.name, result.newContactIdMap, updatedContactIds); } if (newIdMap != null && !newIdMap.isEmpty()) { ContactManager.clearServerId(mContext, newIdMap); } if (!syncContacts) { // if only groups were synced, restart for syncing contacts. syncResult.fullSyncRequested = true; } if (explizitPhotoSave) { // Clear Explizit Flag setExplicitSavePhoto(account, false); } appSyncResult.setState(SyncResultState.SUCCESS); } catch (final AuthenticatorException e) { LogHelper.logE(TAG, "AuthenticatorException", e); syncResult.stats.numParseExceptions++; setPrgErrorMsg(appSyncResult, e); } catch (final OperationCanceledException e) { LogHelper.logI(TAG, "OperationCanceledExcetpion", e); appSyncResult.setState(SyncResultState.AUTH_FAILED); } catch (final IOException e) { LogHelper.logE(TAG, "IOException", e); syncResult.stats.numIoExceptions++; setPrgErrorMsg(appSyncResult, e); } catch (final AuthenticationException e) { LogHelper.logI(TAG, "AuthenticationException", e); syncResult.stats.numAuthExceptions++; appSyncResult.setState(SyncResultState.AUTH_FAILED); } catch (final ParseException e) { LogHelper.logE(TAG, "ParseException", e); syncResult.stats.numParseExceptions++; setPrgErrorMsg(appSyncResult, e); } catch (InvalidKeyException e) { mAccountManager.invalidateAuthToken(Constants.ACCOUNT_TYPE, authtoken); ClientKeyHelper.clearPrivateKeyData(account, mAccountManager); LogHelper.logW(TAG, "InvalidKeyException", e); syncResult.stats.numAuthExceptions++; } catch (NetworkErrorException e) { syncResult.stats.numIoExceptions++; LogHelper.logWCause(TAG, "Sync failed because of a NetworkException", e); appSyncResult.setState(SyncResultState.NETWORK_ERROR); appSyncResult.setErrorMsg(String.format(getText(R.string.sync_network_error), e.getLocalizedMessage())); } catch (ServerException e) { syncResult.stats.numIoExceptions++; LogHelper.logWCause(TAG, "Sync failed because of a ServerException", e); appSyncResult.setState(SyncResultState.SERVER_ERROR); appSyncResult.setErrorMsg(getText(R.string.sync_server_error)); } catch (OperationApplicationException e) { LogHelper.logW(TAG, "Sync failed because a DB-Operation failed", e); syncResult.databaseError = true; setPrgErrorMsg(appSyncResult, e); } catch (HeaderParseException e) { syncResult.stats.numIoExceptions++; LogHelper.logWCause(TAG, "Sync failed because of server reponse could not be parsed", e); setPrgErrorMsg(appSyncResult, e); } catch (HeaderCreateException e) { syncResult.databaseError = true; LogHelper.logE(TAG, "Sync failed because header could not be created", e); setPrgErrorMsg(appSyncResult, e); } }
From source file:com.granita.icloudcalsync.syncadapter.DavSyncAdapter.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override/*from w w w . j av a 2 s . c o m*/ public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { Log.i(TAG, "Performing sync for authority " + authority); // set class loader for iCal4j ResourceLoader Thread.currentThread().setContextClassLoader(getContext().getClassLoader()); // create httpClient, if necessary httpClientLock.writeLock().lock(); if (httpClient == null) { Log.d(TAG, "Creating new DavHttpClient"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); httpClient = DavHttpClient.create(); } // prevent httpClient shutdown until we're ready by holding a read lock // acquiring read lock before releasing write lock will downgrade the write lock to a read lock httpClientLock.readLock().lock(); httpClientLock.writeLock().unlock(); // TODO use VCard 4.0 if possible AccountSettings accountSettings = new AccountSettings(getContext(), account); Log.d(TAG, "Server supports VCard version " + accountSettings.getAddressBookVCardVersion()); Exception exceptionToShow = null; // exception to show notification for Intent exceptionIntent = null; // what shall happen when clicking on the exception notification try { // get local <-> remote collection pairs Map<LocalCollection<?>, RemoteCollection<?>> syncCollections = getSyncPairs(account, provider); if (syncCollections == null) Log.i(TAG, "Nothing to synchronize"); else try { for (Map.Entry<LocalCollection<?>, RemoteCollection<?>> entry : syncCollections.entrySet()) new SyncManager(entry.getKey(), entry.getValue()) .synchronize(extras.containsKey(ContentResolver.SYNC_EXTRAS_MANUAL), syncResult); } catch (DavException ex) { syncResult.stats.numParseExceptions++; Log.e(TAG, "Invalid DAV response", ex); exceptionToShow = ex; } catch (HttpException ex) { if (ex.getCode() == HttpStatus.SC_UNAUTHORIZED) { Log.e(TAG, "HTTP Unauthorized " + ex.getCode(), ex); syncResult.stats.numAuthExceptions++; // hard error exceptionToShow = ex; exceptionIntent = new Intent(context, AccountActivity.class); exceptionIntent.putExtra(AccountActivity.EXTRA_ACCOUNT, account); } else if (ex.isClientError()) { Log.e(TAG, "Hard HTTP error " + ex.getCode(), ex); syncResult.stats.numParseExceptions++; // hard error exceptionToShow = ex; } else { Log.w(TAG, "Soft HTTP error " + ex.getCode() + " (Android will try again later)", ex); syncResult.stats.numIoExceptions++; // soft error } } catch (LocalStorageException ex) { syncResult.databaseError = true; // hard error Log.e(TAG, "Local storage (content provider) exception", ex); exceptionToShow = ex; } catch (IOException ex) { syncResult.stats.numIoExceptions++; // soft error Log.e(TAG, "I/O error (Android will try again later)", ex); if (ex instanceof SSLException) // always notify on SSL/TLS errors exceptionToShow = ex; } catch (URISyntaxException ex) { syncResult.stats.numParseExceptions++; // hard error Log.e(TAG, "Invalid URI (file name) syntax", ex); exceptionToShow = ex; } } finally { // allow httpClient shutdown httpClientLock.readLock().unlock(); } // show sync errors as notification if (exceptionToShow != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (exceptionIntent == null) exceptionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.WEB_URL_VIEW_LOGS)); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, exceptionIntent, 0); Notification.Builder builder = new Notification.Builder(context).setSmallIcon(R.drawable.ic_launcher) .setPriority(Notification.PRIORITY_LOW).setOnlyAlertOnce(true) .setWhen(System.currentTimeMillis()) .setContentTitle(context.getString(R.string.sync_error_title)) .setContentText(exceptionToShow.getLocalizedMessage()).setContentInfo(account.name) .setStyle(new Notification.BigTextStyle() .bigText(account.name + ":\n" + ExceptionUtils.getFullStackTrace(exceptionToShow))) .setContentIntent(contentIntent); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(account.name.hashCode(), builder.build()); } Log.i(TAG, "Sync complete for " + authority); }
From source file:biz.bokhorst.xprivacy.ActivityApp.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final int userId = Util.getUserId(Process.myUid()); // Check privacy service client if (!PrivacyService.checkClient()) return;//from w w w . jav a 2 s.co m // Set layout setContentView(R.layout.restrictionlist); // Get arguments Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } int uid = extras.getInt(cUid); String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null); String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null); // Get app info mAppInfo = new ApplicationInfoEx(this, uid); if (mAppInfo.getPackageName().size() == 0) { finish(); return; } // Set title setTitle(String.format("%s - %s", getString(R.string.app_name), TextUtils.join(", ", mAppInfo.getApplicationName()))); // Handle info click ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo); imgInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Packages can be selected on the web site Util.viewUri(ActivityApp.this, Uri.parse(String.format(ActivityShare.getBaseURL(ActivityApp.this) + "?package_name=%s", mAppInfo.getPackageName().get(0)))); } }); // Display app name TextView tvAppName = (TextView) findViewById(R.id.tvApp); tvAppName.setText(mAppInfo.toString()); // Background color if (mAppInfo.isSystem()) { LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo); llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous))); } // Display app icon final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon); imgIcon.setImageDrawable(mAppInfo.getIcon(this)); // Handle icon click imgIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openContextMenu(imgIcon); } }); // Display on-demand state final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand); if (PrivacyManager.isApplication(mAppInfo.getUid()) && PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true)) { boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); imgCbOnDemand.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, Boolean.toString(ondemand)); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); } }); } else imgCbOnDemand.setVisibility(View.GONE); // Display restriction state swEnabled = (Switch) findViewById(R.id.swEnable); swEnabled.setChecked( PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true)); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, Boolean.toString(isChecked)); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); imgCbOnDemand.setEnabled(isChecked); } }); imgCbOnDemand.setEnabled(swEnabled.isChecked()); // Add context menu to icon registerForContextMenu(imgIcon); // Check if internet access if (!mAppInfo.hasInternet(this)) { ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet); imgInternet.setVisibility(View.INVISIBLE); } // Check if frozen if (!mAppInfo.isFrozen(this)) { ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen); imgFrozen.setVisibility(View.INVISIBLE); } // Display version TextView tvVersion = (TextView) findViewById(R.id.tvVersion); tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this))); // Display package name TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName); tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName())); // Fill privacy list view adapter final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction); lvRestriction.setGroupIndicator(null); mPrivacyListAdapter = new RestrictionAdapter(R.layout.restrictionentry, mAppInfo, restrictionName, methodName); lvRestriction.setAdapter(mPrivacyListAdapter); if (restrictionName != null) { int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values()) .indexOf(restrictionName); lvRestriction.expandGroup(groupPosition); lvRestriction.setSelectedGroup(groupPosition); if (methodName != null) { int childPosition = PrivacyManager.getHooks(restrictionName) .indexOf(new Hook(restrictionName, methodName)); lvRestriction.setSelectedChild(groupPosition, childPosition, true); } } // Listen for package add/remove IntentFilter iff = new IntentFilter(); iff.addAction(Intent.ACTION_PACKAGE_REMOVED); iff.addDataScheme("package"); registerReceiver(mPackageChangeReceiver, iff); mPackageChangeReceiverRegistered = true; // Up navigation getActionBar().setDisplayHomeAsUpEnabled(true); // Tutorial if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) { ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE); ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE); } View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { ViewParent parent = view.getParent(); while (!parent.getClass().equals(ScrollView.class)) parent = parent.getParent(); ((View) parent).setVisibility(View.GONE); PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString()); } }; ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener); ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener); // Process actions if (extras.containsKey(cAction)) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(mAppInfo.getUid()); if (extras.getInt(cAction) == cActionClear) optionClear(); else if (extras.getInt(cAction) == cActionSettings) optionSettings(); } // Annotate Meta.annotate(this); }
From source file:com.irccloud.android.activity.UploadsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (ColorFormatter.file_uri_template != null) template = UriTemplate.fromTemplate(ColorFormatter.file_uri_template); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));/*from w ww.j ava 2 s . c o m*/ cloud.recycle(); } if (Build.VERSION.SDK_INT >= 14) { try { java.io.File httpCacheDir = new java.io.File(getCacheDir(), "http"); long httpCacheSize = 10 * 1024 * 1024; // 10 MiB HttpResponseCache.install(httpCacheDir, httpCacheSize); } catch (IOException e) { Log.i("IRCCloud", "HTTP response cache installation failed:" + e); } } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { cid = savedInstanceState.getInt("cid"); to = savedInstanceState.getString("to"); msg = savedInstanceState.getString("msg"); page = savedInstanceState.getInt("page"); File[] files = (File[]) savedInstanceState.getSerializable("adapter"); for (File f : files) { adapter.addFile(f); } adapter.notifyDataSetChanged(); } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchFilesTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final File f = (File) adapter.getItem(i); AlertDialog.Builder builder = new AlertDialog.Builder(UploadsActivity.this); builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); final View v = getLayoutInflater().inflate(R.layout.dialog_upload, null); final EditText messageinput = (EditText) v.findViewById(R.id.message); messageinput.setText(msg); final ImageView thumbnail = (ImageView) v.findViewById(R.id.thumbnail); v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (messageinput.hasFocus()) { v.post(new Runnable() { @Override public void run() { v.scrollTo(0, v.getBottom()); } }); } } }); if (f.mime_type.startsWith("image/")) { try { thumbnail.setImageBitmap(f.image); thumbnail.setVisibility(View.VISIBLE); thumbnail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(UploadsActivity.this, ImageViewerActivity.class); i.setData(Uri.parse(f.url)); startActivity(i); } }); thumbnail.setClickable(true); } catch (Exception e) { e.printStackTrace(); } } else { thumbnail.setVisibility(View.GONE); } ((TextView) v.findViewById(R.id.filesize)).setText(f.metadata); v.findViewById(R.id.filename).setVisibility(View.GONE); v.findViewById(R.id.filename_heading).setVisibility(View.GONE); builder.setTitle("Send A File To " + to); builder.setView(v); builder.setPositiveButton("Send", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String message = messageinput.getText().toString(); if (message.length() > 0) message += " "; message += f.url; dialog.dismiss(); if (getParent() == null) { setResult(Activity.RESULT_OK); } else { getParent().setResult(Activity.RESULT_OK); } finish(); NetworkConnection.getInstance().say(cid, to, message); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog d = builder.create(); d.setOwnerActivity(UploadsActivity.this); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); d.show(); } }); }
From source file:com.guillaumesoft.escapehellprison.PurchaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mOuyaFacade = OuyaFacade.getInstance(); Bundle developerInfo = new Bundle(); developerInfo.putString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID); developerInfo.putByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, loadApplicationKey()); mOuyaFacade = OuyaFacade.getInstance(); mOuyaFacade.init(this, developerInfo); // Uncomment this line to test against the server using "fake" credits. // This will also switch over to a separate "test" purchase history. //ouyaFacade.setTestMode(); setContentView(R.layout.sample_app); receiptListView = (ListView) findViewById(R.id.receipts); receiptListView.setFocusable(false); /*//from ww w . j ava 2 s .co m * In order to avoid "application not responding" popups, Android demands that long-running operations * happen on a background thread. Listener objects provide a way for you to specify what ought to happen * at the end of the long-running operation. Examples of this pattern in Android include * android.os.AsyncTask. */ findViewById(R.id.gamer_uuid_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fetchGamerInfo(); } }); // Attempt to restore the product and receipt list from the savedInstanceState Bundle if (savedInstanceState != null) { if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) { Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY); mProductList = new ArrayList<Product>(products.length); for (Parcelable product : products) { mProductList.add((Product) product); } addProducts(); } if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) { Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY); mReceiptList = new ArrayList<Receipt>(receipts.length); for (Parcelable receipt : receipts) { mReceiptList.add((Receipt) receipt); } addReceipts(); } } // Request the product list if it could not be restored from the savedInstanceState Bundle if (mProductList == null) { requestProducts(); } // Make sure the receipt ListView starts empty if the receipt list could not be restored // from the savedInstanceState Bundle. if (mReceiptList == null) { receiptListView.setAdapter(new ReceiptAdapter(this, new Receipt[0])); } // Create a PublicKey object from the key data downloaded from the developer portal. try { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(loadApplicationKey()); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); mPublicKey = keyFactory.generatePublic(keySpec); } catch (Exception e) { Log.e(LOG_TAG, "Unable to create encryption key", e); } }
From source file:com.rothconsulting.android.billing.util.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/*w w w. ja v a 2 s .com*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); Utils.log(mDebugTag, "++ --- ownedItems from Service = " + ownedItems); Utils.log(mDebugTag, "++ --- ownedItems itemType = " + itemType); Utils.log(mDebugTag, "++ --- ownedItems keySet = " + ownedItems.keySet()); Utils.log(mDebugTag, "++ --- ownedItems isEmpty = " + ownedItems.isEmpty()); Utils.log(mDebugTag, "++ --- ownedItems INAPP_PURCHASE_ITEM_LIST = " + ownedItems.get("INAPP_PURCHASE_ITEM_LIST")); Utils.log(mDebugTag, "++ --- ownedItems INAPP_PURCHASE_DATA_LIST = " + ownedItems.get("INAPP_PURCHASE_DATA_LIST")); Utils.log(mDebugTag, "++ --- ownedItems INAPP_DATA_SIGNATURE_LIST = " + ownedItems.get("INAPP_DATA_SIGNATURE_LIST")); Utils.log(mDebugTag, "++ --- ownedItems RESPONSE_CODE = " + ownedItems.get("RESPONSE_CODE")); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:com.goodhustle.ouyaunitybridge.OuyaUnityActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); OuyaController.init(this); // Initialize ouyaFacade ouyaFacade = OuyaFacade.getInstance(); ouyaFacade.init(this, DEVELOPER_ID); userManager = UserManager.getInstance(this); playerStates = new ControllerState[OuyaController.MAX_CONTROLLERS]; for (int i = 0; i < OuyaController.MAX_CONTROLLERS; i++) { playerStates[i] = new ControllerState(); }/* w w w.j a va2 s .c om*/ // Create the UnityPlayer mUnityPlayer = new UnityPlayer(this); int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1); boolean trueColor8888 = false; mUnityPlayer.init(glesMode, trueColor8888); setContentView(R.layout.main); // Add the Unity view FrameLayout layout = (FrameLayout) findViewById(R.id.unityLayout); LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layout.addView(mUnityPlayer.getView(), 0, lp); // Set the focus RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.mainLayout); mainLayout.setFocusableInTouchMode(true); // Attempt to restore the product and receipt list from the savedInstanceState Bundle if (savedInstanceState != null) { if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) { Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY); mProductList = new ArrayList<Product>(products.length); for (Parcelable product : products) { mProductList.add((Product) product); } addProducts(); } if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) { Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY); mReceiptList = new ArrayList<Receipt>(receipts.length); for (Parcelable receipt : receipts) { mReceiptList.add((Receipt) receipt); } addReceipts(); } } // Request the product list if it could not be restored from the savedInstanceState Bundle if (mProductList == null) { requestProducts(); } // Create a PublicKey object from the key data downloaded from the developer portal. try { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(APPLICATION_KEY); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); mPublicKey = keyFactory.generatePublic(keySpec); } catch (Exception e) { Log.e(LOG_TAG, "Unable to create encryption key", e); } }