Fix checkstyle errors in android app
This commit is contained in:
parent
78ce7b659b
commit
227596eb90
2 changed files with 128 additions and 108 deletions
|
@ -96,31 +96,31 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
return builder.create();
|
return builder.create();
|
||||||
case DIALOG_MAINACTION_ID:
|
case DIALOG_MAINACTION_ID:
|
||||||
builder.setTitle("Select Main Action");
|
builder.setTitle("Select Main Action");
|
||||||
builder
|
builder.setItems(
|
||||||
.setItems(new String[]
|
new String[] { "Download Manager", "BRouter App" },
|
||||||
{"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)
|
||||||
startDownloadManager();
|
startDownloadManager();
|
||||||
else
|
else
|
||||||
showDialog(DIALOG_SELECTPROFILE_ID);
|
showDialog(DIALOG_SELECTPROFILE_ID);
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
return builder.create();
|
return builder.create();
|
||||||
case DIALOG_SHOW_DM_INFO_ID:
|
case DIALOG_SHOW_DM_INFO_ID:
|
||||||
builder
|
builder
|
||||||
.setTitle("BRouter Download Manager")
|
.setTitle("BRouter Download Manager")
|
||||||
.setMessage(
|
.setMessage(
|
||||||
"*** Attention: ***\n\n" + "The Download Manager is used to download routing-data "
|
"*** Attention: ***\n\n" + "The Download Manager is used to download routing-data "
|
||||||
+ "files which can be up to 170MB each. Do not start the Download Manager " + "on a cellular data connection without a data plan! "
|
+ "files which can be up to 170MB each. Do not start the Download Manager "
|
||||||
+ "Download speed is restricted to 16 MBit/s.").setPositiveButton("I know", new DialogInterface.OnClickListener() {
|
+ "on a cellular data connection without a data plan! "
|
||||||
|
+ "Download speed is restricted to 16 MBit/s.")
|
||||||
|
.setPositiveButton("I know", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
Intent intent = new Intent(BRouterActivity.this, BInstallerActivity.class);
|
Intent intent = new Intent(BRouterActivity.this, BInstallerActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -139,7 +139,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
"You successfully repeated a calculation that previously run into a timeout "
|
"You successfully repeated a calculation that previously run into a timeout "
|
||||||
+ "when started from your map-tool. If you repeat the same request from your "
|
+ "when started from your map-tool. If you repeat the same request from your "
|
||||||
+ "maptool, with the exact same destination point and a close-by starting point, "
|
+ "maptool, with the exact same destination point and a close-by starting point, "
|
||||||
+ "this request is guaranteed not to time out.").setNegativeButton("Exit", new DialogInterface.OnClickListener() {
|
+ "this request is guaranteed not to time out.")
|
||||||
|
.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -149,7 +150,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
builder
|
builder
|
||||||
.setTitle("Local setup needs reset")
|
.setTitle("Local setup needs reset")
|
||||||
.setMessage(
|
.setMessage(
|
||||||
"You are currently using an old version of the lookup-table " + "together with routing data made for this old table. "
|
"You are currently using an old version of the lookup-table "
|
||||||
|
+ "together with routing data made for this old table. "
|
||||||
+ "Before downloading new datafiles made for the new table, "
|
+ "Before downloading new datafiles made for the new table, "
|
||||||
+ "you have to reset your local setup by 'moving away' (or deleting) "
|
+ "you have to reset your local setup by 'moving away' (or deleting) "
|
||||||
+ "your <basedir>/brouter directory and start a new setup by calling the " + "BRouter App again.")
|
+ "your <basedir>/brouter directory and start a new setup by calling the " + "BRouter App again.")
|
||||||
|
@ -161,7 +163,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
return builder.create();
|
return builder.create();
|
||||||
case DIALOG_ROUTINGMODES_ID:
|
case DIALOG_ROUTINGMODES_ID:
|
||||||
builder.setTitle(message);
|
builder.setTitle(message);
|
||||||
builder.setMultiChoiceItems(routingModes, routingModesChecked, new DialogInterface.OnMultiChoiceClickListener() {
|
builder.setMultiChoiceItems(routingModes, routingModesChecked,
|
||||||
|
new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
routingModesChecked[which] = isChecked;
|
routingModesChecked[which] = isChecked;
|
||||||
|
@ -174,7 +177,11 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
case DIALOG_EXCEPTION_ID:
|
case DIALOG_EXCEPTION_ID:
|
||||||
builder.setTitle("An Error occured").setMessage(errorMessage).setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
builder
|
||||||
|
.setTitle("An Error occured")
|
||||||
|
.setMessage(errorMessage)
|
||||||
|
.setPositiveButton("OK",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
mBRouterView.continueProcessing();
|
mBRouterView.continueProcessing();
|
||||||
}
|
}
|
||||||
|
@ -214,7 +221,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
return builder.create();
|
return builder.create();
|
||||||
case DIALOG_VIASELECT_ID:
|
case DIALOG_VIASELECT_ID:
|
||||||
builder.setTitle("Check VIA Selection:");
|
builder.setTitle("Check VIA Selection:");
|
||||||
builder.setMultiChoiceItems(availableVias, getCheckedBooleanArray(availableVias.length), new DialogInterface.OnMultiChoiceClickListener() {
|
builder.setMultiChoiceItems(availableVias, getCheckedBooleanArray(availableVias.length),
|
||||||
|
new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
|
@ -237,7 +245,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
for (int i = 0; i < nogoList.size(); i++)
|
for (int i = 0; i < nogoList.size(); i++)
|
||||||
nogoNames[i] = nogoList.get(i).name;
|
nogoNames[i] = nogoList.get(i).name;
|
||||||
final boolean[] nogoEnabled = getCheckedBooleanArray(nogoList.size());
|
final boolean[] nogoEnabled = getCheckedBooleanArray(nogoList.size());
|
||||||
builder.setMultiChoiceItems(nogoNames, getCheckedBooleanArray(nogoNames.length), new DialogInterface.OnMultiChoiceClickListener() {
|
builder.setMultiChoiceItems(nogoNames, getCheckedBooleanArray(nogoNames.length),
|
||||||
|
new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
nogoEnabled[which] = isChecked;
|
nogoEnabled[which] = isChecked;
|
||||||
|
@ -293,7 +302,11 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
|
|
||||||
return builder.create();
|
return builder.create();
|
||||||
case DIALOG_MODECONFIGOVERVIEW_ID:
|
case DIALOG_MODECONFIGOVERVIEW_ID:
|
||||||
builder.setTitle("Success").setMessage(message).setPositiveButton("Exit", new DialogInterface.OnClickListener() {
|
builder
|
||||||
|
.setTitle("Success")
|
||||||
|
.setMessage(message)
|
||||||
|
.setPositiveButton("Exit",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -345,7 +358,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
try {
|
try {
|
||||||
StatFs stat = new StatFs(f.getAbsolutePath());
|
StatFs stat = new StatFs(f.getAbsolutePath());
|
||||||
size = (long) stat.getAvailableBlocks() * stat.getBlockSize();
|
size = (long) stat.getAvailableBlocks() * stat.getBlockSize();
|
||||||
} catch (Exception e) { /* ignore */ }
|
} catch (Exception e) {
|
||||||
|
/* ignore */ }
|
||||||
dirFreeSizes.add(size);
|
dirFreeSizes.add(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +372,8 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
int bdidx = 0;
|
int bdidx = 0;
|
||||||
DecimalFormat df = new DecimalFormat("###0.00");
|
DecimalFormat df = new DecimalFormat("###0.00");
|
||||||
for (int idx = 0; idx < availableBasedirs.size(); idx++) {
|
for (int idx = 0; idx < availableBasedirs.size(); idx++) {
|
||||||
basedirOptions[bdidx++] = availableBasedirs.get(idx) + " (" + df.format(dirFreeSizes.get(idx) / 1024. / 1024. / 1024.) + " GB free)";
|
basedirOptions[bdidx++] = availableBasedirs.get(idx) + " ("
|
||||||
|
+ df.format(dirFreeSizes.get(idx) / 1024. / 1024. / 1024.) + " GB free)";
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
basedirOptions[bdidx] = "Enter path manually";
|
basedirOptions[bdidx] = "Enter path manually";
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package btools.routingapp;
|
package btools.routingapp;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -49,7 +48,8 @@ public class BRouterService extends Service {
|
||||||
baseDir = br.readLine();
|
baseDir = br.readLine();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
} finally {
|
} finally {
|
||||||
if (configInput != null) try {
|
if (configInput != null)
|
||||||
|
try {
|
||||||
configInput.close();
|
configInput.close();
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,8 @@ public class BRouterService extends Service {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "no brouter service config found, mode " + mode_key;
|
return "no brouter service config found, mode " + mode_key;
|
||||||
} finally {
|
} finally {
|
||||||
if (br != null) try {
|
if (br != null)
|
||||||
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
}
|
}
|
||||||
|
@ -163,7 +164,8 @@ public class BRouterService extends Service {
|
||||||
os = new FileOutputStream(profileFile);
|
os = new FileOutputStream(profileFile);
|
||||||
os.write(profileBytes);
|
os.write(profileBytes);
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null) try {
|
if (os != null)
|
||||||
|
try {
|
||||||
os.close();
|
os.close();
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
}
|
}
|
||||||
|
@ -182,7 +184,6 @@ public class BRouterService extends Service {
|
||||||
worker.nogoPolygonsList = new ArrayList<OsmNodeNamed>();
|
worker.nogoPolygonsList = new ArrayList<OsmNodeNamed>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean fileEqual(byte[] fileBytes, File file) throws Exception {
|
private boolean fileEqual(byte[] fileBytes, File file) throws Exception {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -196,8 +197,10 @@ public class BRouterService extends Service {
|
||||||
is = new FileInputStream(file);
|
is = new FileInputStream(file);
|
||||||
while (pos < nbytes) {
|
while (pos < nbytes) {
|
||||||
int len = is.read(buf, 0, blen);
|
int len = is.read(buf, 0, blen);
|
||||||
if (len <= 0) return false;
|
if (len <= 0)
|
||||||
if (pos + len > nbytes) return false;
|
return false;
|
||||||
|
if (pos + len > nbytes)
|
||||||
|
return false;
|
||||||
for (int j = 0; j < len; j++) {
|
for (int j = 0; j < len; j++) {
|
||||||
if (fileBytes[pos++] != buf[j]) {
|
if (fileBytes[pos++] != buf[j]) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -206,7 +209,8 @@ public class BRouterService extends Service {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) try {
|
if (is != null)
|
||||||
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
}
|
}
|
||||||
|
@ -215,7 +219,8 @@ public class BRouterService extends Service {
|
||||||
|
|
||||||
private String checkForTestDummy(String baseDir) {
|
private String checkForTestDummy(String baseDir) {
|
||||||
File testdummy = new File(baseDir + "/brouter/profiles2/remotetestdummy.brf");
|
File testdummy = new File(baseDir + "/brouter/profiles2/remotetestdummy.brf");
|
||||||
if (!testdummy.exists()) return null;
|
if (!testdummy.exists())
|
||||||
|
return null;
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
|
@ -230,7 +235,8 @@ public class BRouterService extends Service {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("error reading " + testdummy);
|
throw new RuntimeException("error reading " + testdummy);
|
||||||
} finally {
|
} finally {
|
||||||
if (br != null) try {
|
if (br != null)
|
||||||
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
}
|
}
|
||||||
|
@ -261,7 +267,6 @@ public class BRouterService extends Service {
|
||||||
Log.d(getClass().getSimpleName(), "onDestroy()");
|
Log.d(getClass().getSimpleName(), "onDestroy()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is the old onStart method that will be called on the pre-2.0
|
// This is the old onStart method that will be called on the pre-2.0
|
||||||
// platform. On 2.0 or later we override onStartCommand() so this
|
// platform. On 2.0 or later we override onStartCommand() so this
|
||||||
// method will not be called.
|
// method will not be called.
|
||||||
|
|
Loading…
Reference in a new issue