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 title;
|
||||
private int wpCount;
|
||||
private boolean startSilent;
|
||||
|
||||
ActivityResultLauncher<Intent> someActivityResultLauncher;
|
||||
|
||||
/**
|
||||
|
@ -115,9 +117,12 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
|||
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||
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
|
||||
mBRouterView = new BRouterView(this, memoryClass);
|
||||
mBRouterView.init();
|
||||
mBRouterView.init(startSilent);
|
||||
setContentView(mBRouterView);
|
||||
}
|
||||
|
||||
|
@ -139,7 +144,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
|||
case DIALOG_MAINACTION_ID:
|
||||
builder.setTitle("Select Main Action");
|
||||
builder.setItems(
|
||||
new String[] { "Download Manager", "BRouter App" },
|
||||
new String[]{"Download Manager", "BRouter App"},
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
if (item == 0)
|
||||
|
@ -238,7 +243,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
|||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
String basedir = input.getText().toString();
|
||||
mBRouterView.startSetup(new File(basedir), true);
|
||||
mBRouterView.startSetup(new File(basedir), true, false);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
|
@ -254,7 +259,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
|||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
if (selectedBasedir < availableBasedirs.size()) {
|
||||
mBRouterView.startSetup(availableBasedirs.get(selectedBasedir), true);
|
||||
mBRouterView.startSetup(availableBasedirs.get(selectedBasedir), true, false);
|
||||
} else {
|
||||
showADialog(DIALOG_TEXTENTRY_ID);
|
||||
}
|
||||
|
@ -530,7 +535,14 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
|||
basedirOptions[bdidx] = "Enter path manually";
|
||||
}
|
||||
|
||||
showADialog(DIALOG_SELECTBASEDIR_ID);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message) {
|
||||
|
@ -650,9 +662,9 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 0) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
mBRouterView.startSetup(null, true);
|
||||
mBRouterView.startSetup(null, true, false);
|
||||
} else {
|
||||
mBRouterView.init();
|
||||
mBRouterView.init(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class BRouterView extends View {
|
|||
if (cr != null) cr.terminate();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
public void init(boolean silent) {
|
||||
try {
|
||||
// get base dir from private file
|
||||
File baseDir = ConfigHelper.getBaseDir(getContext());
|
||||
|
@ -107,7 +107,7 @@ public class BRouterView extends View {
|
|||
String version = "v" + getContext().getString(R.string.app_version);
|
||||
File vFile = new File(brd, "profiles2/" + version);
|
||||
if (vFile.exists()) {
|
||||
startSetup(baseDir, false);
|
||||
startSetup(baseDir, false, silent);
|
||||
return;
|
||||
}
|
||||
String message = "(previous basedir " + baseDir + " has to migrate )";
|
||||
|
@ -117,7 +117,7 @@ public class BRouterView extends View {
|
|||
waitingForMigration = true;
|
||||
oldMigrationPath = brd.getAbsolutePath();
|
||||
} else {
|
||||
startSetup(baseDir, false);
|
||||
startSetup(baseDir, false, silent);
|
||||
}
|
||||
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) {
|
||||
baseDir = retryBaseDir;
|
||||
retryBaseDir = null;
|
||||
|
@ -239,6 +239,12 @@ public class BRouterView extends View {
|
|||
throw new IllegalArgumentException("The profile-directory " + profileDir + " contains no routing profiles (*.brf)."
|
||||
+ " see brouter.de/brouter for setup instructions.");
|
||||
}
|
||||
if (silent) {
|
||||
Intent intent = new Intent(getContext(), BInstallerActivity.class);
|
||||
getContext().startActivity(intent);
|
||||
return;
|
||||
};
|
||||
|
||||
if (!RoutingHelper.hasDirectoryAnyDatafiles(segmentDir)) {
|
||||
((BRouterActivity) getContext()).startDownloadManager();
|
||||
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
|
||||
|
||||
|
||||
### 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
|
||||
|
||||
### get elevation
|
||||
|
|
Loading…
Reference in a new issue