public static void testGetPossibleLogTypes() throws Exception { final Geocache gcCache = new Geocache(); gcCache.setGeocode("GC123"); gcCache.setType(CacheType.WEBCAM); assertThat(gcCache.getPossibleLogTypes()) .as("possible GC cache log types") .contains(LogType.WEBCAM_PHOTO_TAKEN); assertThat(gcCache.getPossibleLogTypes()) .as("possible GC cache log types") .contains(LogType.NEEDS_MAINTENANCE); final Geocache ocCache = new Geocache(); ocCache.setGeocode("OC1234"); ocCache.setType(CacheType.TRADITIONAL); assertThat(ocCache.getPossibleLogTypes()) .as("traditional cache possible log types") .doesNotContain(LogType.WEBCAM_PHOTO_TAKEN); assertThat(ocCache.getPossibleLogTypes()) .as("OC cache possible log types") .doesNotContain(LogType.NEEDS_MAINTENANCE); }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.logcache_activity); // Get parameters from intent and basic cache information from database final Bundle extras = getIntent().getExtras(); if (extras != null) { cacheid = extras.getString(EXTRAS_ID); geocode = extras.getString(EXTRAS_GEOCODE); } if ((StringUtils.isBlank(cacheid)) && StringUtils.isNotBlank(geocode)) { cacheid = cgData.getCacheidForGeocode(geocode); } if (StringUtils.isBlank(geocode) && StringUtils.isNotBlank(cacheid)) { geocode = cgData.getGeocodeForGuid(cacheid); } cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); possibleLogTypes = cache.getPossibleLogTypes(); if (StringUtils.isNotBlank(cache.getName())) { setTitle(res.getString(R.string.log_new_log) + ": " + cache.getName()); } else { setTitle(res.getString(R.string.log_new_log) + ": " + cache.getGeocode()); } // Get ids for later use 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(); // Restore previous state if (savedInstanceState != null) { rating = savedInstanceState.getDouble(SAVED_STATE_RATING); typeSelected = LogType.getById(savedInstanceState.getInt(SAVED_STATE_TYPE)); date.setTimeInMillis(savedInstanceState.getLong(SAVED_STATE_DATE)); imageCaption = savedInstanceState.getString(SAVED_STATE_IMAGE_CAPTION); imageDescription = savedInstanceState.getString(SAVED_STATE_IMAGE_DESCRIPTION); imageUri = Uri.parse(savedInstanceState.getString(SAVED_STATE_IMAGE_URI)); } else { // If log had been previously saved, load it now, otherwise initialize signature as needed final LogEntry log = cgData.loadLogOffline(geocode); if (log != null) { typeSelected = log.type; date.setTime(new Date(log.date)); text = log.log; } else if (StringUtils.isNotBlank(Settings.getSignature()) && Settings.isAutoInsertSignature() && StringUtils.isBlank(currentLogText())) { insertIntoLog( LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(cache)), false); } } updatePostButtonText(); updateImageButton(); enablePostButton(false); final Button typeButton = (Button) findViewById(R.id.type); typeButton.setText(typeSelected.getL10n()); typeButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { selectLogType(); } }); final Button dateButton = (Button) findViewById(R.id.date); setDate(date); dateButton.setOnClickListener(new DateListener()); final EditText logView = (EditText) findViewById(R.id.log); if (StringUtils.isBlank(currentLogText()) && StringUtils.isNotBlank(text)) { logView.setText(text); } tweetCheck.setChecked(true); 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() { @Override public void onClick(View v) { saveLog(true); } }); final Button clearButton = (Button) findViewById(R.id.clear); clearButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { clearLog(); } }); loggingManager = cache.getLoggingManager(this); loggingManager.init(); }