Style changes and logging
This commit is contained in:
parent
3fd3db6c57
commit
bc9bd0bfcf
|
@ -11,6 +11,7 @@ import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.content.IntentCompat;
|
import android.support.v4.content.IntentCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
|
@ -31,6 +32,7 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
private static final int REQUEST_CODE_RESTORE = 43;
|
private static final int REQUEST_CODE_RESTORE = 43;
|
||||||
private static final int REQUEST_CODE_BACKUP_DOCUMENT = 44;
|
private static final int REQUEST_CODE_BACKUP_DOCUMENT = 44;
|
||||||
private static final String EXPORT_FILENAME = "AntennaPodBackup.db";
|
private static final String EXPORT_FILENAME = "AntennaPodBackup.db";
|
||||||
|
private static final String TAG = ImportExportActivity.class.getSimpleName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -43,11 +45,6 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
findViewById(R.id.button_import).setOnClickListener(view -> restore());
|
findViewById(R.id.button_import).setOnClickListener(view -> restore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == android.R.id.home) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
@ -71,9 +68,9 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
File sd = Environment.getExternalStorageDirectory();
|
File sd = Environment.getExternalStorageDirectory();
|
||||||
File backupDB = new File(sd, EXPORT_FILENAME);
|
File backupDB = new File(sd, EXPORT_FILENAME);
|
||||||
writeBackupTo(new FileOutputStream(backupDB));
|
writeBackupTo(new FileOutputStream(backupDB));
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
Snackbar.make(findViewById(R.id.import_export_layout), e.getMessage(), Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,10 +90,14 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
||||||
if (requestCode == REQUEST_CODE_RESTORE && resultCode == RESULT_OK && resultData != null) {
|
if (resultCode != RESULT_OK || resultData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestCode == REQUEST_CODE_RESTORE) {
|
||||||
Uri uri = resultData.getData();
|
Uri uri = resultData.getData();
|
||||||
restoreFrom(uri);
|
restoreFrom(uri);
|
||||||
} else if (requestCode == REQUEST_CODE_BACKUP_DOCUMENT && resultCode == RESULT_OK && resultData != null) {
|
} else if (requestCode == REQUEST_CODE_BACKUP_DOCUMENT) {
|
||||||
Uri uri = resultData.getData();
|
Uri uri = resultData.getData();
|
||||||
backupToDocument(uri);
|
backupToDocument(uri);
|
||||||
}
|
}
|
||||||
|
@ -109,9 +110,9 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
copyInputStreamToFile(inputStream, currentDB);
|
copyInputStreamToFile(inputStream, currentDB);
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
displayImportSuccessDialog();
|
displayImportSuccessDialog();
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
Snackbar.make(findViewById(R.id.import_export_layout), e.getMessage(), Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +138,9 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
out.write(buf, 0, len);
|
out.write(buf, 0, len);
|
||||||
}
|
}
|
||||||
out.close();
|
out.close();
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,10 +155,8 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
Snackbar.make(findViewById(R.id.import_export_layout),
|
Snackbar.make(findViewById(R.id.import_export_layout),
|
||||||
R.string.export_ok, Snackbar.LENGTH_SHORT).show();
|
R.string.export_ok, Snackbar.LENGTH_SHORT).show();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show();
|
||||||
Snackbar.make(findViewById(R.id.import_export_layout),
|
|
||||||
"Can not write SD", Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,11 +177,9 @@ public class ImportExportActivity extends AppCompatActivity {
|
||||||
Snackbar.make(findViewById(R.id.import_export_layout),
|
Snackbar.make(findViewById(R.id.import_export_layout),
|
||||||
"Can not access current database", Snackbar.LENGTH_SHORT).show();
|
"Can not access current database", Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show();
|
||||||
Snackbar.make(findViewById(R.id.import_export_layout), e.getMessage(), Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue