@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 boolean onTextLayoutClick() { TextLayout textLayout = textLayout() instanceof LineWrapTextLayout ? TextLayout.WORD_WRAP : TextLayout.LINE_WRAP; sourceView.setTextLayout(textLayout); SharedPreferences.Editor editor = SettingsManager.sharedPreferences(TypeInActivity.this).edit(); editor.putString(TextLayoutSetting.KEY, textLayout.toString()); editor.commit(); return true; }
private boolean onVisibleWhitespacesClick() { SharedPreferences sharedPreferences = SettingsManager.sharedPreferences(this); boolean visibleWhitespaces = !sharedPreferences.getBoolean( VisibleWhitespacesSetting.KEY, VisibleWhitespacesSetting.DEFAULT); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(VisibleWhitespacesSetting.KEY, visibleWhitespaces); editor.commit(); sourceView.setVisibleWhitesapces(visibleWhitespaces); return true; }
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(); }