mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-18 06:37:47 +01:00
fix a few warnings
This commit is contained in:
parent
5837689449
commit
f01c9414f5
@ -29,13 +29,14 @@ import android.widget.Button;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.core.app.NavUtils;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import androidx.core.app.NavUtils;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||||
@ -48,30 +49,23 @@ import nodomain.freeyourgadget.gadgetbridge.util.ImportExportSharedPreferences;
|
|||||||
public class DbManagementActivity extends AbstractGBActivity {
|
public class DbManagementActivity extends AbstractGBActivity {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DbManagementActivity.class);
|
private static final Logger LOG = LoggerFactory.getLogger(DbManagementActivity.class);
|
||||||
private static SharedPreferences sharedPrefs;
|
private static SharedPreferences sharedPrefs;
|
||||||
private ImportExportSharedPreferences shared_file = new ImportExportSharedPreferences();
|
|
||||||
|
|
||||||
private Button exportDBButton;
|
|
||||||
private Button importDBButton;
|
|
||||||
private Button deleteOldActivityDBButton;
|
|
||||||
private Button deleteDBButton;
|
|
||||||
private TextView dbPath;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_db_management);
|
setContentView(R.layout.activity_db_management);
|
||||||
|
|
||||||
dbPath = (TextView) findViewById(R.id.activity_db_management_path);
|
TextView dbPath = findViewById(R.id.activity_db_management_path);
|
||||||
dbPath.setText(getExternalPath());
|
dbPath.setText(getExternalPath());
|
||||||
|
|
||||||
exportDBButton = (Button) findViewById(R.id.exportDBButton);
|
Button exportDBButton = findViewById(R.id.exportDBButton);
|
||||||
exportDBButton.setOnClickListener(new View.OnClickListener() {
|
exportDBButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
exportDB();
|
exportDB();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
importDBButton = (Button) findViewById(R.id.importDBButton);
|
Button importDBButton = findViewById(R.id.importDBButton);
|
||||||
importDBButton.setOnClickListener(new View.OnClickListener() {
|
importDBButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -81,7 +75,7 @@ public class DbManagementActivity extends AbstractGBActivity {
|
|||||||
|
|
||||||
int oldDBVisibility = hasOldActivityDatabase() ? View.VISIBLE : View.GONE;
|
int oldDBVisibility = hasOldActivityDatabase() ? View.VISIBLE : View.GONE;
|
||||||
|
|
||||||
deleteOldActivityDBButton = (Button) findViewById(R.id.deleteOldActivityDB);
|
Button deleteOldActivityDBButton = findViewById(R.id.deleteOldActivityDB);
|
||||||
deleteOldActivityDBButton.setVisibility(oldDBVisibility);
|
deleteOldActivityDBButton.setVisibility(oldDBVisibility);
|
||||||
deleteOldActivityDBButton.setOnClickListener(new View.OnClickListener() {
|
deleteOldActivityDBButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -90,7 +84,7 @@ public class DbManagementActivity extends AbstractGBActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteDBButton = (Button) findViewById(R.id.emptyDBButton);
|
Button deleteDBButton = findViewById(R.id.emptyDBButton);
|
||||||
deleteDBButton.setOnClickListener(new View.OnClickListener() {
|
deleteDBButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -115,24 +109,20 @@ public class DbManagementActivity extends AbstractGBActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void exportShared() {
|
private void exportShared() {
|
||||||
// BEGIN EXAMPLE
|
|
||||||
File myPath = null;
|
|
||||||
try {
|
try {
|
||||||
myPath = FileUtils.getExternalFilesDir();
|
File myPath = FileUtils.getExternalFilesDir();
|
||||||
File myFile = new File(myPath, "Export_preference");
|
File myFile = new File(myPath, "Export_preference");
|
||||||
shared_file.exportToFile(sharedPrefs,myFile,null);
|
ImportExportSharedPreferences.exportToFile(sharedPrefs, myFile, null);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
GB.toast(this, getString(R.string.dbmanagementactivity_error_exporting_shared, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
GB.toast(this, getString(R.string.dbmanagementactivity_error_exporting_shared, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importShared() {
|
private void importShared() {
|
||||||
// BEGIN EXAMPLE
|
|
||||||
File myPath = null;
|
|
||||||
try {
|
try {
|
||||||
myPath = FileUtils.getExternalFilesDir();
|
File myPath = FileUtils.getExternalFilesDir();
|
||||||
File myFile = new File(myPath, "Export_preference");
|
File myFile = new File(myPath, "Export_preference");
|
||||||
shared_file.importFromFile(sharedPrefs,myFile );
|
ImportExportSharedPreferences.importFromFile(sharedPrefs, myFile);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
||||||
}
|
}
|
||||||
@ -227,10 +217,9 @@ public class DbManagementActivity extends AbstractGBActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user