Java Code Examples for androidx.appcompat.app.AppCompatDelegate#MODE_NIGHT_AUTO
The following examples show how to use
androidx.appcompat.app.AppCompatDelegate#MODE_NIGHT_AUTO .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesignActivity.java From Android-Plugin-Framework with MIT License | 6 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { switch (AppCompatDelegate.getDefaultNightMode()) { case AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM: menu.findItem(R.id.menu_night_mode_system).setChecked(true); break; case AppCompatDelegate.MODE_NIGHT_AUTO: menu.findItem(R.id.menu_night_mode_auto).setChecked(true); break; case AppCompatDelegate.MODE_NIGHT_YES: menu.findItem(R.id.menu_night_mode_night).setChecked(true); break; case AppCompatDelegate.MODE_NIGHT_NO: menu.findItem(R.id.menu_night_mode_day).setChecked(true); break; } return true; }
Example 2
Source File: PresetThemeStore.java From Jockey with Apache License 2.0 | 5 votes |
@NightMode public int getNightMode() { switch (mPreferenceStore.getBaseColor()) { case AUTO: return AppCompatDelegate.MODE_NIGHT_AUTO; case DARK: return AppCompatDelegate.MODE_NIGHT_YES; case LIGHT: default: return AppCompatDelegate.MODE_NIGHT_NO; } }
Example 3
Source File: BaseActivity.java From Jockey with Apache License 2.0 | 5 votes |
/** * @inheritDoc */ @Override public void onResume() { super.onResume(); Crashlytics.setString("last_foreground_activity", getClass().getName()); // If the theme was changed since this Activity was created, or the automatic day/night // theme has changed state, recreate this activity _mThemeStore.setTheme(this); boolean primaryDiff = mPrimaryColor != _mPreferenceStore.getPrimaryColor(); boolean accentDiff = mAccentColor != _mPreferenceStore.getAccentColor(); boolean backgroundDiff = mBackgroundColor != _mThemeStore.getNightMode(); boolean nightDiff = mNightMode != getResources().getBoolean(R.bool.is_night); if (primaryDiff || accentDiff || backgroundDiff || (mBackgroundColor == AppCompatDelegate.MODE_NIGHT_AUTO && nightDiff)) { recreate(); return; } _mPlayerController.getInfo() .compose(bindToLifecycle()) .subscribe(this::showSnackbar, throwable -> { Timber.e(throwable, "Failed to show info message"); }); _mPlayerController.getError() .compose(bindToLifecycle()) .subscribe(this::showSnackbar, throwable -> { Timber.e(throwable, "Failed to show error message"); }); _mPrivacyPolicyManager.isPrivacyPolicyUpdated() .compose(bindToLifecycle()) .subscribe(privacyPolicyUpdated -> { if (privacyPolicyUpdated) showPrivacyPolicySnackbar(); }, throwable -> Timber.e(throwable, "Failed to check for privacy policy updates")); }
Example 4
Source File: MainActivity.java From trekarta with GNU General Public License v3.0 | 4 votes |
@SuppressLint("WrongConstant") @Override public void onLocationChanged() { if (mLocationState == LocationState.SEARCHING) { mLocationState = mSavedLocationState; //TODO Change from center to location pivot (see zooming) mMap.getEventLayer().setFixOnCenter(true); updateLocationDrawable(); mLocationOverlay.setEnabled(true); mMap.updateMap(true); } Location location = mLocationService.getLocation(); double lat = location.getLatitude(); double lon = location.getLongitude(); float bearing = location.getBearing(); if (bearing < mAveragedBearing - 180f) mAveragedBearing -= 360f; else if (mAveragedBearing < bearing - 180f) mAveragedBearing += 360f; mAveragedBearing = (float) movingAverage(bearing, mAveragedBearing); if (mAveragedBearing < 0f) mAveragedBearing += 360f; if (mAveragedBearing >= 360f) mAveragedBearing -= 360f; updateGauges(); if (mLocationState == LocationState.NORTH || mLocationState == LocationState.TRACK) { long time = SystemClock.uptimeMillis(); // Adjust map movement animation to location acquisition period to make movement smoother long locationDelay = time - mLastLocationMilliseconds; double duration = Math.min(1500, locationDelay); // 1.5 seconds maximum mMovementAnimationDuration = (int) movingAverage(duration, mMovementAnimationDuration); // Update map position mMap.getMapPosition(mMapPosition); boolean rotate = mLocationState == LocationState.TRACK && mTrackingDelay < time; double offset; if (rotate) { offset = mTrackingOffset / mTrackingOffsetFactor; if (mAutoTilt > 0f && !mAutoTiltSet && mAutoTiltShouldSet) mMapPosition.setTilt(mAutoTilt); } else { offset = mMovingOffset; } offset = offset / (mMapPosition.scale * Tile.SIZE); double rad = Math.toRadians(mAveragedBearing); double dx = offset * Math.sin(rad); double dy = offset * Math.cos(rad); if (!mPositionLocked) { mMapPosition.setX(MercatorProjection.longitudeToX(lon) + dx); mMapPosition.setY(MercatorProjection.latitudeToY(lat) - dy); mMapPosition.setBearing(-mAveragedBearing); //FIXME VTM mMap.animator().animateTo(mMovementAnimationDuration, mMapPosition, rotate); } } mLocationOverlay.setPosition(lat, lon, bearing); if (mNavigationLayer != null) mNavigationLayer.setPosition(lat, lon); mLastLocationMilliseconds = SystemClock.uptimeMillis(); // TODO: Fix lint error if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_AUTO) checkNightMode(location); for (WeakReference<LocationChangeListener> weakRef : mLocationChangeListeners) { LocationChangeListener locationChangeListener = weakRef.get(); if (locationChangeListener != null) { locationChangeListener.onLocationChanged(location); } } }