diff --git a/Android_GUI/AndroidManifest.xml b/Android_GUI/AndroidManifest.xml index 6c8d4f865..e4ba27381 100644 --- a/Android_GUI/AndroidManifest.xml +++ b/Android_GUI/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="20160512" android:versionName="0.8.20160512(Test)"> diff --git a/Android_GUI/project.properties b/Android_GUI/project.properties index 73ae647b6..083b08843 100644 --- a/Android_GUI/project.properties +++ b/Android_GUI/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-21 +target=android-23 diff --git a/Android_GUI/src/de/cachebox_test/NotifyService.java b/Android_GUI/src/de/cachebox_test/NotifyService.java index 5032017cf..9d3006c59 100644 --- a/Android_GUI/src/de/cachebox_test/NotifyService.java +++ b/Android_GUI/src/de/cachebox_test/NotifyService.java @@ -2,7 +2,6 @@ import CB_Locator.Events.GPS_FallBackEvent; import CB_Locator.Events.GPS_FallBackEventList; -import android.app.Notification; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; @@ -12,162 +11,157 @@ public class NotifyService extends Service implements GPS_FallBackEvent { - int mStartMode; // indicates how to behave if the service is killed - boolean mAllowRebind; // indicates whether onRebind should be used + int mStartMode; // indicates how to behave if the service is killed + boolean mAllowRebind; // indicates whether onRebind should be used - final static int myID = 1234; + final static int myID = 1234; - // Binder wird von der ServiceConnection verwendet - private final IBinder mBinder = new LocalBinder(); + // Binder wird von der ServiceConnection verwendet + private final IBinder mBinder = new LocalBinder(); + + /** + * Usere verschachtelte Klasse + */ + class LocalBinder extends Binder { /** - * Usere verschachtelte Klasse + * Damit erhalten wir Zugriff auf unseren Service. Gibt unsere Instanz des NotifyService zurück. */ - class LocalBinder extends Binder { - - /** - * Damit erhalten wir Zugriff auf unseren Service. Gibt unsere Instanz des NotifyService zurück. - */ - NotifyService getService() { - return NotifyService.this; - } - } - - @Override - public void onCreate() { - // The service is being created - super.onCreate(); - GPS_FallBackEventList.Add(this); - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - // The service is starting, due to a call to startService() - return mStartMode; - } - - @SuppressWarnings("deprecation") - @Override - public IBinder onBind(Intent intent) { - // A client is binding to the service with bindService() - - Intent mainIntent = new Intent(this, main.class); - mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); - - // This constructor is deprecated. Use Notification.Builder instead - Notification notice = new Notification(R.drawable.cb_icon_0, "Cachebox", System.currentTimeMillis()); - - // This method is deprecated. Use Notification.Builder instead. - notice.setLatestEventInfo(this, "Cachebox", "is running", pendIntent); - - // notice.flags |= Notification.FLAG_NO_CLEAR; - - // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; - - startForeground(myID, notice); - - return mBinder; - } - - public static boolean finish = false; - - @SuppressWarnings("deprecation") - @Override - public boolean onUnbind(Intent intent) { - // All clients have unbound with unbindService() - - if (finish) { - // CB is closing from User - stopForeground(true); - } else { - // CB is killing - Log.d("CACHEBOX", "Service => ACB is killed"); - Intent mainIntent = new Intent(this, main.class); - mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); - - // This constructor is deprecated. Use Notification.Builder instead - Notification notice = new Notification(R.drawable.cb_killed, "Cachebox", System.currentTimeMillis()); - - // This method is deprecated. Use Notification.Builder instead. - notice.setLatestEventInfo(this, "Cachebox", "was killing", pendIntent); - - // notice.flags |= Notification.FLAG_NO_CLEAR; - - // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; - - startForeground(myID, notice); - - } - - return mAllowRebind; - } - - @Override - public void onRebind(Intent intent) { - // A client is binding to the service with bindService(), - // after onUnbind() has already been called + NotifyService getService() { + return NotifyService.this; } + } + + @Override + public void onCreate() { + // The service is being created + super.onCreate(); + GPS_FallBackEventList.Add(this); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + // The service is starting, due to a call to startService() + return mStartMode; + } + + @Override + public IBinder onBind(Intent intent) { + // A client is binding to the service with bindService() + + Intent mainIntent = new Intent(this, main.class); + mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); + + // // This constructor is deprecated. Use Notification.Builder instead + // Notification notice = new Notification(R.drawable.cb_icon_0, "Cachebox", System.currentTimeMillis()); + // + // // This method is deprecated. Use Notification.Builder instead. + // notice.setLatestEventInfo(this, "Cachebox", "is running", pendIntent); + // + // // notice.flags |= Notification.FLAG_NO_CLEAR; + // + // // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; + // + // startForeground(myID, notice); + + return mBinder; + } + + public static boolean finish = false; + + @Override + public boolean onUnbind(Intent intent) { + // All clients have unbound with unbindService() + + if (finish) { + // CB is closing from User + stopForeground(true); + } else { + // CB is killing + Log.d("CACHEBOX", "Service => ACB is killed"); + Intent mainIntent = new Intent(this, main.class); + mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); + + // // This constructor is deprecated. Use Notification.Builder instead + // Notification notice = new Notification(R.drawable.cb_killed, "Cachebox", System.currentTimeMillis()); + // + // // This method is deprecated. Use Notification.Builder instead. + // notice.setLatestEventInfo(this, "Cachebox", "was killing", pendIntent); + // + // // notice.flags |= Notification.FLAG_NO_CLEAR; + // + // // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; + // + // startForeground(myID, notice); - @SuppressWarnings("deprecation") - @Override - public void onDestroy() { - // The service is no longer used and is being destroyed - - if (!finish) { - Log.d("CACHEBOX", "Service => ACB is killed"); - Intent mainIntent = new Intent(this, main.class); - mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); - - // This constructor is deprecated. Use Notification.Builder instead - Notification notice = new Notification(R.drawable.cb_killed, "Cachebox", System.currentTimeMillis()); - - // This method is deprecated. Use Notification.Builder instead. - notice.setLatestEventInfo(this, "Cachebox", "was killing", pendIntent); - - } - } - - @SuppressWarnings("deprecation") - @Override - public void FallBackToNetworkProvider() { - Intent mainIntent = new Intent(this, main.class); - mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); - - // This constructor is deprecated. Use Notification.Builder instead - Notification notice = new Notification(R.drawable.cb_icon_0, "Cachebox", System.currentTimeMillis()); - - // This method is deprecated. Use Notification.Builder instead. - notice.setLatestEventInfo(this, "Cachebox", "is running", pendIntent); - - // notice.flags |= Notification.FLAG_NO_CLEAR; - - // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; - - startForeground(myID, notice); } - @SuppressWarnings("deprecation") - @Override - public void Fix() { - Intent mainIntent = new Intent(this, main.class); - mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); + return mAllowRebind; + } - // This constructor is deprecated. Use Notification.Builder instead - Notification notice = new Notification(R.drawable.cb_icon_1, "Cachebox", System.currentTimeMillis()); + @Override + public void onRebind(Intent intent) { + // A client is binding to the service with bindService(), + // after onUnbind() has already been called + } - // This method is deprecated. Use Notification.Builder instead. - notice.setLatestEventInfo(this, "Cachebox", "is running", pendIntent); + @Override + public void onDestroy() { + // The service is no longer used and is being destroyed - // notice.flags |= Notification.FLAG_NO_CLEAR; + if (!finish) { + Log.d("CACHEBOX", "Service => ACB is killed"); + Intent mainIntent = new Intent(this, main.class); + mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); - // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; + // // This constructor is deprecated. Use Notification.Builder instead + // Notification notice = new Notification(R.drawable.cb_killed, "Cachebox", System.currentTimeMillis()); + // + // // This method is deprecated. Use Notification.Builder instead. + // notice.setLatestEventInfo(this, "Cachebox", "was killing", pendIntent); - startForeground(myID, notice); } + } + + @Override + public void FallBackToNetworkProvider() { + Intent mainIntent = new Intent(this, main.class); + mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); + + // // This constructor is deprecated. Use Notification.Builder instead + // Notification notice = new Notification(R.drawable.cb_icon_0, "Cachebox", System.currentTimeMillis()); + // + // // This method is deprecated. Use Notification.Builder instead. + // notice.setLatestEventInfo(this, "Cachebox", "is running", pendIntent); + // + // // notice.flags |= Notification.FLAG_NO_CLEAR; + // + // // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; + // + // startForeground(myID, notice); + } + + @Override + public void Fix() { + Intent mainIntent = new Intent(this, main.class); + mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent pendIntent = PendingIntent.getActivity(this, 0, mainIntent, 0); + + // // This constructor is deprecated. Use Notification.Builder instead + // Notification notice = new Notification(R.drawable.cb_icon_1, "Cachebox", System.currentTimeMillis()); + // + // // This method is deprecated. Use Notification.Builder instead. + // notice.setLatestEventInfo(this, "Cachebox", "is running", pendIntent); + // + // // notice.flags |= Notification.FLAG_NO_CLEAR; + // + // // TODO no Clear wieder einschalten => runNotification.flags |= Notification.FLAG_NO_CLEAR; + // + // startForeground(myID, notice); + } } diff --git a/Android_GUI/src/de/cachebox_test/PermissionCheck.java b/Android_GUI/src/de/cachebox_test/PermissionCheck.java new file mode 100644 index 000000000..955ef9b9f --- /dev/null +++ b/Android_GUI/src/de/cachebox_test/PermissionCheck.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2016 team-cachebox.de + * + * Licensed under the : GNU General Public License (GPL); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.gnu.org/licenses/gpl.html + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.cachebox_test; + +import java.util.ArrayList; + +import android.app.Activity; +import android.content.pm.PackageManager; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; + +/** + * Created by Longri on 11.05.2016. + */ +public class PermissionCheck { + + public static final int MY_PERMISSIONS_REQUEST = 11052016; + static final String WAKE_LOCK = "android.permission.WAKE_LOCK"; + static final String INTERNET = "android.permission.INTERNET"; + static final String ACCESS_NETWORK_STATE = "android.permission.ACCESS_NETWORK_STATE"; + static final String RECORD_AUDIO = "android.permission.RECORD_AUDIO"; + static final String CAMERA = "android.permission.CAMERA"; + static final String VIBRATE = "android.permission.VIBRATE"; + static final String WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE"; + static final String READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE"; + + static final String[] NEEDED_PERMISSIONS = new String[] { WAKE_LOCK, INTERNET, ACCESS_NETWORK_STATE, RECORD_AUDIO, CAMERA, VIBRATE, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE }; + + public static void checkNeededPermissions(Activity context) { + ArrayList DENIED_List = new ArrayList(); + + for (String permission : NEEDED_PERMISSIONS) { + if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) { + DENIED_List.add(permission); + } + } + + if (!DENIED_List.isEmpty()) { + String[] ar = DENIED_List.toArray(new String[DENIED_List.size()]); + ActivityCompat.requestPermissions(context, ar, MY_PERMISSIONS_REQUEST); + } + + } + +} diff --git a/Android_GUI/src/de/cachebox_test/splash.java b/Android_GUI/src/de/cachebox_test/splash.java index 81a370d23..8408d8130 100644 --- a/Android_GUI/src/de/cachebox_test/splash.java +++ b/Android_GUI/src/de/cachebox_test/splash.java @@ -19,8 +19,10 @@ import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import org.mapsforge.map.android.graphics.ext_AndroidGraphicFactory; import org.mapsforge.map.model.DisplayModel; @@ -74,6 +76,7 @@ import android.content.SharedPreferences.Editor; import android.content.UriPermission; import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Color; @@ -280,6 +283,10 @@ protected void onStart() { super.onStart(); Log.debug(log, "onStart"); + if (android.os.Build.VERSION.SDK_INT >= 23) { + PermissionCheck.checkNeededPermissions(this); + } + // initial GDX Gdx.files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath()); // first, try to find stored preferences of workPath @@ -1330,4 +1337,58 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { return super.onKeyDown(keyCode, event); } + + //############################################################################## + // Implementation of Permission check with Android Version >23 + //############################################################################## + + @TargetApi(23) + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + switch (requestCode) { + case PermissionCheck.MY_PERMISSIONS_REQUEST: { + Map perms = new HashMap(); + // Initial + + for (String permission : PermissionCheck.NEEDED_PERMISSIONS) { + perms.put(permission, PackageManager.PERMISSION_GRANTED); + } + + // Fill with results + for (int i = 0; i < permissions.length; i++) + perms.put(permissions[i], grantResults[i]); + + // check all + ArrayList deniedList = new ArrayList(); + for (String permission : PermissionCheck.NEEDED_PERMISSIONS) { + if (perms.get(permission) != PackageManager.PERMISSION_GRANTED) + deniedList.add(permission); + } + + if (!deniedList.isEmpty()) { + // Permission Denied + String br = System.getProperty("line.separator"); + StringBuilder sb = new StringBuilder(); + sb.append("Some Permission is Denied"); + sb.append(br); + + for (String denied : deniedList) { + sb.append(denied); + sb.append(br); + } + sb.append(br); + + sb.append("Cachbox will close"); + + Toast.makeText(this, sb.toString(), Toast.LENGTH_LONG).show(); + + // close + this.finish(); + } + } + break; + default: + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + } + } } diff --git a/CB_UI/src/CB_UI/GlobalCore.java b/CB_UI/src/CB_UI/GlobalCore.java index 0bb24ebbb..16a777eaa 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 = 20160419; + public static final int CurrentRevision = 20160512; - 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"; - 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 Track AktuelleRoute = null; + public static int aktuelleRouteCount = 0; + // public static long TrackDistance; - public static boolean switchToCompassCompleted = false; + public static boolean switchToCompassCompleted = false; - public static GlobalLocationReceiver receiver; + public static GlobalLocationReceiver receiver; - private static Cache selectedCache = null; - private static boolean autoResort; + private static Cache selectedCache = null; + private static boolean autoResort; - public static void setSelectedCache(Cache cache) { - setSelectedWaypoint(cache, null); - } + public static void setSelectedCache(Cache cache) { + setSelectedWaypoint(cache, null); + } - public static Cache getSelectedCache() { - return selectedCache; - } + public static Cache getSelectedCache() { + return selectedCache; + } - public static boolean selectedCachehasSpoiler() { - if (selectedCache != null) { - return selectedCache.hasSpoiler(); - } else - return false; - } + public static boolean selectedCachehasSpoiler() { + if (selectedCache != null) { + return selectedCache.hasSpoiler(); + } else + return false; + } - private static Cache nearestCache = null; + private static Cache nearestCache = null; - public static Cache NearestCache() { - return nearestCache; - } + public static Cache NearestCache() { + return nearestCache; + } - private static Waypoint selectedWaypoint = null; + private static Waypoint selectedWaypoint = null; - public static void setSelectedWaypoint(Cache cache, Waypoint waypoint) { - if (cache == null) - return; + public static void setSelectedWaypoint(Cache cache, Waypoint waypoint) { + if (cache == null) + return; - 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(",")); - } - } + 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; } - /** - * 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; - } + // // 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; - // // 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; + // load Detail Info if not available + if (selectedCache.detail == null) { + selectedCache.loadDetail(); + } - // load Detail Info if not available - if (selectedCache.detail == null) { - selectedCache.loadDetail(); - } + SelectedCacheEventList.Call(selectedCache, selectedWaypoint); - SelectedCacheEventList.Call(selectedCache, selectedWaypoint); + if (changeAutoResort) { + // switch off auto select + GlobalCore.setAutoResort(false); + } - if (changeAutoResort) { - // switch off auto select - GlobalCore.setAutoResort(false); - } + GL.that.renderOnce(); + } - GL.that.renderOnce(); - } + public static void setNearestCache(Cache Cache) { + nearestCache = Cache; + } - public static void setNearestCache(Cache Cache) { - nearestCache = Cache; - } + public static Waypoint getSelectedWaypoint() { + return selectedWaypoint; + } - public static Waypoint getSelectedWaypoint() { - return selectedWaypoint; + /** + * 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; } - - /** - * 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 (PlatformConnector.isOnline()) { + return true; } - - 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; + 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; } - public static String getVersionString() { - final String ret = "Version: " + CurrentVersion + String.valueOf(CurrentRevision) + " " + (VersionPrefix.equals("") ? "" : "(" + VersionPrefix + ")"); - return ret; + if (JokerPwExist) { + // Log.info(log, "GlobalCore.JokerisOnline() - no Joker Password"); + return false; + } + if (PlatformConnector.isOnline()) { + return true; } + return false; + } - public static Coordinate getSelectedCoord() { - Coordinate ret = null; + public static String getVersionString() { + final String ret = "Version: " + CurrentVersion + String.valueOf(CurrentRevision) + " " + (VersionPrefix.equals("") ? "" : "(" + VersionPrefix + ")"); + return ret; + } - if (selectedWaypoint != null) { - ret = selectedWaypoint.Pos; - } else if (selectedCache != null) { - ret = selectedCache.Pos; - } + public static Coordinate getSelectedCoord() { + Coordinate ret = null; - return ret; + if (selectedWaypoint != null) { + ret = selectedWaypoint.Pos; + } else if (selectedCache != null) { + ret = selectedCache.Pos; } - public static void checkSelectedCacheValid() { + return ret; + } - CacheList List = Database.Data.Query; + public static void checkSelectedCacheValid() { - // 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."); - } - } + CacheList List = Database.Data.Query; - public static boolean getAutoResort() { - return autoResort; + // 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 void setAutoResort(boolean value) { - GlobalCore.autoResort = value; + // 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."); } + } - private static CancelWaitDialog wd; + public static boolean getAutoResort() { + return autoResort; + } - public static boolean RunFromSplash = false; + public static void setAutoResort(boolean value) { + GlobalCore.autoResort = value; + } - public static CancelWaitDialog ImportSpoiler() { - wd = CancelWaitDialog.ShowWait(Translation.Get("downloadSpoiler"), DownloadAnimation.GetINSTANCE(), new IcancelListener() { + private static CancelWaitDialog wd; - @Override - public void isCanceld() { - // TODO Handle Cancel + public static boolean RunFromSplash = false; - } - }, new cancelRunnable() { + public static CancelWaitDialog ImportSpoiler() { + wd = CancelWaitDialog.ShowWait(Translation.Get("downloadSpoiler"), DownloadAnimation.GetINSTANCE(), new IcancelListener() { - @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; - } - } + @Override + public void isCanceld() { + // TODO Handle Cancel - @Override - public boolean cancel() { - // TODO Handle Cancel - return false; - } - }); - return wd; - } + } + }, new cancelRunnable() { - public interface IChkRedyHandler { - public void checkReady(int MemberTypeId); - } + @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; + } - static CancelWaitDialog dia; + if (result == GroundspeakAPI.API_IS_UNAVAILABLE) { + GL.that.Toast(ApiUnavailable.INSTANCE); + return; + } + } - public static void MsgDownloadLimit() { - GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { + @Override + public boolean cancel() { + // TODO Handle Cancel + return false; + } + }); + return wd; + } - @Override - public void run() { - GL_MsgBox.Show(Translation.Get("Limit_msg"), Translation.Get("Limit_title"), MessageBoxButtons.OK, MessageBoxIcon.GC_Live, null); - } - }); + public interface IChkRedyHandler { + public void checkReady(int MemberTypeId); + } - } + static CancelWaitDialog dia; - public static void chkAPiLogInWithWaitDialog(final IChkRedyHandler handler) { + public static void MsgDownloadLimit() { + GL.that.RunOnGLWithThreadCheck(new IRunOnGL() { - if (GroundspeakAPI.ApiLimit()) { - MsgDownloadLimit(); - return; - } + @Override + public void run() { + GL_MsgBox.Show(Translation.Get("Limit_msg"), Translation.Get("Limit_title"), MessageBoxButtons.OK, MessageBoxIcon.GC_Live, null); + } + }); - 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) { - @Override - protected String getVersionPrefix() { - return VersionPrefix; + if (GroundspeakAPI.ApiLimit()) { + MsgDownloadLimit(); + return; } - // 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(); - } + if (!GroundspeakAPI.mAPI_isChecked()) { + dia = CancelWaitDialog.ShowWait("chk API Key", DownloadAnimation.GetINSTANCE(), new IcancelListener() { - @Override - public void sciSetSelectedCache(Cache cache) { - setSelectedCache(cache); - CacheListChangedEventList.Call(); - } + @Override + public void isCanceld() { + dia.close(); + } + }, new cancelRunnable() { - @Override - public void sciSetSelectedWaypoint(Cache cache, Waypoint waypoint) { - setSelectedWaypoint(cache, waypoint); - CacheListChangedEventList.Call(); - } + @Override + public void run() { + final int ret = GroundspeakAPI.chkMembership(false); + dia.close(); - @Override - public Waypoint sciGetSelectedWaypoint() { - return getSelectedWaypoint(); - } + Timer ti = new Timer(); + TimerTask task = new TimerTask() { - /** - * Returns true, if a Cache selected and this Cache object is valid. - * - * @return - */ - public static boolean isSetSelectedCache() { - if (selectedCache == null) - return false; + @Override + public void run() { + handler.checkReady(ret); + } + }; + ti.schedule(task, 300); - if (selectedCache.getGcCode().length() == 0) - return false; + } - return true; + @Override + public boolean cancel() { + // TODO Handle Cancel + return false; + } + }); + } else { + handler.checkReady(GroundspeakAPI.chkMembership(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; + } + }