@Override protected void onResume() { super.onResume(); force_landscape.setChecked(preferences.isForceLandscape()); enable_hq.setChecked(preferences.isHighQualityOn()); force_dark.setChecked(preferences.isDarkLayoutEnabled()); force_dark_widget.setChecked(preferences.isDarkWidgetLayoutEnabled()); hide_toolbars.setChecked(preferences.isToolbarsHidden()); download_path.setText(preferences.getDownloadTarget()); share_image.setChecked(preferences.isSharingImage()); mobile_network.setChecked(preferences.isSlowNetwork()); reverse_landscape.setVisibility(Build.VERSION.SDK_INT >= 9 ? View.VISIBLE : View.GONE); reverse_landscape.setEnabled(preferences.isForceLandscape()); reverse_landscape.setChecked( preferences.isReversedLandscape() && preferences.isForceLandscape()); open_at_latest_strip.setChecked(preferences.isShouldOpenAtLatestStrip()); widget_always_show_latest.setChecked(preferences.isWidgetAlwaysShowLatest()); }
@Override protected void onCreate(Bundle savedInstanceState) { preferences = new DilbertPreferences(this); if (preferences.isForceLandscape()) setRequestedOrientation(preferences.getLandscapeOrientation()); setTheme(preferences.isDarkLayoutEnabled() ? R.style.AppThemeDark : R.style.AppThemeLight); super.onCreate(savedInstanceState); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.preferences); setTitle(R.string.title_preferences); force_landscape = (CheckBox) findViewById(R.id.pref_force_landscape); enable_hq = (CheckBox) findViewById(R.id.pref_enable_high_quality); force_dark = (CheckBox) findViewById(R.id.pref_force_dark_background); force_dark_widget = (CheckBox) findViewById(R.id.pref_force_dark_background_widget); hide_toolbars = (CheckBox) findViewById(R.id.pref_hide_toolbars); share_image = (CheckBox) findViewById(R.id.pref_share_image); mobile_network = (CheckBox) findViewById(R.id.pref_mobile_network); download_path = (TextView) findViewById(R.id.pref_download_path); reverse_landscape = (CheckBox) findViewById(R.id.pref_reverse_landscape); open_at_latest_strip = (CheckBox) findViewById(R.id.pref_open_at_latest_strip); widget_always_show_latest = (CheckBox) findViewById(R.id.pref_widget_always_latest); TextView author = (TextView) findViewById(R.id.app_author); LinearLayout download_path_layout = (LinearLayout) findViewById(R.id.pref_download_path_layout); TextView license = (TextView) findViewById(R.id.pref_show_license); TextView rating = (TextView) findViewById(R.id.pref_rating); download_path_layout.setOnClickListener(downloadPathClickListener); license.setOnClickListener(licenseOnClickListener); rating.setOnClickListener(ratingOnClickListener); author.setOnClickListener(authorOnClickListener); force_landscape.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { reverse_landscape.setEnabled(isChecked); reverse_landscape.setChecked(reverse_landscape.isChecked() && isChecked); } }); }