Sha256: 92a75d45e2410e6df803ad7434ac3d2e0064624d409e92387114e413565c2dc0

Contents?: true

Size: 1.89 KB

Versions: 16

Compression:

Stored size: 1.89 KB

Contents

/*
 ============================================================================
 Author	    : Dmitry Moskalchuk
 Version	: 1.5
 Copyright  : Copyright (C) 2008 Rhomobile. All rights reserved.

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ============================================================================
 */
package com.rhomobile.rhodes.uri;

import com.rhomobile.rhodes.Logger;

import android.content.Context;
import android.content.Intent;
import android.net.MailTo;
import android.net.Uri;

public class MailUriHandler implements UriHandler {
	
	private static final String TAG = "MailUriHandler";
	
	private Context ctx;
	
	public MailUriHandler(Context c) {
		ctx = c;
	}
	
	public boolean handle(String url) {
		Uri uri = Uri.parse(url);
		if (!uri.getScheme().equals("mailto"))
			return false;
	
		Logger.D(TAG, "This is 'mailto' uri, handle it");
		
		MailTo muri = MailTo.parse(url);
		
		Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("message/rfc882");
		
		String s = muri.getTo();
		if (s != null) intent.putExtra(Intent.EXTRA_EMAIL, new String[]{s});
		
		s = muri.getSubject();
		if (s != null) intent.putExtra(Intent.EXTRA_SUBJECT, s);
		
		s = muri.getBody();
		if (s != null) intent.putExtra(Intent.EXTRA_TEXT, s);
		
		ctx.startActivity(Intent.createChooser(intent, "Send e-mail..."));
		return true;
	}

}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rhodes-2.1.0 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.3 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.2 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.rc2 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.rc1 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta11 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta10 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta9 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta8 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta7 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta6 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta4 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta3 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta2 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java
rhodes-2.0.0.beta1 platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java