// Path: src/org/immopoly/android/model/OAuthData.java
// public class OAuthData {
// 
// 	public static final String SERVER = "http://rest.immobilienscout24.de";
// 	public static final String OAUTH_SECURITY_PREFIX = "/restapi/security/oauth/";
// 
// 	public static final String AUTHORIZATION_ENDPOINT = SERVER
// 			+ OAUTH_SECURITY_PREFIX + "confirm_access";
// 	public static final String ACCESS_TOKEN_ENDPOINT = SERVER
// 			+ OAUTH_SECURITY_PREFIX + "access_token";
// 	public static final String REQUEST_TOKEN_ENDPOINT = SERVER
// 			+ OAUTH_SECURITY_PREFIX + "request_token";
// 
// 	public static String CONSUMER_KEY = ""; // e. g. a system
// 	// identifier
// 	public static String CONSUMER_SECRET = "";
// 
// 	// technical and business context of the search webservice
// 	public static final String SEARCH_PREFIX = "/restapi/api" + "/search/v1.0/";
// 
// 	public OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY,
// 			CONSUMER_SECRET);
// 
// 	public OAuthProvider provider = new DefaultOAuthProvider(
// 			REQUEST_TOKEN_ENDPOINT, ACCESS_TOKEN_ENDPOINT,
// 			AUTHORIZATION_ENDPOINT);
// 
// 	public String accessToken = "";
// 	public boolean signedIn = false;
// 
// 	public static String sExposeUrl = "http://mobil.immobilienscout24.de"
// 			+ "/expose/";
// 	public static String sExposeUrlWeb = "http://immobilienscout24.de"
// 			+ "/expose/";
// 	private static OAuthData mInstance = null;
// 
// 	private OAuthData() {
// 	}
// 
// 	private OAuthData(Context context) {
// 		/**
// 		 * AN ERROR HERE IS NORMAL, we don't commit these properties, just
// 		 * create them in you project as resources in the string.xml or create a
// 		 * new file for that
// 		 */
// 		CONSUMER_KEY = context
// 				.getString(org.immopoly.android.R.string.consumer_key);
// 		CONSUMER_SECRET = context
// 				.getString(org.immopoly.android.R.string.consumer_secret);
// 		accessToken = context
// 				.getString(org.immopoly.android.R.string.is24_access_token);
// 		consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
// 		provider = new DefaultOAuthProvider(REQUEST_TOKEN_ENDPOINT,
// 				ACCESS_TOKEN_ENDPOINT, AUTHORIZATION_ENDPOINT);
// 	}
// 
// 	public static OAuthData getInstance(Context context) {
// 		if (mInstance == null) {
// 			mInstance = new OAuthData(context);
// 		}
// 		return mInstance;
// 	}
// }


import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import org.immopoly.android.R;
import org.immopoly.android.model.OAuthData;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.util.DisplayMetrics;
/*
 * This is the Android component of Immopoly
 * http://immopoly.appspot.com
 * Copyright (C) 2011 Tobias Sasse
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package org.immopoly.android.helper;



public class Settings {

	private static ImageListDownloader exposeImageDownloader;
	private static float screenDesity;
	
	public static void shareMessage(Context context, String title,
			String message, String link) {
		final String tag = "@immopoly";
		/*
		 * This code can limit the size of the messages which will be shared, 
		 * not needed at the moment
		final int maxMessage = 140;
		int overhead = maxMessage - message.length() - link.length() - 1
				- tag.length() - 1 - title.length() - 1;
		if (overhead < 0) {
			message = message.substring((-1)*overhead, message.length() - 1);
		}
		message = title + message;
		*/
		message += " " + link + " " + tag;
		final Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_SUBJECT, title);
		intent.putExtra(Intent.EXTRA_TEXT, message);
		context.startActivity(Intent.createChooser(intent, "Share"));
	}

	public static boolean isOnline(Context context) {
		ConnectivityManager cm = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (cm.getActiveNetworkInfo() == null) {
			return false;
		}
		return cm.getActiveNetworkInfo().isConnectedOrConnecting();

	}

	public static String getFlatLink(String exposeID, boolean mobile) {
		if(mobile)
			return OAuthData.sExposeUrl + exposeID;
		else
// Path: src/org/immopoly/android/model/OAuthData.java
// public class OAuthData {
// 
// 	public static final String SERVER = "http://rest.immobilienscout24.de";
// 	public static final String OAUTH_SECURITY_PREFIX = "/restapi/security/oauth/";
// 
// 	public static final String AUTHORIZATION_ENDPOINT = SERVER
// 			+ OAUTH_SECURITY_PREFIX + "confirm_access";
// 	public static final String ACCESS_TOKEN_ENDPOINT = SERVER
// 			+ OAUTH_SECURITY_PREFIX + "access_token";
// 	public static final String REQUEST_TOKEN_ENDPOINT = SERVER
// 			+ OAUTH_SECURITY_PREFIX + "request_token";
// 
// 	public static String CONSUMER_KEY = ""; // e. g. a system
// 	// identifier
// 	public static String CONSUMER_SECRET = "";
// 
// 	// technical and business context of the search webservice
// 	public static final String SEARCH_PREFIX = "/restapi/api" + "/search/v1.0/";
// 
// 	public OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY,
// 			CONSUMER_SECRET);
// 
// 	public OAuthProvider provider = new DefaultOAuthProvider(
// 			REQUEST_TOKEN_ENDPOINT, ACCESS_TOKEN_ENDPOINT,
// 			AUTHORIZATION_ENDPOINT);
// 
// 	public String accessToken = "";
// 	public boolean signedIn = false;
// 
// 	public static String sExposeUrl = "http://mobil.immobilienscout24.de"
// 			+ "/expose/";
// 	public static String sExposeUrlWeb = "http://immobilienscout24.de"
// 			+ "/expose/";
// 	private static OAuthData mInstance = null;
// 
// 	private OAuthData() {
// 	}
// 
// 	private OAuthData(Context context) {
// 		/**
// 		 * AN ERROR HERE IS NORMAL, we don't commit these properties, just
// 		 * create them in you project as resources in the string.xml or create a
// 		 * new file for that
// 		 */
// 		CONSUMER_KEY = context
// 				.getString(org.immopoly.android.R.string.consumer_key);
// 		CONSUMER_SECRET = context
// 				.getString(org.immopoly.android.R.string.consumer_secret);
// 		accessToken = context
// 				.getString(org.immopoly.android.R.string.is24_access_token);
// 		consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
// 		provider = new DefaultOAuthProvider(REQUEST_TOKEN_ENDPOINT,
// 				ACCESS_TOKEN_ENDPOINT, AUTHORIZATION_ENDPOINT);
// 	}
// 
// 	public static OAuthData getInstance(Context context) {
// 		if (mInstance == null) {
// 			mInstance = new OAuthData(context);
// 		}
// 		return mInstance;
// 	}
// }


// Path: src/org/immopoly/android/helper/Settings.java
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import org.immopoly.android.R;
import org.immopoly.android.model.OAuthData;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.util.DisplayMetrics;

/*
 * This is the Android component of Immopoly
 * http://immopoly.appspot.com
 * Copyright (C) 2011 Tobias Sasse
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package org.immopoly.android.helper;



public class Settings {

	private static ImageListDownloader exposeImageDownloader;
	private static float screenDesity;
	
	public static void shareMessage(Context context, String title,
			String message, String link) {
		final String tag = "@immopoly";
		/*
		 * This code can limit the size of the messages which will be shared, 
		 * not needed at the moment
		final int maxMessage = 140;
		int overhead = maxMessage - message.length() - link.length() - 1
				- tag.length() - 1 - title.length() - 1;
		if (overhead < 0) {
			message = message.substring((-1)*overhead, message.length() - 1);
		}
		message = title + message;
		*/
		message += " " + link + " " + tag;
		final Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_SUBJECT, title);
		intent.putExtra(Intent.EXTRA_TEXT, message);
		context.startActivity(Intent.createChooser(intent, "Share"));
	}

	public static boolean isOnline(Context context) {
		ConnectivityManager cm = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (cm.getActiveNetworkInfo() == null) {
			return false;
		}
		return cm.getActiveNetworkInfo().isConnectedOrConnecting();

	}

	public static String getFlatLink(String exposeID, boolean mobile) {
		if(mobile)
			return OAuthData.sExposeUrl + exposeID;
		else
			return OAuthData.sExposeUrlWeb + exposeID;