|
Меню налаштувань дозволяє змінити параметри програми та налаштувати їх так, як це зручно користувачу. Меню налаштувань реалізовано в класі SettingsScreen. Коли вікно відкривається, будується його структура (лістинг 3.9.1)
layout_params_header = new ViewGroup.LayoutParams(ViewGroup.LayoutParams. MATCH_PARENT, ViewGroup.LayoutParams. WRAP_CONTENT);
ViewAdapter viewAdapter = new ViewAdapter(context);
preview = new Preview(context);
//FILL
getPaletteBrushBlock(viewAdapter);
getPaletteBackgroundBlock(viewAdapter);
getPreviewBlock(viewAdapter);
getBrushSizeBlock(viewAdapter);
getEraserSizeBlock(viewAdapter);
getGridSizeBlock(viewAdapter);
getManageMethodBlock(viewAdapter);
getImageProcessingBlock(viewAdapter);
getInterfaceBlock(viewAdapter);
getOrientationBlock(viewAdapter);
getOtherSettingsBlock(viewAdapter);
//SHOW
ListView listView = new ListView(context);
listView.setCacheColorHint(backgroundColor);
listView.setAdapter(viewAdapter);
listView.setBackgroundColor(backgroundColor);
listView.setPadding(Data. store. DPI / 20, 0, Data. store. DPI / 20, 0);
listView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams. FILL_PARENT, ViewGroup.LayoutParams. WRAP_CONTENT, 1));
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout. VERTICAL);
linearLayout.addView(listView);
setContentView(linearLayout);
//blocks
public void getPaletteBrushBlock(ViewAdapter viewAdapter){
viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsBrushcolor)));
//palette
Palette palette = new Palette(this, Palette. getPaletteBrush (), 2, getPaletteBrushApplier(), getPaletteBrushChecker());
palette.setBackgroundColor(backgroundColor);
//button edit
Button palette_brush_edit_button= new AnimatedButton(context);
palette_brush_edit_button.setText(Data. tools. getResource(R.string. settingsBrushcolorOther));
LinearLayout.LayoutParams layout_params_common = new LinearLayout.LayoutParams(ViewGroup.LayoutParams. WRAP_CONTENT, ViewGroup.LayoutParams. FILL_PARENT);
layout_params_common.setMargins(0, DPI /64, 0, DPI /64);
palette_brush_edit_button.setLayoutParams(layout_params_common); palette_brush_edit_button.setOnClickListener(getPaletteBrushEditListener()); ((LinearLayout)palette.getChildAt(0)).addView(palette_brush_edit_button);
viewAdapter.addView(palette);
//delimiter
viewAdapter.addView(getSpacer());
}
public void getBrushSizeBlock(ViewAdapter viewAdapter){
viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsBrushsize)));
viewAdapter.addView(getSlider(1, Data. store. DPI / 3, (Integer) Data. get (Data. brushSizeInt ()), getBrushSizeListener()));
viewAdapter.addView(getSpacer());
}
public void getEraserSizeBlock(ViewAdapter viewAdapter){ viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsErasersize)));
viewAdapter.addView(getSlider(1, (int) (Data. store. DPI * 0.7), (Integer) Data. get (Data. eraserSizeInt ()), getEraserSizeListener()));
viewAdapter.addView(getSpacer());
}
public void getGridSizeBlock(ViewAdapter viewAdapter){ viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsGridsize)));
viewAdapter.addView(getSlider(0, Data. store. DPI, (Integer)Data. get (Data. gridSizeInt ()), getGridSizeListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsGridsizeTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsGridVertical), (Boolean) Data. get (Data. gridVerticalBoolean ()), getGridVerticalListener()));
viewAdapter.addView(getSpacer());
}
public void getManageMethodBlock(ViewAdapter viewAdapter){ viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsBrushsizeManagement)));
int manage_method = (Integer)Data. get (Data. manageMethodInt ());
viewAdapter.addView(getRadioGroup(
new String[]{Data. tools. getResource(R.string. settingsPressure), Data. tools. getResource(R.string. settingsSpeed), Data. tools. getResource(R.string. settingsConstant)}, //names
new String[]{Data. tools. getResource(R.string. settingsPressureTip), Data. tools. getResource(R.string. settingsSpeedTip), Data. tools. getResource(R.string. settingsConstantTip)}, //hints
new View.OnClickListener[]{getManageMethodPressureListener(), getManageMethodSpeedListener(), getManageMethodConstantListener()}, //listeners
new boolean []{manage_method == Data. MANAGE_METHOD_PRESSURE, manage_method == Data. MANAGE_METHOD_SPEED, manage_method == Data. MANAGE_METHOD_CONSTANT })); //checked
viewAdapter.addView(getSpacer());
}
public void getImageProcessingBlock(ViewAdapter viewAdapter){ viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsProcessing))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsAntialiasing), (Boolean)Data. get (Data. antialiasingBoolean ()), getAntialiasingListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsAntialiasingTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsSmoothing), (Boolean)Data. get (Data. smoothingBoolean ()), getSmoothingListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsSmoothingTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsSmoothingExtra), (Boolean)Data. get (Data. smoothingHighQualityBoolean ()), getSmoothingHQListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsSmoothingExtraTip)));
viewAdapter.addView(getSpacer());
}
public void getInterfaceBlock(ViewAdapter viewAdapter){ viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsInterface))); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsInterfaceTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsMenuStrip), (Boolean) Data. get (Data. menuStripBoolean ()), getMenuStripListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsMenuStripTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsPaletteStrip), (Boolean) Data. get (Data. paletteStripBoolean ()), getPaletteStripListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsPaletteStripTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsAddWatermark), (Boolean)Data. get (Data. watermarkBoolean ()), getAddWatermarkListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsAddWatermarkTip)));
viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. SettingsInterfaceScaleButtons), (Boolean)Data. get (Data. showScaleButtonsBoolean ()), getShowScaleButtonsListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. SettingsInterfaceScaleButtonsTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsStatusBar), (Boolean)Data. get (Data. statusBarBoolean ()), getStatusBarListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsStatusBarTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsBackKeyUndo), (Boolean)Data. get (Data. backKeyUndoBoolean ()), getBackKeyUndoListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsBackKeyUndoTip))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. SettingsVolumeKeys), (Boolean)Data. get (Data. volumeButtonsBoolean ()), getVolumeKeysListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. SettingsVolumeKeysHint))); viewAdapter.addView(getCheckbox(Data. tools. getResource(R.string. settingsKeepScreenOn), (Boolean)Data. get (Data. keepScreenOnBoolean ()), getKeepScreenOnListener())); viewAdapter.addView(getHint(Data. tools. getResource(R.string. settingsKeepScreenOnTip)));
viewAdapter.addView(getSpacer());
}
public void getOrientationBlock(ViewAdapter viewAdapter){ viewAdapter.addView(getTitle(Data. tools. getResource(R.string. settingsRotate)));
int orientation_canvas = (Integer)Data. get (Data. orientationCanvasInt ());
viewAdapter.addView(getRadioGroup(
new String[]{Data. tools. getResource(R.string. settingsHorizontal), Data. tools. getResource(R.string. settingsVertical), Data. tools. getResource(R.string. settingsAuto)},
new String[]{ "", "", Data. tools. getResource(R.string. settingsRotateTip)},
new View.OnClickListener[]{getOrientationLandscapeListener(), getOrientationPortraitListener(), getOrientationAutoListener()},
new boolean []{orientation_canvas == Draw.OrientationProvider. ORIENTATION_HORIZONTAL, orientation_canvas == Draw.OrientationProvider. ORIENTATION_VERTICAL, orientation_canvas == Draw.OrientationProvider. ORIENTATION_AUTO }
));
viewAdapter.addView(getSpacer());
}
Лістинг 3.9.1 Побудова меню налаштувань.
Меню налаштувань використовує анімовані клавіші (лістинг 2.4.1), анімовані повзунки (лістинг 2.4.2), палітри Palette, системні текстові поля TextView, системні вимикачі CheckBox, та системні перемикачі RadioButton.
Всі текстові дані завантажуються із ресурсів програми, які зберігаються у вигляді XML файлів із рядками текстів для кожної мови окремо. Система автоматично обирає файл з якого потрібно завантажувати текст в зажежності від обраної в системі мови.
Дата добавления: 2015-08-09; просмотров: 45 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
Модуль відміни | | | СПИСОК ВИКОРИСТАНИХ ЛІТЕРАТУРНИХ ДЖЕРЕЛ |