aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/AbstractLoggingActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/AbstractLoggingActivity.java')
-rw-r--r--main/src/cgeo/geocaching/AbstractLoggingActivity.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/AbstractLoggingActivity.java b/main/src/cgeo/geocaching/AbstractLoggingActivity.java
index 8448e45..cc5546f 100644
--- a/main/src/cgeo/geocaching/AbstractLoggingActivity.java
+++ b/main/src/cgeo/geocaching/AbstractLoggingActivity.java
@@ -2,6 +2,7 @@ package cgeo.geocaching;
import cgeo.geocaching.activity.AbstractActionBarActivity;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.activity.Keyboard;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.gc.GCConnector;
import cgeo.geocaching.connector.gc.GCSmiliesProvider;
@@ -11,6 +12,8 @@ import cgeo.geocaching.utils.LogTemplateProvider;
import cgeo.geocaching.utils.LogTemplateProvider.LogContext;
import cgeo.geocaching.utils.LogTemplateProvider.LogTemplate;
+import org.apache.commons.lang3.StringUtils;
+
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
@@ -55,6 +58,10 @@ public abstract class AbstractLoggingActivity extends AbstractActionBarActivity
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
final int id = item.getItemId();
+ if (id == R.id.menu_repeat_last) {
+ replaceLog(getLastLog());
+ return true;
+ }
final LogTemplate template = LogTemplateProvider.getTemplate(id);
if (template != null) {
@@ -71,10 +78,26 @@ public abstract class AbstractLoggingActivity extends AbstractActionBarActivity
return super.onOptionsItemSelected(item);
}
+ /**
+ * @return the last log text used with this logging activity
+ */
+ protected abstract String getLastLog();
+
protected abstract LogContext getLogContext();
protected final void insertIntoLog(final String newText, final boolean moveCursor) {
final EditText log = (EditText) findViewById(R.id.log);
ActivityMixin.insertAtPosition(log, newText, moveCursor);
}
+
+ private void replaceLog(final String newText) {
+ final EditText log = (EditText) findViewById(R.id.log);
+ log.setText(StringUtils.EMPTY);
+ insertIntoLog(newText, true);
+ }
+
+ protected void requestKeyboardForLogging() {
+ new Keyboard(this).show(findViewById(R.id.log));
+ }
+
}