diff options
Diffstat (limited to 'main/src/cgeo/geocaching/ui')
7 files changed, 37 insertions, 31 deletions
diff --git a/main/src/cgeo/geocaching/ui/DecryptTextClickListener.java b/main/src/cgeo/geocaching/ui/DecryptTextClickListener.java index f10e13a..e2e587e 100644 --- a/main/src/cgeo/geocaching/ui/DecryptTextClickListener.java +++ b/main/src/cgeo/geocaching/ui/DecryptTextClickListener.java @@ -2,36 +2,38 @@ package cgeo.geocaching.ui; import cgeo.geocaching.utils.CryptUtils;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.text.Spannable;
import android.view.View;
import android.widget.TextView;
public class DecryptTextClickListener implements View.OnClickListener {
- @Override
- public void onClick(View view) {
- if (view == null) {
- return;
- }
+ @NonNull private final TextView targetView;
- try {
- final TextView logView = (TextView) view;
+ public DecryptTextClickListener(@NonNull final TextView targetView) {
+ this.targetView = targetView;
+ }
+ @Override
+ public final void onClick(final View view) {
+ try {
// do not run the click listener if a link was clicked
- if (logView.getSelectionStart() != -1 || logView.getSelectionEnd() != -1) {
+ if (targetView.getSelectionStart() != -1 || targetView.getSelectionEnd() != -1) {
return;
}
- CharSequence text = logView.getText();
+ CharSequence text = targetView.getText();
if (text instanceof Spannable) {
Spannable span = (Spannable) text;
- logView.setText(CryptUtils.rot13(span));
+ targetView.setText(CryptUtils.rot13(span));
}
else {
String string = (String) text;
- logView.setText(CryptUtils.rot13(string));
+ targetView.setText(CryptUtils.rot13(string));
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// nothing
}
}
diff --git a/main/src/cgeo/geocaching/ui/EditNoteDialog.java b/main/src/cgeo/geocaching/ui/EditNoteDialog.java index 50cf57a..2af1cb8 100644 --- a/main/src/cgeo/geocaching/ui/EditNoteDialog.java +++ b/main/src/cgeo/geocaching/ui/EditNoteDialog.java @@ -7,7 +7,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.DialogFragment; -import android.view.LayoutInflater; +import android.view.ContextThemeWrapper; import android.view.View; import android.widget.EditText; @@ -35,13 +35,12 @@ public class EditNoteDialog extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - LayoutInflater inflater = getActivity().getLayoutInflater(); - View view = inflater.inflate(R.layout.fragment_edit_note, null); + View view = View.inflate(new ContextThemeWrapper(getActivity(), R.style.dark), R.layout.fragment_edit_note, null); mEditText = (EditText) view.findViewById(R.id.note); String initialNote = getArguments().getString(ARGUMENT_INITIAL_NOTE); if (initialNote != null) { mEditText.setText(initialNote); - initialNote = null; + getArguments().remove(ARGUMENT_INITIAL_NOTE); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); diff --git a/main/src/cgeo/geocaching/ui/GPXListAdapter.java b/main/src/cgeo/geocaching/ui/GPXListAdapter.java index 7f3c33f..988bb81 100644 --- a/main/src/cgeo/geocaching/ui/GPXListAdapter.java +++ b/main/src/cgeo/geocaching/ui/GPXListAdapter.java @@ -5,6 +5,7 @@ import butterknife.InjectView; import cgeo.geocaching.GpxFileListActivity; import cgeo.geocaching.R; import cgeo.geocaching.files.GPXImporter; +import cgeo.geocaching.utils.FileUtils; import cgeo.geocaching.utils.Log; import android.app.Activity; @@ -80,7 +81,7 @@ public class GPXListAdapter extends ArrayAdapter<File> { .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { - file.delete(); + FileUtils.deleteIgnoringFailure(file); GPXListAdapter.this.remove(file); } }) diff --git a/main/src/cgeo/geocaching/ui/LoggingUI.java b/main/src/cgeo/geocaching/ui/LoggingUI.java index 0ee724a..c2e2d24 100644 --- a/main/src/cgeo/geocaching/ui/LoggingUI.java +++ b/main/src/cgeo/geocaching/ui/LoggingUI.java @@ -3,10 +3,9 @@ package cgeo.geocaching.ui; import cgeo.geocaching.Geocache; import cgeo.geocaching.LogEntry; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.cgData; -import cgeo.geocaching.activity.IAbstractActivity; import cgeo.geocaching.enumerations.LogType; +import cgeo.geocaching.settings.Settings; import android.app.Activity; import android.app.AlertDialog; @@ -61,13 +60,13 @@ public class LoggingUI extends AbstractUIFactory { } } - public static boolean onMenuItemSelected(final MenuItem item, IAbstractActivity activity, Geocache cache) { + public static boolean onMenuItemSelected(final MenuItem item, final Activity activity, final Geocache cache) { switch (item.getItemId()) { case R.id.menu_log_visit: cache.logVisit(activity); return true; case R.id.menu_log_visit_offline: - showOfflineMenu(cache, (Activity) activity); + showOfflineMenu(cache, activity); return true; default: return false; @@ -100,7 +99,7 @@ public class LoggingUI extends AbstractUIFactory { if (logTypeEntry.logType == null) { switch (logTypeEntry.specialLogType) { case LOG_CACHE: - cache.logVisit((IAbstractActivity) activity); + cache.logVisit(activity); break; case CLEAR_LOG: diff --git a/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java b/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java index 959cb14..91ce7e3 100644 --- a/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java +++ b/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java @@ -4,7 +4,7 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.settings.Settings; -import cgeo.geocaching.settings.Settings.coordInputFormatEnum; +import cgeo.geocaching.settings.Settings.CoordInputFormatEnum; import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.compatibility.Compatibility; @@ -41,7 +41,7 @@ public class CoordinatesInputDialog extends NoTitleDialog { private CoordinateUpdate cuListener; - private coordInputFormatEnum currentFormat = null; + private CoordInputFormatEnum currentFormat = null; public CoordinatesInputDialog(final AbstractActivity context, final Geocache cache, final Geopoint gp, final IGeoData geo) { super(context, ActivityMixin.getDialogTheme()); @@ -272,7 +272,7 @@ public class CoordinatesInputDialog extends NoTitleDialog { * formatSec 2/3 2 2 3 */ - if (currentFormat == coordInputFormatEnum.Plain) { + if (currentFormat == CoordInputFormatEnum.Plain) { return; } @@ -325,7 +325,7 @@ public class CoordinatesInputDialog extends NoTitleDialog { } private boolean calc(final boolean signalError) { - if (currentFormat == coordInputFormatEnum.Plain) { + if (currentFormat == CoordInputFormatEnum.Plain) { try { gp = new Geopoint(eLat.getText().toString(), eLon.getText().toString()); } catch (final Geopoint.ParseException e) { @@ -375,10 +375,10 @@ public class CoordinatesInputDialog extends NoTitleDialog { if (editText == eLonDeg || editText == eLatSub || editText == eLonSub) { return 3; } - if ((editText == eLatMin || editText == eLonMin) && currentFormat == coordInputFormatEnum.Deg) { + if ((editText == eLatMin || editText == eLonMin) && currentFormat == CoordInputFormatEnum.Deg) { return 5; } - if ((editText == eLatSec || editText == eLonSec) && currentFormat == coordInputFormatEnum.Min) { + if ((editText == eLatSec || editText == eLonSec) && currentFormat == CoordInputFormatEnum.Min) { return 3; } return 2; @@ -402,7 +402,7 @@ public class CoordinatesInputDialog extends NoTitleDialog { } } - currentFormat = coordInputFormatEnum.fromInt(pos); + currentFormat = CoordInputFormatEnum.fromInt(pos); Settings.setCoordInputFormat(currentFormat); updateGUI(); } diff --git a/main/src/cgeo/geocaching/ui/dialog/CustomProgressDialog.java b/main/src/cgeo/geocaching/ui/dialog/CustomProgressDialog.java index e80c446..97c5c29 100644 --- a/main/src/cgeo/geocaching/ui/dialog/CustomProgressDialog.java +++ b/main/src/cgeo/geocaching/ui/dialog/CustomProgressDialog.java @@ -10,6 +10,7 @@ import android.view.View; import android.widget.TextView; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** @@ -38,7 +39,11 @@ public class CustomProgressDialog extends ProgressDialog { method.invoke(textView, View.GONE); } } - } catch (Exception e) { + } catch (NoSuchMethodException e) { + Log.e("Failed to invoke the progressDialog method 'setVisibility' and set 'mProgressNumber' to GONE.", e); + } catch (IllegalAccessException e) { + Log.e("Failed to invoke the progressDialog method 'setVisibility' and set 'mProgressNumber' to GONE.", e); + } catch (InvocationTargetException e) { Log.e("Failed to invoke the progressDialog method 'setVisibility' and set 'mProgressNumber' to GONE.", e); } } diff --git a/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java b/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java index ee2713a..4572bc6 100644 --- a/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java +++ b/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java @@ -129,7 +129,7 @@ public abstract class LogsViewCreator extends AbstractCachingPageViewCreator<Lis if (null == convertView) { holder.author.setOnClickListener(createUserActionsListener()); holder.text.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance()); - holder.text.setOnClickListener(new DecryptTextClickListener()); + holder.text.setOnClickListener(new DecryptTextClickListener(holder.text)); activity.registerForContextMenu(holder.text); } } |
