@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.typein); try { Intent intent = getIntent(); if (null == intent) { finish(); return; } String[] saved = intent.getStringArrayExtra(SAVED); if (null == saved) { finish(); return; } Type type = Types.restoreType(saved, Files.types()); if (null == type) { finish(); return; } Program program = type.restore(saved); if (null == program) { finish(); return; } scrollView = (ScrollView) findViewById(R.id.sourceCodeVScroll); sourceView = new SourceView(this, type, program); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); sourceView.setLayoutParams(params); sourceView.setTextLayout(textLayout()); sourceView.setTextSize(textSize()); sourceView.setVisibleWhitesapces(visibleWhitespaces()); scrollView.addView(sourceView); scrollView.setOnTouchListener(new OnTouch(this)); registerForContextMenu(scrollView); if (keepScreenOn()) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } } catch (Throwable throwable) { AndroidErrorHandler.d(throwable); finish(); } }
private void textSize(int textSize) { sourceView.setTextSize(textSize); SharedPreferences.Editor editor = SettingsManager.sharedPreferences(TypeInActivity.this).edit(); editor.putString(TextSizeSetting.KEY, Integer.toString(textSize)); editor.commit(); }