mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
fixed string resources in dialog preferences
This commit is contained in:
parent
0c27f7590b
commit
b836e176f9
5 changed files with 41 additions and 17 deletions
|
@ -26,6 +26,7 @@ import android.widget.TextView;
|
|||
|
||||
import yuku.ambilwarna.AmbilWarnaDialog;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.util.ZLColor;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
@ -54,7 +55,11 @@ public abstract class ColorPreference extends Preference {
|
|||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
new AmbilWarnaDialog(getContext(), ZLAndroidColorUtil.rgb(getSavedColor()), new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
||||
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
|
||||
new AmbilWarnaDialog(
|
||||
getContext(),
|
||||
ZLAndroidColorUtil.rgb(getSavedColor()),
|
||||
new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
||||
@Override
|
||||
public void onOk(AmbilWarnaDialog dialog, int color) {
|
||||
if (!callChangeListener(color)) {
|
||||
|
@ -67,6 +72,9 @@ public abstract class ColorPreference extends Preference {
|
|||
@Override
|
||||
public void onCancel(AmbilWarnaDialog dialog) {
|
||||
}
|
||||
}).show();
|
||||
},
|
||||
buttonResource.getResource("ok").getValue(),
|
||||
buttonResource.getResource("cancel").getValue()
|
||||
).show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ abstract class ZLStringListPreference extends ListPreference {
|
|||
super(context);
|
||||
setTitle(resource.getValue());
|
||||
myValuesResource = valuesResource;
|
||||
|
||||
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
|
||||
setPositiveButtonText(buttonResource.getResource("ok").getValue());
|
||||
setNegativeButtonText(buttonResource.getResource("cancel").getValue());
|
||||
}
|
||||
|
||||
protected final void setList(String[] values) {
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BackgroundPreference extends Preference {
|
|||
|
||||
final ZLColor color = myProfile.BackgroundOption.getValue();
|
||||
if (color != null) {
|
||||
call.putExtra(COLOR_KEY, color.intValue());
|
||||
call.putExtra(COLOR_KEY, ZLAndroidColorUtil.rgb(color));
|
||||
}
|
||||
|
||||
((Activity)getContext()).startActivityForResult(call, myRequestCode);
|
||||
|
|
|
@ -74,12 +74,18 @@ public class Chooser extends ListActivity implements AdapterView.OnItemClickList
|
|||
public final void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
{
|
||||
final ZLResource buttonResource =
|
||||
ZLResource.resource("dialog").getResource("button");
|
||||
new AmbilWarnaDialog(
|
||||
this,
|
||||
getIntent().getIntExtra(BackgroundPreference.COLOR_KEY, 0),
|
||||
myColorChooserListener
|
||||
myColorChooserListener,
|
||||
buttonResource.getResource("ok").getValue(),
|
||||
buttonResource.getResource("cancel").getValue()
|
||||
).show();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
startActivityForResult(new Intent(this, PredefinedImages.class), 1);
|
||||
break;
|
||||
|
|
|
@ -24,6 +24,9 @@ public class AmbilWarnaDialog {
|
|||
final ViewGroup viewContainer;
|
||||
final float[] currentColorHsv = new float[3];
|
||||
|
||||
private final CharSequence positiveButtonText;
|
||||
private final CharSequence negativeButtonText;
|
||||
|
||||
/**
|
||||
* create an AmbilWarnaDialog. call this only from OnCreateDialog() or from a background thread.
|
||||
*
|
||||
|
@ -34,10 +37,13 @@ public class AmbilWarnaDialog {
|
|||
* @param listener
|
||||
* an OnAmbilWarnaListener, allowing you to get back error or
|
||||
*/
|
||||
public AmbilWarnaDialog(final Context context, int color, OnAmbilWarnaListener listener) {
|
||||
public AmbilWarnaDialog(final Context context, int color, OnAmbilWarnaListener listener, String positiveButtonText, String negativeButtonText) {
|
||||
this.listener = listener;
|
||||
Color.colorToHSV(color, currentColorHsv);
|
||||
|
||||
this.positiveButtonText = positiveButtonText;
|
||||
this.negativeButtonText = negativeButtonText;
|
||||
|
||||
final View view = LayoutInflater.from(context).inflate(R.layout.ambilwarna_dialog, null);
|
||||
viewHue = view.findViewById(R.id.ambilwarna_viewHue);
|
||||
viewSatVal = (AmbilWarnaKotak) view.findViewById(R.id.ambilwarna_viewSatBri);
|
||||
|
@ -102,14 +108,14 @@ public class AmbilWarnaDialog {
|
|||
});
|
||||
|
||||
dialog = new AlertDialog.Builder(context)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {
|
||||
@Override public void onClick(DialogInterface dialog, int which) {
|
||||
if (AmbilWarnaDialog.this.listener != null) {
|
||||
AmbilWarnaDialog.this.listener.onOk(AmbilWarnaDialog.this, getColor());
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
.setNegativeButton(negativeButtonText, new DialogInterface.OnClickListener() {
|
||||
@Override public void onClick(DialogInterface dialog, int which) {
|
||||
if (AmbilWarnaDialog.this.listener != null) {
|
||||
AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue