Java Code Examples for android.support.v7.app.AppCompatDelegate.MODE_NIGHT_NO

The following are Jave code examples for showing how to use MODE_NIGHT_NO of the android.support.v7.app.AppCompatDelegate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AURdroid   File: MainActivity.java   Source Code and License Vote up 6 votes
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    /*
      app share and rate group
      hide on AurPackageDetailsFragment
     */
    MenuItem menuItem = menu.findItem(R.id.menu_main_app_group);
    Fragment fragmentByTag = fragmentManager.findFragmentByTag(AUR_PACKAGE_DETAILS_FRAGMENT_TAG);
    menuItem.setVisible(fragmentByTag == null);
    // night mode
    switch (AppCompatDelegate.getDefaultNightMode()) {
        case AppCompatDelegate.MODE_NIGHT_AUTO:
            menu.findItem(R.id.menu_main_action_night_mode_auto).setChecked(true);
            break;
        case AppCompatDelegate.MODE_NIGHT_YES:
            menu.findItem(R.id.menu_main_action_night_mode_night).setChecked(true);
            break;
        case AppCompatDelegate.MODE_NIGHT_NO:
            menu.findItem(R.id.menu_main_action_night_mode_day).setChecked(true);
            break;
    }
    return true;
}
 
Example 2
Project: PNightMode   File: MainAppCompatActivity.java   Source Code and License Vote up 5 votes
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.btn_second_activity:
            Intent intent = new Intent();
            intent.setClass(this, SecondAppCompatActivity.class);
            startActivity(intent);
            break;
        case R.id.btn_toggle_night_mode:
            int mode = AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES
                    ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES;
            toggleGlobalNightMode(mode);
            break;
    }
}
 
Example 3
Project: PNightMode   File: SecondAppCompatActivity.java   Source Code and License Vote up 5 votes
@Override
public void onClick(View view) {
    int mode = getDelegate().getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES
            ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES;
    switch (view.getId()) {
        case R.id.btn_toggle_global_night_mode:
            toggleNightModeForAllActivities(mode);
            break;
        case R.id.btn_toggle_local_night_mode:
            toggleLocalNightMode(mode);
            break;
    }
}
 
Example 4
Project: QuotesOnDesign   File: App.java   Source Code and License Vote up 4 votes
private void applyDayNight( boolean isNightMode )
{
  int mode = isNightMode ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO;
  AppCompatDelegate.setDefaultNightMode( mode );
}
 
Example 5
Project: Movie-Notifier-Android   File: SettingsMainFragment.java   Source Code and License Vote up 4 votes
private void updateValues() {
    int dayNightPreference = settings.getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO);
    switch(dayNightPreference) {
        case AppCompatDelegate.MODE_NIGHT_NO:
            dayNight.setIcon(R.drawable.ic_brightness_day);
            dayNight.setValue(R.string.settings_general_daynight_day);
            break;
        case AppCompatDelegate.MODE_NIGHT_YES:
            dayNight.setIcon(R.drawable.ic_brightness_night);
            dayNight.setValue(R.string.settings_general_daynight_night);
            break;
        case AppCompatDelegate.MODE_NIGHT_AUTO:
        default:
            dayNight.setIcon(R.drawable.ic_brightness_auto);
            dayNight.setValue(R.string.settings_general_daynight_auto);
            break;
    }
    dayNightLocation.setVisibility((dayNightPreference == AppCompatDelegate.MODE_NIGHT_AUTO && getContext() != null
            && ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
            ? View.VISIBLE : View.GONE);

    String locationPreference = settings.getString("prefDefaultCinema", "");
    String locationPrefText = "";
    if(locationPreference.equals("")) {
        locationPrefText = getString(R.string.settings_general_location_default);
    } else {
        locationPrefText = locationPreference;
        if(cinemas != null) {
            for(Cinema cinema : cinemas) {
                if(cinema.getID().equals(locationPreference)) {
                    locationPrefText = cinema.getName();
                }
            }
        }
    }
    location.setValue(locationPrefText);

    if(settings.getLong("cinemasUpdated", -1) != -1) {
        DateFormat format = SimpleDateFormat.getDateInstance(DateFormat.LONG);
        service.setValue(getString(R.string.settings_general_location_service_lastupdate, format.format(new Date(settings.getLong("cinemasUpdated", -1)))));
    } else {
        service.setValue(getString(R.string.settings_general_location_service_lastupdate, getString(R.string.settings_general_location_service_never)));
    }

    boolean granted = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
    if(settings.getInt("prefAutocompleteLocation", -1) == 1 && !granted) {
        settings.edit().putInt("prefAutocompleteLocation", 0).apply(); // Turn off, we won't get the location anyway
    }
    if(settings.getInt("prefAutomagicLocation", -1) == 1 && !granted) {
        settings.edit().putInt("prefAutomagicLocation", 0).apply(); // Turn off, we won't get the location anyway
    }
    autocomplete.setChecked(settings.getInt("prefAutocompleteLocation", -1) == 1 && granted);
    automagic.setChecked(settings.getInt("prefAutomagicLocation", -1) == 1 && granted);

    int accounts = users.size();
    if(accounts == 0) {
        accountsRecycler.setVisibility(View.GONE);
    } else {
        accountsRecycler.setVisibility(View.VISIBLE);

        users = DBHelper.getInstance(getContext()).getUsers();
        adapter.swapItems(users);
    }
}