Java Code Examples for android.support.v7.app.AppCompatDelegate#MODE_NIGHT_NO
The following examples show how to use
android.support.v7.app.AppCompatDelegate#MODE_NIGHT_NO .
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 styT with Apache License 2.0 | 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: ThemeUtils.java From sleep-cycle-alarm with GNU General Public License v3.0 | 6 votes |
public static int getCurrentTheme(String themeId) { int currentTheme; switch(themeId) { case "1": currentTheme = AppCompatDelegate.MODE_NIGHT_NO; break; case "2": currentTheme = AppCompatDelegate.MODE_NIGHT_AUTO; break; case "3": currentTheme = AppCompatDelegate.MODE_NIGHT_YES; break; default: Log.e(ThemeUtils.class.getName(), "Default case in setAppTheme switch"); currentTheme = AppCompatDelegate.MODE_NIGHT_NO; break; } return currentTheme; }
Example 3
Source File: SettingFragment.java From Ency with Apache License 2.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == provincialFlowPreference) { sharePrefManager.setProvincialTrafficPatterns((Boolean) newValue); } else if (preference == nightModePreference) { sharePrefManager.setNightMode((Boolean) newValue); int currentMode = (Boolean) newValue ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO; AppCompatDelegate.setDefaultNightMode(currentMode); // recreate()会产生闪屏 // if (getActivity() instanceof SettingActivity) { // getActivity().recreate(); // } // 调用startActivity启动,并为其添加了一个透明渐变的启动动画,最后调用finish结束掉旧的页面。 getActivity().startActivity(new Intent(getActivity(), SettingActivity.class)); getActivity().overridePendingTransition(R.anim.alpha_start, R.anim.alpha_out); getActivity().finish(); } return true; }
Example 4
Source File: FlavorRecyclerAdapter.java From Scoops with Apache License 2.0 | 6 votes |
@SuppressWarnings("WrongConstant") @Override public void onClick(View v) { int i = v.getId(); int mode = 0; if (i == R.id.opt_auto) { mode = AppCompatDelegate.MODE_NIGHT_AUTO; } else if (i == R.id.opt_system) { mode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; } else if (i == R.id.opt_off) { mode = AppCompatDelegate.MODE_NIGHT_NO; } else if (i == R.id.opt_on) { mode = AppCompatDelegate.MODE_NIGHT_YES; } AppCompatDelegate.setDefaultNightMode(mode); Scoop.getInstance().chooseDayNightMode(mode); bindOptions(mode); }
Example 5
Source File: DayNightModeMapper.java From PainlessMusicPlayer with Apache License 2.0 | 6 votes |
@AppCompatDelegate.NightMode public int toDayNightMode(@NonNull final Theme theme) { switch (theme) { case NIGHT: return AppCompatDelegate.MODE_NIGHT_YES; case DAY: return AppCompatDelegate.MODE_NIGHT_NO; case DAYNIGHT: return AppCompatDelegate.MODE_NIGHT_AUTO; default: throw new IllegalArgumentException("Unexpected theme: " + theme); } }
Example 6
Source File: MainActivity.java From cheesesquare with Apache License 2.0 | 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 7
Source File: EmbeddedNavigationActivity.java From graphhopper-navigation-android with MIT License | 5 votes |
private void alternateNightMode(int currentNightMode) { int newNightMode; if (currentNightMode == Configuration.UI_MODE_NIGHT_YES) { newNightMode = AppCompatDelegate.MODE_NIGHT_NO; } else { newNightMode = AppCompatDelegate.MODE_NIGHT_YES; } saveNightModeToPreferences(newNightMode); recreate(); }
Example 8
Source File: SettingActivity.java From apkextractor with GNU General Public License v3.0 | 4 votes |
private void refreshSettingValues(){ if(settings==null)return; //SharedPreferences.Editor editor=settings.edit(); ((TextView)findViewById(R.id.settings_path_value)).setText(SPUtil.getDisplayingExportPath(this)); ((TextView)findViewById(R.id.settings_share_mode_value)).setText( getResources().getString( settings.getInt(Constants.PREFERENCE_SHAREMODE,Constants.PREFERENCE_SHAREMODE_DEFAULT)==Constants.SHARE_MODE_DIRECT? R.string.share_mode_direct:R.string.share_mode_export)); String night_mode_value=""; switch (settings.getInt(Constants.PREFERENCE_NIGHT_MODE,Constants.PREFERENCE_NIGHT_MODE_DEFAULT)){ default:break; case AppCompatDelegate.MODE_NIGHT_YES:night_mode_value=getResources().getString(R.string.night_mode_enabled);break; case AppCompatDelegate.MODE_NIGHT_NO:night_mode_value=getResources().getString(R.string.night_mode_disabled);break; case AppCompatDelegate.MODE_NIGHT_AUTO:night_mode_value=getResources().getString(R.string.night_mode_auto);break; case AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM:night_mode_value=getResources().getString(R.string.night_mode_follow_system);break; } ((TextView)findViewById(R.id.settings_night_mode_value)).setText(night_mode_value); String read_options=""; if(settings.getBoolean(Constants.PREFERENCE_LOAD_PERMISSIONS,Constants.PREFERENCE_LOAD_PERMISSIONS_DEFAULT)){ read_options+=getResources().getString(R.string.activity_detail_permissions); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_ACTIVITIES,Constants.PREFERENCE_LOAD_ACTIVITIES_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.activity_detail_activities); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_SERVICES,Constants.PREFERENCE_LOAD_SERVICES_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.activity_detail_services); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_RECEIVERS,Constants.PREFERENCE_LOAD_RECEIVERS_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.activity_detail_receivers); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_PROVIDERS,Constants.PREFERENCE_LOAD_PROVIDERS_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.activity_detail_providers); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_STATIC_LOADERS,Constants.PREFERENCE_LOAD_STATIC_LOADERS_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.activity_detail_static_loaders); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_APK_SIGNATURE,Constants.PREFERENCE_LOAD_APK_SIGNATURE_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.dialog_loading_selection_signature); } if(settings.getBoolean(Constants.PREFERENCE_LOAD_FILE_HASH,Constants.PREFERENCE_LOAD_FILE_HASH_DEFAULT)){ if(!read_options.equals(""))read_options+=","; read_options+=getResources().getString(R.string.dialog_loading_selection_file_hash); } if(read_options.trim().equals(""))read_options=getResources().getString(R.string.word_blank); ((TextView)findViewById(R.id.settings_loading_options_value)).setText(read_options); String language_value=""; switch (SPUtil.getGlobalSharedPreferences(this).getInt(Constants.PREFERENCE_LANGUAGE,Constants.PREFERENCE_LANGUAGE_DEFAULT)){ default:break; case Constants.LANGUAGE_FOLLOW_SYSTEM:language_value=getResources().getString(R.string.language_follow_system);break; case Constants.LANGUAGE_CHINESE:language_value=getResources().getString(R.string.language_chinese);break; case Constants.LANGUAGE_ENGLISH:language_value=getResources().getString(R.string.language_english);break; } ((TextView)findViewById(R.id.settings_language_value)).setText(language_value); ((TextView)findViewById(R.id.settings_port_number_value)).setText(String.valueOf(SPUtil.getPortNumber(this))); ((TextView)findViewById(R.id.settings_device_name_value)).setText(SPUtil.getDeviceName(this)); ((TextView)findViewById(R.id.settings_extension_value)).setText(SPUtil.getCompressingExtensionName(this)); final int value_package_scope=settings.getInt(Constants.PREFERENCE_PACKAGE_SCOPE,Constants.PREFERENCE_PACKAGE_SCOPE_DEFAULT); TextView tv_package_scope=findViewById(R.id.settings_package_scope_value); switch (value_package_scope){ default:break; case Constants.PACKAGE_SCOPE_ALL:{ tv_package_scope.setText(getResources().getString(R.string.package_scope_all)); } break; case Constants.PACKAGE_SCOPE_EXPORTING_PATH:{ tv_package_scope.setText(getResources().getString(R.string.package_scope_exporting_path)); } break; } ((TextView)findViewById(R.id.settings_package_name_separator_value)).setText(settings.getString(Constants.PREFERENCE_COPYING_PACKAGE_NAME_SEPARATOR,Constants.PREFERENCE_COPYING_PACKAGE_NAME_SEPARATOR_DEFAULT)); }