// Path: app/src/main/java/com/pindroid/client/NetworkUtilities.java
// public class NetworkUtilities {
//     private static final String TAG = "NetworkUtilities";
// 
//     private static final String SCHEME = "https";
//     private static final String PINBOARD_AUTHORITY = "api.pinboard.in";
//     private static final int PORT = 443;
//  
//     private static final AuthScope SCOPE = new AuthScope(PINBOARD_AUTHORITY, PORT);
// 
//     /**
//      * Attempts to authenticate to Pinboard using a legacy Pinboard account.
//      * 
//      * @param username The user's username.
//      * @param password The user's password.
//      * @param handler The hander instance from the calling UI thread.
//      * @param context The context of the calling Activity.
//      * @return The boolean result indicating whether the user was
//      *         successfully authenticated.
//      */
//     public static boolean pinboardAuthenticate(String username, String password) {
//         final HttpResponse resp;
//         
//         Uri.Builder builder = new Uri.Builder();
//         builder.scheme(SCHEME);
//         builder.authority(PINBOARD_AUTHORITY);
//         builder.appendEncodedPath("v1/posts/update");
//         Uri uri = builder.build();
// 
//         HttpGet request = new HttpGet(String.valueOf(uri));
// 
//         DefaultHttpClient client = (DefaultHttpClient)HttpClientFactory.getThreadSafeClient();
//         
//         CredentialsProvider provider = client.getCredentialsProvider();
//         Credentials credentials = new UsernamePasswordCredentials(username, password);
//         provider.setCredentials(SCOPE, credentials);
// 
//         try {
//             resp = client.execute(request);
//             if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
//                 if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                     Log.v(TAG, "Successful authentication");
//                 }
//                 return true;
//             } else {
//                 if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                     Log.v(TAG, "Error authenticating" + resp.getStatusLine());
//                 }
//                 return false;
//             }
//         } catch (final IOException e) {
//             if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                 Log.v(TAG, "IOException when getting authtoken", e);
//             }
//             return false;
//         } finally {
//             if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                 Log.v(TAG, "getAuthtoken completing");
//             }
//         }
//     }
//     
//     /**
//      * Gets the title of a web page.
//      * 
//      * @param url The URL of the web page.
//      * @return A String containing the title of the web page.
//      */
//     public static String getWebpageTitle(String url) {
//    	
//     	if(url != null && !url.equals("")) {
//     		
//     		if(!url.startsWith("http")){
//     			url = "http://" + url;
//     		}
// 	
// 	    	HttpResponse resp = null;
// 	    	HttpGet post = null;
// 	    	
// 	    	try {
// 				post = new HttpGet(url.replace("|", "%7C"));
// 	
// 				post.setHeader("User-Agent", "Mozilla/5.0");
// 	
// 				resp = HttpClientFactory.getThreadSafeClient().execute(post);
// 
// 		    	if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 		    		String response = EntityUtils.toString(resp.getEntity(), HTTP.UTF_8);
// 		    		int start = response.indexOf("<title>") + 7;
// 		    		int end = response.indexOf("</title>", start + 1);
// 		    		String title = response.substring(start, end);
// 		    		return title;
// 		    	} else return "";
// 			} catch (Exception e) {
// 				return "";
// 			}
//     	} else return "";
//     }
//     
//     /**
//      * Gets the title of a web page.
//      * 
//      * @param url The URL of the web page.
//      * @return A String containing the title of the web page.
//      */
//     public static Article getArticleText(String url) {
//    	
//     	if(url != null && !url.equals("")) {
//     		
//     		if(!url.startsWith("http")){
//     			url = "http://" + url;
//     		}
// 	
// 	    	HttpResponse resp = null;
// 	    	HttpGet post = null;
// 	    	
// 	    	try {
// 				post = new HttpGet(Constants.TEXT_EXTRACTOR_URL + URLEncoder.encode(url, "UTF-8") + "&format=json");
// 	
// 				post.setHeader("User-Agent", "Mozilla/5.0");
// 	
// 				resp = HttpClientFactory.getThreadSafeClient().execute(post);
// 				
// 		        
// 		        final int statusCode = resp.getStatusLine().getStatusCode();
// 				
// 		    	if (statusCode == HttpStatus.SC_OK) {		    		
// 		    		final String response = EntityUtils.toString(resp.getEntity());
// 		    		
// 		    		final JSONObject article = new JSONObject(response);
// 		    		
// 		    		return Article.valueOf(article);
// 		    	}
// 			} catch (Exception e) {
// 				return null;
// 			}
//     	}
// 		return null;
//     }
// }


import android.os.AsyncTask;
import com.pindroid.client.NetworkUtilities;

package com.pindroid.action;




public class GetWebpageTitleTask extends AsyncTask<String, Integer, String>{
	private String url;
	
	@Override
	protected String doInBackground(String... args) {
		
		if(args.length > 0 && args[0] != null && args[0] != "") {
    		url = args[0];
	

// Path: app/src/main/java/com/pindroid/client/NetworkUtilities.java
// public class NetworkUtilities {
//     private static final String TAG = "NetworkUtilities";
// 
//     private static final String SCHEME = "https";
//     private static final String PINBOARD_AUTHORITY = "api.pinboard.in";
//     private static final int PORT = 443;
//  
//     private static final AuthScope SCOPE = new AuthScope(PINBOARD_AUTHORITY, PORT);
// 
//     /**
//      * Attempts to authenticate to Pinboard using a legacy Pinboard account.
//      * 
//      * @param username The user's username.
//      * @param password The user's password.
//      * @param handler The hander instance from the calling UI thread.
//      * @param context The context of the calling Activity.
//      * @return The boolean result indicating whether the user was
//      *         successfully authenticated.
//      */
//     public static boolean pinboardAuthenticate(String username, String password) {
//         final HttpResponse resp;
//         
//         Uri.Builder builder = new Uri.Builder();
//         builder.scheme(SCHEME);
//         builder.authority(PINBOARD_AUTHORITY);
//         builder.appendEncodedPath("v1/posts/update");
//         Uri uri = builder.build();
// 
//         HttpGet request = new HttpGet(String.valueOf(uri));
// 
//         DefaultHttpClient client = (DefaultHttpClient)HttpClientFactory.getThreadSafeClient();
//         
//         CredentialsProvider provider = client.getCredentialsProvider();
//         Credentials credentials = new UsernamePasswordCredentials(username, password);
//         provider.setCredentials(SCOPE, credentials);
// 
//         try {
//             resp = client.execute(request);
//             if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
//                 if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                     Log.v(TAG, "Successful authentication");
//                 }
//                 return true;
//             } else {
//                 if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                     Log.v(TAG, "Error authenticating" + resp.getStatusLine());
//                 }
//                 return false;
//             }
//         } catch (final IOException e) {
//             if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                 Log.v(TAG, "IOException when getting authtoken", e);
//             }
//             return false;
//         } finally {
//             if (Log.isLoggable(TAG, Log.VERBOSE)) {
//                 Log.v(TAG, "getAuthtoken completing");
//             }
//         }
//     }
//     
//     /**
//      * Gets the title of a web page.
//      * 
//      * @param url The URL of the web page.
//      * @return A String containing the title of the web page.
//      */
//     public static String getWebpageTitle(String url) {
//    	
//     	if(url != null && !url.equals("")) {
//     		
//     		if(!url.startsWith("http")){
//     			url = "http://" + url;
//     		}
// 	
// 	    	HttpResponse resp = null;
// 	    	HttpGet post = null;
// 	    	
// 	    	try {
// 				post = new HttpGet(url.replace("|", "%7C"));
// 	
// 				post.setHeader("User-Agent", "Mozilla/5.0");
// 	
// 				resp = HttpClientFactory.getThreadSafeClient().execute(post);
// 
// 		    	if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 		    		String response = EntityUtils.toString(resp.getEntity(), HTTP.UTF_8);
// 		    		int start = response.indexOf("<title>") + 7;
// 		    		int end = response.indexOf("</title>", start + 1);
// 		    		String title = response.substring(start, end);
// 		    		return title;
// 		    	} else return "";
// 			} catch (Exception e) {
// 				return "";
// 			}
//     	} else return "";
//     }
//     
//     /**
//      * Gets the title of a web page.
//      * 
//      * @param url The URL of the web page.
//      * @return A String containing the title of the web page.
//      */
//     public static Article getArticleText(String url) {
//    	
//     	if(url != null && !url.equals("")) {
//     		
//     		if(!url.startsWith("http")){
//     			url = "http://" + url;
//     		}
// 	
// 	    	HttpResponse resp = null;
// 	    	HttpGet post = null;
// 	    	
// 	    	try {
// 				post = new HttpGet(Constants.TEXT_EXTRACTOR_URL + URLEncoder.encode(url, "UTF-8") + "&format=json");
// 	
// 				post.setHeader("User-Agent", "Mozilla/5.0");
// 	
// 				resp = HttpClientFactory.getThreadSafeClient().execute(post);
// 				
// 		        
// 		        final int statusCode = resp.getStatusLine().getStatusCode();
// 				
// 		    	if (statusCode == HttpStatus.SC_OK) {		    		
// 		    		final String response = EntityUtils.toString(resp.getEntity());
// 		    		
// 		    		final JSONObject article = new JSONObject(response);
// 		    		
// 		    		return Article.valueOf(article);
// 		    	}
// 			} catch (Exception e) {
// 				return null;
// 			}
//     	}
// 		return null;
//     }
// }


// Path: app/src/main/java/com/pindroid/action/GetWebpageTitleTask.java
import android.os.AsyncTask;
import com.pindroid.client.NetworkUtilities;

package com.pindroid.action;




public class GetWebpageTitleTask extends AsyncTask<String, Integer, String>{
	private String url;
	
	@Override
	protected String doInBackground(String... args) {
		
		if(args.length > 0 && args[0] != null && args[0] != "") {
    		url = args[0];
	

    		return NetworkUtilities.getWebpageTitle(url);
