androidx.appcompat.app.AppCompatDelegate Java Examples
The following examples show how to use
androidx.appcompat.app.AppCompatDelegate.
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: MainActivity.java From trekarta with GNU General Public License v3.0 | 6 votes |
private void onMapsLongClicked() { PanelMenuFragment fragment = (PanelMenuFragment) Fragment.instantiate(this, PanelMenuFragment.class.getName()); fragment.setMenu(R.menu.menu_map, menu -> { Resources resources = getResources(); MenuItem item = menu.findItem(R.id.actionNightMode); String[] nightModes = resources.getStringArray(R.array.night_mode_array); ((TextView) item.getActionView()).setText(nightModes[AppCompatDelegate.getDefaultNightMode()]); item = menu.findItem(R.id.actionStyle); String[] mapStyles = resources.getStringArray(R.array.mapStyles); ((TextView) item.getActionView()).setText(mapStyles[Configuration.getMapStyle()]); item = menu.findItem(R.id.actionFontSize); String[] fontSizes = resources.getStringArray(R.array.font_size_array); ((TextView) item.getActionView()).setText(fontSizes[Configuration.getMapFontSize()]); item = menu.findItem(R.id.actionLanguage); ((TextView) item.getActionView()).setText(Configuration.getLanguage()); menu.findItem(R.id.actionAutoTilt).setChecked(mAutoTilt != -1f); if (!BuildConfig.FULL_VERSION) menu.removeItem(R.id.actionNightMode); }); showExtendPanel(PANEL_STATE.MAPS, "mapMenu", fragment); }
Example #2
Source File: ThemeHelper.java From android-DarkTheme with Apache License 2.0 | 6 votes |
public static void applyTheme(@NonNull String themePref) { switch (themePref) { case LIGHT_MODE: { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break; } case DARK_MODE: { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break; } default: { if (BuildCompat.isAtLeastQ()) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY); } break; } } }
Example #3
Source File: BitmaskApp.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); if (LeakCanary.isInAnalyzerProcess(this)) { // This process is dedicated to LeakCanary for heap analysis. // You should not init your app in this process. return; } refWatcher = LeakCanary.install(this); // Normal app init code...*/ PRNGFixes.apply(); SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); providerObservable = ProviderObservable.getInstance(); providerObservable.updateProvider(getSavedProviderFromSharedPreferences(preferences)); EipSetupObserver.init(this, preferences); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); TetheringStateManager.getInstance().init(this); }
Example #4
Source File: MyApplication.java From weather with Apache License 2.0 | 6 votes |
@Override public void onCreate() { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); super.onCreate(); ViewPump.init(ViewPump.builder() .addInterceptor(new CalligraphyInterceptor( new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Vazir.ttf") .setFontAttrId(R.attr.fontPath) .build())) .build()); createBoxStore(); if (SharedPreferencesUtil.getInstance(this).isDarkThemeEnabled()) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); else AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); }
Example #5
Source File: AppCompatPreferenceActivity.java From MHViewer with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { final AppCompatDelegate delegate = getDelegate(); delegate.installViewFactory(); delegate.onCreate(savedInstanceState); if (delegate.applyDayNight() && mThemeId != 0) { // If DayNight has been applied, we need to re-apply the theme for // the changes to take effect. On API 23+, we should bypass // setTheme(), which will no-op if the theme ID is identical to the // current theme ID. if (Build.VERSION.SDK_INT >= 23) { onApplyThemeResource(getTheme(), mThemeId, false); } else { setTheme(mThemeId); } } super.onCreate(savedInstanceState); }
Example #6
Source File: ThemeHelper.java From user-interface-samples with Apache License 2.0 | 6 votes |
public static void applyTheme(@NonNull String themePref) { switch (themePref) { case LIGHT_MODE: { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break; } case DARK_MODE: { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break; } default: { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY); } break; } } }
Example #7
Source File: BaseActivity.java From Bop with Apache License 2.0 | 6 votes |
public boolean refreshMode() { String mode = Main.settings.get("modes", "Day"); if (!currentMode.equals(mode)) { switch (mode) { case "Day": getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); break; case "Night": getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); break; } currentMode = mode; return true; } return false; }
Example #8
Source File: KaliumApplication.java From natrium-android-wallet with BSD 2-Clause "Simplified" License | 6 votes |
public void onCreate() { super.onCreate(); // initialize Realm database Realm.init(this); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } // create new instance of the application component (DI) mApplicationComponent = DaggerApplicationComponent .builder() .applicationModule(new ApplicationModule(this)) .build(); // initialize vault Vault.initializeVault(this); generateEncryptionKey(); // initialize fingerprint Reprint.initialize(this); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); }
Example #9
Source File: LaunchActivity.java From WanAndroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { AppCompatDelegate.setDefaultNightMode( App.getContext().getAppComponent() .getDataModel() .getNightModeState() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launch); SVGBgView svgBgView = findViewById(R.id.iv_launch); ObjectAnimator animator = ObjectAnimator .ofFloat(svgBgView, "alpha", 0, 1f) .setDuration(2800); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); new Handler().postDelayed(() -> { startActivity(new Intent(LaunchActivity.this, MainActivity.class)); overridePendingTransition(R.anim.anim_launch_enter, 0); finish(); }, 3000); }
Example #10
Source File: BaseActivity.java From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); Utils.DARK_THEME = Themes.isDarkTheme(this); Themes.Theme theme = Themes.getTheme(this, Utils.DARK_THEME); if (Utils.DARK_THEME) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); } setTheme(theme.getStyle()); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(statusBarColor()); } }
Example #11
Source File: LinphonePreferences.java From linphone-android with GNU General Public License v3.0 | 6 votes |
public boolean isDarkModeEnabled() { if (getConfig() == null) return false; if (!mContext.getResources().getBoolean(R.bool.allow_dark_mode)) return false; boolean useNightModeDefault = AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES; if (mContext != null) { int nightMode = mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; if (nightMode == Configuration.UI_MODE_NIGHT_YES) { useNightModeDefault = true; } } return getConfig().getBool("app", "dark_mode", useNightModeDefault); }
Example #12
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 #13
Source File: BlinkyApplication.java From Android-nRF-Blinky with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onCreate() { super.onCreate(); // Added to support vector drawables for devices below Android 21. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); } }
Example #14
Source File: EmojiApplication.java From Emoji with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY); EmojiManager.install(new IosEmojiProvider()); if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().build()); } }
Example #15
Source File: HoneycombUtil.java From shortyz with GNU General Public License v3.0 | 5 votes |
@Override public void toggleNightMode(ShortyzActivity activity){ activity.nightMode.toggle(); if(activity.nightMode.isNightMode()){ activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); } else { activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); } }
Example #16
Source File: ThemeHelper.java From intra42 with Apache License 2.0 | 5 votes |
private static void applyThemeBlitheness(Context context) { AppSettings.Theme.EnumBrightness brightness = AppSettings.Theme.getBrightness(context); if (brightness == AppSettings.Theme.EnumBrightness.DARK) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); else if (brightness == AppSettings.Theme.EnumBrightness.LIGHT) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); else AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); }
Example #17
Source File: ThemedAppCompatActivity.java From syncthing-android with Mozilla Public License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { // Load theme. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Integer prefAppTheme = Integer.parseInt(prefs.getString(Constants.PREF_APP_THEME, LIGHT_THEME)); AppCompatDelegate.setDefaultNightMode(prefAppTheme); super.onCreate(savedInstanceState); }
Example #18
Source File: BaseActivity.java From AppOpsX with MIT License | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { LangHelper.updateLanguage(this); super.onCreate(savedInstanceState); AppCompatDelegate.setDefaultNightMode(SpHelper.getThemeMode(this)); }
Example #19
Source File: MageApplication.java From mage-android with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); //This ensures the singleton is created with the correct context, which needs to be the //application context DaoStore.getInstance(this.getApplicationContext()); LayerHelper.getInstance(this.getApplicationContext()); StaticFeatureHelper.getInstance(this.getApplicationContext()); ProcessLifecycleOwner.get().getLifecycle().addObserver(this); HttpClientManager.initialize(this); // setup the screen unlock stuff registerReceiver(ScreenChangeReceiver.getInstance(), new IntentFilter(Intent.ACTION_SCREEN_ON)); registerActivityLifecycleCallbacks(this); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); int dayNightTheme = preferences.getInt(getResources().getString(R.string.dayNightThemeKey), getResources().getInteger(R.integer.dayNightThemeDefaultValue)); AppCompatDelegate.setDefaultNightMode(dayNightTheme); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationChannel channel = new NotificationChannel(MAGE_NOTIFICATION_CHANNEL_ID,"MAGE", NotificationManager.IMPORTANCE_LOW); channel.setShowBadge(true); notificationManager.createNotificationChannel(channel); NotificationChannel observationChannel = new NotificationChannel(MAGE_OBSERVATION_NOTIFICATION_CHANNEL_ID,"MAGE Observations", NotificationManager.IMPORTANCE_HIGH); observationChannel.setShowBadge(true); notificationManager.createNotificationChannel(observationChannel); } }
Example #20
Source File: MainActivity.java From MaterialPreference with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_night_mode: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES); recreate(); return true; case R.id.rtl: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Resources resources = getBaseContext().getResources(); Locale locale = resources.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? Locale.ENGLISH : new Locale("ar"); Locale.setDefault(locale); resources.getConfiguration().setLocale(locale); resources.updateConfiguration(resources.getConfiguration(), resources.getDisplayMetrics()); startActivity(new Intent(this, this.getClass())); finish(); } return true; } return super.onOptionsItemSelected(item); }
Example #21
Source File: MainActivity.java From cythara with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { requestRecordAudioPermission(); } else { startRecording(); } enableTheme(); setContentView(R.layout.activity_main); setTuning(); setReferencePitch(); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); Toolbar myToolbar = findViewById(R.id.my_toolbar); myToolbar.setTitle(R.string.app_name); myToolbar.showOverflowMenu(); setSupportActionBar(myToolbar); }
Example #22
Source File: ToolbarManager.java From material with Apache License 2.0 | 5 votes |
public ToolbarManager(AppCompatDelegate delegate, Toolbar toolbar, int defaultGroupId, int rippleStyle, Animator animator){ mAppCompatDelegate = delegate; mToolbar = toolbar; mCurrentGroup = defaultGroupId; mRippleStyle = rippleStyle; mAnimator = animator; mAppCompatDelegate.setSupportActionBar(toolbar); }
Example #23
Source File: Utils.java From SmartPack-Kernel-Manager with GNU General Public License v3.0 | 5 votes |
public static void initializeAppTheme(Context context) { if (Prefs.getBoolean("darktheme", true, context)) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_YES); } else { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_NO); } }
Example #24
Source File: SettingsActivity.java From InjuredAndroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Switch darkModeSwitch = findViewById(R.id.switch1); darkModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); } }); }
Example #25
Source File: History.java From EBookDownloader with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setContentView(R.layout.activity_history); try { historyDB = DBFactory.open(getApplicationContext(), "history"); } catch (SnappydbException e) { e.printStackTrace(); } ListView listHistory = findViewById(R.id.list_history); history = new ArrayList<>(); fillHistoryList(); arrayAdapter = new ArrayAdapter<>(this, R.layout.listview_list_item, history); listHistory.setAdapter(arrayAdapter); listHistory.setOnItemLongClickListener(this); listHistory.setOnItemClickListener(this); if (history.isEmpty()) { showNoHistory(); } }
Example #26
Source File: DownloadActivity.java From EBookDownloader with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setContentView(R.layout.activity_download); String quote = null; try { quote = new Global().getRandomQuote(); } catch (IOException e) { e.printStackTrace(); } ListView listView = findViewById(R.id.expanded_list); links = new ArrayList<>(); linkText = new ArrayList<>(); arrayAdapter = new ArrayAdapter<>(this, R.layout.listview_list_item, linkText); linkText.add("Searching... Read this amazing quote:\n\n\n" + quote); listView.setAdapter(arrayAdapter); listView.setOnItemClickListener(this); performSearch(getIntent().getStringExtra("query"), Objects.requireNonNull(getIntent().getStringExtra("choice"))); }
Example #27
Source File: MainActivity.java From EBookDownloader with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); initializerThread.run(); Log.i(TAG, "onCreate: Executed"); }
Example #28
Source File: KWApplication.java From GetApk with MIT License | 5 votes |
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); } }
Example #29
Source File: DynamicApplication.java From dynamic-support with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); DynamicTheme.getInstance().setDynamicThemeWork(onSetupDynamicWork()); mConfiguration = new Configuration(getResources().getConfiguration()); onInitialize(); setDynamicTheme(); }
Example #30
Source File: SettingsFragment.java From lbry-android with MIT License | 5 votes |
public void onSharedPreferenceChanged(SharedPreferences sp, String key) { if (key.equalsIgnoreCase(MainActivity.PREFERENCE_KEY_DARK_MODE)) { boolean darkMode = sp.getBoolean(MainActivity.PREFERENCE_KEY_DARK_MODE, false); AppCompatDelegate.setDefaultNightMode(darkMode ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); } else if (key.equalsIgnoreCase(MainActivity.PREFERENCE_KEY_PARTICIPATE_DATA_NETWORK)) { boolean dhtEnabled = sp.getBoolean(MainActivity.PREFERENCE_KEY_PARTICIPATE_DATA_NETWORK, false); updateDHTFileSetting(dhtEnabled); } }