changed the account adding a bit, hopefully working with Froyo, at least preventing a crash

Update issue 39
added:
<string name="error_accountReadingNotAllowed">no permission to read the account</string>
This commit is contained in:
Thialfihar 2010-08-05 11:25:44 +00:00
parent a88af8a85e
commit 281535cfcc
4 changed files with 55 additions and 10 deletions

View File

@ -17,7 +17,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.thialfihar.android.apg"
android:versionCode="19" android:versionName="1.0.5">
android:versionCode="20" android:versionName="1.0.6">
<application
android:icon="@drawable/icon"
@ -198,6 +198,7 @@
android:description="@string/permission_read_key_details_description"/>
<uses-permission android:name="com.google.android.providers.gmail.permission.READ_GMAIL" />
<uses-permission android:name="com.google.android.gm.permission.READ_GMAIL" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.fsck.k9.permission.READ_ATTACHMENT" />

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dip"
android:paddingRight="5dip">
<EditText
android:id="@+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"/>
</LinearLayout>

View File

@ -197,6 +197,7 @@
<string name="error_noKnownEncryptionFound">no known kind of encryption found</string>
<string name="error_externalStorageNotReady">external storage not ready</string>
<string name="error_accountNotFound">account \'%s\' not found</string>
<string name="error_accountReadingNotAllowed">no permission to read the account</string>
<string name="error_addingAccountFailed">adding account \'%s\' failed</string>
<string name="error_invalidEmail">invalid email \'%s\'</string>
<string name="error_keySizeMinimum512bit">key size must be at least 512bit</string>

View File

@ -140,8 +140,12 @@ public class MainActivity extends BaseActivity {
alert.setTitle(R.string.title_addAccount);
alert.setMessage(R.string.specifyGoogleMailAccount);
final EditText input = new EditText(this);
alert.setView(input);
LayoutInflater inflater =
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = (View) inflater.inflate(R.layout.add_account_dialog, null);
final EditText input = (EditText) view.findViewById(R.id.input);
alert.setView(view);
alert.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@ -149,15 +153,23 @@ public class MainActivity extends BaseActivity {
MainActivity.this.removeDialog(Id.dialog.new_account);
String accountName = "" + input.getText();
Cursor testCursor =
managedQuery(Uri.parse("content://gmail-ls/conversations/" +
accountName),
null, null, null, null);
if (testCursor == null) {
try {
Cursor testCursor =
managedQuery(Uri.parse("content://gmail-ls/conversations/" +
accountName),
null, null, null, null);
if (testCursor == null) {
Toast.makeText(MainActivity.this,
getString(R.string.errorMessage,
getString(R.string.error_accountNotFound,
accountName)),
Toast.LENGTH_SHORT).show();
return;
}
} catch (SecurityException e) {
Toast.makeText(MainActivity.this,
getString(R.string.errorMessage,
getString(R.string.error_accountNotFound,
accountName)),
getString(R.string.error_accountReadingNotAllowed)),
Toast.LENGTH_SHORT).show();
return;
}