Android Open Source - ParticlePlay Preferences






From Project

Back to project page ParticlePlay.

License

The source code is released under:

GNU General Public License

If you think the Android project ParticlePlay 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.droidinteractive.particleplay.preferences;
/*//from w w w.java 2  s . c  o m
 * Copyright (c) 2010 Ragdoll Games
 * Copyright (c) 2010-2014 Droid Interactive
 * Copyright (c) 2010-2014 IDKJava Team
 * 
 * This file is part of Particle Play.
 * 
 * Particle Play is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Particle Play is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Particle Play. If not, see <http://www.gnu.org/licenses/>.
 */
import com.droidinteractive.particleplay.MainActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Preferences
{
  public static SharedPreferences sharedPreferences;

  //Initialize the sharedPreferences based on the context
  public static void initSharedPreferences(Context context)
  {
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
  }

  //Set the ui state in MainActivity based on sharedPreferences
  public static void loadUIState()
  {
    //MainActivity.ui = sharedPreferences.getBoolean("ui_state", true);
  }
  public static void savePreferences()
  {
    SharedPreferences.Editor prefEditor = sharedPreferences.edit();
    //prefEditor.putBoolean("accel_state", MainActivity.accel);
    prefEditor.commit();
  }

  //Set everything except UI based on the preferences that are in existence
  public static void loadPreferences()
  {
    //Log.v("Particle Play", "setPreferences");
    //int backgroundColor = sharedPreferences.getInt("background_color",0);
    //setBackgroundColor((char) Color.red(backgroundColor), (char) Color.green(backgroundColor), (char) Color.blue(backgroundColor));
    setFlippedState(sharedPreferences.getBoolean("flipped_state", false));
    //setAccelState(sharedPreferences.getBoolean("accel_state", false));
    //setAtmosphereTemp((char) sharedPreferences.getInt("atmosphere_temp", 100));
    //setAtmosphereGravity(sharedPreferences.getFloat("atmosphere_gravity", 1));
    setBorderState(sharedPreferences.getBoolean("border_left", true), sharedPreferences.getBoolean("border_top", true), sharedPreferences.getBoolean("border_right", true), sharedPreferences.getBoolean("border_bottom", true));
    setZoom(Integer.parseInt(sharedPreferences.getString("screen_zoom", "4")));
  }

  public static void loadScreenState()
  {
    MainActivity.sand_view.setKeepScreenOn(sharedPreferences.getBoolean("screen_state", true));
  }

  //@formatter:off
    public static native void setBorderState(boolean leftBorderState, boolean topBorderState, boolean rightBorderState, boolean bottomBorderState);
  public static native void setFlippedState(boolean flippedState);
  public static native void setAccelState(boolean accelState);
  public static native void setBackgroundColor(char red, char green, char blue);
  public static native void setAtmosphereTemp(char temp);
  public static native void setAtmosphereGravity(float gravity);
    public static native void setZoom(int zoom);
  //@formatter:on

  static
  {
    System.loadLibrary("particleplay"); // Load the JNI library (libparticleplay.so)
  }
}




Java Source Code List

com.droidinteractive.colorpicker.ColorPickerBox.java
com.droidinteractive.colorpicker.ColorPickerDialog.java
com.droidinteractive.colorpicker.widget.ColorPickerPreferenceWidgetView.java
com.droidinteractive.colorpicker.widget.ColorPickerPreference.java
com.droidinteractive.particleplay.FixMeActivity.java
com.droidinteractive.particleplay.Globals.java
com.droidinteractive.particleplay.LoadStateActivity.java
com.droidinteractive.particleplay.MainActivity.java
com.droidinteractive.particleplay.MenuActivity.java
com.droidinteractive.particleplay.SaveStateActivity.java
com.droidinteractive.particleplay.SplashActivity.java
com.droidinteractive.particleplay.custom.CustomElementActivity.java
com.droidinteractive.particleplay.custom.CustomElementAdvancedActivity.java
com.droidinteractive.particleplay.custom.CustomElementBasicActivity.java
com.droidinteractive.particleplay.custom.CustomElementManagerActivity.java
com.droidinteractive.particleplay.custom.CustomElementManager.java
com.droidinteractive.particleplay.custom.CustomElement.java
com.droidinteractive.particleplay.game.ActionItem.java
com.droidinteractive.particleplay.game.Control.java
com.droidinteractive.particleplay.game.CustomElementManager.java
com.droidinteractive.particleplay.game.FileManager.java
com.droidinteractive.particleplay.game.MenuBar.java
com.droidinteractive.particleplay.game.PopupWindows.java
com.droidinteractive.particleplay.game.QuickAction.java
com.droidinteractive.particleplay.game.SandView.java
com.droidinteractive.particleplay.game.SaveManager.java
com.droidinteractive.particleplay.game.Temperature.java
com.droidinteractive.particleplay.preferences.AlphaPatternDrawable.java
com.droidinteractive.particleplay.preferences.ColorPickerDialogPref.java
com.droidinteractive.particleplay.preferences.ColorPickerPanelView.java
com.droidinteractive.particleplay.preferences.ColorPickerPreference.java
com.droidinteractive.particleplay.preferences.ColorPickerView.java
com.droidinteractive.particleplay.preferences.PreferencesActivity.java
com.droidinteractive.particleplay.preferences.Preferences.java
com.droidinteractive.particleplay.preferences.SeekBarPreference.java
com.droidinteractive.slidingdrawer.OnDrawerCloseListener.java
com.droidinteractive.slidingdrawer.OnDrawerOpenListener.java
com.droidinteractive.slidingdrawer.OnDrawerScrollListener.java
com.droidinteractive.slidingdrawer.SlidingDrawer.java