Merge pull request #532 from afischerdev/app-online-check
App changes, online check
This commit is contained in:
commit
e1766792ac
7 changed files with 55 additions and 42 deletions
|
@ -18,6 +18,7 @@
|
|||
android:label="@string/app_name"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
android:hasFragileUserData="true"
|
||||
android:largeHeap="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:theme="@style/Theme.App">
|
||||
<activity
|
||||
|
|
Binary file not shown.
|
@ -33,7 +33,6 @@ import androidx.work.NetworkType;
|
|||
import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.WorkInfo;
|
||||
import androidx.work.WorkManager;
|
||||
import androidx.work.WorkRequest;
|
||||
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -92,8 +91,7 @@ public class BInstallerActivity extends AppCompatActivity {
|
|||
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.POST_NOTIFICATIONS)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
// nothing to do
|
||||
}
|
||||
if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
|
||||
} else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
|
||||
//
|
||||
} else {
|
||||
// You can directly ask for the permission.
|
||||
|
@ -222,14 +220,14 @@ public class BInstallerActivity extends AppCompatActivity {
|
|||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build();
|
||||
|
||||
WorkRequest downloadWorkRequest =
|
||||
OneTimeWorkRequest downloadWorkRequest =
|
||||
new OneTimeWorkRequest.Builder(DownloadWorker.class)
|
||||
.setInputData(inputData)
|
||||
.setConstraints(constraints)
|
||||
.build();
|
||||
|
||||
WorkManager workManager = WorkManager.getInstance(getApplicationContext());
|
||||
workManager.enqueueUniqueWork(DownloadWorker.WORKER_NAME, ExistingWorkPolicy.KEEP, (OneTimeWorkRequest) downloadWorkRequest);
|
||||
workManager.enqueueUniqueWork(DownloadWorker.WORKER_NAME, ExistingWorkPolicy.KEEP, downloadWorkRequest);
|
||||
|
||||
try {
|
||||
WorkInfo wi = WorkManager.getInstance(getApplicationContext()).getWorkInfoById(downloadWorkRequest.getId()).get();
|
||||
|
@ -256,7 +254,6 @@ public class BInstallerActivity extends AppCompatActivity {
|
|||
private void startObserver(WorkInfo workInfo) {
|
||||
if (workInfo != null) {
|
||||
if (workInfo.getState() == WorkInfo.State.ENQUEUED || workInfo.getState() == WorkInfo.State.BLOCKED) {
|
||||
Log.d("worker", "cancel " + workInfo.getState());
|
||||
//WorkManager.getInstance(getApplicationContext()).cancelWorkById(downloadWorkRequest.getId());
|
||||
}
|
||||
|
||||
|
@ -265,6 +262,9 @@ public class BInstallerActivity extends AppCompatActivity {
|
|||
mProgressIndicator.hide();
|
||||
mProgressIndicator.setIndeterminate(true);
|
||||
mProgressIndicator.show();
|
||||
|
||||
mButtonDownload.setText(getString(R.string.action_cancel));
|
||||
mButtonDownload.setEnabled(true);
|
||||
}
|
||||
|
||||
if (workInfo.getState() == WorkInfo.State.RUNNING) {
|
||||
|
@ -310,12 +310,17 @@ public class BInstallerActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
if (error != null && error.startsWith("error new app")) {
|
||||
if (error != null && error.startsWith("Version new app")) {
|
||||
showAppUpdate();
|
||||
} else if (error != null && error.startsWith("Version error")) {
|
||||
showConfirmNextSteps();
|
||||
} else if (error != null && error.startsWith("Version diffs")) {
|
||||
showConfirmGetDiffs();
|
||||
} else if (error != null) {
|
||||
stopDownload();
|
||||
mBInstallerView.setOnSelectListener(onSelectListener);
|
||||
mBInstallerView.clearAllTilesStatus(MASK_SELECTED_RD5);
|
||||
scanExistingFiles();
|
||||
} else {
|
||||
mBInstallerView.setOnSelectListener(onSelectListener);
|
||||
mBInstallerView.clearAllTilesStatus(MASK_SELECTED_RD5);
|
||||
|
|
|
@ -29,7 +29,6 @@ public class BRouterService extends Service {
|
|||
|
||||
@Override
|
||||
public IBinder onBind(Intent arg0) {
|
||||
Log.d(getClass().getSimpleName(), "onBind()");
|
||||
return myBRouterServiceStub;
|
||||
}
|
||||
|
||||
|
@ -277,13 +276,11 @@ public class BRouterService extends Service {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.d(getClass().getSimpleName(), "onCreate()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(getClass().getSimpleName(), "onDestroy()");
|
||||
}
|
||||
|
||||
// This is the old onStart method that will be called on the pre-2.0
|
||||
|
|
|
@ -266,7 +266,7 @@ public class DownloadWorker extends Worker {
|
|||
}
|
||||
if (newappversion != -1 && newappversion > appversion) {
|
||||
if (DEBUG) Log.d(LOG_TAG, "app version old " + appversion + " new " + newappversion);
|
||||
errorCode = "error new app";
|
||||
errorCode = "Version new app";
|
||||
return false;
|
||||
}
|
||||
if (changed && downloadAll == VALUE_SEGMENT_PARTS) {
|
||||
|
@ -375,15 +375,24 @@ public class DownloadWorker extends Worker {
|
|||
connection.setConnectTimeout(5000);
|
||||
connection.setRequestMethod("HEAD");
|
||||
connection.setDoInput(false);
|
||||
try {
|
||||
connection.connect();
|
||||
|
||||
return connection.getResponseCode() == HttpURLConnection.HTTP_OK;
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean downloadFile(URL downloadUrl, File outputFile, int fileSize, boolean limitDownloadSpeed, DownloadType type) throws IOException, InterruptedException {
|
||||
if (DEBUG) Log.d(LOG_TAG, "download " + outputFile.getAbsolutePath());
|
||||
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.setDefaultUseCaches(false);
|
||||
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
try {
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
|
@ -402,9 +411,6 @@ public class DownloadWorker extends Worker {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
try {
|
||||
input = connection.getInputStream();
|
||||
output = new FileOutputStream(outputFile);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ elevation-enabled routing tools. However, the routing algorithm is able to
|
|||
extract the information on real ascends and descends and ignores the noise.
|
||||
|
||||
For latitudes above 60 degree in northern Europe, BRouter uses Lidar data, that
|
||||
were [compiled and resampled by Sonny](https://data.opendataportal.at/dataset/dtm-europe)
|
||||
were [compiled and resampled by Sonny](https://sonny.4lima.de/)
|
||||
|
||||
On the reporting side, BRouter uses a similar concept to compute the *filtered
|
||||
ascend*, which is the ascend without the noise and the small hills and which
|
||||
|
|
|
@ -10,14 +10,12 @@
|
|||
|
||||
---context:global
|
||||
|
||||
assign consider_elevation 1 # 0 as default, otherwise less interesting flat roads are chosen.
|
||||
assign consider_elevation true # %consider_elevation% | Set to false, otherwise less interesting flat roads are chosen | boolean
|
||||
|
||||
assign shortest_way 0 # 0 as default, duplicate shortest standard profile, SAC access limit ignored for now
|
||||
|
||||
assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style]
|
||||
assign turnInstructionCatchingRange 20 # V1.8.5 / default=40, but foot paths may be more distingushed, especially in cities.
|
||||
|
||||
assign iswet 0 # 0 as default, 1 tries to prevent muddy boots and wet buttocks
|
||||
assign hiking_routes_preference 0.20 # 0.10 as default, Increases cost of non hiking routes by multiplier 1 + hiking_routes_preference
|
||||
assign iswet 0 # %iswet% | tries to prevent muddy boots and wet buttocks | boolean
|
||||
assign hiking_routes_preference 0.20 # %hiking_routes_preference% | Increases cost of non hiking routes by multiplier 1 + hiking_routes_preference (0.10 to 2.0) | number
|
||||
|
||||
assign Offroad_factor 0.0 # default 0.0, see ****), see also https://github.com/poutnikl/Brouter-profiles/wiki/Trekking-MTB-Profiles---legend
|
||||
|
||||
|
@ -25,9 +23,9 @@ assign path_preference 0.0 # 0.0 as default, try 20.0 to penalize non
|
|||
|
||||
#SAC - mountain hiking - see http://wiki.openstreetmap.org/wiki/Key:sac_scale
|
||||
|
||||
assign SAC_scale_limit 3 # 0..6, 0 to avoid any SAC paths, 1 for T1 as maximum, 6 for T6 as maximum
|
||||
# all paths with sac_scale higher than SAC_scale_limit are forbidden.
|
||||
assign SAC_scale_preferred 1 # The same, but the preferred SAC scale level. Level below are slightly, above strongly penalized
|
||||
assign SAC_scale_limit 3 # %SAC_scale_limit% | all paths with sac_scale higher than SAC_scale_limit are forbidden | [0=avoid any SAC paths, 1=SAC T1, 2=SAC T2, 3=SAC T3, 4=SAC T4, 5=SAC T5, 6=SAC T6]
|
||||
assign SAC_scale_preferred 1 # %SAC_scale_preferred% | The same, but the preferred SAC scale level. Level below are slightly, above strongly penalized | [0=avoid any SAC paths, 1=SAC T1, 2=SAC T2, 3=SAC T3, 4=SAC T4, 5=SAC T5, 6=SAC T6]
|
||||
|
||||
assign SAC_access_penalty 9000 # costfactor 9999 means the most horrible but allowed road.,
|
||||
# 100000=forbidden. This makes difference if forbidden way is the only option.
|
||||
assign SAC_K1 0.05 # Penalizing of SAC levels below preferred
|
||||
|
@ -38,14 +36,20 @@ assign turncost_value 0 # not used now
|
|||
assign initialcost_value 0 # not used now
|
||||
|
||||
#less frequently changed flags
|
||||
assign allow_steps 1 # 1 as default
|
||||
assign allow_ferries 1 # 1 as default
|
||||
assign allow_steps true # %allow_steps% | Set to false to disallow steps | boolean
|
||||
assign allow_ferries true # %allow_ferries% | set to false to disallow ferries | boolean
|
||||
|
||||
assign cost_of_unknown 2 # 2 as default
|
||||
|
||||
#
|
||||
assign elevationpenaltybuffer 5 # 5 as default
|
||||
assign elevationmaxbuffer 10 # 10 as default
|
||||
assign elevationbufferreduce 1.0 # 0.0 as default
|
||||
|
||||
assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style]
|
||||
assign turnInstructionCatchingRange 20 # V1.8.5 / default=40, but foot paths may be more distingushed, especially in cities.
|
||||
|
||||
|
||||
# as initial point, considered flat speed 4 km/h, climbing speed 600 m /h
|
||||
assign uphillcostvalue 7
|
||||
assign uphillcutoffvalue 3
|
||||
|
|
Loading…
Reference in a new issue