use of com.foobnix.android.utils.IntegerResponse in project LibreraReader by foobnix.
the class BrightnessHelper method showBlueLigthDialogAndBrightness.
public static void showBlueLigthDialogAndBrightness(final Activity a, View inflate, final Runnable onRefresh) {
final CheckBox isEnableBlueFilter = (CheckBox) inflate.findViewById(R.id.isEnableBlueFilter);
isEnableBlueFilter.setVisibility(Dips.isEInk(a) ? View.GONE : View.VISIBLE);
isEnableBlueFilter.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AppState.get().isEnableBlueFilter = isChecked;
if (onRefresh != null) {
onRefresh.run();
}
}
});
final TextView onBlueFilter = (TextView) inflate.findViewById(R.id.onBlueFilter);
onBlueFilter.setVisibility(Dips.isEInk(a) ? View.GONE : View.VISIBLE);
TxtUtils.underlineTextView(onBlueFilter);
onBlueFilter.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle(R.string.bluelight_filter);
final View inflate = LayoutInflater.from(a).inflate(R.layout.dialog_bluelight, null, false);
final CustomColorView blueLightColor = (CustomColorView) inflate.findViewById(R.id.blueLightColor);
TxtUtils.bold(blueLightColor.getText1());
blueLightColor.withDefaultColors(AppState.BLUE_FILTER_DEFAULT_COLOR, Color.parseColor("#FFDD00"), Color.RED, Color.GREEN);
blueLightColor.init(AppState.get().blueLightColor);
blueLightColor.setOnColorChanged(new StringResponse() {
@Override
public boolean onResultRecive(String string) {
AppState.get().isEnableBlueFilter = true;
AppState.get().blueLightColor = Color.parseColor(string);
if (onRefresh != null) {
onRefresh.run();
}
// Keyboards.hideNavigation(a);
return false;
}
});
final CustomSeek blueLightAlpha = (CustomSeek) inflate.findViewById(R.id.blueLightAlpha);
blueLightAlpha.init(0, 99, AppState.get().blueLightAlpha);
blueLightAlpha.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
AppState.get().isEnableBlueFilter = true;
AppState.get().blueLightAlpha = result;
blueLightAlpha.setValueText("" + AppState.get().blueLightAlpha + "%");
if (onRefresh != null) {
onRefresh.run();
}
return false;
}
});
blueLightAlpha.setValueText("" + AppState.get().blueLightAlpha + "%");
builder.setView(inflate);
builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int id) {
isEnableBlueFilter.setChecked(AppState.get().isEnableBlueFilter);
if (dialog != null) {
dialog.dismiss();
}
}
});
AlertDialog dialog = builder.create();
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Keyboards.hideNavigation(a);
}
});
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dialog.show();
}
});
// brightness
final CheckBox autoSettings = (CheckBox) inflate.findViewById(R.id.autoSettings);
final int systemBrigtnessInt = getSystemBrigtnessInt(a);
final CustomSeek customBrightness = (CustomSeek) inflate.findViewById(R.id.customBrightness);
int value = 0;
if (AppState.get().appBrightness == AppState.AUTO_BRIGTNESS) {
value = systemBrigtnessInt;
} else {
value = AppState.get().isEnableBlueFilter ? AppState.get().blueLightAlpha * -1 : AppState.get().appBrightness;
}
customBrightness.init(-100, 100, value);
customBrightness.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
customBrightness.setValueText("" + result);
EventBus.getDefault().post(new MessegeBrightness(result));
isEnableBlueFilter.setChecked(AppState.get().isEnableBlueFilter);
return false;
}
});
autoSettings.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (!buttonView.isPressed()) {
return;
}
if (isChecked) {
// auto
customBrightness.setEnabled(false);
customBrightness.reset(systemBrigtnessInt);
EventBus.getDefault().post(new MessegeBrightness(AppState.AUTO_BRIGTNESS));
} else {
customBrightness.setEnabled(true);
EventBus.getDefault().post(new MessegeBrightness(systemBrigtnessInt));
}
isEnableBlueFilter.setChecked(AppState.get().isEnableBlueFilter);
}
});
isEnableBlueFilter.setChecked(AppState.get().isEnableBlueFilter);
autoSettings.setChecked(AppState.get().appBrightness == AppState.AUTO_BRIGTNESS);
customBrightness.setEnabled(AppState.get().appBrightness != AppState.AUTO_BRIGTNESS);
}
use of com.foobnix.android.utils.IntegerResponse in project LibreraReader by foobnix.
the class DragingDialogs method preferences.
public static DragingPopup preferences(final FrameLayout anchor, final DocumentController controller, final Runnable onRefresh, final Runnable updateUIRefresh) {
final int cssHash = BookCSS.get().toCssString().hashCode();
final int appHash = Objects.hashCode(AppState.get());
if (ExtUtils.isNotValidFile(controller.getCurrentBook())) {
DragingPopup dialog = new DragingPopup(R.string.preferences, anchor, PREF_WIDTH, PREF_HEIGHT) {
@Override
public View getContentView(final LayoutInflater inflater) {
TextView txt = new TextView(anchor.getContext());
txt.setText(R.string.file_not_found);
return txt;
}
};
return dialog;
}
DragingPopup dialog = new DragingPopup(R.string.preferences, anchor, PREF_WIDTH, PREF_HEIGHT) {
@Override
public View getContentView(final LayoutInflater inflater) {
View inflate = inflater.inflate(R.layout.dialog_prefs, null, false);
// TOP panel start
View topPanelLine = inflate.findViewById(R.id.topPanelLine);
View topPanelLineDiv = inflate.findViewById(R.id.topPanelLineDiv);
// topPanelLine.setVisibility(controller instanceof
// DocumentControllerHorizontalView ? View.VISIBLE : View.GONE);
topPanelLine.setVisibility(View.GONE);
topPanelLineDiv.setVisibility(controller.isTextFormat() ? View.VISIBLE : View.GONE);
inflate.findViewById(R.id.allBGConfig).setVisibility(Dips.isEInk(inflate.getContext()) ? View.GONE : View.VISIBLE);
View onRecent = inflate.findViewById(R.id.onRecent);
onRecent.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
closeDialog();
DragingDialogs.recentBooks(anchor, controller);
}
});
final View onRotate = inflate.findViewById(R.id.onRotate);
onRotate.setOnClickListener(new OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT <= 10) {
Toast.makeText(anchor.getContext(), R.string.this_function_will_works_in_modern_android, Toast.LENGTH_SHORT).show();
return;
}
// closeDialog();
MenuBuilderM.addRotateMenu(onRotate, null, updateUIRefresh).show();
}
});
inflate.findViewById(R.id.onPageFlip).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
closeDialog();
DragingDialogs.pageFlippingDialog(anchor, controller, onRefresh);
}
});
ImageView brightness = (ImageView) inflate.findViewById(R.id.onBrightness);
brightness.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
AppState.get().isDayNotInvert = !AppState.get().isDayNotInvert;
controller.restartActivity();
}
});
brightness.setImageResource(!AppState.get().isDayNotInvert ? R.drawable.glyphicons_232_sun : R.drawable.glyphicons_2_moon);
final ImageView isCrop = (ImageView) inflate.findViewById(R.id.onCrop);
// isCrop.setVisibility(controller.isTextFormat() ||
// AppState.get().isCut ? View.GONE : View.VISIBLE);
isCrop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
AppState.get().isCrop = !AppState.get().isCrop;
SettingsManager.getBookSettings().updateFromAppState();
TintUtil.setTintImageWithAlpha(isCrop, !AppState.get().isCrop ? TintUtil.COLOR_TINT_GRAY : Color.LTGRAY);
updateUIRefresh.run();
}
});
TintUtil.setTintImageWithAlpha(isCrop, !AppState.get().isCrop ? TintUtil.COLOR_TINT_GRAY : Color.LTGRAY);
final ImageView bookCut = (ImageView) inflate.findViewById(R.id.bookCut);
// bookCut.setVisibility(controller.isTextFormat() ? View.GONE :
// View.VISIBLE);
bookCut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
closeDialog();
DragingDialogs.sliceDialog(anchor, controller, updateUIRefresh, new ResultResponse<Integer>() {
@Override
public boolean onResultRecive(Integer result) {
TintUtil.setTintImageWithAlpha(bookCut, !AppState.get().isCut ? TintUtil.COLOR_TINT_GRAY : Color.LTGRAY);
SettingsManager.getBookSettings().updateFromAppState();
EventBus.getDefault().post(new InvalidateMessage());
return false;
}
});
}
});
TintUtil.setTintImageWithAlpha(bookCut, !AppState.get().isCut ? TintUtil.COLOR_TINT_GRAY : Color.LTGRAY);
inflate.findViewById(R.id.onFullScreen).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
AppState.get().isFullScreen = !AppState.get().isFullScreen;
DocumentController.chooseFullScreen(controller.getActivity(), AppState.get().isFullScreen);
if (controller.isTextFormat()) {
if (onRefresh != null) {
onRefresh.run();
}
controller.restartActivity();
}
}
});
View tts = inflate.findViewById(R.id.onTTS);
tts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
closeDialog();
DragingDialogs.textToSpeachDialog(anchor, controller);
}
});
final ImageView pin = (ImageView) inflate.findViewById(R.id.onPin);
pin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
AppState.get().isShowToolBar = !AppState.get().isShowToolBar;
pin.setImageResource(AppState.get().isShowToolBar ? R.drawable.glyphicons_336_pushpin : R.drawable.glyphicons_200_ban);
if (onRefresh != null) {
onRefresh.run();
}
}
});
pin.setImageResource(AppState.get().isShowToolBar ? R.drawable.glyphicons_336_pushpin : R.drawable.glyphicons_200_ban);
// TOP panel end
CheckBox isPreText = (CheckBox) inflate.findViewById(R.id.isPreText);
isPreText.setChecked(AppState.get().isPreText);
isPreText.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AppState.get().isPreText = isChecked;
}
});
isPreText.setVisibility(BookType.TXT.is(controller.getCurrentBook().getPath()) ? View.VISIBLE : View.GONE);
CheckBox isLineBreaksText = (CheckBox) inflate.findViewById(R.id.isLineBreaksText);
isLineBreaksText.setChecked(AppState.get().isLineBreaksText);
isLineBreaksText.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AppState.get().isLineBreaksText = isChecked;
}
});
isLineBreaksText.setVisibility(BookType.TXT.is(controller.getCurrentBook().getPath()) ? View.VISIBLE : View.GONE);
//
TextView moreSettings = (TextView) inflate.findViewById(R.id.moreSettings);
moreSettings.setVisibility(controller.isTextFormat() ? View.VISIBLE : View.GONE);
inflate.findViewById(R.id.moreSettingsDiv).setVisibility(controller.isTextFormat() ? View.VISIBLE : View.GONE);
// View moreSettingsImage =
// inflate.findViewById(R.id.moreSettingsImage);
// moreSettingsImage.setVisibility(controller.isTextFormat() ?
// View.VISIBLE : View.GONE);
TxtUtils.underlineTextView(moreSettings).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
moreBookSettings(anchor, controller, onRefresh, updateUIRefresh);
}
});
TextView performanceSettings = TxtUtils.underlineTextView((TextView) inflate.findViewById(R.id.performanceSettigns));
performanceSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
performanceSettings(anchor, controller, onRefresh, updateUIRefresh);
}
});
TextView statusBarSettings = TxtUtils.underlineTextView((TextView) inflate.findViewById(R.id.statusBarSettings));
statusBarSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
statusBarSettings(anchor, controller, onRefresh, updateUIRefresh);
}
});
final CustomSeek fontSizeSp = (CustomSeek) inflate.findViewById(R.id.fontSizeSp);
fontSizeSp.init(10, 70, AppState.get().fontSizeSp);
fontSizeSp.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
AppState.get().fontSizeSp = result;
return false;
}
});
fontSizeSp.setValueText("" + AppState.get().fontSizeSp);
inflate.findViewById(R.id.fontSizeLayout).setVisibility(ExtUtils.isTextFomat(controller.getCurrentBook().getPath()) ? View.VISIBLE : View.GONE);
inflate.findViewById(R.id.fontNameSelectionLayout).setVisibility(ExtUtils.isTextFomat(controller.getCurrentBook().getPath()) ? View.VISIBLE : View.GONE);
final TextView textFontName = (TextView) inflate.findViewById(R.id.textFontName);
textFontName.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final List<FontPack> fontPacks = BookCSS.get().getAllFontsPacks();
MyPopupMenu popup = new MyPopupMenu(controller.getActivity(), v);
for (final FontPack pack : fontPacks) {
LOG.d("pack.normalFont", pack.normalFont);
popup.getMenu().add(pack.dispalyName, pack.normalFont).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
BookCSS.get().resetAll(pack);
TxtUtils.underline(textFontName, BookCSS.get().displayFontName);
return false;
}
});
}
popup.show();
}
});
TxtUtils.underline(textFontName, BookCSS.get().displayFontName);
final View moreFontSettings = inflate.findViewById(R.id.moreFontSettings);
moreFontSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
FontDialog.show(controller.getActivity(), new Runnable() {
@Override
public void run() {
TxtUtils.underline(textFontName, BookCSS.get().displayFontName);
}
});
}
});
final View downloadFonts = inflate.findViewById(R.id.downloadFonts);
downloadFonts.setVisibility(FontExtractor.hasZipFonts() ? View.GONE : View.VISIBLE);
downloadFonts.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
FontExtractor.showDownloadFontsDialog(controller.getActivity(), downloadFonts, textFontName);
}
});
// crop
CheckBox isCropBorders = (CheckBox) inflate.findViewById(R.id.isCropBorders);
isCropBorders.setChecked(controller.isCropCurrentBook());
isCropBorders.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
controller.onCrop();
}
});
// volume
final CheckBox isReverseKyes = (CheckBox) inflate.findViewById(R.id.isReverseKyes);
isReverseKyes.setChecked(AppState.get().isReverseKeys);
isReverseKyes.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AppState.get().isReverseKeys = isChecked;
}
});
isReverseKyes.setEnabled(AppState.get().isUseVolumeKeys ? true : false);
CheckBox isUseVolumeKeys = (CheckBox) inflate.findViewById(R.id.isUseVolumeKeys);
isUseVolumeKeys.setChecked(AppState.get().isUseVolumeKeys);
isUseVolumeKeys.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AppState.get().isUseVolumeKeys = isChecked;
isReverseKyes.setEnabled(AppState.get().isUseVolumeKeys ? true : false);
}
});
// orientation begin
final TextView screenOrientation = (TextView) inflate.findViewById(R.id.screenOrientation);
screenOrientation.setText(DocumentController.getRotationText());
TxtUtils.underlineTextView(screenOrientation);
screenOrientation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu menu = new PopupMenu(v.getContext(), v);
for (int i = 0; i < DocumentController.orientationIds.size(); i++) {
final int j = i;
final int name = DocumentController.orientationTexts.get(i);
menu.getMenu().add(name).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AppState.get().orientation = DocumentController.orientationIds.get(j);
screenOrientation.setText(DocumentController.orientationTexts.get(j));
TxtUtils.underlineTextView(screenOrientation);
DocumentController.doRotation(controller.getActivity());
return false;
}
});
}
menu.show();
}
});
// orientation end
BrightnessHelper.showBlueLigthDialogAndBrightness(controller.getActivity(), inflate, onRefresh);
// brightness end
// dicts
final TextView selectedDictionaly = (TextView) inflate.findViewById(R.id.selectedDictionaly);
selectedDictionaly.setText(DialogTranslateFromTo.getSelectedDictionaryUnderline());
selectedDictionaly.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DialogTranslateFromTo.show(controller.getActivity(), new Runnable() {
@Override
public void run() {
selectedDictionaly.setText(DialogTranslateFromTo.getSelectedDictionaryUnderline());
}
});
}
});
((CheckBox) inflate.findViewById(R.id.isRememberDictionary)).setChecked(AppState.get().isRememberDictionary);
((CheckBox) inflate.findViewById(R.id.isRememberDictionary)).setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
AppState.get().isRememberDictionary = isChecked;
}
});
// Colors
TextView textCustomizeFontBGColor = (TextView) inflate.findViewById(R.id.textCustomizeFontBGColor);
if (AppState.get().isCustomizeBgAndColors || controller.isTextFormat()) {
textCustomizeFontBGColor.setText(R.string.customize_font_background_colors);
} else {
textCustomizeFontBGColor.setText(R.string.customize_background_color);
}
final ImageView onDayColorImage = (ImageView) inflate.findViewById(R.id.onDayColorImage);
final TextView textDayColor = TxtUtils.underlineTextView((TextView) inflate.findViewById(R.id.onDayColor));
textDayColor.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
boolean isSolid = !AppState.get().isUseBGImageDay;
new ColorsDialog((FragmentActivity) controller.getActivity(), true, AppState.get().colorDayText, AppState.get().colorDayBg, false, isSolid, new ColorsDialogResult() {
@Override
public void onChooseColor(int colorText, int colorBg) {
textDayColor.setTextColor(colorText);
textDayColor.setBackgroundColor(colorBg);
TintUtil.setTintImageWithAlpha(onDayColorImage, colorText);
AppState.get().colorDayText = colorText;
AppState.get().colorDayBg = colorBg;
ImageLoader.getInstance().clearDiskCache();
ImageLoader.getInstance().clearMemoryCache();
if (AppState.get().isUseBGImageDay) {
textDayColor.setBackgroundDrawable(MagicHelper.getBgImageDayDrawable(true));
}
}
});
}
});
final ImageView onNigthColorImage = (ImageView) inflate.findViewById(R.id.onNigthColorImage);
final TextView textNigthColor = TxtUtils.underlineTextView((TextView) inflate.findViewById(R.id.onNigthColor));
textNigthColor.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
boolean isSolid = !AppState.get().isUseBGImageNight;
new ColorsDialog((FragmentActivity) controller.getActivity(), false, AppState.get().colorNigthText, AppState.get().colorNigthBg, false, isSolid, new ColorsDialogResult() {
@Override
public void onChooseColor(int colorText, int colorBg) {
textNigthColor.setTextColor(colorText);
textNigthColor.setBackgroundColor(colorBg);
TintUtil.setTintImageWithAlpha(onNigthColorImage, colorText);
AppState.get().colorNigthText = colorText;
AppState.get().colorNigthBg = colorBg;
if (AppState.get().isUseBGImageNight) {
textNigthColor.setBackgroundDrawable(MagicHelper.getBgImageNightDrawable(true));
}
}
});
}
});
final LinearLayout lc = (LinearLayout) inflate.findViewById(R.id.preColors);
TintUtil.setTintImageWithAlpha(onDayColorImage, AppState.get().colorDayText);
TintUtil.setTintImageWithAlpha(onNigthColorImage, AppState.get().colorNigthText);
textNigthColor.setTextColor(AppState.get().colorNigthText);
textNigthColor.setBackgroundColor(AppState.get().colorNigthBg);
textDayColor.setTextColor(AppState.get().colorDayText);
textDayColor.setBackgroundColor(AppState.get().colorDayBg);
if (AppState.get().isUseBGImageDay) {
textDayColor.setTextColor(Color.BLACK);
textDayColor.setBackgroundDrawable(MagicHelper.getBgImageDayDrawable(true));
}
if (AppState.get().isUseBGImageNight) {
textNigthColor.setTextColor(Color.WHITE);
textNigthColor.setBackgroundDrawable(MagicHelper.getBgImageNightDrawable(true));
}
// lc.setVisibility(controller.isTextFormat() ||
// AppState.get().isCustomizeBgAndColors ? View.VISIBLE :
// View.GONE);
final int padding = Dips.dpToPx(3);
final Runnable colorsLine = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
lc.removeAllViews();
for (String line : AppState.get().readColors.split(";")) {
if (TxtUtils.isEmpty(line)) {
continue;
}
String[] split = line.split(",");
LOG.d("Split colors", split[0], split[1], split[2]);
String name = split[0];
final int bg = Color.parseColor(split[1]);
final int text = Color.parseColor(split[2]);
final boolean isDay = split[3].equals("0");
BorderTextView t1 = new BorderTextView(controller.getActivity());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Dips.dpToPx(30), Dips.dpToPx(30));
params.setMargins(padding, padding, padding, padding);
t1.setLayoutParams(params);
t1.setGravity(Gravity.CENTER);
t1.setBackgroundColor(bg);
if (controller.isTextFormat() || AppState.get().isCustomizeBgAndColors) {
t1.setText(name);
t1.setTextColor(text);
t1.setTypeface(null, Typeface.BOLD);
}
t1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isDay) {
if (controller.isTextFormat() || AppState.get().isCustomizeBgAndColors) {
AppState.get().colorDayText = text;
textDayColor.setTextColor(text);
}
AppState.get().colorDayBg = bg;
textDayColor.setBackgroundColor(bg);
AppState.get().isUseBGImageDay = false;
} else {
if (controller.isTextFormat() || AppState.get().isCustomizeBgAndColors) {
AppState.get().colorNigthText = text;
textNigthColor.setTextColor(text);
}
AppState.get().colorNigthBg = bg;
textNigthColor.setBackgroundColor(bg);
AppState.get().isUseBGImageNight = false;
}
TintUtil.setTintImageWithAlpha(onDayColorImage, AppState.get().colorDayText);
TintUtil.setTintImageWithAlpha(onNigthColorImage, AppState.get().colorNigthText);
}
});
lc.addView(t1);
}
// add DayBG
{
ImageView t1 = new ImageView(controller.getActivity());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Dips.dpToPx(30), Dips.dpToPx(30));
params.setMargins(padding, padding, padding, padding);
t1.setLayoutParams(params);
t1.setScaleType(ScaleType.FIT_XY);
t1.setImageDrawable(MagicHelper.getBgImageDayDrawable(false));
t1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AppState.get().colorDayText = AppState.COLOR_BLACK;
AppState.get().colorDayBg = AppState.COLOR_WHITE;
textDayColor.setTextColor(Color.BLACK);
textDayColor.setBackgroundDrawable(MagicHelper.getBgImageDayDrawable(false));
AppState.get().isUseBGImageDay = true;
TintUtil.setTintImageWithAlpha(onDayColorImage, AppState.get().colorDayText);
}
});
lc.addView(t1, AppState.get().readColors.split(";").length / 2);
}
// add Night
{
ImageView t2 = new ImageView(controller.getActivity());
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(Dips.dpToPx(30), Dips.dpToPx(30));
params2.setMargins(padding, padding, padding, padding);
t2.setLayoutParams(params2);
t2.setScaleType(ScaleType.FIT_XY);
t2.setImageDrawable(MagicHelper.getBgImageNightDrawable(false));
t2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AppState.get().colorNigthText = AppState.COLOR_WHITE;
AppState.get().colorNigthBg = AppState.COLOR_BLACK;
textNigthColor.setTextColor(Color.WHITE);
textNigthColor.setBackgroundDrawable(MagicHelper.getBgImageNightDrawable(false));
AppState.get().isUseBGImageNight = true;
TintUtil.setTintImageWithAlpha(onNigthColorImage, AppState.get().colorNigthText);
}
});
lc.addView(t2);
}
}
};
colorsLine.run();
TxtUtils.underlineTextView((TextView) inflate.findViewById(R.id.onDefaultColor)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialogs.showOkDialog(controller.getActivity(), controller.getString(R.string.restore_defaults_full), new Runnable() {
@Override
public void run() {
AppState.get().readColors = AppState.READ_COLORS_DEAFAUL;
AppState.get().isUseBGImageDay = false;
AppState.get().isUseBGImageNight = false;
AppState.get().bgImageDayTransparency = AppState.DAY_TRANSPARENCY;
AppState.get().bgImageDayPath = MagicHelper.IMAGE_BG_1;
AppState.get().bgImageNightTransparency = AppState.NIGHT_TRANSPARENCY;
AppState.get().bgImageNightPath = MagicHelper.IMAGE_BG_1;
AppState.get().isCustomizeBgAndColors = false;
AppState.get().colorDayText = AppState.COLOR_BLACK;
AppState.get().colorDayBg = AppState.COLOR_WHITE;
textDayColor.setTextColor(AppState.COLOR_BLACK);
textDayColor.setBackgroundColor(AppState.COLOR_WHITE);
AppState.get().colorNigthText = AppState.COLOR_WHITE;
AppState.get().colorNigthBg = AppState.COLOR_BLACK;
textNigthColor.setTextColor(AppState.COLOR_WHITE);
textNigthColor.setBackgroundColor(AppState.COLOR_BLACK);
TintUtil.setTintImageWithAlpha(onDayColorImage, AppState.get().colorDayText);
TintUtil.setTintImageWithAlpha(onNigthColorImage, AppState.get().colorNigthText);
AppState.get().statusBarColorDay = AppState.TEXT_COLOR_DAY;
AppState.get().statusBarColorNight = AppState.TEXT_COLOR_NIGHT;
colorsLine.run();
}
});
}
});
inflate.findViewById(R.id.moreReadColorSettings).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog.Builder builder = new AlertDialog.Builder(controller.getActivity());
builder.setTitle(R.string.customize);
final LinearLayout root = new LinearLayout(controller.getActivity());
root.setOrientation(LinearLayout.VERTICAL);
for (String line : AppState.get().readColors.split(";")) {
if (TxtUtils.isEmpty(line)) {
continue;
}
final String[] split = line.split(",");
LOG.d("Split colors", split[0], split[1], split[2]);
final String name = split[0];
final int bg = Color.parseColor(split[1]);
final int text = Color.parseColor(split[2]);
final boolean isDay = split[3].equals("0");
final LinearLayout child = new LinearLayout(controller.getActivity());
child.setOrientation(LinearLayout.HORIZONTAL);
child.setTag(line);
final TextView t1Img = new TextView(controller.getActivity());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Dips.dpToPx(60), Dips.dpToPx(30));
params.setMargins(padding, padding, padding, padding);
t1Img.setLayoutParams(params);
t1Img.setGravity(Gravity.CENTER);
t1Img.setBackgroundColor(bg);
t1Img.setText(name);
t1Img.setTextColor(text);
t1Img.setTypeface(null, Typeface.BOLD);
t1Img.setTag(isDay);
TextView t0 = new TextView(controller.getActivity());
t0.setEms(1);
TextView t00 = new TextView(controller.getActivity());
t00.setEms(2);
final TextView t2BG = new TextView(controller.getActivity());
t2BG.setText(TxtUtils.underline(split[1]));
t2BG.setEms(5);
t2BG.setTag(bg);
final TextView t3Text = new TextView(controller.getActivity());
t3Text.setText(TxtUtils.underline(split[2]));
t3Text.setEms(5);
t3Text.setTag(text);
child.addView(t0);
child.addView(t1Img);
child.addView(t00);
child.addView(t2BG);
child.addView(t3Text);
child.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new ColorsDialog((FragmentActivity) controller.getActivity(), (Boolean) t1Img.getTag(), (Integer) t3Text.getTag(), (Integer) t2BG.getTag(), true, true, new ColorsDialogResult() {
@Override
public void onChooseColor(int colorText, int colorBg) {
t1Img.setTextColor(colorText);
t1Img.setBackgroundColor(colorBg);
t2BG.setText(TxtUtils.underline(MagicHelper.colorToString(colorBg)));
t3Text.setText(TxtUtils.underline(MagicHelper.colorToString(colorText)));
t2BG.setTag(colorBg);
t3Text.setTag(colorText);
String line = name + "," + MagicHelper.colorToString(colorBg) + "," + MagicHelper.colorToString(colorText) + "," + split[3];
child.setTag(line);
}
});
}
});
root.addView(child);
}
builder.setView(root);
builder.setNegativeButton(R.string.apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String res = "";
for (int i = 0; i < root.getChildCount(); i++) {
View childAt = root.getChildAt(i);
String line = (String) childAt.getTag();
res = res + line + ";";
}
AppState.get().readColors = res;
LOG.d("SAVE readColors", AppState.get().readColors);
colorsLine.run();
}
});
builder.setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}
});
return inflate;
}
}.show(DragingPopup.PREF + "_preferences").setOnCloseListener(new Runnable() {
@Override
public void run() {
if (//
//
appHash != Objects.hashCode(AppState.get()) || (controller.isTextFormat() && cssHash != BookCSS.get().toCssString().hashCode())) {
if (onRefresh != null) {
onRefresh.run();
}
controller.restartActivity();
}
}
});
return dialog;
}
use of com.foobnix.android.utils.IntegerResponse in project LibreraReader by foobnix.
the class DragingDialogs method moreBookSettings.
public static DragingPopup moreBookSettings(final FrameLayout anchor, final DocumentController controller, final Runnable onRefresh, final Runnable updateUIRefresh) {
final int initCssHash = BookCSS.get().toCssString().hashCode();
DragingPopup dialog = new DragingPopup(R.string.reading_settings, anchor, PREF_WIDTH, PREF_HEIGHT) {
@Override
public void beforeCreate() {
titleAction = controller.getString(R.string.preferences);
titleRunnable = new Runnable() {
@Override
public void run() {
if (initCssHash != BookCSS.get().toCssString().hashCode()) {
AlertDialogs.showDialog(controller.getActivity(), controller.getString(R.string.you_neet_to_apply_the_new_settings), controller.getString(R.string.apply), new Runnable() {
@Override
public void run() {
closeDialog();
}
});
} else {
preferences(anchor, controller, onRefresh, updateUIRefresh);
}
}
};
}
@Override
public View getContentView(final LayoutInflater inflater) {
View inflate = inflater.inflate(R.layout.dialog_reading_pref, null, false);
final CustomSeek fontWeight = (CustomSeek) inflate.findViewById(R.id.fontWeight);
fontWeight.init(1, 9, BookCSS.get().fontWeight / 100);
fontWeight.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
fontWeight.setValueText("" + (result * 100));
BookCSS.get().fontWeight = result * 100;
return false;
}
});
fontWeight.setValueText("" + BookCSS.get().fontWeight);
// begin styles
final List<String> docStyles = //
Arrays.asList(//
controller.getString(R.string.document_styles) + " + " + controller.getString(R.string.user_styles), //
controller.getString(R.string.document_styles), controller.getString(R.string.user_styles));
final TextView docStyle = (TextView) inflate.findViewById(R.id.documentStyle);
docStyle.setText(docStyles.get(BookCSS.get().documentStyle));
TxtUtils.underlineTextView(docStyle);
inflate.findViewById(R.id.documentStyleLayout).setVisibility(ExtUtils.isTextFomat(controller.getCurrentBook().getPath()) ? View.VISIBLE : View.GONE);
docStyle.setOnClickListener(new OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
final PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
for (int i = 0; i < docStyles.size(); i++) {
String type = docStyles.get(i);
final int j = i;
popupMenu.getMenu().add(type).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
BookCSS.get().documentStyle = j;
docStyle.setText(docStyles.get(BookCSS.get().documentStyle));
TxtUtils.underlineTextView(docStyle);
return false;
}
});
}
popupMenu.show();
}
});
// end styles
// hypens
boolean isSupportHypens = controller.isTextFormat();
CheckBox isAutoHypens = (CheckBox) inflate.findViewById(R.id.isAutoHypens);
isAutoHypens.setVisibility(isSupportHypens ? View.VISIBLE : View.GONE);
isAutoHypens.setChecked(BookCSS.get().isAutoHypens);
isAutoHypens.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
BookCSS.get().isAutoHypens = isChecked;
}
});
final TextView hypenLangLabel = (TextView) inflate.findViewById(R.id.hypenLangLabel);
final TextView hypenLang = (TextView) inflate.findViewById(R.id.hypenLang);
hypenLang.setVisibility(isSupportHypens ? View.VISIBLE : View.GONE);
hypenLangLabel.setVisibility(isSupportHypens ? View.VISIBLE : View.GONE);
// hypenLang.setVisibility(View.GONE);
// hypenLangLabel.setVisibility(View.GONE);
hypenLang.setText(DialogTranslateFromTo.getLanuageByCode(BookCSS.get().hypenLang));
TxtUtils.underlineTextView(hypenLang);
hypenLang.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
HyphenPattern[] values = HyphenPattern.values();
List<String> all = new ArrayList<String>();
for (HyphenPattern p : values) {
String e = DialogTranslateFromTo.getLanuageByCode(p.lang) + ":" + p.lang;
all.add(e);
}
Collections.sort(all);
for (final String langFull : all) {
String[] split = langFull.split(":");
final String titleLang = split[0];
final String code = split[1];
popupMenu.getMenu().add(titleLang).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
BookCSS.get().hypenLang = code;
hypenLang.setText(titleLang);
TxtUtils.underlineTextView(hypenLang);
FileMeta load = AppDB.get().load(controller.getCurrentBook().getPath());
if (load != null) {
load.setLang(code);
AppDB.get().update(load);
}
return false;
}
});
}
popupMenu.show();
}
});
// - hypens
View customCSS = inflate.findViewById(R.id.customCSS);
// TxtUtils.underlineTextView(customCSS);
customCSS.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
final AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle(R.string.custom_css);
final EditText edit = new EditText(v.getContext());
edit.setMinWidth(Dips.dpToPx(1000));
edit.setLines(8);
edit.setGravity(Gravity.TOP);
edit.setText(BookCSS.get().customCSS1);
builder.setView(edit);
builder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int id) {
BookCSS.get().customCSS1 = edit.getText().toString();
BookCSS.get().save(v.getContext());
}
});
builder.show();
}
});
final CustomSeek lineHeight = (CustomSeek) inflate.findViewById(R.id.lineHeight);
lineHeight.init(0, 30, BookCSS.get().lineHeight);
lineHeight.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().lineHeight = result;
return false;
}
});
final CustomSeek paragraphHeight = (CustomSeek) inflate.findViewById(R.id.paragraphHeight);
paragraphHeight.init(0, 20, BookCSS.get().paragraphHeight);
paragraphHeight.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().paragraphHeight = result;
return false;
}
});
final CustomSeek fontParagraph = (CustomSeek) inflate.findViewById(R.id.fontParagraph);
fontParagraph.init(0, 30, BookCSS.get().textIndent);
fontParagraph.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().textIndent = result;
return false;
}
});
final CustomSeek emptyLine = (CustomSeek) inflate.findViewById(R.id.emptyLine);
// || //
boolean isShow = BookType.FB2.is(controller.getCurrentBook().getPath());
// BookType.HTML.is(controller.getCurrentBook().getPath()) || //
// BookType.TXT.is(controller.getCurrentBook().getPath());//
emptyLine.setVisibility(isShow ? View.VISIBLE : View.GONE);
emptyLine.init(0, 30, BookCSS.get().emptyLine);
emptyLine.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().emptyLine = result;
return false;
}
});
// Margins
final CustomSeek marginTop = (CustomSeek) inflate.findViewById(R.id.marginTop);
marginTop.init(0, 30, BookCSS.get().marginTop);
marginTop.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().marginTop = result;
return false;
}
});
final CustomSeek marginBottom = (CustomSeek) inflate.findViewById(R.id.marginBottom);
marginBottom.init(0, 30, BookCSS.get().marginBottom);
marginBottom.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().marginBottom = result;
return false;
}
});
final CustomSeek marginLeft = (CustomSeek) inflate.findViewById(R.id.marginLeft);
marginLeft.init(0, 30, BookCSS.get().marginLeft);
marginLeft.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().marginLeft = result;
return false;
}
});
final CustomSeek marginRight = (CustomSeek) inflate.findViewById(R.id.marginRight);
marginRight.init(0, 30, BookCSS.get().marginRight);
marginRight.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
BookCSS.get().marginRight = result;
return false;
}
});
// font folder
LOG.d("fontFolder2-2", BookCSS.get().fontFolder);
final TextView fontsFolder = (TextView) inflate.findViewById(R.id.fontsFolder);
TxtUtils.underline(fontsFolder, TxtUtils.lastTwoPath(BookCSS.get().fontFolder));
fontsFolder.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ChooserDialogFragment.chooseFolder((FragmentActivity) controller.getActivity(), BookCSS.get().fontFolder).setOnSelectListener(new ResultResponse2<String, Dialog>() {
@Override
public boolean onResultRecive(String nPath, Dialog dialog) {
File result = new File(nPath);
BookCSS.get().fontFolder = result.getPath();
TxtUtils.underline(fontsFolder, TxtUtils.lastTwoPath(BookCSS.get().fontFolder));
BookCSS.get().save(controller.getActivity());
dialog.dismiss();
return false;
}
});
}
});
final View downloadFonts = inflate.findViewById(R.id.downloadFonts);
downloadFonts.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
FontExtractor.showDownloadFontsDialog(controller.getActivity(), downloadFonts, fontsFolder);
}
});
// / aling
final Map<Integer, String> alignConst = new LinkedHashMap<Integer, String>();
alignConst.put(BookCSS.TEXT_ALIGN_JUSTIFY, controller.getString(R.string.width));
alignConst.put(BookCSS.TEXT_ALIGN_LEFT, controller.getString(R.string.left));
alignConst.put(BookCSS.TEXT_ALIGN_RIGHT, controller.getString(R.string.right));
alignConst.put(BookCSS.TEXT_ALIGN_CENTER, controller.getString(R.string.center));
// align
final TextView textAlign = (TextView) inflate.findViewById(R.id.textAlign);
textAlign.setText(TxtUtils.underline(alignConst.get(BookCSS.get().textAlign)));
textAlign.setOnClickListener(new OnClickListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT <= 10) {
BookCSS.get().textAlign += 1;
if (BookCSS.get().textAlign == 4) {
BookCSS.get().textAlign = 0;
}
textAlign.setText(TxtUtils.underline(alignConst.get(BookCSS.get().textAlign)));
return;
}
final PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
for (final int key : alignConst.keySet()) {
String name = alignConst.get(key);
popupMenu.getMenu().add(name).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
BookCSS.get().textAlign = key;
textAlign.setText(TxtUtils.underline(alignConst.get(BookCSS.get().textAlign)));
return false;
}
});
}
popupMenu.show();
}
});
// link color
final CustomColorView linkColorDay = (CustomColorView) inflate.findViewById(R.id.linkColorDay);
linkColorDay.withDefaultColors(Color.parseColor(BookCSS.LINK_COLOR_DAY), Color.parseColor(BookCSS.LINK_COLOR_UNIVERSAL));
linkColorDay.init(Color.parseColor(BookCSS.get().linkColorDay));
linkColorDay.setOnColorChanged(new StringResponse() {
@Override
public boolean onResultRecive(String string) {
BookCSS.get().linkColorDay = string;
return false;
}
});
final CustomColorView linkColorNight = (CustomColorView) inflate.findViewById(R.id.linkColorNight);
linkColorNight.withDefaultColors(Color.parseColor(BookCSS.LINK_COLOR_NIGHT), Color.parseColor(BookCSS.LINK_COLOR_UNIVERSAL));
linkColorNight.init(Color.parseColor(BookCSS.get().linkColorNight));
linkColorNight.setOnColorChanged(new StringResponse() {
@Override
public boolean onResultRecive(String string) {
BookCSS.get().linkColorNight = string;
return false;
}
});
linkColorDay.getText1().getLayoutParams().width = Dips.dpToPx(150);
linkColorNight.getText1().getLayoutParams().width = Dips.dpToPx(150);
TxtUtils.underlineTextView((TextView) inflate.findViewById(R.id.onResetStyles)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialogs.showOkDialog(controller.getActivity(), controller.getString(R.string.restore_defaults_full), new Runnable() {
@Override
public void run() {
BookCSS.get().resetToDefault(controller.getActivity());
fontsFolder.setText(TxtUtils.underline(TxtUtils.lastTwoPath(BookCSS.get().fontFolder)));
textAlign.setText(TxtUtils.underline(alignConst.get(BookCSS.get().textAlign)));
fontWeight.reset(BookCSS.get().fontWeight / 100);
fontWeight.setValueText("" + BookCSS.get().fontWeight);
lineHeight.reset(BookCSS.get().lineHeight);
paragraphHeight.reset(BookCSS.get().paragraphHeight);
fontParagraph.reset(BookCSS.get().textIndent);
//
marginTop.reset(BookCSS.get().marginTop);
marginBottom.reset(BookCSS.get().marginBottom);
marginLeft.reset(BookCSS.get().marginLeft);
marginRight.reset(BookCSS.get().marginRight);
emptyLine.reset(BookCSS.get().emptyLine);
linkColorDay.init(Color.parseColor(BookCSS.get().linkColorDay));
linkColorNight.init(Color.parseColor(BookCSS.get().linkColorNight));
}
});
}
});
return inflate;
}
};
dialog.show(DragingPopup.PREF + "_moreBookSettings");
dialog.setOnCloseListener(new Runnable() {
@Override
public void run() {
if (initCssHash != BookCSS.get().toCssString().hashCode()) {
AppState.get().save(controller.getActivity());
if (onRefresh != null) {
onRefresh.run();
}
controller.restartActivity();
}
}
});
return dialog;
}
use of com.foobnix.android.utils.IntegerResponse in project LibreraReader by foobnix.
the class DragingDialogs method pageFlippingDialog.
public static void pageFlippingDialog(final FrameLayout anchor, final DocumentController controller, final Runnable onRefresh) {
new DragingPopup(anchor.getContext().getString(R.string.automatic_page_flipping), anchor, 300, 300) {
@Override
public View getContentView(LayoutInflater inflater) {
View inflate = inflater.inflate(R.layout.dialog_flipping_pages, null, false);
CheckBox isScrollAnimation = (CheckBox) inflate.findViewById(R.id.isScrollAnimation);
isScrollAnimation.setVisibility(AppState.get().isAlwaysOpenAsMagazine ? View.VISIBLE : View.GONE);
isScrollAnimation.setChecked(AppState.get().isScrollAnimation);
isScrollAnimation.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
AppState.get().isScrollAnimation = isChecked;
}
});
CheckBox isLoopAutoplay = (CheckBox) inflate.findViewById(R.id.isLoopAutoplay);
isLoopAutoplay.setChecked(AppState.get().isLoopAutoplay);
isLoopAutoplay.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
AppState.get().isLoopAutoplay = isChecked;
}
});
CheckBox isShowToolBar = (CheckBox) inflate.findViewById(R.id.isShowToolBar);
isShowToolBar.setChecked(AppState.get().isShowToolBar);
isShowToolBar.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
AppState.get().isShowToolBar = isChecked;
if (onRefresh != null) {
onRefresh.run();
}
}
});
final CustomSeek flippingInterval = (CustomSeek) inflate.findViewById(R.id.flippingInterval);
flippingInterval.init(1, 240, AppState.get().flippingInterval);
flippingInterval.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
flippingInterval.setValueText("" + result);
AppState.get().flippingInterval = result;
return false;
}
});
flippingInterval.setValueText("" + AppState.get().flippingInterval);
inflate.findViewById(R.id.flippingStart).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().post(new FlippingStart());
}
});
inflate.findViewById(R.id.flippingStop).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().post(new FlippingStop());
}
});
return inflate;
}
}.show("pageFlippingDialog").setOnCloseListener(new Runnable() {
@Override
public void run() {
}
});
}
use of com.foobnix.android.utils.IntegerResponse in project LibreraReader by foobnix.
the class DocumentWrapperUI method doChooseNextType.
public void doChooseNextType(View view) {
final MyPopupMenu popupMenu = new MyPopupMenu(view.getContext(), view);
String pages = dc.getString(R.string.by_pages);
String screen = dc.getString(R.string.of_screen).toLowerCase(Locale.US);
String screens = dc.getString(R.string.by_screans);
final List<Integer> values = Arrays.asList(AppState.NEXT_SCREEN_SCROLL_BY_PAGES, 100, 95, 75, 50, 25, 10);
for (int i = 0; i < values.size(); i++) {
final int n = i;
String name = i == AppState.NEXT_SCREEN_SCROLL_BY_PAGES ? pages : values.get(i) + "% " + screen;
if (values.get(i) == 100) {
name = screens;
}
popupMenu.getMenu().add(name).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AppState.get().nextScreenScrollBy = values.get(n);
initNextType();
Keyboards.hideNavigation(dc.getActivity());
return false;
}
});
}
popupMenu.getMenu().add(R.string.custom_value).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Activity a = dc.getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(a);
builder.setTitle(R.string.custom_value);
final CustomSeek myValue = new CustomSeek(a);
myValue.init(1, 100, AppState.get().nextScreenScrollMyValue);
myValue.setOnSeekChanged(new IntegerResponse() {
@Override
public boolean onResultRecive(int result) {
AppState.get().nextScreenScrollMyValue = result;
myValue.setValueText(AppState.get().nextScreenScrollMyValue + "%");
return false;
}
});
myValue.setValueText(AppState.get().nextScreenScrollMyValue + "%");
builder.setView(myValue);
builder.setPositiveButton(R.string.apply, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AppState.get().nextScreenScrollBy = AppState.get().nextScreenScrollMyValue;
initNextType();
Keyboards.hideNavigation(dc.getActivity());
}
});
builder.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.show();
return false;
}
});
popupMenu.show();
}
Aggregations