mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-20 17:11:32 -08:00
Add warning when sdcard is not mounted.
This commit is contained in:
1 parent
611a639b54
commit
db7d2edf04
5 files changed
+39
-1
No files matched your search
@@ -21,6 +21,11 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView android:id="@+id/label_warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:visibility="invisible" />
|
||||
<TextView android:id="@+id/label_open_by_filename"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<com.keepassdroid.view.FileNameView
|
||||
<com.keepassdroid.view.FileNameView android:id="@+id/file_select"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
<!--
|
||||
|
||||
@@ -145,6 +145,8 @@
|
||||
<string name="show_password">Show password</string>
|
||||
<string name="twofish">Twofish</string>
|
||||
<string name="unsupported_db_version">Unsupported database version.</string>
|
||||
<string name="warning_read_only">Your sd card is currently read-only. You may not be able to save changes to your database.</string>
|
||||
<string name="warning_unmounted">Your sd card is not currently mounted on your device. You will not be able to load or create your database.</string>
|
||||
|
||||
<string-array name="clipboard_timeout_options">
|
||||
<item>30 seconds</item>
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.keepassdroid.intents.Intents;
|
||||
import com.keepassdroid.settings.AppSettingsActivity;
|
||||
import com.keepassdroid.utils.Interaction;
|
||||
import com.keepassdroid.utils.Util;
|
||||
import com.keepassdroid.view.FileNameView;
|
||||
|
||||
public class FileSelectActivity extends ListActivity {
|
||||
|
||||
@@ -316,6 +317,9 @@ public class FileSelectActivity extends ListActivity {
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
FileNameView fnv = (FileNameView) findViewById(R.id.file_select);
|
||||
fnv.updateExternalStorageWarning();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.keepassdroid.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.keepass.R;
|
||||
|
||||
@@ -27,4 +29,29 @@ public class FileNameView extends RelativeLayout {
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.file_selection_filename, this);
|
||||
}
|
||||
|
||||
public void updateExternalStorageWarning() {
|
||||
int warning = -1;
|
||||
String state = Environment.getExternalStorageState();
|
||||
if (state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
|
||||
warning = R.string.warning_read_only;
|
||||
} else if (!state.equals(Environment.MEDIA_MOUNTED)) {
|
||||
warning = R.string.warning_unmounted;
|
||||
}
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.label_warning);
|
||||
TextView label = (TextView) findViewById(R.id.label_open_by_filename);
|
||||
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
if (warning != -1) {
|
||||
tv.setText(warning);
|
||||
tv.setVisibility(VISIBLE);
|
||||
|
||||
lp.addRule(RelativeLayout.BELOW, R.id.label_warning);
|
||||
} else {
|
||||
tv.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
label.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user