From dc53fa7be33f3052e39952112679c7b0e0b3b324 Mon Sep 17 00:00:00 2001 From: rsudev Date: Thu, 27 Jun 2013 17:46:41 +0200 Subject: Implements #2900, Support logging with password (oc) Extends db, geocache and OKAPI to retrieve and store the property Extends logging UI and OKAPI to allow entering and sending it --- main/src/cgeo/geocaching/LogCacheActivity.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'main/src/cgeo/geocaching/LogCacheActivity.java') diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java index 62c94ce..b3b6c09 100644 --- a/main/src/cgeo/geocaching/LogCacheActivity.java +++ b/main/src/cgeo/geocaching/LogCacheActivity.java @@ -71,6 +71,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia private Button postButton = null; private CheckBox tweetCheck = null; private LinearLayout tweetBox = null; + private LinearLayout logPasswordBox = null; private boolean tbChanged = false; private SparseArray actionButtons; @@ -252,6 +253,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia postButton = (Button) findViewById(R.id.post); tweetBox = (LinearLayout) findViewById(R.id.tweet_box); tweetCheck = (CheckBox) findViewById(R.id.tweet); + logPasswordBox = (LinearLayout) findViewById(R.id.log_password_box); // initialize with default values setDefaultValues(); @@ -302,6 +304,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia tweetCheck.setChecked(true); updateTweetBox(typeSelected); + updateLogPasswordBox(typeSelected); final Button imageButton = (Button) findViewById(R.id.image_btn); imageButton.setOnClickListener(new View.OnClickListener() { @@ -377,6 +380,8 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia final EditText logView = (EditText) findViewById(R.id.log); logView.setText(StringUtils.EMPTY); + final EditText logPasswordView = (EditText) findViewById(R.id.log_password); + logPasswordView.setText(StringUtils.EMPTY); updateImageButton(); @@ -491,6 +496,14 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia } } + private void updateLogPasswordBox(LogType type) { + if (type == LogType.FOUND_IT && cache.isLogPasswordRequired()) { + logPasswordBox.setVisibility(View.VISIBLE); + } else { + logPasswordBox.setVisibility(View.GONE); + } + } + private class DateListener implements View.OnClickListener { @Override @@ -507,7 +520,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia final String message = res.getString(StringUtils.isBlank(imageUri.getPath()) ? R.string.log_saving : R.string.log_saving_and_uploading); - new Poster(LogCacheActivity.this, message).execute(currentLogText()); + new Poster(LogCacheActivity.this, message).execute(currentLogText(), currentLogPassword()); } } @@ -520,8 +533,9 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia @Override protected StatusCode doInBackgroundInternal(final String[] logTexts) { final String log = logTexts[0]; + final String logPwd = logTexts.length > 1 ? logTexts[1] : null; try { - final LogResult logResult = loggingManager.postLog(cache, typeSelected, date, log, trackables); + final LogResult logResult = loggingManager.postLog(cache, typeSelected, date, log, logPwd, trackables); if (logResult.getPostLogResult() == StatusCode.NO_ERROR) { final LogEntry logNow = new LogEntry(date, typeSelected, log); @@ -593,6 +607,10 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia return ((EditText) findViewById(R.id.log)).getText().toString(); } + private String currentLogPassword() { + return ((EditText) findViewById(R.id.log_password)).getText().toString(); + } + @Override protected LogContext getLogContext() { return new LogContext(cache); -- cgit v1.1