mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 20:36:51 +01:00
make look nicer - font, uri string, buttons positions
This commit is contained in:
parent
503fe854eb
commit
3d6ddb8d5e
@ -17,13 +17,18 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@ -45,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
@ -104,7 +110,8 @@ public class DbManagementActivity extends AbstractGBActivity {
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
boolean autoExportEnabled = prefs.getBoolean(GBPrefs.AUTO_EXPORT_ENABLED, false);
|
||||
Integer autoExportInterval = prefs.getInt(GBPrefs.AUTO_EXPORT_INTERVAL, 0);
|
||||
String autoExportLocation = prefs.getString(GBPrefs.AUTO_EXPORT_LOCATION, "");
|
||||
//returns an ugly content://...
|
||||
//String autoExportLocation = prefs.getString(GBPrefs.AUTO_EXPORT_LOCATION, "");
|
||||
|
||||
int testExportVisibility = (autoExportInterval > 0 && autoExportEnabled) ? View.VISIBLE : View.GONE;
|
||||
|
||||
@ -114,22 +121,54 @@ public class DbManagementActivity extends AbstractGBActivity {
|
||||
TextView autoExportLocation_intro = findViewById(R.id.autoExportLocation_intro);
|
||||
autoExportLocation_intro.setVisibility(testExportVisibility);
|
||||
|
||||
TextView autoExportLocationview = findViewById(R.id.autoExportLocationview);
|
||||
autoExportLocationview.setVisibility(testExportVisibility);
|
||||
autoExportLocationview.setText(autoExportLocation);
|
||||
TextView autoExportLocation_path = findViewById(R.id.autoExportLocation_path);
|
||||
autoExportLocation_path.setVisibility(testExportVisibility);
|
||||
autoExportLocation_path.setText(getAutoExportLocationSummary());
|
||||
|
||||
final Context context = getApplicationContext();
|
||||
Button testExportDBButton = findViewById(R.id.testExportDBButton);
|
||||
testExportDBButton.setVisibility(testExportVisibility);
|
||||
testExportDBButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sendBroadcast(new Intent(getApplicationContext(), PeriodicExporter.class));
|
||||
sendBroadcast(new Intent(context, PeriodicExporter.class));
|
||||
GB.toast(context,
|
||||
context.getString(R.string.activity_DB_test_export_message),
|
||||
Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
});
|
||||
|
||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
}
|
||||
|
||||
//would rather re-use method of SettingsActivity... but lifecycle...
|
||||
private String getAutoExportLocationSummary() {
|
||||
String autoExportLocation = GBApplication.getPrefs().getString(GBPrefs.AUTO_EXPORT_LOCATION, null);
|
||||
if (autoExportLocation == null) {
|
||||
return "";
|
||||
}
|
||||
Uri uri = Uri.parse(autoExportLocation);
|
||||
try {
|
||||
return AndroidUtils.getFilePath(getApplicationContext(), uri);
|
||||
} catch (IllegalArgumentException e) {
|
||||
try {
|
||||
Cursor cursor = getContentResolver().query(
|
||||
uri,
|
||||
new String[]{DocumentsContract.Document.COLUMN_DISPLAY_NAME},
|
||||
null, null, null, null
|
||||
);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return cursor.getString(cursor.getColumnIndex(DocumentsContract.Document.COLUMN_DISPLAY_NAME));
|
||||
}
|
||||
}
|
||||
catch (Exception fdfsdfds) {
|
||||
LOG.warn("fuck");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private boolean hasOldActivityDatabase() {
|
||||
return new DBHelper(this).existsDB("ActivityDatabase");
|
||||
}
|
||||
|
@ -30,18 +30,6 @@
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_columnWeight="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/exportDBButton"
|
||||
android:text="@string/activity_DB_ExportButton"
|
||||
grid:layout_column="0"
|
||||
grid:layout_gravity="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/importDBButton"
|
||||
android:text="@string/activity_DB_import_button"
|
||||
grid:layout_column="1"
|
||||
grid:layout_gravity="center" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/db_management_intro"
|
||||
@ -56,11 +44,24 @@
|
||||
android:id="@+id/activity_db_management_path"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold"
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_columnWeight="1" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/exportDBButton"
|
||||
android:text="@string/activity_DB_ExportButton"
|
||||
grid:layout_column="0"
|
||||
grid:layout_gravity="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/importDBButton"
|
||||
android:text="@string/activity_DB_import_button"
|
||||
grid:layout_column="1"
|
||||
grid:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/autoExportLocation_label"
|
||||
android:layout_width="wrap_content"
|
||||
@ -82,10 +83,11 @@
|
||||
grid:layout_columnWeight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/autoExportLocationview"
|
||||
android:id="@+id/autoExportLocation_path"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold"
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_columnWeight="1" />
|
||||
|
||||
|
@ -569,7 +569,8 @@
|
||||
<string name="activity_db_management_autoexport_label">AutoExport</string>
|
||||
<string name="activity_DB_ExportButton">Export DB</string>
|
||||
<string name="activity_DB_import_button">Import DB</string>
|
||||
<string name="activity_DB_test_export_button">Test AutoExport Now</string>
|
||||
<string name="activity_DB_test_export_button">Run AutoExport Now</string>
|
||||
<string name="activity_DB_test_export_message">Exporting database...</string>
|
||||
<string name="activity_DB_delete_legacy_button">Delete old DB</string>
|
||||
<string name="activity_DB_empty_button">Empty DB</string>
|
||||
<string name="activity_db_management_empty_DB">Empty Database</string>
|
||||
|
Loading…
Reference in New Issue
Block a user