Android Open Source - ArduinoRGBLighting Settings Activity






From Project

Back to project page ArduinoRGBLighting.

License

The source code is released under:

Apache License

If you think the Android project ArduinoRGBLighting listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.dannixon.rgblighting;
//from w ww  .ja  v a 2  s. c o m
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;

import java.util.List;

public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
  private static final boolean ALWAYS_SIMPLE_PREFS = false;

  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    setupSimplePreferencesScreen();
  }

  private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
      return;
    }
    addPreferencesFromResource(R.xml.pref_general);
  }

  /** {@inheritDoc} */
  @Override
  public boolean onIsMultiPane() {
    return isXLargeTablet(this) && !isSimplePreferences(this);
  }

  private static boolean isXLargeTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
  }

  private static boolean isSimplePreferences(Context context) {
    return ALWAYS_SIMPLE_PREFS || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || !isXLargeTablet(context);
  }

  /** {@inheritDoc} */
  @Override
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public void onBuildHeaders(List<Header> target) {
    if (!isSimplePreferences(this)) {
      loadHeadersFromResource(R.xml.pref_headers, target);
    }
  }

  @Override
  public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
  }
  
  public static class GeneralPreferenceFragment extends PreferenceFragment {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.pref_general);
      }
  }
}




Java Source Code List

com.dannixon.rgblighting.ColourSliderListener.java
com.dannixon.rgblighting.ControlMain.java
com.dannixon.rgblighting.DeviceConnector.java
com.dannixon.rgblighting.SettingsActivity.java
com.dannixon.rgblighting.UIManager.java
com.dannixon.rgblighting.WhiteSliderListener.java