diff --git a/CongressRoutePlanner/app/build.gradle b/CongressRoutePlanner/app/build.gradle deleted file mode 100644 index e69ea72..0000000 --- a/CongressRoutePlanner/app/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -apply plugin: 'com.android.application' - -ext.versionMajor = 4 -ext.versionMinor = 1 -ext.versionPatch = 1 -ext.minimumSdkVersion = 14 - -android { - compileSdkVersion 29 - buildToolsVersion '29.0.2' - - defaultConfig { - applicationId "de.c3nav.droid" - minSdkVersion project.ext.minimumSdkVersion - targetSdkVersion 29 - versionCode generateVersionCode() - versionName generateVersionName() - buildConfigField "String", "WEB_URL", "\"https://36c3.c3nav.de\"" - } - signingConfigs { - release { - storeFile file("../../c3nav.keystore") - storePassword System.getenv("KSTOREPWD") - keyAlias "c3nav" - keyPassword System.getenv("KSTOREPWD") - } - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - zipAlignEnabled true - signingConfig signingConfigs.release - } - debug { - debuggable true - applicationIdSuffix ".debug" - versionNameSuffix "-debug" - zipAlignEnabled true - } - } - lintOptions { - disable 'AddJavascriptInterface', 'SetJavaScriptEnabled' - } -} - -private Integer generateVersionCode() { - return ext.minimumSdkVersion * 1000000 + ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch -} - -private String generateVersionName() { - return "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}" -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - testImplementation 'junit:junit:4.12' - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.0.0' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.preference:preference:1.1.0' - implementation 'androidx.legacy:legacy-preference-v14:1.0.0' - implementation 'com.android.support:support-annotations:28.0.0' -} diff --git a/CongressRoutePlanner/app/build.gradle.kts b/CongressRoutePlanner/app/build.gradle.kts new file mode 100644 index 0000000..1d27f37 --- /dev/null +++ b/CongressRoutePlanner/app/build.gradle.kts @@ -0,0 +1,68 @@ +plugins { + id("com.android.application") +} + +val versionMajor = 4 +val versionMinor = 2 +val versionPatch = 5 +val minimumSdkVersion = 14 + +android { + namespace = "de.c3nav.droid" + compileSdk = 34 + buildToolsVersion = "34.0.0" + + defaultConfig { + applicationId = "de.c3nav.droid" + minSdk = minimumSdkVersion + targetSdk = 34 + versionCode = generateVersionCode() + versionName = generateVersionName() + buildConfigField("String", "WEB_URL", "\"https://37c3.c3nav.de\"") + } + signingConfigs { + create("release") { + storeFile = file("../../c3nav.keystore") + storePassword = System.getenv("KSTOREPWD") + keyAlias = "c3nav" + keyPassword = System.getenv("KSTOREPWD") + } + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + signingConfig = signingConfigs.findByName("release") + } + debug { + isDebuggable = true + applicationIdSuffix = ".debug" + versionNameSuffix = "-debug" + } + } + buildFeatures { + buildConfig = true + } + lint { + disable.add("AddJavascriptInterface") + disable.add("SetJavaScriptEnabled") + } +} + +fun generateVersionCode(): Int { + return minimumSdkVersion * 1000000 + versionMajor * 10000 + versionMinor * 100 + versionPatch +} + +fun generateVersionName(): String { + return "${versionMajor}.${versionMinor}.${versionPatch}" +} + +dependencies { + implementation("androidx.appcompat:appcompat:1.1.0") + implementation("com.google.android.material:material:1.0.0") + implementation("androidx.legacy:legacy-support-v4:1.0.0") + implementation("androidx.preference:preference:1.1.0") + implementation("androidx.legacy:legacy-preference-v14:1.0.0") + implementation("com.android.support:support-annotations:28.0.0") + testImplementation("junit:junit:4.12") +} diff --git a/CongressRoutePlanner/app/src/main/AndroidManifest.xml b/CongressRoutePlanner/app/src/main/AndroidManifest.xml index 9fbd485..107ff18 100644 --- a/CongressRoutePlanner/app/src/main/AndroidManifest.xml +++ b/CongressRoutePlanner/app/src/main/AndroidManifest.xml @@ -1,17 +1,18 @@ - + + - + - - - - - - - - - - + + + + diff --git a/CongressRoutePlanner/app/src/main/ic_launcher_basic-playstore.png b/CongressRoutePlanner/app/src/main/ic_launcher_basic-playstore.png new file mode 100644 index 0000000..91e6dd9 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/ic_launcher_basic-playstore.png differ diff --git a/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/MainActivity.java b/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/MainActivity.java index 8312a93..a9a44dc 100644 --- a/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/MainActivity.java +++ b/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/MainActivity.java @@ -16,10 +16,15 @@ import android.graphics.Typeface; import android.graphics.drawable.Icon; import android.media.MediaPlayer; +import android.net.MacAddress; import android.net.ParseException; import android.net.Uri; import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; +import android.net.wifi.rtt.RangingRequest; +import android.net.wifi.rtt.RangingResult; +import android.net.wifi.rtt.RangingResultCallback; +import android.net.wifi.rtt.WifiRttManager; import android.os.Build; import android.os.Bundle; import android.os.Handler; @@ -195,7 +200,12 @@ protected void onCreate(Bundle savedInstanceState) { intentCategories.contains(Intent.CATEGORY_DEFAULT) || intentCategories.contains(Intent.CATEGORY_BROWSABLE) ); - sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + Context context = getApplicationContext(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + sharedPrefs = context.getSharedPreferences(PreferenceManager.getDefaultSharedPreferencesName(context), Context.MODE_PRIVATE); + } else { + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + } locationPermissionRequested = sharedPrefs.getBoolean(getString(R.string.location_permission_requested_key), false); if (BuildConfig.DEBUG && sharedPrefs.getBoolean(getString(R.string.developer_mode_enabled_key), false)) { settingDeveloperInstanceUrl = sharedPrefs.getString(getString(R.string.developer_instance_url_key), ""); @@ -220,57 +230,58 @@ public boolean onNavigationItemSelected(MenuItem item) { Intent browserIntent; Uri uri; mDrawerLayout.closeDrawers(); - switch (item.getItemId()) { - case R.id.accountLink: - if (loggedIn) { - uri = MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/account/").build(); - } else { - uri = MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/login") - .appendQueryParameter("next", Uri.parse(webView.getUrl()).getPath()).build(); - } - MainActivity.this.evaluateJavascript("window.openInModal ? openInModal('" + uri.toString() + "') : window.location='" + uri.toString() + "';"); - return true; - case R.id.editorChangesLink: - webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/editor/changeset/").build().toString()); - return true; - case R.id.editorDashboardLink: - webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/editor/user/").build().toString()); - return true; - case R.id.mapLink: - webView.loadUrl(instanceBaseUrl.toString()); - return true; - case R.id.editorLink: - webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/editor/").build().toString()); - return true; - case R.id.controlPanelLink: - webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/control/").build().toString()); - return true; - case R.id.apiLink: - browserIntent = new Intent(Intent.ACTION_VIEW, MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/api/").build()); - startActivity(browserIntent); - return true; - case R.id.twitterLink: - browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/c3nav/")); - startActivity(browserIntent); - return true; - case R.id.githubLink: - browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/c3nav/")); - startActivity(browserIntent); - return true; - case R.id.aboutLink: - uri = MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/about/").build(); - MainActivity.this.evaluateJavascript("window.openInModal ? openInModal('" + uri.toString() + "') : window.location='" + uri.toString() + "';"); - return true; - case R.id.settingsButton: - Intent settingsIntent = new Intent(MainActivity.this, SettingsActivity.class); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - ActivityCompat.startActivityForResult(MainActivity.this, settingsIntent, SETTINGS_REQUEST, ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this).toBundle()); - } else { - startActivityForResult(settingsIntent, SETTINGS_REQUEST); - } - default: - return false; + int itemId = item.getItemId(); + if (itemId == R.id.accountLink) { + if (loggedIn) { + uri = MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/account/").build(); + } else { + uri = MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/login") + .appendQueryParameter("next", Uri.parse(webView.getUrl()).getPath()).build(); + } + MainActivity.this.evaluateJavascript("window.openInModal ? openInModal('" + uri.toString() + "') : window.location='" + uri.toString() + "';"); + return true; + } else if (itemId == R.id.editorChangesLink) { + webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/editor/changeset/").build().toString()); + return true; + } else if (itemId == R.id.editorDashboardLink) { + webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/editor/user/").build().toString()); + return true; + } else if (itemId == R.id.mapLink) { + webView.loadUrl(instanceBaseUrl.toString()); + return true; + } else if (itemId == R.id.editorLink) { + webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/editor/").build().toString()); + return true; + } else if (itemId == R.id.controlPanelLink) { + webView.loadUrl(MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/control/").build().toString()); + return true; + } else if (itemId == R.id.apiLink) { + browserIntent = new Intent(Intent.ACTION_VIEW, MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/api/").build()); + startActivity(browserIntent); + return true; + } else if (itemId == R.id.fediLink) { + browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://chaos.social/@c3nav")); + startActivity(browserIntent); + return true; + } else if (itemId == R.id.githubLink) { + browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/c3nav/")); + startActivity(browserIntent); + return true; + } else if (itemId == R.id.aboutLink) { + uri = MainActivity.this.instanceBaseUrl.buildUpon().encodedPath("/about/").build(); + MainActivity.this.evaluateJavascript("window.openInModal ? openInModal('" + uri.toString() + "') : window.location='" + uri.toString() + "';"); + return true; + } else if (itemId == R.id.settingsButton) { + Intent settingsIntent = new Intent(MainActivity.this, SettingsActivity.class); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + ActivityCompat.startActivityForResult(MainActivity.this, settingsIntent, SETTINGS_REQUEST, ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this).toBundle()); + } else { + startActivityForResult(settingsIntent, SETTINGS_REQUEST); + } + + return false; } + return false; } }); @@ -289,7 +300,7 @@ public boolean onNavigationItemSelected(MenuItem item) { authLoginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - MainActivity.this.handleLoginScreenSubmitt(); + MainActivity.this.handleLoginScreenSubmit(); } }); @@ -298,7 +309,7 @@ public void onClick(View view) { public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEND || keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) { - MainActivity.this.handleLoginScreenSubmitt(); + MainActivity.this.handleLoginScreenSubmit(); return true; } return false; @@ -327,7 +338,8 @@ public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent if (!splashScreenDone && activityStartedFromLauncher) { mDrawerLayout.closeDrawers(); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); - showSplash(); + //showSplash(); + showLogoScreen(); } else { skipSplash(); } @@ -356,7 +368,7 @@ public void onPageFinished(WebView view, String url) { initialPageLoaded = true; Log.d("c3navWebView", "loading ended"); maybeEndSplash(); - maybeHideLoginScreen(); + maybeHideLoginOrLogoScreen(); } @Override @@ -663,6 +675,13 @@ protected void showLogoScreen() { logoScreenIsVisible = true; } + protected void hideLogoScreen() { + TransitionManager.go(new Scene((ViewGroup) logoScreen.getParent()), new Slide(Gravity.LEFT)); + logoScreen.setVisibility(View.GONE); + logoScreenMessage.setVisibility(View.GONE); + logoScreenIsVisible = false; + } + protected void showLoginScreen(String message) { if (!logoScreenIsVisible) showLogoScreen(); logoScreenMessage.setText(R.string.auth_title); @@ -696,15 +715,12 @@ protected void showLoginScreen() { } protected void hideLoginScreen() { - TransitionManager.go(new Scene((ViewGroup) logoScreen.getParent()), new Slide(Gravity.LEFT)); - logoScreen.setVisibility(View.GONE); - logoScreenMessage.setVisibility(View.GONE); + hideLogoScreen(); authUsername.setVisibility(View.GONE); authPassword.setVisibility(View.GONE); authMessage.setVisibility(View.GONE); authLoginButton.setVisibility(View.GONE); loginScreenIsActive = false; - logoScreenIsVisible = false; } protected void maybeShowLoginScreen() { @@ -717,13 +733,15 @@ protected void maybeShowLoginScreen() { } } - protected void maybeHideLoginScreen() { + protected void maybeHideLoginOrLogoScreen() { if (loginScreenIsActive && initialPageLoaded) { hideLoginScreen(); + } else if (logoScreenIsVisible && initialPageLoaded) { + hideLogoScreen(); } } - protected void handleLoginScreenSubmitt() { + protected void handleLoginScreenSubmit() { if (lastAuthHandler != null) { lastAuthHandler.proceed(authUsername.getText().toString(), authPassword.getText().toString()); lastAuthHandler = null; @@ -746,7 +764,7 @@ protected void onSaveInstanceState(Bundle savedInstanceState) { protected void onResume() { super.onResume(); Log.d("lifecycleEvents", "onResume called"); - evaluateJavascript("if (mobileclientOnResume) {mobileclientOnResume()};"); + evaluateJavascript("if (window.mobileclientOnResume) {mobileclientOnResume()};"); registerReceiver(wifiReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); if(checkLocationPermission(false, true)) startScan(); if (splashScreenPaused && !splashScreenDone) { @@ -821,10 +839,10 @@ protected boolean checkLocationPermission(boolean requestPermission, boolean ign if (ignoreCache || locationPermissionCache == null) { int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION); - locationPermissionCache = new Boolean(permissionCheck == PackageManager.PERMISSION_GRANTED); + locationPermissionCache = permissionCheck == PackageManager.PERMISSION_GRANTED; } - if (!locationPermissionCache.booleanValue()) { + if (!locationPermissionCache) { if (requestPermission) { ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, @@ -848,7 +866,6 @@ protected boolean hasLocationPermission() { return checkLocationPermission(false); } - @SuppressWarnings("deprecation") protected void startScan() { if (!settingUseWifiLocating) return; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { @@ -1092,71 +1109,177 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - mDrawerLayout.openDrawer(GravityCompat.START); - return true; - case R.id.share: - Intent i = new Intent(Intent.ACTION_SEND); - i.setType("text/plain"); - i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); - i.putExtra(Intent.EXTRA_TEXT, webView.getUrl()); - startActivity(Intent.createChooser(i, getString(R.string.share))); - return true; - case R.id.refresh: - webView.loadUrl(instanceBaseUrl.toString()); - return true; - default: - return super.onOptionsItemSelected(item); + int itemId = item.getItemId(); + if (itemId == android.R.id.home) { + mDrawerLayout.openDrawer(GravityCompat.START); + return true; + } else if (itemId == R.id.share) { + Intent i = new Intent(Intent.ACTION_SEND); + i.setType("text/plain"); + i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); + i.putExtra(Intent.EXTRA_TEXT, webView.getUrl()); + startActivity(Intent.createChooser(i, getString(R.string.share))); + return true; + } else if (itemId == R.id.refresh) { + webView.loadUrl(instanceBaseUrl.toString()); + return true; } + return super.onOptionsItemSelected(item); } - class WifiReceiver extends BroadcastReceiver { - public void onReceive(Context c, Intent intent) { - - if (!checkLocationPermission()) return; + static class WifiResult { + public final ScanResult scan; + public final RangingResult rtt; + WifiResult(@NonNull ScanResult scan, RangingResult rtt) { + this.scan = scan; + this.rtt = rtt; + } + } - List wifiList = wifiManager.getScanResults(); - JSONArray ja = new JSONArray(); - Map newLevelValues = new HashMap(); - for (ScanResult result : wifiList) { - JSONObject jo = new JSONObject(); - try { - jo.put("bssid", result.BSSID); - jo.put("ssid", result.SSID); - jo.put("level", result.level); - jo.put("frequency", result.frequency); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - if (SystemClock.elapsedRealtime() - result.timestamp / 1000 > 1000) { - continue; - } - jo.put("last", SystemClock.elapsedRealtime() - result.timestamp / 1000); - } else { - // Workaround for older devices: If the signal level did not change - // at all since the last scan, we will assume that it is a cached - // value and should not be used. - newLevelValues.put(result.BSSID, result.level); - if (lastLevelValues.containsKey(result.BSSID) && lastLevelValues.get(result.BSSID) == result.level) { - Log.d("scan result", "Discard " + result.BSSID + " because level did not change"); - continue; - } - } - ja.put(jo); - } catch (JSONException e) { - e.printStackTrace(); + public void processWifiResults(List results) { + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + RangingRequest.Builder builder = new RangingRequest.Builder(); + builder.setRttBurstSize(16); + // todo: use max peers + int numPeers = 0; + for (ScanResult scanResult : results) { + if (scanResult.is80211mcResponder()) { + builder.addAccessPoint(scanResult); + Log.d("rtt", String.format("rtt-capable access point: %s", scanResult.BSSID)); + numPeers += 1; } } - Log.d("scan result", ja.toString()); - mobileClient.setNearbyStations(ja); - lastLevelValues = newLevelValues; + if (numPeers == 0) { + processCompleteWifiResultsWithoutRtt(results); + return; + } + RangingRequest req = builder.build(); + WifiRttManager mgr = (WifiRttManager) this.getSystemService(Context.WIFI_RTT_RANGING_SERVICE); + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, Manifest.permission.NEARBY_WIFI_DEVICES) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.NEARBY_WIFI_DEVICES}, 0); + // TODO: we are already requesting permissions in another place, it should all happen centralised + + processCompleteWifiResultsWithoutRtt(results); + return; + } + Log.d("rtt", String.format("starting rtt ranging with %d peers", numPeers)); + mgr.startRanging(req, getMainExecutor(), new RangingResultCallback() { - webView.post(new Runnable() { @Override - public void run() { - MainActivity.this.evaluateJavascript("nearby_stations_available();"); + public void onRangingFailure(int code) { + Log.w("rtt", String.format("ranging failure: %d", code)); + processCompleteWifiResultsWithoutRtt(results); + } + + @Override + public void onRangingResults(@NonNull List rangingResults) { + Map resultMap = new HashMap<>(); + for (ScanResult result : results) { + resultMap.put(result.BSSID, new WifiResult(result, null)); + } + for (RangingResult result : rangingResults) { + if (result.getStatus() == RangingResult.STATUS_SUCCESS) { + Log.d("rtt", String.format("ranging success: %s", result)); + MacAddress mac = result.getMacAddress(); + if (mac != null) { + WifiResult entry = resultMap.get(mac.toString()); + if (entry != null) { + ScanResult scanResult = entry.scan; + resultMap.put(scanResult.BSSID, new WifiResult(scanResult, result)); + } else { + Log.w("rtt", String.format("got result for unknown mac %s", mac)); + } + } else { + Log.w("rtt", "no mac address in result"); + } + + } else { + Log.d("rtt", String.format("ranging failure: %s", result)); + } + } + List finalResults = new ArrayList<>(resultMap.size()); + finalResults.addAll(resultMap.values()); + processCompleteWifiResults(finalResults); } }); + + + } + } + + + public void processCompleteWifiResults(List results) { + JSONArray ja = new JSONArray(); + Map newLevelValues = new HashMap(); + for (WifiResult result : results) { + JSONObject jo = new JSONObject(); + try { + jo.put("bssid", result.scan.BSSID); + jo.put("ssid", result.scan.SSID); + jo.put("rssi", result.scan.level); + jo.put("frequency", result.scan.frequency); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + jo.put("supports80211mc", result.scan.is80211mcResponder()); + } + if (result.rtt != null) { + JSONObject rtt = new JSONObject(); + rtt.put("distance_mm", result.rtt.getDistanceMm()); + rtt.put("distance_std_dev_mm", result.rtt.getDistanceStdDevMm()); + rtt.put("measurement_bandwidth", result.rtt.getMeasurementBandwidth()); + rtt.put("num_attempted_measurements", result.rtt.getNumAttemptedMeasurements()); + rtt.put("num_successful_measurements", result.rtt.getNumSuccessfulMeasurements()); + rtt.put("ranging_timestamp_millis", result.rtt.getRangingTimestampMillis()); + jo.put("rtt", rtt); + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (SystemClock.elapsedRealtime() - result.scan.timestamp / 1000 > 1000) { + continue; + } + jo.put("last", SystemClock.elapsedRealtime() - result.scan.timestamp / 1000); + } else { + // Workaround for older devices: If the signal level did not change + // at all since the last scan, we will assume that it is a cached + // value and should not be used. + newLevelValues.put(result.scan.BSSID, result.scan.level); + if (lastLevelValues.containsKey(result.scan.BSSID) + && lastLevelValues.get(result.scan.BSSID) == result.scan.level) { + Log.d("scan result.scan", "Discard " + result.scan.BSSID + " because level did not change"); + continue; + } + } + ja.put(jo); + } catch (JSONException e) { + e.printStackTrace(); + } + } + Log.d("scan result", ja.toString()); + mobileClient.setNearbyStations(ja); + lastLevelValues = newLevelValues; + + webView.post(new Runnable() { + @Override + public void run() { + MainActivity.this.evaluateJavascript("nearby_stations_available();"); + } + }); + } + + public void processCompleteWifiResultsWithoutRtt(List results) { + List new_results = new ArrayList<>(results.size()); + for (ScanResult result : results) { + new_results.add(new WifiResult(result, null)); + } + processCompleteWifiResults(new_results); + } + + class WifiReceiver extends BroadcastReceiver { + public void onReceive(Context c, Intent intent) { + + if (!checkLocationPermission()) return; + + List wifiList = wifiManager.getScanResults(); + MainActivity.this.processWifiResults(wifiList); } } @@ -1174,7 +1297,6 @@ public void onAttachedToWindow() { setWindowFlags(); } - @SuppressWarnings("deprecation") private void setWindowFlags() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) { if ((settingKeepOnTop && !isInEditor()) || settingKeepScreenOn && isWifiMeasurementRunning()) { @@ -1212,7 +1334,7 @@ public ShortcutInfo getShortcutInfo(@NonNull String id, @NonNull String shortLab } @RequiresApi(Build.VERSION_CODES.N_MR1) - public ShortcutInfo getShortcutInfo(@NonNull String id, @NonNull int shortLabelRessource, int longLabelRessource, @NonNull int iconRessource, @NonNull String action, Uri data) { + public ShortcutInfo getShortcutInfo(@NonNull String id, int shortLabelRessource, int longLabelRessource, int iconRessource, @NonNull String action, Uri data) { String shortLabel = getString(shortLabelRessource); String longLabel = (longLabelRessource != -1) ? getString(longLabelRessource) : null; Icon icon = Icon.createWithResource(getApplicationContext(), iconRessource); diff --git a/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/SettingsFragment.java b/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/SettingsFragment.java index ce4ad6a..3ac6ceb 100644 --- a/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/SettingsFragment.java +++ b/CongressRoutePlanner/app/src/main/java/de/c3nav/droid/SettingsFragment.java @@ -1,8 +1,10 @@ package de.c3nav.droid; import android.Manifest; +import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import androidx.preference.SwitchPreference; @@ -16,7 +18,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { - private SharedPreferences sharePrefs; + private SharedPreferences sharedPrefs; public CheckBoxPreference useWifiLocating; private PreferenceCategory developerSettings; @@ -31,8 +33,13 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.preferences, rootKey); useWifiLocating = (CheckBoxPreference)this.findPreference(getString(R.string.use_wifi_locating_key)); - sharePrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - if (sharePrefs.getBoolean(getString(R.string.use_wifi_locating_key), true) && !checkLocationPermisson()) { + Context context = getContext(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + sharedPrefs = context.getSharedPreferences(PreferenceManager.getDefaultSharedPreferencesName(context), Context.MODE_PRIVATE); + } else { + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + } + if (sharedPrefs.getBoolean(getString(R.string.use_wifi_locating_key), true) && !checkLocationPermisson()) { useWifiLocating.setChecked(false); } useWifiLocating.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { diff --git a/CongressRoutePlanner/app/src/main/res/drawable/ic_launcher_basic_foreground.xml b/CongressRoutePlanner/app/src/main/res/drawable/ic_launcher_basic_foreground.xml new file mode 100644 index 0000000..1b2fc36 --- /dev/null +++ b/CongressRoutePlanner/app/src/main/res/drawable/ic_launcher_basic_foreground.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/CongressRoutePlanner/app/src/main/res/drawable/ic_navigation.xml b/CongressRoutePlanner/app/src/main/res/drawable/ic_navigation.xml new file mode 100644 index 0000000..4d80b3c --- /dev/null +++ b/CongressRoutePlanner/app/src/main/res/drawable/ic_navigation.xml @@ -0,0 +1,5 @@ + + + diff --git a/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_build.xml b/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_build.xml index 461e12a..b4486ff 100644 --- a/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_build.xml +++ b/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_build.xml @@ -7,6 +7,6 @@ android:pathData="M24,24m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0" android:fillColor="#f5f5f5" /> diff --git a/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_edit.xml b/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_edit.xml index e449859..38106e1 100644 --- a/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_edit.xml +++ b/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_edit.xml @@ -7,6 +7,6 @@ android:pathData="M24,24m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0" android:fillColor="#f5f5f5" /> diff --git a/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_my_location.xml b/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_my_location.xml index bd795dc..df55b0c 100644 --- a/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_my_location.xml +++ b/CongressRoutePlanner/app/src/main/res/drawable/ic_shortcut_my_location.xml @@ -7,6 +7,6 @@ android:pathData="M24,24m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0" android:fillColor="#f5f5f5" /> diff --git a/CongressRoutePlanner/app/src/main/res/drawable/logo.png b/CongressRoutePlanner/app/src/main/res/drawable/logo.png index 091d940..3d65922 100644 Binary files a/CongressRoutePlanner/app/src/main/res/drawable/logo.png and b/CongressRoutePlanner/app/src/main/res/drawable/logo.png differ diff --git a/CongressRoutePlanner/app/src/main/res/menu/menu_nav_main.xml b/CongressRoutePlanner/app/src/main/res/menu/menu_nav_main.xml index 583ccf2..0ec665a 100644 --- a/CongressRoutePlanner/app/src/main/res/menu/menu_nav_main.xml +++ b/CongressRoutePlanner/app/src/main/res/menu/menu_nav_main.xml @@ -46,9 +46,9 @@ android:icon="@drawable/ic_code" android:title="@string/api" /> + + + + + \ No newline at end of file diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-anydpi-v26/ic_launcher_basic_round.xml b/CongressRoutePlanner/app/src/main/res/mipmap-anydpi-v26/ic_launcher_basic_round.xml new file mode 100644 index 0000000..7b2ccd7 --- /dev/null +++ b/CongressRoutePlanner/app/src/main/res/mipmap-anydpi-v26/ic_launcher_basic_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-hdpi/ic_launcher_basic.webp b/CongressRoutePlanner/app/src/main/res/mipmap-hdpi/ic_launcher_basic.webp new file mode 100644 index 0000000..97bfb02 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-hdpi/ic_launcher_basic.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-hdpi/ic_launcher_basic_round.webp b/CongressRoutePlanner/app/src/main/res/mipmap-hdpi/ic_launcher_basic_round.webp new file mode 100644 index 0000000..a0455cf Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-hdpi/ic_launcher_basic_round.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-mdpi/ic_launcher_basic.webp b/CongressRoutePlanner/app/src/main/res/mipmap-mdpi/ic_launcher_basic.webp new file mode 100644 index 0000000..df70344 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-mdpi/ic_launcher_basic.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-mdpi/ic_launcher_basic_round.webp b/CongressRoutePlanner/app/src/main/res/mipmap-mdpi/ic_launcher_basic_round.webp new file mode 100644 index 0000000..cd9da4d Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-mdpi/ic_launcher_basic_round.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-xhdpi/ic_launcher_basic.webp b/CongressRoutePlanner/app/src/main/res/mipmap-xhdpi/ic_launcher_basic.webp new file mode 100644 index 0000000..a105d22 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-xhdpi/ic_launcher_basic.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-xhdpi/ic_launcher_basic_round.webp b/CongressRoutePlanner/app/src/main/res/mipmap-xhdpi/ic_launcher_basic_round.webp new file mode 100644 index 0000000..bc96549 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-xhdpi/ic_launcher_basic_round.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-xxhdpi/ic_launcher_basic.webp b/CongressRoutePlanner/app/src/main/res/mipmap-xxhdpi/ic_launcher_basic.webp new file mode 100644 index 0000000..5a78d75 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-xxhdpi/ic_launcher_basic.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-xxhdpi/ic_launcher_basic_round.webp b/CongressRoutePlanner/app/src/main/res/mipmap-xxhdpi/ic_launcher_basic_round.webp new file mode 100644 index 0000000..815009b Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-xxhdpi/ic_launcher_basic_round.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-xxxhdpi/ic_launcher_basic.webp b/CongressRoutePlanner/app/src/main/res/mipmap-xxxhdpi/ic_launcher_basic.webp new file mode 100644 index 0000000..5c795be Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-xxxhdpi/ic_launcher_basic.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/mipmap-xxxhdpi/ic_launcher_basic_round.webp b/CongressRoutePlanner/app/src/main/res/mipmap-xxxhdpi/ic_launcher_basic_round.webp new file mode 100644 index 0000000..fb16ee7 Binary files /dev/null and b/CongressRoutePlanner/app/src/main/res/mipmap-xxxhdpi/ic_launcher_basic_round.webp differ diff --git a/CongressRoutePlanner/app/src/main/res/values/arrays.xml b/CongressRoutePlanner/app/src/main/res/values/arrays.xml new file mode 100644 index 0000000..1ccda43 --- /dev/null +++ b/CongressRoutePlanner/app/src/main/res/values/arrays.xml @@ -0,0 +1,25 @@ + + + + 5 s + 10 s + 15 s + 20 s + 25 s + 30 s + 40 s + 50 s + 60 s + + + 5 + 10 + 15 + 20 + 25 + 30 + 40 + 50 + 60 + + \ No newline at end of file diff --git a/CongressRoutePlanner/app/src/main/res/values/colors.xml b/CongressRoutePlanner/app/src/main/res/values/colors.xml index 155949b..3dac2a6 100644 --- a/CongressRoutePlanner/app/src/main/res/values/colors.xml +++ b/CongressRoutePlanner/app/src/main/res/values/colors.xml @@ -2,7 +2,7 @@ #000000 #000000 - #00bb31 + #9b4dca #000000 #ff5900 diff --git a/CongressRoutePlanner/app/src/main/res/values/ic_launcher_basic_background.xml b/CongressRoutePlanner/app/src/main/res/values/ic_launcher_basic_background.xml new file mode 100644 index 0000000..822d622 --- /dev/null +++ b/CongressRoutePlanner/app/src/main/res/values/ic_launcher_basic_background.xml @@ -0,0 +1,4 @@ + + + #9B4DC9 + \ No newline at end of file diff --git a/CongressRoutePlanner/app/src/main/res/xml/network_security_config.xml b/CongressRoutePlanner/app/src/main/res/xml/network_security_config.xml index 073201c..ea060bc 100644 --- a/CongressRoutePlanner/app/src/main/res/xml/network_security_config.xml +++ b/CongressRoutePlanner/app/src/main/res/xml/network_security_config.xml @@ -3,7 +3,7 @@ c3nav.de - YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg= + jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0= \ No newline at end of file diff --git a/CongressRoutePlanner/build.gradle b/CongressRoutePlanner/build.gradle.kts similarity index 67% rename from CongressRoutePlanner/build.gradle rename to CongressRoutePlanner/build.gradle.kts index 0cc143e..f77586e 100644 --- a/CongressRoutePlanner/build.gradle +++ b/CongressRoutePlanner/build.gradle.kts @@ -2,11 +2,11 @@ buildscript { repositories { - jcenter() google() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath("com.android.tools.build:gradle:8.2.0") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,11 +15,11 @@ buildscript { allprojects { repositories { - jcenter() google() + mavenCentral() } } -task clean(type: Delete) { - delete rootProject.buildDir +tasks.create("clean") { + delete(rootProject.layout.buildDirectory) } diff --git a/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.jar b/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.jar index 05ef575..7f93135 100644 Binary files a/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.jar and b/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.jar differ diff --git a/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.properties b/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.properties index ba068a7..3fa8f86 100644 --- a/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.properties +++ b/CongressRoutePlanner/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Tue Dec 17 00:15:42 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/CongressRoutePlanner/gradlew b/CongressRoutePlanner/gradlew index 9d82f78..1aa94a4 100755 --- a/CongressRoutePlanner/gradlew +++ b/CongressRoutePlanner/gradlew @@ -1,74 +1,127 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -77,84 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/CongressRoutePlanner/gradlew.bat b/CongressRoutePlanner/gradlew.bat index aec9973..6689b85 100644 --- a/CongressRoutePlanner/gradlew.bat +++ b/CongressRoutePlanner/gradlew.bat @@ -1,4 +1,20 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -8,20 +24,24 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,44 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/CongressRoutePlanner/settings.gradle b/CongressRoutePlanner/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/CongressRoutePlanner/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/CongressRoutePlanner/settings.gradle.kts b/CongressRoutePlanner/settings.gradle.kts new file mode 100644 index 0000000..15a801b --- /dev/null +++ b/CongressRoutePlanner/settings.gradle.kts @@ -0,0 +1 @@ +include(":app") diff --git a/README.md b/README.md index 85c1002..72a3e1b 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,5 @@ You can get the app on the [Play Store](https://play.google.com/store/apps/detai on [GitHub](https://github.com/c3nav/c3nav-android/releases) and on [F-Droid](https://f-droid.org/repository/browse/?fdid=de.c3nav.droid) . [![Play Store](https://developer.android.com/images/brand/en_app_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=de.c3nav.droid) -[![Android app on FDroid](https://f-droid.org/wiki/images/c/c4/F-Droid-button_available-on.png)](https://f-droid.org/repository/browse/?fdid=de.c3nav.droid) +[![Android app on FDroid](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Get_it_on_F-Droid_%28material_design%29.svg/190px-Get_it_on_F-Droid_%28material_design%29.svg.png)](https://f-droid.org/repository/browse/?fdid=de.c3nav.droid) +[![F-Droid repository](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Get_it_on_F-Droid_%28material_design%29.svg/190px-Get_it_on_F-Droid_%28material_design%29.svg.png)](https://f-droid.c3nav.de/fdroid/repo/?fingerprint=C1EC2D062F67A43F87CCF95B8096630285E1B2577DC803A0826539DF6FB4C95D) diff --git a/current_version b/current_version index a2317f7..0086d6d 100644 --- a/current_version +++ b/current_version @@ -1 +1 @@ -4.1.1:14040101 +4.2.5:14040205