Hide the "merge old activity database" elements when there is no old db

This commit is contained in:
cpfeiffer 2016-09-05 23:55:00 +02:00
parent 9928ad80c4
commit afef50dfab
1 changed files with 14 additions and 0 deletions

View File

@ -68,7 +68,16 @@ public class DbManagementActivity extends GBActivity {
}
});
boolean hasOldDB = hasOldActivityDatabase();
int oldDBVisibility = hasOldDB ? View.VISIBLE : View.GONE;
View oldDBTitle = findViewById(R.id.mergeOldActivityDataTitle);
oldDBTitle.setVisibility(oldDBVisibility);
View oldDBText = findViewById(R.id.mergeOldActivityDataText);
oldDBText.setVisibility(oldDBVisibility);
importOldActivityDataButton = (Button) findViewById(R.id.mergeOldActivityData);
importOldActivityDataButton.setVisibility(oldDBVisibility);
importOldActivityDataButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -77,6 +86,7 @@ public class DbManagementActivity extends GBActivity {
});
deleteOldActivityDBButton = (Button) findViewById(R.id.deleteOldActivityDB);
deleteOldActivityDBButton.setVisibility(oldDBVisibility);
deleteOldActivityDBButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -93,6 +103,10 @@ public class DbManagementActivity extends GBActivity {
});
}
private boolean hasOldActivityDatabase() {
return new DBHelper(this).getOldActivityDatabaseHandler() != null;
}
private String getExternalPath() {
try {
return FileUtils.getExternalFilesDir().getAbsolutePath();