diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2012-10-25 20:34:52 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2012-10-25 20:34:52 +0200 |
| commit | eb77c0668c5187c6c00479269fa09524b2dbb6c6 (patch) | |
| tree | 0b00c13133fe3dac859cc92a6c6f893cc806a118 /main | |
| parent | 869a2f4c995bab5285fc4ef6531c9b7e5d18becf (diff) | |
| parent | 2ab1a677b17e79eed9ef389742e100280edc6b9a (diff) | |
| download | cgeo-eb77c0668c5187c6c00479269fa09524b2dbb6c6.zip cgeo-eb77c0668c5187c6c00479269fa09524b2dbb6c6.tar.gz cgeo-eb77c0668c5187c6c00479269fa09524b2dbb6c6.tar.bz2 | |
Merge remote-tracking branch 'jowi24/feature_409'
* remove useless margins
* hide personal note text view if empty
Diffstat (limited to 'main')
| -rw-r--r-- | main/res/layout/cacheview_description.xml | 11 | ||||
| -rw-r--r-- | main/res/layout/editor.xml | 25 | ||||
| -rw-r--r-- | main/res/values-de/strings.xml | 4 | ||||
| -rw-r--r-- | main/res/values/strings.xml | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 57 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/ui/EditorDialog.java | 59 |
6 files changed, 138 insertions, 24 deletions
diff --git a/main/res/layout/cacheview_description.xml b/main/res/layout/cacheview_description.xml index c985bfb..60e70e7 100644 --- a/main/res/layout/cacheview_description.xml +++ b/main/res/layout/cacheview_description.xml @@ -110,8 +110,7 @@ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dip"
- android:orientation="vertical"
- android:visibility="gone" >
+ android:orientation="vertical" >
<RelativeLayout style="@style/separator_horizontal_layout" >
@@ -129,8 +128,12 @@ android:linksClickable="true"
android:textColor="?text_color"
android:textColorLink="?text_color_link"
- android:textSize="14dip"
- android:visibility="gone" />
+ android:textSize="14dip" />
+ <Button
+ android:id="@+id/edit_personalnote"
+ style="@style/button_small"
+ android:text="@string/cache_personal_note_edit" />
+
</LinearLayout>
</LinearLayout>
diff --git a/main/res/layout/editor.xml b/main/res/layout/editor.xml new file mode 100644 index 0000000..88b1b10 --- /dev/null +++ b/main/res/layout/editor.xml @@ -0,0 +1,25 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/linearLayout1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:background="?background_color" > + + <EditText + android:id="@+id/editorEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:inputType="textMultiLine" + android:scrollbars="vertical" > + + <requestFocus /> + </EditText> + + <Button style="@style/button_full" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/editorSave" + android:text="@string/editor_save" /> + +</LinearLayout> diff --git a/main/res/values-de/strings.xml b/main/res/values-de/strings.xml index 3158eb8..9501763 100644 --- a/main/res/values-de/strings.xml +++ b/main/res/values-de/strings.xml @@ -514,6 +514,7 @@ <string name="cache_log_images_title">Logbild</string> <string name="cache_log_image_default_title">Bild</string> <string name="cache_personal_note">Persönliche Notiz</string> + <string name="cache_personal_note_edit">Bearbeiten</string> <string name="cache_description">Beschreibung</string> <string name="cache_description_long">Ausführliche Beschreibung</string> <string name="cache_description_table_note">Diese Beschreibung enthält Tabellenelemente, die evtl. nur auf Geocaching.com korrekt angezeigt werden.</string> @@ -614,6 +615,9 @@ <string name="cache_share_field">Weiterleiten</string> <string name="cache_time_full_hours">Uhr</string> + <!-- editor dialog --> + <string name="editor_save">Speichern</string> + <!-- file list base --> <string name="file_searching_in">Suche nach Dateien\nin</string> <string name="file_searching_sdcard_in">Keine Dateien in Standardverzeichnissen gefunden:\n%1$s\n\nDurchsuche komplette SD-Karte:\n</string> diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml index 042ae35..64ffe97 100644 --- a/main/res/values/strings.xml +++ b/main/res/values/strings.xml @@ -524,6 +524,7 @@ <string name="cache_log_images_title">Log images</string> <string name="cache_log_image_default_title">Photo</string> <string name="cache_personal_note">Personal note</string> + <string name="cache_personal_note_edit">Edit</string> <string name="cache_description">Description</string> <string name="cache_description_long">Long Description</string> <string name="cache_description_table_note">Description contains table formatting which may need to be viewed at geocaching.com to be seen correctly.</string> @@ -624,7 +625,10 @@ <string name="cache_image_open_browser">Open in browser</string> <string name="cache_share_field">Share</string> <string name="cache_time_full_hours">o\'clock</string> - + + <!-- editor dialog --> + <string name="editor_save">Save</string> + <!-- file list base --> <string name="file_searching_in">Searching for files\nin</string> <string name="file_searching_sdcard_in">No files found in default folders:\n%1$s\n\nSearching whole SD card for files:\n</string> diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index fec3758..60b5bec 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -18,6 +18,7 @@ import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.ui.CacheDetailsCreator; import cgeo.geocaching.ui.DecryptTextClickListener; +import cgeo.geocaching.ui.EditorDialog; import cgeo.geocaching.ui.Formatter; import cgeo.geocaching.ui.LoggingUI; import cgeo.geocaching.utils.BaseUtils; @@ -166,7 +167,7 @@ public class CacheDetailActivity extends AbstractActivity { /** * A {@link List} of all available pages. - * + * * TODO Move to adapter */ private final List<Page> pageOrder = new ArrayList<Page>(); @@ -1892,28 +1893,37 @@ public class CacheDetailActivity extends AbstractActivity { } // cache personal note - if (StringUtils.isNotBlank(cache.getPersonalNote())) { - view.findViewById(R.id.personalnote_box).setVisibility(View.VISIBLE); - - TextView personalNoteText = (TextView) view.findViewById(R.id.personalnote); - personalNoteText.setVisibility(View.VISIBLE); - personalNoteText.setText(cache.getPersonalNote(), TextView.BufferType.SPANNABLE); - personalNoteText.setMovementMethod(LinkMovementMethod.getInstance()); - registerForContextMenu(personalNoteText); - } - else { - view.findViewById(R.id.personalnote_box).setVisibility(View.GONE); - } + final TextView personalNoteView = (TextView) view.findViewById(R.id.personalnote); + setPersonalNote(personalNoteView); + personalNoteView.setMovementMethod(LinkMovementMethod.getInstance()); + registerForContextMenu(personalNoteView); + final Button personalNoteEdit = (Button) view.findViewById(R.id.edit_personalnote); + personalNoteEdit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + EditorDialog editor = new EditorDialog(CacheDetailActivity.this, personalNoteView.getText()); + editor.setOnEditorUpdate(new EditorDialog.EditorUpdate() { + @Override + public void update(CharSequence editorText) { + cache.setPersonalNote(editorText.toString()); + setPersonalNote(personalNoteView); + app.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB)); + } + }); + editor.show(); + } + }); // cache hint and spoiler images + final View hintBoxView = view.findViewById(R.id.hint_box); if (StringUtils.isNotBlank(cache.getHint()) || CollectionUtils.isNotEmpty(cache.getSpoilers())) { - view.findViewById(R.id.hint_box).setVisibility(View.VISIBLE); + hintBoxView.setVisibility(View.VISIBLE); } else { - view.findViewById(R.id.hint_box).setVisibility(View.GONE); + hintBoxView.setVisibility(View.GONE); } + final TextView hintView = ((TextView) view.findViewById(R.id.hint)); if (StringUtils.isNotBlank(cache.getHint())) { - TextView hintView = ((TextView) view.findViewById(R.id.hint)); if (BaseUtils.containsHtml(cache.getHint())) { hintView.setText(Html.fromHtml(cache.getHint(), new HtmlImage(cache.getGeocode(), false, cache.getListId(), false), null), TextView.BufferType.SPANNABLE); hintView.setText(CryptUtils.rot13((Spannable) hintView.getText())); @@ -1926,14 +1936,13 @@ public class CacheDetailActivity extends AbstractActivity { hintView.setOnClickListener(new DecryptTextClickListener()); registerForContextMenu(hintView); } else { - TextView hintView = ((TextView) view.findViewById(R.id.hint)); hintView.setVisibility(View.GONE); hintView.setClickable(false); hintView.setOnClickListener(null); } + final TextView spoilerlinkView = ((TextView) view.findViewById(R.id.hint_spoilerlink)); if (CollectionUtils.isNotEmpty(cache.getSpoilers())) { - TextView spoilerlinkView = ((TextView) view.findViewById(R.id.hint_spoilerlink)); spoilerlinkView.setVisibility(View.VISIBLE); spoilerlinkView.setClickable(true); spoilerlinkView.setOnClickListener(new View.OnClickListener() { @@ -1948,7 +1957,6 @@ public class CacheDetailActivity extends AbstractActivity { } }); } else { - TextView spoilerlinkView = ((TextView) view.findViewById(R.id.hint_spoilerlink)); spoilerlinkView.setVisibility(View.GONE); spoilerlinkView.setClickable(true); spoilerlinkView.setOnClickListener(null); @@ -1957,6 +1965,17 @@ public class CacheDetailActivity extends AbstractActivity { return view; } + private void setPersonalNote(final TextView personalNoteView) { + final String personalNote = cache.getPersonalNote(); + personalNoteView.setText(personalNote, TextView.BufferType.SPANNABLE); + if (StringUtils.isNotBlank(personalNote)) { + personalNoteView.setVisibility(View.VISIBLE); + } + else { + personalNoteView.setVisibility(View.GONE); + } + } + private void loadLongDescription() { Button showDesc = (Button) view.findViewById(R.id.show_description); showDesc.setVisibility(View.GONE); diff --git a/main/src/cgeo/geocaching/ui/EditorDialog.java b/main/src/cgeo/geocaching/ui/EditorDialog.java new file mode 100644 index 0000000..50b3e27 --- /dev/null +++ b/main/src/cgeo/geocaching/ui/EditorDialog.java @@ -0,0 +1,59 @@ +package cgeo.geocaching.ui; + +import cgeo.geocaching.CacheDetailActivity; +import cgeo.geocaching.R; + +import android.app.Dialog; +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import android.widget.Button; +import android.widget.EditText; + +public class EditorDialog extends Dialog { + + private CharSequence editorText; + private EditorUpdate editorUpdate; + + public EditorDialog(CacheDetailActivity cacheDetailActivity, CharSequence editable) { + super(cacheDetailActivity); + this.editorText = editable; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + requestWindowFeature(Window.FEATURE_NO_TITLE); + setContentView(R.layout.editor); + + final EditText editText = (EditText) findViewById(R.id.editorEditText); + editText.setText(editorText); + + final Button buttonSave = (Button) findViewById(R.id.editorSave); + buttonSave.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + editorUpdate.update(editText.getEditableText()); + EditorDialog.this.hide(); + } + }); + } + + public interface EditorUpdate { + public void update(CharSequence editorText); + } + + public void setOnEditorUpdate(EditorUpdate editorUpdate) { + this.editorUpdate = editorUpdate; + + } + + @Override + public void show() { + super.show(); + getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); + } + +} |
