mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 02:12:15 -05:00
Merge pull request #125 from wilian-cb/issue-3945
3945: Handling error when there's no File Manager application used in import settings
This commit is contained in:
commit
8d5ad172c6
@ -1128,4 +1128,10 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
|
||||
<string name="unread_widget_label">K-9 Unread</string>
|
||||
<string name="unread_widget_select_account">Show unread count for…</string>
|
||||
|
||||
<string name="import_dialog_error_title">Missing File Manager Application</string>
|
||||
<string name="import_dialog_error_message">There is no suitable application to handle
|
||||
the import operation. Please install a file manager application from Android Market</string>
|
||||
<string name="open_market">Open Market</string>
|
||||
<string name="close">Close</string>
|
||||
</resources>
|
||||
|
@ -24,6 +24,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -106,6 +107,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
*/
|
||||
private static final Flag[] EMPTY_FLAG_ARRAY = new Flag[0];
|
||||
|
||||
/**
|
||||
* URL used to open Android Market application
|
||||
*/
|
||||
private static final String ANDROID_MARKET_URL = "http://market.android.com/";
|
||||
|
||||
/**
|
||||
* Number of special accounts ('Unified Inbox' and 'All Messages')
|
||||
*/
|
||||
@ -1256,7 +1262,33 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
i.setType(MimeUtility.K9_SETTINGS_MIME_TYPE);
|
||||
startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
|
||||
|
||||
PackageManager packageManager = getPackageManager();
|
||||
List<ResolveInfo> infos = packageManager.queryIntentActivities(i, 0);
|
||||
|
||||
if (infos.size() > 0) {
|
||||
startActivityForResult(Intent.createChooser(i, null),
|
||||
ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
|
||||
} else {
|
||||
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int button) {
|
||||
if (button == DialogInterface.BUTTON_POSITIVE) {
|
||||
Uri uri = Uri.parse(ANDROID_MARKET_URL);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
} else if (button == DialogInterface.BUTTON_NEGATIVE) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(getString(R.string.import_dialog_error_title))
|
||||
.setMessage(getString(R.string.import_dialog_error_message))
|
||||
.setPositiveButton(getString(R.string.open_market), listener)
|
||||
.setNegativeButton(getString(R.string.close), listener)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user