Merge pull request #587 from afischerdev/app-ui-update
Add a silent mode for app start
This commit is contained in:
commit
f96b83750e
3 changed files with 42 additions and 11 deletions
|
@ -77,6 +77,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
private String title;
|
private String title;
|
||||||
private int wpCount;
|
private int wpCount;
|
||||||
|
private boolean startSilent;
|
||||||
|
|
||||||
ActivityResultLauncher<Intent> someActivityResultLauncher;
|
ActivityResultLauncher<Intent> someActivityResultLauncher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,9 +117,12 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||||
int memoryClass = am.getMemoryClass();
|
int memoryClass = am.getMemoryClass();
|
||||||
|
|
||||||
|
Intent i = getIntent();
|
||||||
|
if (i.hasExtra("runsilent")) startSilent = true;
|
||||||
|
// startQuiete = true;
|
||||||
// instantiate our simulation view and set it as the activity's content
|
// instantiate our simulation view and set it as the activity's content
|
||||||
mBRouterView = new BRouterView(this, memoryClass);
|
mBRouterView = new BRouterView(this, memoryClass);
|
||||||
mBRouterView.init();
|
mBRouterView.init(startSilent);
|
||||||
setContentView(mBRouterView);
|
setContentView(mBRouterView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +144,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
case DIALOG_MAINACTION_ID:
|
case DIALOG_MAINACTION_ID:
|
||||||
builder.setTitle("Select Main Action");
|
builder.setTitle("Select Main Action");
|
||||||
builder.setItems(
|
builder.setItems(
|
||||||
new String[] { "Download Manager", "BRouter App" },
|
new String[]{"Download Manager", "BRouter App"},
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
if (item == 0)
|
if (item == 0)
|
||||||
|
@ -238,7 +243,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
String basedir = input.getText().toString();
|
String basedir = input.getText().toString();
|
||||||
mBRouterView.startSetup(new File(basedir), true);
|
mBRouterView.startSetup(new File(basedir), true, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
|
@ -254,7 +259,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
if (selectedBasedir < availableBasedirs.size()) {
|
if (selectedBasedir < availableBasedirs.size()) {
|
||||||
mBRouterView.startSetup(availableBasedirs.get(selectedBasedir), true);
|
mBRouterView.startSetup(availableBasedirs.get(selectedBasedir), true, false);
|
||||||
} else {
|
} else {
|
||||||
showADialog(DIALOG_TEXTENTRY_ID);
|
showADialog(DIALOG_TEXTENTRY_ID);
|
||||||
}
|
}
|
||||||
|
@ -530,8 +535,15 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
basedirOptions[bdidx] = "Enter path manually";
|
basedirOptions[bdidx] = "Enter path manually";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (startSilent) {
|
||||||
|
mBRouterView.startSetup(availableBasedirs.get(0), true, startSilent);
|
||||||
|
Intent intent = new Intent(BRouterActivity.this, BInstallerActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
showADialog(DIALOG_SELECTBASEDIR_ID);
|
showADialog(DIALOG_SELECTBASEDIR_ID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message) {
|
public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message) {
|
||||||
routingModes = modes;
|
routingModes = modes;
|
||||||
|
@ -650,9 +662,9 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if (requestCode == 0) {
|
if (requestCode == 0) {
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
mBRouterView.startSetup(null, true);
|
mBRouterView.startSetup(null, true, false);
|
||||||
} else {
|
} else {
|
||||||
mBRouterView.init();
|
mBRouterView.init(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class BRouterView extends View {
|
||||||
if (cr != null) cr.terminate();
|
if (cr != null) cr.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init(boolean silent) {
|
||||||
try {
|
try {
|
||||||
// get base dir from private file
|
// get base dir from private file
|
||||||
File baseDir = ConfigHelper.getBaseDir(getContext());
|
File baseDir = ConfigHelper.getBaseDir(getContext());
|
||||||
|
@ -107,7 +107,7 @@ public class BRouterView extends View {
|
||||||
String version = "v" + getContext().getString(R.string.app_version);
|
String version = "v" + getContext().getString(R.string.app_version);
|
||||||
File vFile = new File(brd, "profiles2/" + version);
|
File vFile = new File(brd, "profiles2/" + version);
|
||||||
if (vFile.exists()) {
|
if (vFile.exists()) {
|
||||||
startSetup(baseDir, false);
|
startSetup(baseDir, false, silent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String message = "(previous basedir " + baseDir + " has to migrate )";
|
String message = "(previous basedir " + baseDir + " has to migrate )";
|
||||||
|
@ -117,7 +117,7 @@ public class BRouterView extends View {
|
||||||
waitingForMigration = true;
|
waitingForMigration = true;
|
||||||
oldMigrationPath = brd.getAbsolutePath();
|
oldMigrationPath = brd.getAbsolutePath();
|
||||||
} else {
|
} else {
|
||||||
startSetup(baseDir, false);
|
startSetup(baseDir, false, silent);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public class BRouterView extends View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startSetup(File baseDir, boolean storeBasedir) {
|
public void startSetup(File baseDir, boolean storeBasedir, boolean silent) {
|
||||||
if (baseDir == null) {
|
if (baseDir == null) {
|
||||||
baseDir = retryBaseDir;
|
baseDir = retryBaseDir;
|
||||||
retryBaseDir = null;
|
retryBaseDir = null;
|
||||||
|
@ -239,6 +239,12 @@ public class BRouterView extends View {
|
||||||
throw new IllegalArgumentException("The profile-directory " + profileDir + " contains no routing profiles (*.brf)."
|
throw new IllegalArgumentException("The profile-directory " + profileDir + " contains no routing profiles (*.brf)."
|
||||||
+ " see brouter.de/brouter for setup instructions.");
|
+ " see brouter.de/brouter for setup instructions.");
|
||||||
}
|
}
|
||||||
|
if (silent) {
|
||||||
|
Intent intent = new Intent(getContext(), BInstallerActivity.class);
|
||||||
|
getContext().startActivity(intent);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
if (!RoutingHelper.hasDirectoryAnyDatafiles(segmentDir)) {
|
if (!RoutingHelper.hasDirectoryAnyDatafiles(segmentDir)) {
|
||||||
((BRouterActivity) getContext()).startDownloadManager();
|
((BRouterActivity) getContext()).startDownloadManager();
|
||||||
waitingForSelection = true;
|
waitingForSelection = true;
|
||||||
|
|
|
@ -46,6 +46,19 @@ For the app it is a list of params concatenated by '&'. E.g. extraParams=avoidfe
|
||||||
The server calls profile params by a prefix 'profile:'. E.g. ...&profile:avoidferry=1&profile:avoidsteps=0
|
The server calls profile params by a prefix 'profile:'. E.g. ...&profile:avoidferry=1&profile:avoidsteps=0
|
||||||
|
|
||||||
|
|
||||||
|
### silent app call
|
||||||
|
|
||||||
|
The app can be started from other apps by using a call like this
|
||||||
|
|
||||||
|
```
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setClassName("btools.routingapp", "btools.routingapp.BRouterActivity");
|
||||||
|
intent.putExtra("runsilent", true);
|
||||||
|
startActivity(intent);
|
||||||
|
```
|
||||||
|
|
||||||
|
This suppress the first question after installation for the BRouter path, generates the BRouter folders in main space and starts the download dialog.
|
||||||
|
|
||||||
## other routing engine modes in app
|
## other routing engine modes in app
|
||||||
|
|
||||||
### get elevation
|
### get elevation
|
||||||
|
|
Loading…
Reference in a new issue