android.support.v7.app.AppCompatDelegate#MODE_NIGHT_NO源码实例Demo

下面列出了android.support.v7.app.AppCompatDelegate#MODE_NIGHT_NO 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: styT   文件: MainActivity.java
@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;
}
 
源代码2 项目: sleep-cycle-alarm   文件: ThemeUtils.java
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;
}
 
源代码3 项目: Ency   文件: SettingFragment.java
@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;
    }
 
源代码4 项目: Scoops   文件: FlavorRecyclerAdapter.java
@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);
}
 
源代码5 项目: PainlessMusicPlayer   文件: DayNightModeMapper.java
@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);
    }
}
 
源代码6 项目: cheesesquare   文件: MainActivity.java
@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;
}
 
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();
}
 
源代码8 项目: apkextractor   文件: SettingActivity.java
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));
}