Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);
    state = getSharedPreferences(STATE_PREFS_NAME, MODE_PRIVATE);
    prefsSaver = PrefsSaver.get(this);
    games = getResources().getStringArray(R.array.games);
    gameTypes = new LinkedHashMap<Integer, String>();

    applyFullscreen(false); // must precede super.onCreate and setContentView
    cachedFullscreen = startedFullscreen = prefs.getBoolean(FULLSCREEN_KEY, false);
    applyStayAwake();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mainLayout = (RelativeLayout) findViewById(R.id.mainLayout);
    statusBar = (TextView) findViewById(R.id.statusBar);
    gameView = (GameView) findViewById(R.id.game);
    keyboard = (SmallKeyboard) findViewById(R.id.keyboard);
    actionBarCompat = ActionBarCompat.get(this);
    try {
      actionBarHomeId = android.R.id.class.getField("home").getInt(null);
    } catch (Exception e) {
    }
    setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
    gameView.requestFocus();
    onNewIntent(getIntent());
  }
Esempio n. 2
0
 @SuppressLint("CommitPrefEdits")
 void save() {
   String s = saveToString();
   if (s == null || s.length() == 0) return;
   SharedPreferences.Editor ed = state.edit();
   ed.remove("engineName");
   ed.putString("savedGame", s);
   prefsSaver.save(ed);
 }
Esempio n. 3
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   prefsSaver = PrefsSaver.get(this);
   addPreferencesFromResource(R.xml.preferences);
   updateSummary((ListPreference) findPreference(SGTPuzzles.ARROW_KEYS_KEY));
   if (ActionBarCompat.get(this) != null) {
     getPreferenceScreen().removePreference(findPreference("gameChooser"));
   } else {
     updateSummary((ListPreference) findPreference(GameChooser.CHOOSER_STYLE_KEY));
   }
 }
Esempio n. 4
0
 @Override
 protected void onPause() {
   super.onPause();
   getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
   prefsSaver.backup();
 }