aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-05-28 07:24:05 +0200
committerBananeweizen <bananeweizen@gmx.de>2014-05-28 07:24:05 +0200
commit763ef20606ef217a81e96da8eb82ded95f0dbf39 (patch)
tree3e88d1b882c1a07f4a04c2b115383af5d534567b
parent41eb2aa0afe0fad2e23387a702b29f2eef8fec6c (diff)
downloadcgeo-763ef20606ef217a81e96da8eb82ded95f0dbf39.zip
cgeo-763ef20606ef217a81e96da8eb82ded95f0dbf39.tar.gz
cgeo-763ef20606ef217a81e96da8eb82ded95f0dbf39.tar.bz2
#3903: image selection via actionbar
-rw-r--r--main/res/drawable-mdpi/ic_menu_attachment.pngbin0 -> 1132 bytes
-rw-r--r--main/res/layout/logcache_activity.xml6
-rw-r--r--main/res/menu/abstract_logging_activity.xml8
-rw-r--r--main/src/cgeo/geocaching/LogCacheActivity.java37
4 files changed, 19 insertions, 32 deletions
diff --git a/main/res/drawable-mdpi/ic_menu_attachment.png b/main/res/drawable-mdpi/ic_menu_attachment.png
new file mode 100644
index 0000000..d3d4812
--- /dev/null
+++ b/main/res/drawable-mdpi/ic_menu_attachment.png
Binary files differ
diff --git a/main/res/layout/logcache_activity.xml b/main/res/layout/logcache_activity.xml
index f38795d..b00a70a 100644
--- a/main/res/layout/logcache_activity.xml
+++ b/main/res/layout/logcache_activity.xml
@@ -120,12 +120,6 @@
android:textSize="14sp" />
</LinearLayout>
- <Button
- android:id="@+id/image_btn"
- style="@style/button_full"
- android:text="@string/log_image_attach" />
-
-
<RelativeLayout style="@style/separator_horizontal_layout" >
<View style="@style/separator_horizontal" />
diff --git a/main/res/menu/abstract_logging_activity.xml b/main/res/menu/abstract_logging_activity.xml
index 7577cde..8ef0cf1 100644
--- a/main/res/menu/abstract_logging_activity.xml
+++ b/main/res/menu/abstract_logging_activity.xml
@@ -17,6 +17,14 @@
<menu /> <!-- filled dynamically -->
</item>
<item
+ android:id="@+id/menu_image"
+ android:icon="@drawable/ic_menu_attachment"
+ android:title="@string/log_image_attach"
+ android:visible="false"
+ cgeo:showAsAction="ifRoom|withText">
+ <menu /> <!-- filled dynamically -->
+ </item>
+ <item
android:id="@+id/menu_smilies"
android:icon="@drawable/ic_menu_emoticons"
android:title="@string/log_smilies"
diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java
index d604882..d6f7f43 100644
--- a/main/src/cgeo/geocaching/LogCacheActivity.java
+++ b/main/src/cgeo/geocaching/LogCacheActivity.java
@@ -32,6 +32,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
@@ -213,6 +214,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
}
cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ invalidateOptionsMenuCompatible();
possibleLogTypes = cache.getPossibleLogTypes();
if (StringUtils.isNotBlank(cache.getName())) {
@@ -253,7 +255,6 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
insertIntoLog(LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(cache, null)), false);
}
}
- updateImageButton();
enablePostButton(false);
final Button typeButton = (Button) findViewById(R.id.type);
@@ -280,15 +281,6 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
updateTweetBox(typeSelected);
updateLogPasswordBox(typeSelected);
- final Button imageButton = (Button) findViewById(R.id.image_btn);
- imageButton.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View view) {
- selectImage();
- }
- });
-
final Button saveButton = (Button) findViewById(R.id.save);
saveButton.setOnClickListener(new View.OnClickListener() {
@@ -359,8 +351,6 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
final EditText logPasswordView = (EditText) findViewById(R.id.log_password);
logPasswordView.setText(StringUtils.EMPTY);
- updateImageButton();
-
showToast(res.getString(R.string.info_log_cleared));
}
@@ -627,19 +617,6 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
// Image capture failed, advise user
showToast(getResources().getString(R.string.err_select_logimage_failed));
}
- updateImageButton();
-
- }
- }
-
- private void updateImageButton() {
- final Button imageButton = (Button) findViewById(R.id.image_btn);
- if (cache.supportsLogImages()) {
- imageButton.setVisibility(View.VISIBLE);
- imageButton.setText(StringUtils.isNotBlank(imageUri.getPath()) ?
- res.getString(R.string.log_image_edit) : res.getString(R.string.log_image_attach));
- } else {
- imageButton.setVisibility(View.GONE);
}
}
@@ -649,7 +626,9 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
case R.id.menu_send:
sendLog();
return true;
-
+ case R.id.menu_image:
+ selectImage();
+ return true;
default:
break;
}
@@ -668,4 +647,10 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
new Poster(LogCacheActivity.this, message).execute(currentLogText(), currentLogPassword());
}
}
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ menu.findItem(R.id.menu_image).setVisible(cache.supportsLogImages());
+ return super.onPrepareOptionsMenu(menu);
+ }
}