List of usage examples for android.accounts AccountManager getAccounts
@NonNull
public Account[] getAccounts()
From source file:com.einzig.ipst2.activities.MainActivity.java
/** * Search through accounts on the user's device now that we have permission to do so. *//*from ww w . ja v a2 s . c o m*/ public void gotAccountsPermission() { AccountManager manager = AccountManager.get(MainActivity.this); int numGoogAcct = 0; Account[] accountList = manager.getAccounts(); for (Account a : accountList) { if (a.type.equals("com.google")) { numGoogAcct++; } } if (numGoogAcct == 0) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this, ThemeHelper.getDialogTheme(this)); builder.setTitle(R.string.noaccountstitle); builder.setMessage(R.string.noaccountsmessage);//. Would you like to log in manually?") builder.setCancelable(true); builder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); } else { runOnUiThread(new Runnable() { @Override public void run() { findViewById(R.id.progress_view_mainactivity).setVisibility(View.VISIBLE); findViewById(R.id.gmail_login_button).setVisibility(View.INVISIBLE); } }); Intent intent = AccountManager.newChooseAccountIntent(null, null, new String[] { "com.google" }, false, null, null, null, null); startActivityForResult(intent, LOGIN_ACTIVITY_CODE); } }
From source file:com.sintef_energy.ubisolar.activities.DrawerActivity.java
/** * Logout From the app/*from www. ja v a2s . c o m*/ */ private void performLogout(Context context) { Session session = Session.getActiveSession(); if (session != null) { if (!session.isClosed()) { session.closeAndClearTokenInformation(); //clear your preferences if saved } } else { session = new Session(context); Session.setActiveSession(session); session.closeAndClearTokenInformation(); //clear your preferences if saved } /* UPDATE VIEW */ changeNavdrawerSessionsView(false); Utils.makeLongToast(getApplicationContext(), getResources().getString(R.string.fb_logout)); /* REMOVE ACCOUNT */ AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE); Account[] accounts = accountManager.getAccounts(); for (Account account : accounts) { if (account.type.intern().equals(ACCOUNT_TYPE)) { Log.v(TAG, "Removing account: " + account.name + " for authority: " + AUTHORITY_PROVIDER); accountManager.removeAccount(account, null, new Handler()); } } /* REMOVE PREFERENCES*/ PreferencesManager.getInstance().clearSessionData(); /* REMOVE DATA*/ getContentResolver().delete( EnergyContract.Devices.CONTENT_URI.buildUpon().appendPath(EnergyContract.DELETE).build(), null, null); getContentResolver().delete( EnergyContract.Energy.CONTENT_URI.buildUpon().appendPath(EnergyContract.DELETE).build(), null, null); }
From source file:com.granita.tasks.TaskListFragment.java
/** * Trigger a synchronization for all accounts. */// w w w . ja va 2 s .c om private void doSyncNow() { AccountManager accountManager = AccountManager.get(mAppContext); Account[] accounts = accountManager.getAccounts(); for (Account account : accounts) { // TODO: do we need a new bundle for each account or can we reuse it? Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(account, mAuthority, extras); } }
From source file:com.quarterfull.newsAndroid.NewsReaderListActivity.java
public void startSync() { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); if (mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null) == null) StartLoginFragment(this); else {//from www . j av a2 s. c om if (!ownCloudSyncService.isSyncRunning()) { new PostDelayHandler(this).stopRunningPostDelayHandler();//Stop pending sync handler Bundle accBundle = new Bundle(); accBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); AccountManager mAccountManager = AccountManager.get(this); Account[] accounts = mAccountManager.getAccounts(); for (Account acc : accounts) if (acc.type.equals(AccountGeneral.ACCOUNT_TYPE)) ContentResolver.requestSync(acc, AccountGeneral.ACCOUNT_TYPE, accBundle); //http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync } else { UpdateButtonLayout(); } } }
From source file:com.quarterfull.newsAndroid.NewsReaderListActivity.java
/** * Check if the account is in the Android Account Manager. If not it will be added automatically *//*from w w w.j av a2s . c om*/ private void initAccountManager() { AccountManager mAccountManager = AccountManager.get(this); boolean isAccountThere = false; Account[] accounts = mAccountManager.getAccounts(); for (Account account : accounts) { if (account.type.intern().equals(AccountGeneral.ACCOUNT_TYPE)) { isAccountThere = true; } } //If the account is not in the Android Account Manager if (!isAccountThere) { //Then add the new account Account account = new Account(getString(R.string.app_name), AccountGeneral.ACCOUNT_TYPE); mAccountManager.addAccountExplicitly(account, "", new Bundle()); SyncIntervalSelectorActivity.SetAccountSyncInterval(this); } }
From source file:de.luhmer.owncloudnewsreader.NewsReaderListActivity.java
public void startSync() { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); if (mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null) == null) StartLoginFragment(this); else {/*w w w . j ava2 s. com*/ try { if (!_ownCloudSyncService.isSyncRunning()) { new PostDelayHandler(this).stopRunningPostDelayHandler();//Stop pending sync handler Bundle accBundle = new Bundle(); accBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); AccountManager mAccountManager = AccountManager.get(this); Account[] accounts = mAccountManager.getAccounts(); for (Account acc : accounts) if (acc.type.equals(AccountGeneral.ACCOUNT_TYPE)) ContentResolver.requestSync(acc, AccountGeneral.ACCOUNT_TYPE, accBundle); //http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync } else { UpdateButtonLayout(); } } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:com.landenlabs.all_devtool.SystemFragment.java
public void updateList() { // Time today = new Time(Time.getCurrentTimezone()); // today.setToNow(); // today.format(" %H:%M:%S") Date dt = new Date(); m_titleTime.setText(m_timeFormat.format(dt)); boolean expandAll = m_list.isEmpty(); m_list.clear();/*from www .j av a 2s.c o m*/ // Swap colors int color = m_rowColor1; m_rowColor1 = m_rowColor2; m_rowColor2 = color; ActivityManager actMgr = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); try { String androidIDStr = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID); addBuild("Android ID", androidIDStr); try { AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getContext()); final String adIdStr = adInfo.getId(); final boolean isLAT = adInfo.isLimitAdTrackingEnabled(); addBuild("Ad ID", adIdStr); } catch (IOException e) { // Unrecoverable error connecting to Google Play services (e.g., // the old version of the service doesn't support getting AdvertisingId). } catch (GooglePlayServicesNotAvailableException e) { // Google Play services is not available entirely. } /* try { InstanceID instanceID = InstanceID.getInstance(getContext()); if (instanceID != null) { // Requires a Google Developer project ID. String authorizedEntity = "<need to make this on google developer site>"; instanceID.getToken(authorizedEntity, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); addBuild("Instance ID", instanceID.getId()); } } catch (Exception ex) { } */ ConfigurationInfo info = actMgr.getDeviceConfigurationInfo(); addBuild("OpenGL", info.getGlEsVersion()); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { long heapSize = Debug.getNativeHeapSize(); // long maxHeap = Runtime.getRuntime().maxMemory(); // ConfigurationInfo cfgInfo = actMgr.getDeviceConfigurationInfo(); int largHeapMb = actMgr.getLargeMemoryClass(); int heapMb = actMgr.getMemoryClass(); MemoryInfo memInfo = new MemoryInfo(); actMgr.getMemoryInfo(memInfo); final String sFmtMB = "%.2f MB"; Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("Mem Available (now)", String.format(sFmtMB, (double) memInfo.availMem / MB)); listStr.put("Mem LowWhenOnlyAvail", String.format(sFmtMB, (double) memInfo.threshold / MB)); if (Build.VERSION.SDK_INT >= 16) { listStr.put("Mem Installed", String.format(sFmtMB, (double) memInfo.totalMem / MB)); } listStr.put("Heap (this app)", String.format(sFmtMB, (double) heapSize / MB)); listStr.put("HeapMax (default)", String.format(sFmtMB, (double) heapMb)); listStr.put("HeapMax (large)", String.format(sFmtMB, (double) largHeapMb)); addBuild("Memory...", listStr); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { List<ProcessErrorStateInfo> procErrList = actMgr.getProcessesInErrorState(); int errCnt = (procErrList == null ? 0 : procErrList.size()); procErrList = null; // List<RunningAppProcessInfo> procList = actMgr.getRunningAppProcesses(); int procCnt = actMgr.getRunningAppProcesses().size(); int srvCnt = actMgr.getRunningServices(100).size(); Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("#Processes", String.valueOf(procCnt)); listStr.put("#Proc With Err", String.valueOf(errCnt)); listStr.put("#Services", String.valueOf(srvCnt)); // Requires special permission // int taskCnt = actMgr.getRunningTasks(100).size(); // listStr.put("#Tasks", String.valueOf(taskCnt)); addBuild("Processes...", listStr); } catch (Exception ex) { m_log.e("System-Processes %s", ex.getMessage()); } try { Map<String, String> listStr = new LinkedHashMap<String, String>(); listStr.put("LargeIconDensity", String.valueOf(actMgr.getLauncherLargeIconDensity())); listStr.put("LargeIconSize", String.valueOf(actMgr.getLauncherLargeIconSize())); putIf(listStr, "isRunningInTestHarness", "Yes", ActivityManager.isRunningInTestHarness()); putIf(listStr, "isUserAMonkey", "Yes", ActivityManager.isUserAMonkey()); addBuild("Misc...", listStr); } catch (Exception ex) { m_log.e("System-Misc %s", ex.getMessage()); } // --------------- Locale / Timezone ------------- try { Locale ourLocale = Locale.getDefault(); Date m_date = new Date(); TimeZone tz = TimeZone.getDefault(); Map<String, String> localeListStr = new LinkedHashMap<String, String>(); localeListStr.put("Locale Name", ourLocale.getDisplayName()); localeListStr.put(" Variant", ourLocale.getVariant()); localeListStr.put(" Country", ourLocale.getCountry()); localeListStr.put(" Country ISO", ourLocale.getISO3Country()); localeListStr.put(" Language", ourLocale.getLanguage()); localeListStr.put(" Language ISO", ourLocale.getISO3Language()); localeListStr.put(" Language Dsp", ourLocale.getDisplayLanguage()); localeListStr.put("TimeZoneID", tz.getID()); localeListStr.put(" DayLightSavings", tz.useDaylightTime() ? "Yes" : "No"); localeListStr.put(" In DLS", tz.inDaylightTime(m_date) ? "Yes" : "No"); localeListStr.put(" Short Name", tz.getDisplayName(false, TimeZone.SHORT, ourLocale)); localeListStr.put(" Long Name", tz.getDisplayName(false, TimeZone.LONG, ourLocale)); addBuild("Locale TZ...", localeListStr); } catch (Exception ex) { m_log.e("Locale/TZ %s", ex.getMessage()); } // --------------- Location Services ------------- try { Map<String, String> listStr = new LinkedHashMap<String, String>(); final LocationManager locMgr = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); GpsStatus gpsStatus = locMgr.getGpsStatus(null); if (gpsStatus != null) { listStr.put("Sec ToGetGPS", String.valueOf(gpsStatus.getTimeToFirstFix())); Iterable<GpsSatellite> satellites = gpsStatus.getSatellites(); Iterator<GpsSatellite> sat = satellites.iterator(); while (sat.hasNext()) { GpsSatellite satellite = sat.next(); putIf(listStr, String.format("Azm:%.0f, Elev:%.0f", satellite.getAzimuth(), satellite.getElevation()), String.format("%.2f Snr", satellite.getSnr()), satellite.usedInFix()); } } Location location = null; if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { location = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); } if (null != location) { listStr.put(location.getProvider() + " lat,lng", String.format("%.3f, %.3f", location.getLatitude(), location.getLongitude())); } if (listStr.size() != 0) { List<String> gpsProviders = locMgr.getAllProviders(); int idx = 1; for (String providerName : gpsProviders) { LocationProvider provider = locMgr.getProvider(providerName); if (null != provider) { listStr.put(providerName, (locMgr.isProviderEnabled(providerName) ? "On " : "Off ") + String.format("Accuracy:%d Pwr:%d", provider.getAccuracy(), provider.getPowerRequirement())); } } addBuild("GPS...", listStr); } else addBuild("GPS", "Off"); } catch (Exception ex) { m_log.e(ex.getMessage()); } // --------------- Application Info ------------- ApplicationInfo appInfo = getActivity().getApplicationInfo(); if (null != appInfo) { Map<String, String> appList = new LinkedHashMap<String, String>(); try { appList.put("ProcName", appInfo.processName); appList.put("PkgName", appInfo.packageName); appList.put("DataDir", appInfo.dataDir); appList.put("SrcDir", appInfo.sourceDir); // appList.put("PkgResDir", getActivity().getPackageResourcePath()); // appList.put("PkgCodeDir", getActivity().getPackageCodePath()); String[] dbList = getActivity().databaseList(); if (dbList != null && dbList.length != 0) appList.put("DataBase", dbList[0]); // getActivity().getComponentName(). } catch (Exception ex) { } addBuild("AppInfo...", appList); } // --------------- Account Services ------------- final AccountManager accMgr = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE); if (null != accMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); try { for (Account account : accMgr.getAccounts()) { strList.put(account.name, account.type); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Accounts...", strList); } // --------------- Package Features ------------- PackageManager pm = getActivity().getPackageManager(); FeatureInfo[] features = pm.getSystemAvailableFeatures(); if (features != null) { Map<String, String> strList = new LinkedHashMap<String, String>(); for (FeatureInfo featureInfo : features) { strList.put(featureInfo.name, ""); } addBuild("Features...", strList); } // --------------- Sensor Services ------------- final SensorManager senMgr = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (null != senMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); // Sensor accelerometer = senMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // senMgr.registerListener(foo, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); List<Sensor> listSensor = senMgr.getSensorList(Sensor.TYPE_ALL); try { for (Sensor sensor : listSensor) { strList.put(sensor.getName(), sensor.getVendor()); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Sensors...", strList); } try { if (Build.VERSION.SDK_INT >= 17) { final UserManager userMgr = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); if (null != userMgr) { try { addBuild("UserName", userMgr.getUserName()); } catch (Exception ex) { m_log.e(ex.getMessage()); } } } } catch (Exception ex) { } try { Map<String, String> strList = new LinkedHashMap<String, String>(); int screenTimeout = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT); strList.put("ScreenTimeOut", String.valueOf(screenTimeout / 1000)); int rotate = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.ACCELEROMETER_ROTATION); strList.put("RotateEnabled", String.valueOf(rotate)); if (Build.VERSION.SDK_INT >= 17) { // Global added in API 17 int adb = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED); strList.put("AdbEnabled", String.valueOf(adb)); } addBuild("Settings...", strList); } catch (Exception ex) { } if (expandAll) { // updateList(); int count = m_list.size(); for (int position = 0; position < count; position++) m_listView.expandGroup(position); } m_adapter.notifyDataSetChanged(); }
From source file:com.irccloud.android.activity.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { 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, 0xff0b2e60));/* w w w .j a v a2 s . c o m*/ cloud.recycle(); } requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); setContentView(R.layout.activity_login); loading = findViewById(R.id.loading); connecting = findViewById(R.id.connecting); connectingMsg = (TextView) findViewById(R.id.connectingMsg); progressBar = (ProgressBar) findViewById(R.id.connectingProgress); loginHint = (LinearLayout) findViewById(R.id.loginHint); signupHint = (LinearLayout) findViewById(R.id.signupHint); hostHint = (TextView) findViewById(R.id.hostHint); login = findViewById(R.id.login); name = (EditText) findViewById(R.id.name); if (savedInstanceState != null && savedInstanceState.containsKey("name")) name.setText(savedInstanceState.getString("name")); email = (AutoCompleteTextView) findViewById(R.id.email); if (BuildConfig.ENTERPRISE) email.setHint(R.string.email_enterprise); ArrayList<String> accounts = new ArrayList<String>(); AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); for (Account a : am.getAccounts()) { if (a.name.contains("@") && !accounts.contains(a.name)) accounts.add(a.name); } if (accounts.size() > 0) email.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, accounts.toArray(new String[accounts.size()]))); if (savedInstanceState != null && savedInstanceState.containsKey("email")) email.setText(savedInstanceState.getString("email")); password = (EditText) findViewById(R.id.password); password.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { new LoginTask().execute((Void) null); return true; } return false; } }); if (savedInstanceState != null && savedInstanceState.containsKey("password")) password.setText(savedInstanceState.getString("password")); host = (EditText) findViewById(R.id.host); if (BuildConfig.ENTERPRISE) host.setText(NetworkConnection.IRCCLOUD_HOST); else host.setVisibility(View.GONE); host.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { new LoginTask().execute((Void) null); return true; } return false; } }); if (savedInstanceState != null && savedInstanceState.containsKey("host")) host.setText(savedInstanceState.getString("host")); else host.setText(getSharedPreferences("prefs", 0).getString("host", BuildConfig.HOST)); if (host.getText().toString().equals("api.irccloud.com") || host.getText().toString().equals("www.irccloud.com")) host.setText(""); loginBtn = (Button) findViewById(R.id.loginBtn); loginBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new LoginTask().execute((Void) null); } }); loginBtn.setFocusable(true); loginBtn.requestFocus(); sendAccessLinkBtn = (Button) findViewById(R.id.sendAccessLink); sendAccessLinkBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { new ResetPasswordTask().execute((Void) null); } }); nextBtn = (Button) findViewById(R.id.nextBtn); nextBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (host.getText().length() > 0) { NetworkConnection.IRCCLOUD_HOST = host.getText().toString(); trimHost(); new EnterpriseConfigTask().execute((Void) null); } } }); TOS = (TextView) findViewById(R.id.TOS); TOS.setMovementMethod(new LinkMovementMethod()); forgotPassword = (TextView) findViewById(R.id.forgotPassword); forgotPassword.setOnClickListener(forgotPasswordClickListener); enterpriseLearnMore = (TextView) findViewById(R.id.enterpriseLearnMore); enterpriseLearnMore.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (isPackageInstalled("com.irccloud.android", LoginActivity.this)) { startActivity(getPackageManager().getLaunchIntentForPackage("com.irccloud.android")); } else { try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.irccloud.android"))); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.irccloud.android"))); } } } private boolean isPackageInstalled(String packagename, Context context) { PackageManager pm = context.getPackageManager(); try { pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES); return true; } catch (NameNotFoundException e) { return false; } } }); enterpriseHint = (LinearLayout) findViewById(R.id.enterpriseHint); EnterYourEmail = (TextView) findViewById(R.id.enterYourEmail); signupHint.setOnClickListener(signupHintClickListener); loginHint.setOnClickListener(loginHintClickListener); signupBtn = (Button) findViewById(R.id.signupBtn); signupBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { new LoginTask().execute((Void) null); } }); TextView version = (TextView) findViewById(R.id.version); try { version.setText("Version " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName); } catch (NameNotFoundException e) { version.setVisibility(View.GONE); } Typeface LatoRegular = Typeface.createFromAsset(getAssets(), "Lato-Regular.ttf"); Typeface LatoLightItalic = Typeface.createFromAsset(getAssets(), "Lato-LightItalic.ttf"); for (int i = 0; i < signupHint.getChildCount(); i++) { View v = signupHint.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); } } for (int i = 0; i < loginHint.getChildCount(); i++) { View v = loginHint.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); } } LinearLayout IRCCloud = (LinearLayout) findViewById(R.id.IRCCloud); for (int i = 0; i < IRCCloud.getChildCount(); i++) { View v = IRCCloud.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); } } notAProblem = (LinearLayout) findViewById(R.id.notAProblem); for (int i = 0; i < notAProblem.getChildCount(); i++) { View v = notAProblem.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface((i == 0) ? LatoRegular : LatoLightItalic); } } loginSignupHint = (LinearLayout) findViewById(R.id.loginSignupHint); for (int i = 0; i < loginSignupHint.getChildCount(); i++) { View v = loginSignupHint.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(LatoRegular); ((TextView) v).setOnClickListener((i == 0) ? loginHintClickListener : signupHintClickListener); } } name.setTypeface(LatoRegular); email.setTypeface(LatoRegular); password.setTypeface(LatoRegular); host.setTypeface(LatoRegular); loginBtn.setTypeface(LatoRegular); signupBtn.setTypeface(LatoRegular); TOS.setTypeface(LatoRegular); EnterYourEmail.setTypeface(LatoRegular); hostHint.setTypeface(LatoLightItalic); if (BuildConfig.ENTERPRISE) { name.setVisibility(View.GONE); email.setVisibility(View.GONE); password.setVisibility(View.GONE); loginBtn.setVisibility(View.GONE); signupBtn.setVisibility(View.GONE); TOS.setVisibility(View.GONE); signupHint.setVisibility(View.GONE); loginHint.setVisibility(View.GONE); forgotPassword.setVisibility(View.GONE); loginSignupHint.setVisibility(View.GONE); EnterYourEmail.setVisibility(View.GONE); sendAccessLinkBtn.setVisibility(View.GONE); notAProblem.setVisibility(View.GONE); enterpriseLearnMore.setVisibility(View.VISIBLE); enterpriseHint.setVisibility(View.VISIBLE); host.setVisibility(View.VISIBLE); nextBtn.setVisibility(View.VISIBLE); hostHint.setVisibility(View.VISIBLE); host.requestFocus(); } if (savedInstanceState != null && savedInstanceState.containsKey("signup") && savedInstanceState.getBoolean("signup")) { signupHintClickListener.onClick(null); } if (savedInstanceState != null && savedInstanceState.containsKey("login") && savedInstanceState.getBoolean("login")) { loginHintClickListener.onClick(null); } if (savedInstanceState != null && savedInstanceState.containsKey("forgotPassword") && savedInstanceState.getBoolean("forgotPassword")) { forgotPasswordClickListener.onClick(null); } mResolvingError = savedInstanceState != null && savedInstanceState.getBoolean("resolving_error", false); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Auth.CREDENTIALS_API) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); }
From source file:com.phonegap.ContactAccessorSdk5.java
@Override /**// ww w . j a v a 2 s . c o m * This method will save a contact object into the devices contacts database. * * @param contact the contact to be saved. * @returns true if the contact is successfully saved, false otherwise. */ public boolean save(JSONObject contact) { AccountManager mgr = AccountManager.get(mApp); Account[] accounts = mgr.getAccounts(); Account account = null; if (accounts.length == 1) account = accounts[0]; else if (accounts.length > 1) { for (Account a : accounts) { if (a.type.contains("eas") && a.name.matches(EMAIL_REGEXP)) /*Exchange ActiveSync*/ { account = a; break; } } if (account == null) { for (Account a : accounts) { if (a.type.contains("com.google") && a.name.matches(EMAIL_REGEXP)) /*Google sync provider*/ { account = a; break; } } } if (account == null) { for (Account a : accounts) { if (a.name.matches(EMAIL_REGEXP)) /*Last resort, just look for an email address...*/ { account = a; break; } } } } if (account == null) return false; String id = getJsonString(contact, "id"); // Create new contact if (id == null) { return createNewContact(contact, account); } // Modify existing contact else { return modifyContact(id, contact, account); } }
From source file:org.skt.runtime.html5apis.contacts.ContactAccessorSdk5.java
@Override /**/*www. java 2 s .c o m*/ * This method will add a contact object into the devices contacts database. * * @param contact the contact to be saved. * @returns the id if the contact is successfully saved, null otherwise. */ public String add(JSONObject contact) { AccountManager mgr = AccountManager.get(mApp); Account[] accounts = mgr.getAccounts(); String accountName = null; String accountType = null; if (accounts.length == 1) { accountName = accounts[0].name; accountType = accounts[0].type; } else if (accounts.length > 1) { for (Account a : accounts) { if (a.type.contains("eas") && a.name.matches(EMAIL_REGEXP)) /*Exchange ActiveSync*/ { accountName = a.name; accountType = a.type; break; } } if (accountName == null) { for (Account a : accounts) { if (a.type.contains("com.google") && a.name.matches(EMAIL_REGEXP)) /*Google sync provider*/ { accountName = a.name; accountType = a.type; break; } } } if (accountName == null) { for (Account a : accounts) { if (a.name.matches(EMAIL_REGEXP)) /*Last resort, just look for an email address...*/ { accountName = a.name; accountType = a.type; break; } } } } String id = getJsonString(contact, "id"); // Create new contact if (id == null) { return createNewContact(contact, accountType, accountName); } // Modify existing contact else { return modifyContact(id, contact, accountType, accountName); } }