diff --git a/Android_GUI/AndroidManifest.xml b/Android_GUI/AndroidManifest.xml index 5491d55dd..6c8d4f865 100644 --- a/Android_GUI/AndroidManifest.xml +++ b/Android_GUI/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="20160419" android:versionName="0.8.20160419(Test)"> diff --git a/Android_GUI/src/de/cachebox_test/splash.java b/Android_GUI/src/de/cachebox_test/splash.java index 1d4bc2875..81a370d23 100644 --- a/Android_GUI/src/de/cachebox_test/splash.java +++ b/Android_GUI/src/de/cachebox_test/splash.java @@ -707,9 +707,6 @@ private String getExternalSdPath(String Folder) { final java.io.File[] externalCacheDirs = ContextCompat.getExternalCacheDirs(context); final List result = new ArrayList(); - //set internal Work Path - workPath = externalCacheDirs[0].getParent() + "/files"; - for (int i = 1; i < externalCacheDirs.length; ++i) { final java.io.File file = externalCacheDirs[i]; if (file == null) diff --git a/CB_UI/src/CB_UI/GlobalCore.java b/CB_UI/src/CB_UI/GlobalCore.java index 613b9926f..0bb24ebbb 100644 --- a/CB_UI/src/CB_UI/GlobalCore.java +++ b/CB_UI/src/CB_UI/GlobalCore.java @@ -54,362 +54,362 @@ * @author longri */ public class GlobalCore extends CB_UI_Base.Global implements SolverCacheInterface { - final static org.slf4j.Logger log = LoggerFactory.getLogger(GlobalCore.class); + final static org.slf4j.Logger log = LoggerFactory.getLogger(GlobalCore.class); - public static final int CurrentRevision = 20160510; + public static final int CurrentRevision = 20160419; - public static final String CurrentVersion = "0.8."; - public static final String VersionPrefix = "Test-svn2771"; + public static final String CurrentVersion = "0.8."; + public static final String VersionPrefix = "Test-svn2771"; - public static final String aboutMsg1 = "Team Cachebox (2011-2016)" + br; - public static final String teamLink = "www.team-cachebox.de"; - public static final String aboutMsg2 = br + "Cache Icons Copyright 2009," + br + "Groundspeak Inc. Used with permission"; - public static final String aboutMsg = aboutMsg1 + teamLink + aboutMsg2; + public static final String aboutMsg1 = "Team Cachebox (2011-2016)" + br; + public static final String teamLink = "www.team-cachebox.de"; + public static final String aboutMsg2 = br + "Cache Icons Copyright 2009," + br + "Groundspeak Inc. Used with permission"; + public static final String aboutMsg = aboutMsg1 + teamLink + aboutMsg2; - public static final String splashMsg = aboutMsg + br + br + "POWERED BY:"; + public static final String splashMsg = aboutMsg + br + br + "POWERED BY:"; - public static boolean restartAfterKill = false; - public static String restartCache; - public static String restartWaypoint; - public static boolean filterLogsOfFriends = false; + public static boolean restartAfterKill = false; + public static String restartCache; + public static String restartWaypoint; + public static boolean filterLogsOfFriends = false; - // ###########create instance############# - public final static GlobalCore INSTANCE = new GlobalCore(); + // ###########create instance############# + public final static GlobalCore INSTANCE = new GlobalCore(); - private GlobalCore() { - super(); - Solver.solverCacheInterface = this; - } - - // ####################################### + private GlobalCore() { + super(); + Solver.solverCacheInterface = this; + } - public static Track AktuelleRoute = null; - public static int aktuelleRouteCount = 0; - // public static long TrackDistance; + // ####################################### - public static boolean switchToCompassCompleted = false; + public static Track AktuelleRoute = null; + public static int aktuelleRouteCount = 0; + // public static long TrackDistance; - public static GlobalLocationReceiver receiver; + public static boolean switchToCompassCompleted = false; - private static Cache selectedCache = null; - private static boolean autoResort; + public static GlobalLocationReceiver receiver; - public static void setSelectedCache(Cache cache) { - setSelectedWaypoint(cache, null); - } + private static Cache selectedCache = null; + private static boolean autoResort; - public static Cache getSelectedCache() { - return selectedCache; - } + public static void setSelectedCache(Cache cache) { + setSelectedWaypoint(cache, null); + } - public static boolean selectedCachehasSpoiler() { - if (selectedCache != null) { - return selectedCache.hasSpoiler(); - } else - return false; - } + public static Cache getSelectedCache() { + return selectedCache; + } - private static Cache nearestCache = null; + public static boolean selectedCachehasSpoiler() { + if (selectedCache != null) { + return selectedCache.hasSpoiler(); + } else + return false; + } - public static Cache NearestCache() { - return nearestCache; - } + private static Cache nearestCache = null; - private static Waypoint selectedWaypoint = null; + public static Cache NearestCache() { + return nearestCache; + } - public static void setSelectedWaypoint(Cache cache, Waypoint waypoint) { - if (cache == null) - return; + private static Waypoint selectedWaypoint = null; - setSelectedWaypoint(cache, waypoint, true); - if (waypoint == null) { - CoreSettingsForward.cacheHistory = cache.getGcCode() + "," + CoreSettingsForward.cacheHistory; - if (CoreSettingsForward.cacheHistory.length() > 120) { - CoreSettingsForward.cacheHistory = CoreSettingsForward.cacheHistory.substring(0, CoreSettingsForward.cacheHistory.lastIndexOf(",")); - } - } - } - - /** - * if changeAutoResort == false -> do not change state of autoResort Flag - * - * @param cache - * @param waypoint - * @param changeAutoResort - */ - public static void setSelectedWaypoint(Cache cache, Waypoint waypoint, boolean changeAutoResort) { - - if (cache == null) { - Log.info(log, "[GlobalCore]setSelectedWaypoint: cache=null"); - selectedCache = null; - selectedWaypoint = null; - return; - } + public static void setSelectedWaypoint(Cache cache, Waypoint waypoint) { + if (cache == null) + return; - // // rewrite Changed Values ( like Favroite state) - // if (selectedCache != null) - // { - // if (!Cache.getGcCode().equals("CBPark")) - // { - // Cache lastCache = Database.Data.Query.GetCacheById(selectedCache.Id); - // - // } - // } - - // remove Detail Info from old selectedCache - if ((selectedCache != cache) && (selectedCache != null) && (selectedCache.detail != null)) { - selectedCache.deleteDetail(Config.ShowAllWaypoints.getValue()); + setSelectedWaypoint(cache, waypoint, true); + if (waypoint == null) { + CoreSettingsForward.cacheHistory = cache.getGcCode() + "," + CoreSettingsForward.cacheHistory; + if (CoreSettingsForward.cacheHistory.length() > 120) { + CoreSettingsForward.cacheHistory = CoreSettingsForward.cacheHistory.substring(0, CoreSettingsForward.cacheHistory.lastIndexOf(",")); + } + } } - selectedCache = cache; - Log.info(log, "[GlobalCore]setSelectedWaypoint: cache=" + cache.getGcCode()); - selectedWaypoint = waypoint; - // load Detail Info if not available - if (selectedCache.detail == null) { - selectedCache.loadDetail(); - } + /** + * if changeAutoResort == false -> do not change state of autoResort Flag + * + * @param cache + * @param waypoint + * @param changeAutoResort + */ + public static void setSelectedWaypoint(Cache cache, Waypoint waypoint, boolean changeAutoResort) { + + if (cache == null) { + Log.info(log, "[GlobalCore]setSelectedWaypoint: cache=null"); + selectedCache = null; + selectedWaypoint = null; + return; + } - SelectedCacheEventList.Call(selectedCache, selectedWaypoint); + // // rewrite Changed Values ( like Favroite state) + // if (selectedCache != null) + // { + // if (!Cache.getGcCode().equals("CBPark")) + // { + // Cache lastCache = Database.Data.Query.GetCacheById(selectedCache.Id); + // + // } + // } + + // remove Detail Info from old selectedCache + if ((selectedCache != cache) && (selectedCache != null) && (selectedCache.detail != null)) { + selectedCache.deleteDetail(Config.ShowAllWaypoints.getValue()); + } + selectedCache = cache; + Log.info(log, "[GlobalCore]setSelectedWaypoint: cache=" + cache.getGcCode()); + selectedWaypoint = waypoint; - if (changeAutoResort) { - // switch off auto select - GlobalCore.setAutoResort(false); - } + // load Detail Info if not available + if (selectedCache.detail == null) { + selectedCache.loadDetail(); + } - GL.that.renderOnce(); - } + SelectedCacheEventList.Call(selectedCache, selectedWaypoint); - public static void setNearestCache(Cache Cache) { - nearestCache = Cache; - } + if (changeAutoResort) { + // switch off auto select + GlobalCore.setAutoResort(false); + } - public static Waypoint getSelectedWaypoint() { - return selectedWaypoint; - } + GL.that.renderOnce(); + } - /** - * APIisOnline Liefert TRUE wenn die Möglichkeit besteht auf das Internet zuzugreifen und ein API Access Token vorhanden ist. - */ - public static boolean APIisOnline() { - if (Config.GetAccessToken().length() == 0) { - Log.info(log, "GlobalCore.APIisOnline() - no GC - API AccessToken"); - return false; + public static void setNearestCache(Cache Cache) { + nearestCache = Cache; } - if (PlatformConnector.isOnline()) { - return true; + + public static Waypoint getSelectedWaypoint() { + return selectedWaypoint; } - return false; - } - - static boolean JaokerPwChk = false; - static boolean JokerPwExist = false; - - /** - * JokerisOnline Liefert TRUE wenn die Möglichkeit besteht auf das Internet zuzugreifen und ein Passwort für gcJoker.de vorhanden - * ist. - */ - public static boolean JokerisOnline() { - if (!JaokerPwChk) { - JokerPwExist = Config.GcJoker.getValue().length() == 0; - JaokerPwChk = true; + + /** + * APIisOnline Liefert TRUE wenn die Möglichkeit besteht auf das Internet zuzugreifen und ein API Access Token vorhanden ist. + */ + public static boolean APIisOnline() { + if (Config.GetAccessToken().length() == 0) { + Log.info(log, "GlobalCore.APIisOnline() - no GC - API AccessToken"); + return false; + } + if (PlatformConnector.isOnline()) { + return true; + } + return false; } - if (JokerPwExist) { - // Log.info(log, "GlobalCore.JokerisOnline() - no Joker Password"); - return false; + static boolean JaokerPwChk = false; + static boolean JokerPwExist = false; + + /** + * JokerisOnline Liefert TRUE wenn die Möglichkeit besteht auf das Internet zuzugreifen und ein Passwort für gcJoker.de vorhanden + * ist. + */ + public static boolean JokerisOnline() { + if (!JaokerPwChk) { + JokerPwExist = Config.GcJoker.getValue().length() == 0; + JaokerPwChk = true; + } + + if (JokerPwExist) { + // Log.info(log, "GlobalCore.JokerisOnline() - no Joker Password"); + return false; + } + if (PlatformConnector.isOnline()) { + return true; + } + return false; } - if (PlatformConnector.isOnline()) { - return true; + + public static String getVersionString() { + final String ret = "Version: " + CurrentVersion + String.valueOf(CurrentRevision) + " " + (VersionPrefix.equals("") ? "" : "(" + VersionPrefix + ")"); + return ret; } - return false; - } - public static String getVersionString() { - final String ret = "Version: " + CurrentVersion + String.valueOf(CurrentRevision) + " " + (VersionPrefix.equals("") ? "" : "(" + VersionPrefix + ")"); - return ret; - } + public static Coordinate getSelectedCoord() { + Coordinate ret = null; - public static Coordinate getSelectedCoord() { - Coordinate ret = null; + if (selectedWaypoint != null) { + ret = selectedWaypoint.Pos; + } else if (selectedCache != null) { + ret = selectedCache.Pos; + } - if (selectedWaypoint != null) { - ret = selectedWaypoint.Pos; - } else if (selectedCache != null) { - ret = selectedCache.Pos; + return ret; } - return ret; - } + public static void checkSelectedCacheValid() { - public static void checkSelectedCacheValid() { + CacheList List = Database.Data.Query; - CacheList List = Database.Data.Query; + // Prüfen, ob der SelectedCache noch in der cacheList drin ist. + if ((List.size() > 0) && (GlobalCore.isSetSelectedCache()) && (List.GetCacheById(GlobalCore.getSelectedCache().Id) == null)) { + // der SelectedCache ist nicht mehr in der cacheList drin -> einen beliebigen aus der CacheList auswählen + Log.debug(log, "Change SelectedCache from " + GlobalCore.getSelectedCache().getGcCode() + "to" + List.get(0).getGcCode()); + GlobalCore.setSelectedCache(List.get(0)); + } + // Wenn noch kein Cache Selected ist dann einfach den ersten der Liste aktivieren + if ((GlobalCore.getSelectedCache() == null) && (List.size() > 0)) { + GlobalCore.setSelectedCache(List.get(0)); + Log.debug(log, "Set SelectedCache to " + List.get(0).getGcCode() + " first in List."); + } + } - // Prüfen, ob der SelectedCache noch in der cacheList drin ist. - if ((List.size() > 0) && (GlobalCore.isSetSelectedCache()) && (List.GetCacheById(GlobalCore.getSelectedCache().Id) == null)) { - // der SelectedCache ist nicht mehr in der cacheList drin -> einen beliebigen aus der CacheList auswählen - Log.debug(log, "Change SelectedCache from " + GlobalCore.getSelectedCache().getGcCode() + "to" + List.get(0).getGcCode()); - GlobalCore.setSelectedCache(List.get(0)); + public static boolean getAutoResort() { + return autoResort; } - // Wenn noch kein Cache Selected ist dann einfach den ersten der Liste aktivieren - if ((GlobalCore.getSelectedCache() == null) && (List.size() > 0)) { - GlobalCore.setSelectedCache(List.get(0)); - Log.debug(log, "Set SelectedCache to " + List.get(0).getGcCode() + " first in List."); + + public static void setAutoResort(boolean value) { + GlobalCore.autoResort = value; } - } - public static boolean getAutoResort() { - return autoResort; - } + private static CancelWaitDialog wd; - public static void setAutoResort(boolean value) { - GlobalCore.autoResort = value; - } + public static boolean RunFromSplash = false; - private static CancelWaitDialog wd; + public static CancelWaitDialog ImportSpoiler() { + wd = CancelWaitDialog.ShowWait(Translation.Get("downloadSpoiler"), DownloadAnimation.GetINSTANCE(), new IcancelListener() { - public static boolean RunFromSplash = false; + @Override + public void isCanceld() { + // TODO Handle Cancel - public static CancelWaitDialog ImportSpoiler() { - wd = CancelWaitDialog.ShowWait(Translation.Get("downloadSpoiler"), DownloadAnimation.GetINSTANCE(), new IcancelListener() { + } + }, new cancelRunnable() { - @Override - public void isCanceld() { - // TODO Handle Cancel + @Override + public void run() { + Importer importer = new Importer(); + ImporterProgress ip = new ImporterProgress(); + int result = importer.importSpoilerForCacheNew(ip, GlobalCore.getSelectedCache()); + wd.close(); + if (result == GroundspeakAPI.CONNECTION_TIMEOUT) { + GL.that.Toast(ConnectionError.INSTANCE); + return; + } + + if (result == GroundspeakAPI.API_IS_UNAVAILABLE) { + GL.that.Toast(ApiUnavailable.INSTANCE); + return; + } + } - } - }, new cancelRunnable() { + @Override + public boolean cancel() { + // TODO Handle Cancel + return false; + } + }); + return wd; + } - @Override - public void run() { - Importer importer = new Importer(); - ImporterProgress ip = new ImporterProgress(); - int result = importer.importSpoilerForCacheNew(ip, GlobalCore.getSelectedCache()); - wd.close(); - if (result == GroundspeakAPI.CONNECTION_TIMEOUT) { - GL.that.Toast(ConnectionError.INSTANCE); - return; - } + public interface IChkRedyHandler { + public void checkReady(int MemberTypeId); + } - if (result == GroundspeakAPI.API_IS_UNAVAILABLE) { - GL.that.Toast(ApiUnavailable.INSTANCE); - return; - } - } + static CancelWaitDialog dia; - @Override - public boolean cancel() { - // TODO Handle Cancel - return false; - } - }); - return wd; - } + public static void MsgDownloadLimit() { + GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { - public interface IChkRedyHandler { - public void checkReady(int MemberTypeId); - } + @Override + public void run() { + GL_MsgBox.Show(Translation.Get("Limit_msg"), Translation.Get("Limit_title"), MessageBoxButtons.OK, MessageBoxIcon.GC_Live, null); + } + }); - static CancelWaitDialog dia; + } - public static void MsgDownloadLimit() { - GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { + public static void chkAPiLogInWithWaitDialog(final IChkRedyHandler handler) { - @Override - public void run() { - GL_MsgBox.Show(Translation.Get("Limit_msg"), Translation.Get("Limit_title"), MessageBoxButtons.OK, MessageBoxIcon.GC_Live, null); - } - }); + if (GroundspeakAPI.ApiLimit()) { + MsgDownloadLimit(); + return; + } - } + if (!GroundspeakAPI.mAPI_isChecked()) { + dia = CancelWaitDialog.ShowWait("chk API Key", DownloadAnimation.GetINSTANCE(), new IcancelListener() { + + @Override + public void isCanceld() { + dia.close(); + } + }, new cancelRunnable() { + + @Override + public void run() { + final int ret = GroundspeakAPI.chkMembership(false); + dia.close(); + + Timer ti = new Timer(); + TimerTask task = new TimerTask() { + + @Override + public void run() { + handler.checkReady(ret); + } + }; + ti.schedule(task, 300); + + } + + @Override + public boolean cancel() { + // TODO Handle Cancel + return false; + } + }); + } else { + handler.checkReady(GroundspeakAPI.chkMembership(true)); + } - public static void chkAPiLogInWithWaitDialog(final IChkRedyHandler handler) { + } - if (GroundspeakAPI.ApiLimit()) { - MsgDownloadLimit(); - return; + @Override + protected String getVersionPrefix() { + return VersionPrefix; } - if (!GroundspeakAPI.mAPI_isChecked()) { - dia = CancelWaitDialog.ShowWait("chk API Key", DownloadAnimation.GetINSTANCE(), new IcancelListener() { + // Interface für den Solver zum Zugriff auf den SelectedCache. + // Direkter Zugriff geht nicht da der Solver im Core definiert ist + @Override + public Cache sciGetSelectedCache() { + return getSelectedCache(); + } - @Override - public void isCanceld() { - dia.close(); - } - }, new cancelRunnable() { + @Override + public void sciSetSelectedCache(Cache cache) { + setSelectedCache(cache); + CacheListChangedEventList.Call(); + } - @Override - public void run() { - final int ret = GroundspeakAPI.chkMembership(false); - dia.close(); + @Override + public void sciSetSelectedWaypoint(Cache cache, Waypoint waypoint) { + setSelectedWaypoint(cache, waypoint); + CacheListChangedEventList.Call(); + } - Timer ti = new Timer(); - TimerTask task = new TimerTask() { + @Override + public Waypoint sciGetSelectedWaypoint() { + return getSelectedWaypoint(); + } - @Override - public void run() { - handler.checkReady(ret); - } - }; - ti.schedule(task, 300); + /** + * Returns true, if a Cache selected and this Cache object is valid. + * + * @return + */ + public static boolean isSetSelectedCache() { + if (selectedCache == null) + return false; - } + if (selectedCache.getGcCode().length() == 0) + return false; - @Override - public boolean cancel() { - // TODO Handle Cancel - return false; - } - }); - } else { - handler.checkReady(GroundspeakAPI.chkMembership(true)); + return true; } - } - - @Override - protected String getVersionPrefix() { - return VersionPrefix; - } - - // Interface für den Solver zum Zugriff auf den SelectedCache. - // Direkter Zugriff geht nicht da der Solver im Core definiert ist - @Override - public Cache sciGetSelectedCache() { - return getSelectedCache(); - } - - @Override - public void sciSetSelectedCache(Cache cache) { - setSelectedCache(cache); - CacheListChangedEventList.Call(); - } - - @Override - public void sciSetSelectedWaypoint(Cache cache, Waypoint waypoint) { - setSelectedWaypoint(cache, waypoint); - CacheListChangedEventList.Call(); - } - - @Override - public Waypoint sciGetSelectedWaypoint() { - return getSelectedWaypoint(); - } - - /** - * Returns true, if a Cache selected and this Cache object is valid. - * - * @return - */ - public static boolean isSetSelectedCache() { - if (selectedCache == null) - return false; - - if (selectedCache.getGcCode().length() == 0) - return false; - - return true; - } - }