diff options
| author | Arne Schwabe <arne@rfc2549.org> | 2014-07-13 01:29:07 +0200 |
|---|---|---|
| committer | Arne Schwabe <arne@rfc2549.org> | 2014-07-13 01:30:21 +0200 |
| commit | 61ba89fac5bd6b23777564b6f380e3588c830f11 (patch) | |
| tree | 81f2be5d52df3f62b55f094e96bd6b3bb09d1775 /main/src | |
| parent | 1af104f9c4d27a280cfef06198667ab75b1075cb (diff) | |
| download | cgeo-61ba89fac5bd6b23777564b6f380e3588c830f11.zip cgeo-61ba89fac5bd6b23777564b6f380e3588c830f11.tar.gz cgeo-61ba89fac5bd6b23777564b6f380e3588c830f11.tar.bz2 | |
Do not assume that all dialog have dark theme on Honeycomb and later (Fixes issue #4068)
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/export/FieldnoteExport.java | 12 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/export/GpxExport.java | 12 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/ui/EditNoteDialog.java | 13 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/ui/dialog/Dialogs.java | 11 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java | 11 |
5 files changed, 51 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/export/FieldnoteExport.java b/main/src/cgeo/geocaching/export/FieldnoteExport.java index 04c9dac..f6f27c6 100644 --- a/main/src/cgeo/geocaching/export/FieldnoteExport.java +++ b/main/src/cgeo/geocaching/export/FieldnoteExport.java @@ -18,7 +18,10 @@ import cgeo.geocaching.utils.Log; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; +import android.content.Context; import android.content.DialogInterface; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.os.Environment; import android.view.ContextThemeWrapper; import android.view.View; @@ -55,8 +58,13 @@ public class FieldnoteExport extends AbstractExport { private Dialog getExportOptionsDialog(final Geocache[] caches, final Activity activity) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); - // AlertDialog has always dark style, so we have to apply it as well always - final View layout = View.inflate(new ContextThemeWrapper(activity, R.style.dark), R.layout.fieldnote_export_dialog, null); + final Context themedContext; + if (Settings.isLightSkin() && VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) + themedContext = new ContextThemeWrapper(activity, R.style.dark); + else + themedContext = activity; + final View layout = View.inflate(themedContext, R.layout.fieldnote_export_dialog, null); + builder.setView(layout); final CheckBox uploadOption = ButterKnife.findById(layout, R.id.upload); diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java index 5a95128..26e96b3 100644 --- a/main/src/cgeo/geocaching/export/GpxExport.java +++ b/main/src/cgeo/geocaching/export/GpxExport.java @@ -17,7 +17,10 @@ import org.apache.commons.lang3.CharEncoding; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; +import android.content.Context; import android.content.DialogInterface; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.os.Environment; import android.view.ContextThemeWrapper; import android.view.View; @@ -59,8 +62,13 @@ public class GpxExport extends AbstractExport { private Dialog getExportDialog(final String[] geocodes, final Activity activity) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); - // AlertDialog has always dark style, so we have to apply it as well always - final View layout = View.inflate(new ContextThemeWrapper(activity, R.style.dark), R.layout.gpx_export_dialog, null); + final Context themedContext; + if (Settings.isLightSkin() && VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) + themedContext = new ContextThemeWrapper(activity, R.style.dark); + else + themedContext = activity; + + final View layout = View.inflate(themedContext, R.layout.gpx_export_dialog, null); builder.setView(layout); final TextView text = ButterKnife.findById(layout, R.id.info); diff --git a/main/src/cgeo/geocaching/ui/EditNoteDialog.java b/main/src/cgeo/geocaching/ui/EditNoteDialog.java index cb1b11d..013fdff 100644 --- a/main/src/cgeo/geocaching/ui/EditNoteDialog.java +++ b/main/src/cgeo/geocaching/ui/EditNoteDialog.java @@ -4,13 +4,17 @@ import butterknife.ButterKnife; import cgeo.geocaching.R; import cgeo.geocaching.activity.Keyboard; +import cgeo.geocaching.settings.Settings; import cgeo.geocaching.ui.dialog.Dialogs; import org.eclipse.jdt.annotation.NonNull; import android.app.AlertDialog; import android.app.Dialog; +import android.content.Context; import android.content.DialogInterface; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; @@ -43,7 +47,14 @@ public class EditNoteDialog extends DialogFragment { @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final @NonNull FragmentActivity activity = getActivity(); - final View view = View.inflate(new ContextThemeWrapper(activity, R.style.dark), R.layout.fragment_edit_note, null); + + final Context themedContext; + if (Settings.isLightSkin() && VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) + themedContext = new ContextThemeWrapper(activity, R.style.dark); + else + themedContext = activity; + + final View view = View.inflate(themedContext, R.layout.fragment_edit_note, null); mEditText = ButterKnife.findById(view, R.id.note); final String initialNote = getArguments().getString(ARGUMENT_INITIAL_NOTE); if (initialNote != null) { diff --git a/main/src/cgeo/geocaching/ui/dialog/Dialogs.java b/main/src/cgeo/geocaching/ui/dialog/Dialogs.java index 6a2f9a5..79775fb 100644 --- a/main/src/cgeo/geocaching/ui/dialog/Dialogs.java +++ b/main/src/cgeo/geocaching/ui/dialog/Dialogs.java @@ -2,6 +2,7 @@ package cgeo.geocaching.ui.dialog; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; +import cgeo.geocaching.settings.Settings; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.Nullable; @@ -15,6 +16,8 @@ import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.graphics.drawable.Drawable; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; @@ -327,7 +330,13 @@ public final class Dialogs { * listener to be run on okay */ public static void input(final Activity context, final int title, final String defaultValue, final int buttonTitle, final Action1<String> okayListener) { - final Context themedContext = new ContextThemeWrapper(context, R.style.dark); + final Context themedContext; + + if (Settings.isLightSkin() && VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) + themedContext = new ContextThemeWrapper(context, R.style.dark); + else + themedContext = context; + final EditText input = new EditText(themedContext); input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_CLASS_TEXT); input.setText(defaultValue); diff --git a/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java b/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java index c29f549..9858c28 100644 --- a/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java +++ b/main/src/cgeo/geocaching/ui/dialog/LiveMapInfoDialogBuilder.java @@ -6,7 +6,10 @@ import cgeo.geocaching.settings.Settings; import android.app.Activity; import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.view.ContextThemeWrapper; import android.view.View; @@ -15,8 +18,12 @@ public class LiveMapInfoDialogBuilder { public static AlertDialog create(Activity activity) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); - // AlertDialog has always dark style, so we have to apply it as well always - final View layout = View.inflate(new ContextThemeWrapper(activity, R.style.dark), R.layout.livemapinfo, null); + final Context themedContext; + if (Settings.isLightSkin() && VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) + themedContext = new ContextThemeWrapper(activity, R.style.dark); + else + themedContext = activity; + final View layout = View.inflate(themedContext, R.layout.livemapinfo, null); builder.setView(layout); final int showCount = Settings.getLiveMapHintShowCount(); |
