mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
K-9 Mail now opens the Accounts Activity when started with an Intent
with an enclosed URI with a content type of application/x-k9settings. This allows a user to bootstrap K-9 Mail configuration by email a settings file from one device to another, perhaps using a GMail account on the receiving end.
This commit is contained in:
parent
d9cb84047b
commit
107408c0d9
@ -75,6 +75,12 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:mimeType="application/x-k9settings" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -22,6 +22,7 @@ import android.webkit.WebView;
|
||||
import android.widget.*;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
import com.fsck.k9.*;
|
||||
import com.fsck.k9.helper.SizeFormatter;
|
||||
import com.fsck.k9.activity.setup.AccountSettings;
|
||||
@ -30,6 +31,7 @@ import com.fsck.k9.activity.setup.Prefs;
|
||||
import com.fsck.k9.controller.MessagingController;
|
||||
import com.fsck.k9.controller.MessagingListener;
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mail.internet.MimeUtility;
|
||||
import com.fsck.k9.view.ColorChip;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
@ -238,7 +240,23 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
intent.putExtra(EXTRA_STARTUP, false);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent)
|
||||
{
|
||||
Uri uri = intent.getData();
|
||||
Log.i(K9.LOG_TAG, "Accounts Activity got uri " + uri);
|
||||
if (uri != null) {
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
|
||||
Log.i(K9.LOG_TAG, "Accounts Activity got content of type " + contentResolver.getType(uri));
|
||||
|
||||
String contentType = contentResolver.getType(uri);
|
||||
if (MimeUtility.K9_SETTINGS_MIME_TYPE.equals(contentType)) {
|
||||
onImport(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@ -254,7 +272,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
|
||||
Account[] accounts = Preferences.getPreferences(this).getAccounts();
|
||||
Intent intent = getIntent();
|
||||
boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
|
||||
boolean startup = intent.getData() == null && intent.getBooleanExtra(EXTRA_STARTUP, true);
|
||||
onNewIntent(intent);
|
||||
if (startup && K9.startIntegratedInbox()) {
|
||||
onOpenAccount(integratedInboxAccount);
|
||||
finish();
|
||||
@ -280,6 +299,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||
|
||||
restoreAccountStats(icicle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -19,7 +19,7 @@ import java.nio.charset.Charset;
|
||||
public class MimeUtility {
|
||||
public static final String DEFAULT_ATTACHMENT_MIME_TYPE = "application/octet-stream";
|
||||
|
||||
|
||||
public static final String K9_SETTINGS_MIME_TYPE = "application/x-k9settings";
|
||||
|
||||
/*
|
||||
* http://www.w3schools.com/media/media_mimeref.asp
|
||||
@ -341,7 +341,7 @@ public class MimeUtility {
|
||||
{ "jpm", "video/jpm"},
|
||||
{ "js", "application/x-javascript"},
|
||||
{ "json", "application/json"},
|
||||
{ "k9s", "application/x-k9settings"},
|
||||
{ "k9s", K9_SETTINGS_MIME_TYPE},
|
||||
{ "kar", "audio/midi"},
|
||||
{ "karbon", "application/vnd.kde.karbon"},
|
||||
{ "kfo", "application/vnd.kde.kformula"},
|
||||
|
Loading…
Reference in New Issue
Block a user