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 yuku.ambilwarna.AmbilWarnaDialog;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLColor;
|
import org.geometerplus.zlibrary.core.util.ZLColor;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.R;
|
import org.geometerplus.zlibrary.ui.android.R;
|
||||||
|
@ -54,19 +55,26 @@ public abstract class ColorPreference extends Preference {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
new AmbilWarnaDialog(getContext(), ZLAndroidColorUtil.rgb(getSavedColor()), new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
|
||||||
@Override
|
new AmbilWarnaDialog(
|
||||||
public void onOk(AmbilWarnaDialog dialog, int color) {
|
getContext(),
|
||||||
if (!callChangeListener(color)) {
|
ZLAndroidColorUtil.rgb(getSavedColor()),
|
||||||
return;
|
new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
||||||
|
@Override
|
||||||
|
public void onOk(AmbilWarnaDialog dialog, int color) {
|
||||||
|
if (!callChangeListener(color)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saveColor(new ZLColor(color));
|
||||||
|
notifyChanged();
|
||||||
}
|
}
|
||||||
saveColor(new ZLColor(color));
|
|
||||||
notifyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(AmbilWarnaDialog dialog) {
|
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);
|
super(context);
|
||||||
setTitle(resource.getValue());
|
setTitle(resource.getValue());
|
||||||
myValuesResource = valuesResource;
|
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) {
|
protected final void setList(String[] values) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class BackgroundPreference extends Preference {
|
||||||
|
|
||||||
final ZLColor color = myProfile.BackgroundOption.getValue();
|
final ZLColor color = myProfile.BackgroundOption.getValue();
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
call.putExtra(COLOR_KEY, color.intValue());
|
call.putExtra(COLOR_KEY, ZLAndroidColorUtil.rgb(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
((Activity)getContext()).startActivityForResult(call, myRequestCode);
|
((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) {
|
public final void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
|
{
|
||||||
|
final ZLResource buttonResource =
|
||||||
|
ZLResource.resource("dialog").getResource("button");
|
||||||
new AmbilWarnaDialog(
|
new AmbilWarnaDialog(
|
||||||
this,
|
this,
|
||||||
getIntent().getIntExtra(BackgroundPreference.COLOR_KEY, 0),
|
getIntent().getIntExtra(BackgroundPreference.COLOR_KEY, 0),
|
||||||
myColorChooserListener
|
myColorChooserListener,
|
||||||
|
buttonResource.getResource("ok").getValue(),
|
||||||
|
buttonResource.getResource("cancel").getValue()
|
||||||
).show();
|
).show();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 1:
|
case 1:
|
||||||
startActivityForResult(new Intent(this, PredefinedImages.class), 1);
|
startActivityForResult(new Intent(this, PredefinedImages.class), 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,6 +24,9 @@ public class AmbilWarnaDialog {
|
||||||
final ViewGroup viewContainer;
|
final ViewGroup viewContainer;
|
||||||
final float[] currentColorHsv = new float[3];
|
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.
|
* create an AmbilWarnaDialog. call this only from OnCreateDialog() or from a background thread.
|
||||||
*
|
*
|
||||||
|
@ -34,10 +37,13 @@ public class AmbilWarnaDialog {
|
||||||
* @param listener
|
* @param listener
|
||||||
* an OnAmbilWarnaListener, allowing you to get back error or
|
* 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;
|
this.listener = listener;
|
||||||
Color.colorToHSV(color, currentColorHsv);
|
Color.colorToHSV(color, currentColorHsv);
|
||||||
|
|
||||||
|
this.positiveButtonText = positiveButtonText;
|
||||||
|
this.negativeButtonText = negativeButtonText;
|
||||||
|
|
||||||
final View view = LayoutInflater.from(context).inflate(R.layout.ambilwarna_dialog, null);
|
final View view = LayoutInflater.from(context).inflate(R.layout.ambilwarna_dialog, null);
|
||||||
viewHue = view.findViewById(R.id.ambilwarna_viewHue);
|
viewHue = view.findViewById(R.id.ambilwarna_viewHue);
|
||||||
viewSatVal = (AmbilWarnaKotak) view.findViewById(R.id.ambilwarna_viewSatBri);
|
viewSatVal = (AmbilWarnaKotak) view.findViewById(R.id.ambilwarna_viewSatBri);
|
||||||
|
@ -102,14 +108,14 @@ public class AmbilWarnaDialog {
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog = new AlertDialog.Builder(context)
|
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) {
|
@Override public void onClick(DialogInterface dialog, int which) {
|
||||||
if (AmbilWarnaDialog.this.listener != null) {
|
if (AmbilWarnaDialog.this.listener != null) {
|
||||||
AmbilWarnaDialog.this.listener.onOk(AmbilWarnaDialog.this, getColor());
|
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) {
|
@Override public void onClick(DialogInterface dialog, int which) {
|
||||||
if (AmbilWarnaDialog.this.listener != null) {
|
if (AmbilWarnaDialog.this.listener != null) {
|
||||||
AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this);
|
AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue