diff --git a/res/drawable-hdpi/ic_null.png b/res/drawable-hdpi/ic_null.png
new file mode 100644
index 0000000..f4bc042
--- /dev/null
+++ b/res/drawable-hdpi/ic_null.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_null.png b/res/drawable-mdpi/ic_null.png
new file mode 100644
index 0000000..f536636
--- /dev/null
+++ b/res/drawable-mdpi/ic_null.png
Binary files differ
diff --git a/res/layout/dev_card.xml b/res/layout/dev_card.xml
new file mode 100644
index 0000000..4b43b41
--- /dev/null
+++ b/res/layout/dev_card.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2013, The Android Open Kang Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:paddingLeft="15dip"
+    android:paddingRight="15dip">
+
+    <RelativeLayout
+            android:id="@+id/image_here"
+            android:layout_width="wrap_content"
+            android:layout_height="150dip"
+            android:paddingTop="8dip"
+            android:gravity="center_vertical"
+            android:orientation="vertical">
+
+        <ImageView
+                android:id="@+id/photo"
+                android:layout_width="match_parent"
+                android:layout_height="150dip"
+                android:scaleType="centerCrop"/>
+
+        <View
+                android:id="@+id/photo_text_bar"
+                android:layout_width="wrap_content"
+                android:layout_height="42dip"
+                android:layout_alignBottom="@id/photo"
+                android:layout_alignLeft="@id/photo"
+                android:background="#7F000000"/>
+
+        <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="42dip"
+                android:layout_alignBottom="@id/photo"
+                android:layout_alignLeft="@id/photo"
+                android:gravity="center_vertical">
+
+            <TextView
+                    android:id="@+id/name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="8dip"
+                    android:singleLine="true"
+                    android:ellipsize="end"
+                    android:textColor="@android:color/white"
+                    android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+            <ImageView
+                    android:id="@+id/gplus_button"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="8dip"
+                    android:scaleType="centerInside"/>
+
+        </LinearLayout>
+
+	<ImageView
+                android:id="@+id/github_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignBottom="@id/photo"
+                android:layout_alignParentRight="true"
+                android:paddingRight="4dip"
+                android:paddingBottom="4dp"
+                android:layout_toRightOf="@+id/gplus_button"
+                android:scaleType="centerInside" />
+        
+    </RelativeLayout>
+
+</FrameLayout> 
diff --git a/res/layout/image_list_preference.xml b/res/layout/image_list_preference.xml
new file mode 100644
index 0000000..270e9d9
--- /dev/null
+++ b/res/layout/image_list_preference.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2013, The Android Open Kang Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:paddingBottom="12dp"
+    android:paddingLeft="6dp"
+    android:paddingRight="6dp"
+    android:paddingTop="12dp" >
+
+    <ImageView
+        android:id="@+id/image"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:adjustViewBounds="true" />
+
+</LinearLayout>
diff --git a/res/layout/summary_image_preference.xml b/res/layout/summary_image_preference.xml
new file mode 100644
index 0000000..08784e6
--- /dev/null
+++ b/res/layout/summary_image_preference.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2013, The Android Open Kang Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:gravity="center_vertical"
+    android:minHeight="?android:attr/listPreferredItemHeight"
+    android:paddingLeft="6dp"
+    android:paddingRight="6dp" >
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:gravity="center"
+        android:orientation="horizontal" >
+
+        <ImageView
+            android:id="@+android:id/icon"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:minWidth="48dp"
+            android:paddingRight="6dp" />
+    </LinearLayout>
+
+    <RelativeLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:paddingBottom="6dip"
+        android:paddingRight="6dp"
+        android:paddingTop="6dip" >
+
+        <TextView
+            android:id="@+android:id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ellipsize="marquee"
+            android:fadingEdge="horizontal"
+            android:singleLine="true"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="60dp"
+            android:layout_alignLeft="@android:id/title"
+            android:layout_below="@android:id/title" >
+
+            <ImageView
+                android:id="@+id/summary_image"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center" />
+        </LinearLayout>
+    </RelativeLayout>
+
+</LinearLayout>
diff --git a/res/values/bliss_attrs.xml b/res/values/bliss_attrs.xml
new file mode 100644
index 0000000..7d85594
--- /dev/null
+++ b/res/values/bliss_attrs.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 BlissRoms Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+    <!-- About Bliss -->
+     <declare-styleable name="DeveloperPreference">
+         <attr name="gplusHandle" format="string" />
+         <attr name="nameDev" format="string"/>
+	 <attr name="githubLink" format="string" />
+         <attr name="emailDev" format="string" />
+     </declare-styleable>
+ 
+     <declare-styleable name="ImageListPreference">
+         <attr name="summaryImage" format="reference" />
+         <attr name="entryImages" format="reference" />
+     </declare-styleable>
+
+</resources>
diff --git a/res/values/bliss_strings.xml b/res/values/bliss_strings.xml
index 9c93747..cb3ad20 100644
--- a/res/values/bliss_strings.xml
+++ b/res/values/bliss_strings.xml
@@ -17,5 +17,30 @@
 
     <!-- About Bliss -->
     <string name="about_bliss_title">Bliss</string>
+    <string name="about_phone_title">Phone</string>
+    <string name="share_bliss_title">Share BlissRoms</string>
+    <string name="share_bliss_summary">Let everyone know you are a Bliss</string>
+    <string name="share_message">get to know about #BlissRoms @ https://plus.google.com/communities/118265887490106132524</string>
+    <string name="share_chooser_title">Share BlissRoms</string>
+    <string name="bliss_source_title">Github</string>
+    <string name="bliss_source_summary">Build bliss for any device</string>
+    <string name="bliss_google_plus_title">Google</string>
+    <string name="bliss_google_plus_summary">Visit our G page for support and news</string>
+    <string name="team_bliss_title">Teambliss</string>
+    <string name="bliss_telegram_title">Telegram</string>
+    <string name="bliss_telegram_summary">Get Updates on News and Device builds via telegram</string>
+
+   <!-- Bliss version -->
+   <string name="bliss_version">Bliss version</string>
+   <string name="bliss_version_default">Unknown</string>
+
+   <!-- Bliss build date -->
+   <string name="build_date">Bliss build date</string>
+   <string name="build_date_default">2014-01-01-0000</string>
+
+    <!-- Changelog -->
+    <string name="changelog_bliss_title">Changelog</string>
+    <string name="changelog_bliss_error">Unable to load changelog</string>
+    <string name="changelog_summary">Quick peek on an update</string>
 
 </resources>
diff --git a/res/xml/about_bliss.xml b/res/xml/about_bliss.xml
index 0f736f8..d0166f4 100644
--- a/res/xml/about_bliss.xml
+++ b/res/xml/about_bliss.xml
@@ -16,5 +16,59 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
     android:title="@string/about_bliss_title" >
+    <PreferenceScreen android:layout="@layout/bliss_logo_row" android:key="bliss_logo" />
+
+        <!-- BlissRoms OTA -->
+        <PreferenceScreen 
+            android:key="bliss_ota"
+            android:title="@string/bliss_ota">
+                <intent
+                    android:action="android.intent.action.MAIN"
+    		        android:targetPackage="blissroms.updates"
+                    android:targetClass="blissroms.updates.activities.MainActivity" />
+        </PreferenceScreen>
+
+	<!-- Bliss version -->
+        <Preference android:key="bliss_version"
+            style="?android:preferenceInformationStyle"
+            android:title="@string/bliss_version"
+            android:summary="@string/bliss_version_default" />
+
+	<!-- Bliss build date -->
+        <Preference android:key="build_date"
+            style="?android:preferenceInformationStyle"
+            android:title="@string/build_date"
+            android:summary="@string/build_date_default" />
+
+	<!-- Changelog -->
+        <PreferenceScreen
+            android:key="changelog"
+            android:title="@string/changelog_bliss_title"
+            android:fragment="com.blissroms.about.Changelog"
+	    android:summary="@string/changelog_summary" />
+
+        <!-- Bliss Share -->
+        <PreferenceScreen
+            android:key="share"
+            android:title="@string/share_bliss_title"
+            android:summary="@string/share_bliss_summary" />
+
+        <!-- Bliss Github -->
+        <PreferenceScreen
+            android:key="bliss_source"
+            android:title="@string/bliss_source_title"
+            android:summary="@string/bliss_source_summary" />
+
+	<!-- Bliss Telegram -->
+        <PreferenceScreen
+            android:key="bliss_telegram"
+            android:title="@string/bliss_telegram_title"
+            android:summary="@string/bliss_telegram_summary" />
+
+        <!-- Bliss GooglePlus -->
+        <PreferenceScreen
+            android:key="bliss_google_plus"
+            android:title="@string/bliss_google_plus_title"
+            android:summary="@string/bliss_google_plus_summary" />
 
 </PreferenceScreen>
diff --git a/src/com/blissroms/About.java b/src/com/blissroms/BlissInfoSettings.java
similarity index 93%
rename from src/com/blissroms/About.java
rename to src/com/blissroms/BlissInfoSettings.java
index 5368cb3..10b6d12 100644
--- a/src/com/blissroms/About.java
+++ b/src/com/blissroms/BlissInfoSettings.java
@@ -34,6 +34,7 @@
 import android.view.ViewGroup;
 import com.android.settings.DeviceInfoSettings;
 import com.blissroms.blissify.PagerSlidingTabStrip;
+import com.blissroms.about.AboutBliss;
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.SettingsPreferenceFragment;
@@ -43,7 +44,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-public class About extends SettingsPreferenceFragment {
+public class BlissInfoSettings extends SettingsPreferenceFragment {
 
     ViewPager mViewPager;
     String titleString[];
@@ -56,7 +57,7 @@
         mContainer = container;
 	final ActionBar actionBar = getActivity().getActionBar();
 
-        View view = inflater.inflate(R.layout.additional_settings, container, false);
+        View view = inflater.inflate(R.layout.blissify_ui, container, false);
         mViewPager = (ViewPager) view.findViewById(R.id.pager);
 	mTabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
 
@@ -116,7 +117,7 @@
     private String[] getTitles() {
         String titleString[];
         titleString = new String[]{
-		    getString(R.string.about_settings),
+		    getString(R.string.about_phone_title),
   		    getString(R.string.about_bliss_title)};
         return titleString;
     }
diff --git a/src/com/blissroms/about/AboutBliss.java b/src/com/blissroms/about/AboutBliss.java
index 8ddf55d..d003d73 100644
--- a/src/com/blissroms/about/AboutBliss.java
+++ b/src/com/blissroms/about/AboutBliss.java
@@ -16,11 +16,14 @@
 
 package com.blissroms.about;
 
+import android.app.Activity;
 import android.os.Bundle;
+import android.net.Uri;
+import android.os.Build;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
 import android.provider.Settings;
-
+import android.content.Intent;
 import com.android.settings.Utils;
 import android.os.SystemProperties;
 import com.android.settings.R;
@@ -34,17 +37,64 @@
 
 public class AboutBliss extends SettingsPreferenceFragment {
 
+	private static final String KEY_MOD_BUILD_DATE = "build_date";
+	private static final String KEY_BLISS_VERSION = "bliss_version";
+	private static final String KEY_BLISS_SHARE = "share";
+
+	Preference mSourceUrl;
+	Preference mGoogleUrl;
+	Preference mTelegramUrl;
+
+
     @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
         addPreferencesFromResource(R.xml.about_bliss);
+
+	setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");
+	setValueSummary(KEY_BLISS_VERSION, "ro.bliss.version");
+	findPreference(KEY_BLISS_VERSION).setEnabled(true);
+        mSourceUrl = findPreference("bliss_source");
+	mTelegramUrl = findPreference("bliss_telegram");
+        mGoogleUrl = findPreference("bliss_google_plus");
+    }
+
+   private void setValueSummary(String preference, String property) {
+        try {
+            findPreference(preference).setSummary(
+                    SystemProperties.get(property,
+                            getResources().getString(R.string.device_info_default)));
+        } catch (RuntimeException e) {
+            // No recovery
+        }
     }
 
     @Override
-    public boolean onPreferenceChange(Preference preference, Object objValue) {
-        return false;
+    public boolean onPreferenceTreeClick(Preference preference) {
+        if (preference == mSourceUrl) {
+            launchUrl("https://github.com/BlissRoms");
+        } else if (preference == mTelegramUrl) {
+            launchUrl("");
+        } else if (preference == mGoogleUrl) {
+            launchUrl("https://plus.google.com/communities/118265887490106132524");
+        } else if (preference.getKey().equals(KEY_BLISS_SHARE)) {
+        Intent intent = new Intent();
+        intent.setAction(Intent.ACTION_SEND);
+        intent.setType("text/plain");
+        intent.putExtra(Intent.EXTRA_TEXT, String.format(
+                getActivity().getString(R.string.share_message), Build.MODEL));
+        startActivity(Intent.createChooser(intent, getActivity().getString(R.string.share_chooser_title)));
+        }
+        return super.onPreferenceTreeClick(preference);
     }
 
+    private void launchUrl(String url) {
+        Uri uriUrl = Uri.parse(url);
+        Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
+        getActivity().startActivity(intent);
+}
+
     @Override
     protected int getMetricsCategory() {
         return MetricsEvent.ABOUT_BLISS;
diff --git a/src/com/blissroms/about/Changelog.java b/src/com/blissroms/about/Changelog.java
new file mode 100644
index 0000000..313cf64
--- /dev/null
+++ b/src/com/blissroms/about/Changelog.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 crDroid Android
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.blissroms.about;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.android.settings.R;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class Changelog extends Fragment {
+
+    private static final String CHANGELOG_PATH = "/system/etc/Changelog.txt";
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                Bundle savedInstanceState) {
+        InputStreamReader inputReader = null;
+        String text = null;
+
+        try {
+            StringBuilder data = new StringBuilder();
+            char tmp[] = new char[2048];
+            int numRead;
+
+            inputReader = new FileReader(CHANGELOG_PATH);
+            while ((numRead = inputReader.read(tmp)) >= 0) {
+                data.append(tmp, 0, numRead);
+            }
+            text = data.toString();
+        } catch (IOException e) {
+            text = getString(R.string.changelog_bliss_error);
+        } finally {
+            try {
+                if (inputReader != null) {
+                    inputReader.close();
+                }
+            } catch (IOException e) {
+            }
+        }
+
+        final TextView textView = new TextView(getActivity());
+        textView.setText(text);
+
+        final ScrollView scrollView = new ScrollView(getActivity());
+        scrollView.addView(textView);
+
+        return scrollView;
+    }
+}
diff --git a/src/com/blissroms/widget/DeveloperPreference.java b/src/com/blissroms/widget/DeveloperPreference.java
new file mode 100644
index 0000000..8f21f99
--- /dev/null
+++ b/src/com/blissroms/widget/DeveloperPreference.java
@@ -0,0 +1,164 @@
+package com.blissroms.widget;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.Point;
+import android.graphics.BitmapFactory;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.net.http.AndroidHttpClient;
+import android.os.AsyncTask;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.view.Display;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.koushikdutta.urlimageviewhelper.UrlImageViewCallback;
+import com.koushikdutta.urlimageviewhelper.UrlImageViewHelper;
+
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.params.HttpClientParams;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+public class DeveloperPreference extends Preference {
+
+    private static final String TAG = "DeveloperPreference";
+    public static final String GRAVATAR_API = "http://www.gravatar.com/avatar/";
+    public static int mDefaultAvatarSize = 250;
+    private ImageView gplusButton;
+    private ImageView githubButton;
+    private ImageView photoView;
+
+    private TextView devName;
+
+    private String nameDev;
+    private String gplusName;
+    private String githubLink;
+    private String devEmail;
+    private final Display mDisplay;
+
+    public DeveloperPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+
+        TypedArray typedArray = null;
+        try {
+            typedArray = context.obtainStyledAttributes(attrs, R.styleable.DeveloperPreference);
+            nameDev = typedArray.getString(R.styleable.DeveloperPreference_nameDev);
+            gplusName = typedArray.getString(R.styleable.DeveloperPreference_gplusHandle);
+	    githubLink = typedArray.getString(R.styleable.DeveloperPreference_githubLink);
+            devEmail = typedArray.getString(R.styleable.DeveloperPreference_emailDev);
+        } finally {
+            if (typedArray != null) {
+                typedArray.recycle();
+            }
+        }
+        WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
+        mDisplay = wm.getDefaultDisplay();
+    }
+
+    @Override
+    protected View onCreateView(ViewGroup parent) {
+        super.onCreateView(parent);
+
+        View layout = View.inflate(getContext(), R.layout.dev_card, null);
+
+        gplusButton = (ImageView) layout.findViewById(R.id.gplus_button);
+	githubButton = (ImageView) layout.findViewById(R.id.github_button);
+        devName = (TextView) layout.findViewById(R.id.name);
+        photoView = (ImageView) layout.findViewById(R.id.photo);
+
+        return layout;
+    }
+
+    @Override
+    protected void onBindView(View view) {
+        super.onBindView(view);
+
+        if (githubLink != null) {
+            final OnClickListener openGithub = new OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    Uri githubURL = Uri.parse(githubLink);
+                    final Intent intent = new Intent(Intent.ACTION_VIEW, githubURL);
+                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+                    getContext().startActivity(intent);
+                }
+            };
+            githubButton.setOnClickListener(openGithub);
+        } else {
+            githubButton.setVisibility(View.GONE);
+        }
+
+
+            final OnPreferenceClickListener openGplus = new OnPreferenceClickListener() {
+                @Override
+                public boolean onPreferenceClick(Preference preference) {
+
+			if (gplusName != null) {
+
+	                    Uri gplusURL = Uri.parse("https://plus.google.com/+" + gplusName);
+        	            final Intent intent = new Intent(Intent.ACTION_VIEW, gplusURL);
+        	            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        	            getContext().startActivity(intent);
+
+			}
+        
+	            return true;
+                }
+            };
+
+            this.setOnPreferenceClickListener(openGplus);
+            UrlImageViewHelper.setUrlDrawable(this.photoView,
+                    getGravatarUrl(devEmail),
+                    R.drawable.ic_null,
+                    UrlImageViewHelper.CACHE_DURATION_ONE_WEEK);
+
+        if (gplusName == null)
+		gplusButton.setVisibility(View.INVISIBLE);
+
+
+        devName.setText(nameDev);
+
+    }
+
+    public String getGravatarUrl(String email) {
+        try {
+            Point point = new Point();
+            mDisplay.getSize(point);
+            mDefaultAvatarSize = point.x;
+            String emailMd5 = getMd5(email.trim().toLowerCase());
+            return String.format("%s%s?s=%d",
+                    GRAVATAR_API,
+                    emailMd5,
+                    mDefaultAvatarSize);
+        } catch (NoSuchAlgorithmException e) {
+            return null;
+        }
+    }
+
+    private String getMd5(String devEmail) throws NoSuchAlgorithmException {
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        md.update(devEmail.getBytes());
+        byte byteData[] = md.digest();
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < byteData.length; i++)
+            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
+        return sb.toString();
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/Constants.java b/src/com/koushikdutta/urlimageviewhelper/Constants.java
new file mode 100644
index 0000000..d96ef60
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/Constants.java
@@ -0,0 +1,11 @@
+package com.koushikdutta.urlimageviewhelper;
+
+public interface Constants {
+
+    public static final String LOGTAG = "UrlImageViewHelper";
+
+    public static final boolean LOG_ENABLED = false; //set to True to enable verbose logging
+
+    //set here and not in Build to maintain proper backwards compatibility
+    public static final int HONEYCOMB = 11;
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/DiskLruCache.java b/src/com/koushikdutta/urlimageviewhelper/DiskLruCache.java
new file mode 100644
index 0000000..dd2c2fb
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/DiskLruCache.java
@@ -0,0 +1,930 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.koushikdutta.urlimageviewhelper;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedWriter;
+import java.io.Closeable;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A cache that uses a bounded amount of space on a filesystem. Each cache
+ * entry has a string key and a fixed number of values. Values are byte
+ * sequences, accessible as streams or files. Each value must be between {@code
+ * 0} and {@code Integer.MAX_VALUE} bytes in length.
+ *
+ * <p>The cache stores its data in a directory on the filesystem. This
+ * directory must be exclusive to the cache; the cache may delete or overwrite
+ * files from its directory. It is an error for multiple processes to use the
+ * same cache directory at the same time.
+ *
+ * <p>This cache limits the number of bytes that it will store on the
+ * filesystem. When the number of stored bytes exceeds the limit, the cache will
+ * remove entries in the background until the limit is satisfied. The limit is
+ * not strict: the cache may temporarily exceed it while waiting for files to be
+ * deleted. The limit does not include filesystem overhead or the cache
+ * journal so space-sensitive applications should set a conservative limit.
+ *
+ * <p>Clients call {@link #edit} to create or update the values of an entry. An
+ * entry may have only one editor at one time; if a value is not available to be
+ * edited then {@link #edit} will return null.
+ * <ul>
+ *     <li>When an entry is being <strong>created</strong> it is necessary to
+ *         supply a full set of values; the empty value should be used as a
+ *         placeholder if necessary.
+ *     <li>When an entry is being <strong>edited</strong>, it is not necessary
+ *         to supply data for every value; values default to their previous
+ *         value.
+ * </ul>
+ * Every {@link #edit} call must be matched by a call to {@link Editor#commit}
+ * or {@link Editor#abort}. Committing is atomic: a read observes the full set
+ * of values as they were before or after the commit, but never a mix of values.
+ *
+ * <p>Clients call {@link #get} to read a snapshot of an entry. The read will
+ * observe the value at the time that {@link #get} was called. Updates and
+ * removals after the call do not impact ongoing reads.
+ *
+ * <p>This class is tolerant of some I/O errors. If files are missing from the
+ * filesystem, the corresponding entries will be dropped from the cache. If
+ * an error occurs while writing a cache value, the edit will fail silently.
+ * Callers should handle other problems by catching {@code IOException} and
+ * responding appropriately.
+ */
+public final class DiskLruCache implements Closeable {
+    static final String JOURNAL_FILE = "journal";
+    static final String JOURNAL_FILE_TMP = "journal.tmp";
+    static final String MAGIC = "libcore.io.DiskLruCache";
+    static final String VERSION_1 = "1";
+    static final long ANY_SEQUENCE_NUMBER = -1;
+    private static final String CLEAN = "CLEAN";
+    private static final String DIRTY = "DIRTY";
+    private static final String REMOVE = "REMOVE";
+    private static final String READ = "READ";
+
+    /* XXX From java.util.Arrays */
+    @SuppressWarnings("unchecked")
+    private static <T> T[] copyOfRange(T[] original, int start, int end) {
+        int originalLength = original.length; // For exception priority compatibility.
+        if (start > end) {
+            throw new IllegalArgumentException();
+        }
+        if (start < 0 || start > originalLength) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+        int resultLength = end - start;
+        int copyLength = Math.min(resultLength, originalLength - start);
+        T[] result = (T[]) Array.newInstance(original.getClass().getComponentType(), resultLength);
+        System.arraycopy(original, start, result, 0, copyLength);
+        return result;
+    }
+
+    /* XXX From java.nio.charset.Charsets */
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+    /* XXX From libcore.io.IoUtils */
+    private static void deleteContents(File dir) throws IOException {
+        File[] files = dir.listFiles();
+        if (files == null) {
+            throw new IllegalArgumentException("not a directory: " + dir);
+        }
+        for (File file : files) {
+            if (file.isDirectory()) {
+                deleteContents(file);
+            }
+            if (!file.delete()) {
+                throw new IOException("failed to delete file: " + file);
+            }
+        }
+    }
+
+    /* XXX From libcore.io.IoUtils */
+    private static void closeQuietly(/*Auto*/Closeable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (RuntimeException rethrown) {
+                throw rethrown;
+            } catch (Exception ignored) {
+            }
+        }
+    }
+
+    /* XXX From libcore.io.Streams */
+    private static String readFully(Reader reader) throws IOException {
+        try {
+            StringWriter writer = new StringWriter();
+            char[] buffer = new char[1024];
+            int count;
+            while ((count = reader.read(buffer)) != -1) {
+                writer.write(buffer, 0, count);
+            }
+            return writer.toString();
+        } finally {
+            reader.close();
+        }
+    }
+
+    /* XXX From libcore.io.Streams */
+    private static String readAsciiLine(InputStream in) throws IOException {
+        // TODO: support UTF-8 here instead
+
+        StringBuilder result = new StringBuilder(80);
+        while (true) {
+            int c = in.read();
+            if (c == -1) {
+                throw new EOFException();
+            } else if (c == '\n') {
+                break;
+            }
+
+            result.append((char) c);
+        }
+        int length = result.length();
+        if (length > 0 && result.charAt(length - 1) == '\r') {
+            result.setLength(length - 1);
+        }
+        return result.toString();
+    }
+
+    /*
+     * This cache uses a journal file named "journal". A typical journal file
+     * looks like this:
+     *     libcore.io.DiskLruCache
+     *     1
+     *     100
+     *     2
+     *
+     *     CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054
+     *     DIRTY 335c4c6028171cfddfbaae1a9c313c52
+     *     CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342
+     *     REMOVE 335c4c6028171cfddfbaae1a9c313c52
+     *     DIRTY 1ab96a171faeeee38496d8b330771a7a
+     *     CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234
+     *     READ 335c4c6028171cfddfbaae1a9c313c52
+     *     READ 3400330d1dfc7f3f7f4b8d4d803dfcf6
+     *
+     * The first five lines of the journal form its header. They are the
+     * constant string "libcore.io.DiskLruCache", the disk cache's version,
+     * the application's version, the value count, and a blank line.
+     *
+     * Each of the subsequent lines in the file is a record of the state of a
+     * cache entry. Each line contains space-separated values: a state, a key,
+     * and optional state-specific values.
+     *   o DIRTY lines track that an entry is actively being created or updated.
+     *     Every successful DIRTY action should be followed by a CLEAN or REMOVE
+     *     action. DIRTY lines without a matching CLEAN or REMOVE indicate that
+     *     temporary files may need to be deleted.
+     *   o CLEAN lines track a cache entry that has been successfully published
+     *     and may be read. A publish line is followed by the lengths of each of
+     *     its values.
+     *   o READ lines track accesses for LRU.
+     *   o REMOVE lines track entries that have been deleted.
+     *
+     * The journal file is appended to as cache operations occur. The journal may
+     * occasionally be compacted by dropping redundant lines. A temporary file named
+     * "journal.tmp" will be used during compaction; that file should be deleted if
+     * it exists when the cache is opened.
+     */
+
+    private final File directory;
+    private final File journalFile;
+    private final File journalFileTmp;
+    private final int appVersion;
+    private final long maxSize;
+    private final int valueCount;
+    private long size = 0;
+    private Writer journalWriter;
+    private final LinkedHashMap<String, Entry> lruEntries
+            = new LinkedHashMap<String, Entry>(0, 0.75f, true);
+    private int redundantOpCount;
+
+    /**
+     * To differentiate between old and current snapshots, each entry is given
+     * a sequence number each time an edit is committed. A snapshot is stale if
+     * its sequence number is not equal to its entry's sequence number.
+     */
+    private long nextSequenceNumber = 0;
+
+    /** This cache uses a single background thread to evict entries. */
+    private final ExecutorService executorService = new ThreadPoolExecutor(0, 1,
+            60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
+    private final Callable<Void> cleanupCallable = new Callable<Void>() {
+        @Override public Void call() throws Exception {
+            synchronized (DiskLruCache.this) {
+                if (journalWriter == null) {
+                    return null; // closed
+                }
+                trimToSize();
+                if (journalRebuildRequired()) {
+                    rebuildJournal();
+                    redundantOpCount = 0;
+                }
+            }
+            return null;
+        }
+    };
+
+    private DiskLruCache(File directory, int appVersion, int valueCount, long maxSize) {
+        this.directory = directory;
+        this.appVersion = appVersion;
+        this.journalFile = new File(directory, JOURNAL_FILE);
+        this.journalFileTmp = new File(directory, JOURNAL_FILE_TMP);
+        this.valueCount = valueCount;
+        this.maxSize = maxSize;
+    }
+
+    /**
+     * Opens the cache in {@code directory}, creating a cache if none exists
+     * there.
+     *
+     * @param directory a writable directory
+     * @param appVersion
+     * @param valueCount the number of values per cache entry. Must be positive.
+     * @param maxSize the maximum number of bytes this cache should use to store
+     * @throws IOException if reading or writing the cache directory fails
+     */
+    public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize)
+            throws IOException {
+        if (maxSize <= 0) {
+            throw new IllegalArgumentException("maxSize <= 0");
+        }
+        if (valueCount <= 0) {
+            throw new IllegalArgumentException("valueCount <= 0");
+        }
+
+        // prefer to pick up where we left off
+        DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
+        if (cache.journalFile.exists()) {
+            try {
+                cache.readJournal();
+                cache.processJournal();
+                cache.journalWriter = new BufferedWriter(new FileWriter(cache.journalFile, true));
+                return cache;
+            } catch (IOException journalIsCorrupt) {
+                System.out.println("DiskLruCache " + directory + " is corrupt: "
+                        + journalIsCorrupt.getMessage() + ", removing");
+                cache.delete();
+            }
+        }
+
+        // create a new empty cache
+        directory.mkdirs();
+        cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
+        cache.rebuildJournal();
+        return cache;
+    }
+
+    private void readJournal() throws IOException {
+        InputStream in = new BufferedInputStream(new FileInputStream(journalFile));
+        try {
+            String magic = /*Streams.*/readAsciiLine(in);
+            String version = /*Streams.*/readAsciiLine(in);
+            String appVersionString = /*Streams.*/readAsciiLine(in);
+            String valueCountString = /*Streams.*/readAsciiLine(in);
+            String blank = /*Streams.*/readAsciiLine(in);
+            if (!MAGIC.equals(magic)
+                    || !VERSION_1.equals(version)
+                    || !Integer.toString(appVersion).equals(appVersionString)
+                    || !Integer.toString(valueCount).equals(valueCountString)
+                    || !"".equals(blank)) {
+                throw new IOException("unexpected journal header: ["
+                        + magic + ", " + version + ", " + valueCountString + ", " + blank + "]");
+            }
+
+            while (true) {
+                try {
+                    readJournalLine(/*Streams.*/readAsciiLine(in));
+                } catch (EOFException endOfJournal) {
+                    break;
+                }
+            }
+        } finally {
+            /*IoUtils.*/closeQuietly(in);
+        }
+    }
+
+    private void readJournalLine(String line) throws IOException {
+        String[] parts = line.split(" ");
+        if (parts.length < 2) {
+            throw new IOException("unexpected journal line: " + line);
+        }
+
+        String key = parts[1];
+        if (parts[0].equals(REMOVE) && parts.length == 2) {
+            lruEntries.remove(key);
+            return;
+        }
+
+        Entry entry = lruEntries.get(key);
+        if (entry == null) {
+            entry = new Entry(key);
+            lruEntries.put(key, entry);
+        }
+
+        if (parts[0].equals(CLEAN) && parts.length == 2 + valueCount) {
+            entry.readable = true;
+            entry.currentEditor = null;
+            entry.setLengths(/*Arrays.*/copyOfRange(parts, 2, parts.length));
+        } else if (parts[0].equals(DIRTY) && parts.length == 2) {
+            entry.currentEditor = new Editor(entry);
+        } else if (parts[0].equals(READ) && parts.length == 2) {
+            // this work was already done by calling lruEntries.get()
+        } else {
+            throw new IOException("unexpected journal line: " + line);
+        }
+    }
+
+    /**
+     * Computes the initial size and collects garbage as a part of opening the
+     * cache. Dirty entries are assumed to be inconsistent and will be deleted.
+     */
+    private void processJournal() throws IOException {
+        deleteIfExists(journalFileTmp);
+        for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext(); ) {
+            Entry entry = i.next();
+            if (entry.currentEditor == null) {
+                for (int t = 0; t < valueCount; t++) {
+                    size += entry.lengths[t];
+                }
+            } else {
+                entry.currentEditor = null;
+                for (int t = 0; t < valueCount; t++) {
+                    deleteIfExists(entry.getCleanFile(t));
+                    deleteIfExists(entry.getDirtyFile(t));
+                }
+                i.remove();
+            }
+        }
+    }
+
+    /**
+     * Creates a new journal that omits redundant information. This replaces the
+     * current journal if it exists.
+     */
+    private synchronized void rebuildJournal() throws IOException {
+        if (journalWriter != null) {
+            journalWriter.close();
+        }
+
+        Writer writer = new BufferedWriter(new FileWriter(journalFileTmp));
+        writer.write(MAGIC);
+        writer.write("\n");
+        writer.write(VERSION_1);
+        writer.write("\n");
+        writer.write(Integer.toString(appVersion));
+        writer.write("\n");
+        writer.write(Integer.toString(valueCount));
+        writer.write("\n");
+        writer.write("\n");
+
+        for (Entry entry : lruEntries.values()) {
+            if (entry.currentEditor != null) {
+                writer.write(DIRTY + ' ' + entry.key + '\n');
+            } else {
+                writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
+            }
+        }
+
+        writer.close();
+        journalFileTmp.renameTo(journalFile);
+        journalWriter = new BufferedWriter(new FileWriter(journalFile, true));
+    }
+
+    private static void deleteIfExists(File file) throws IOException {
+        /*try {
+            Libcore.os.remove(file.getPath());
+        } catch (ErrnoException errnoException) {
+            if (errnoException.errno != OsConstants.ENOENT) {
+                throw errnoException.rethrowAsIOException();
+            }
+        }*/
+        if (file.exists() && !file.delete()) {
+            throw new IOException();
+        }
+    }
+
+    /**
+     * Returns a snapshot of the entry named {@code key}, or null if it doesn't
+     * exist is not currently readable. If a value is returned, it is moved to
+     * the head of the LRU queue.
+     */
+    public synchronized Snapshot get(String key) throws IOException {
+        checkNotClosed();
+        validateKey(key);
+        Entry entry = lruEntries.get(key);
+        if (entry == null) {
+            return null;
+        }
+
+        if (!entry.readable) {
+            return null;
+        }
+
+        /*
+         * Open all streams eagerly to guarantee that we see a single published
+         * snapshot. If we opened streams lazily then the streams could come
+         * from different edits.
+         */
+        InputStream[] ins = new InputStream[valueCount];
+        try {
+            for (int i = 0; i < valueCount; i++) {
+                ins[i] = new FileInputStream(entry.getCleanFile(i));
+            }
+        } catch (FileNotFoundException e) {
+            // a file must have been deleted manually!
+            return null;
+        }
+
+        redundantOpCount++;
+        journalWriter.append(READ + ' ' + key + '\n');
+        if (journalRebuildRequired()) {
+            executorService.submit(cleanupCallable);
+        }
+
+        return new Snapshot(key, entry.sequenceNumber, ins);
+    }
+
+    /**
+     * Returns an editor for the entry named {@code key}, or null if another
+     * edit is in progress.
+     */
+    public Editor edit(String key) throws IOException {
+        return edit(key, ANY_SEQUENCE_NUMBER);
+    }
+
+    private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException {
+        checkNotClosed();
+        validateKey(key);
+        Entry entry = lruEntries.get(key);
+        if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER
+                && (entry == null || entry.sequenceNumber != expectedSequenceNumber)) {
+            return null; // snapshot is stale
+        }
+        if (entry == null) {
+            entry = new Entry(key);
+            lruEntries.put(key, entry);
+        } else if (entry.currentEditor != null) {
+            return null; // another edit is in progress
+        }
+
+        Editor editor = new Editor(entry);
+        entry.currentEditor = editor;
+
+        // flush the journal before creating files to prevent file leaks
+        journalWriter.write(DIRTY + ' ' + key + '\n');
+        journalWriter.flush();
+        return editor;
+    }
+
+    /**
+     * Returns the directory where this cache stores its data.
+     */
+    public File getDirectory() {
+        return directory;
+    }
+
+    /**
+     * Returns the maximum number of bytes that this cache should use to store
+     * its data.
+     */
+    public long maxSize() {
+        return maxSize;
+    }
+
+    /**
+     * Returns the number of bytes currently being used to store the values in
+     * this cache. This may be greater than the max size if a background
+     * deletion is pending.
+     */
+    public synchronized long size() {
+        return size;
+    }
+
+    private synchronized void completeEdit(Editor editor, boolean success) throws IOException {
+        Entry entry = editor.entry;
+        if (entry.currentEditor != editor) {
+            throw new IllegalStateException();
+        }
+
+        // if this edit is creating the entry for the first time, every index must have a value
+        if (success && !entry.readable) {
+            for (int i = 0; i < valueCount; i++) {
+                if (!entry.getDirtyFile(i).exists()) {
+                    editor.abort();
+                    throw new IllegalStateException("edit didn't create file " + i);
+                }
+            }
+        }
+
+        for (int i = 0; i < valueCount; i++) {
+            File dirty = entry.getDirtyFile(i);
+            if (success) {
+                if (dirty.exists()) {
+                    File clean = entry.getCleanFile(i);
+                    dirty.renameTo(clean);
+                    long oldLength = entry.lengths[i];
+                    long newLength = clean.length();
+                    entry.lengths[i] = newLength;
+                    size = size - oldLength + newLength;
+                }
+            } else {
+                deleteIfExists(dirty);
+            }
+        }
+
+        redundantOpCount++;
+        entry.currentEditor = null;
+        if (entry.readable | success) {
+            entry.readable = true;
+            journalWriter.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
+            if (success) {
+                entry.sequenceNumber = nextSequenceNumber++;
+            }
+        } else {
+            lruEntries.remove(entry.key);
+            journalWriter.write(REMOVE + ' ' + entry.key + '\n');
+        }
+
+        if (size > maxSize || journalRebuildRequired()) {
+            executorService.submit(cleanupCallable);
+        }
+    }
+
+    /**
+     * We only rebuild the journal when it will halve the size of the journal
+     * and eliminate at least 2000 ops.
+     */
+    private boolean journalRebuildRequired() {
+        final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000;
+        return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD
+                && redundantOpCount >= lruEntries.size();
+    }
+
+    /**
+     * Drops the entry for {@code key} if it exists and can be removed. Entries
+     * actively being edited cannot be removed.
+     *
+     * @return true if an entry was removed.
+     */
+    public synchronized boolean remove(String key) throws IOException {
+        checkNotClosed();
+        validateKey(key);
+        Entry entry = lruEntries.get(key);
+        if (entry == null || entry.currentEditor != null) {
+            return false;
+        }
+
+        for (int i = 0; i < valueCount; i++) {
+            File file = entry.getCleanFile(i);
+            if (!file.delete()) {
+                throw new IOException("failed to delete " + file);
+            }
+            size -= entry.lengths[i];
+            entry.lengths[i] = 0;
+        }
+
+        redundantOpCount++;
+        journalWriter.append(REMOVE + ' ' + key + '\n');
+        lruEntries.remove(key);
+
+        if (journalRebuildRequired()) {
+            executorService.submit(cleanupCallable);
+        }
+
+        return true;
+    }
+
+    /**
+     * Returns true if this cache has been closed.
+     */
+    public boolean isClosed() {
+        return journalWriter == null;
+    }
+
+    private void checkNotClosed() {
+        if (journalWriter == null) {
+            throw new IllegalStateException("cache is closed");
+        }
+    }
+
+    /**
+     * Force buffered operations to the filesystem.
+     */
+    public synchronized void flush() throws IOException {
+        checkNotClosed();
+        trimToSize();
+        journalWriter.flush();
+    }
+
+    /**
+     * Closes this cache. Stored values will remain on the filesystem.
+     */
+    public synchronized void close() throws IOException {
+        if (journalWriter == null) {
+            return; // already closed
+        }
+        for (Entry entry : new ArrayList<Entry>(lruEntries.values())) {
+            if (entry.currentEditor != null) {
+                entry.currentEditor.abort();
+            }
+        }
+        trimToSize();
+        journalWriter.close();
+        journalWriter = null;
+    }
+
+    private void trimToSize() throws IOException {
+        while (size > maxSize) {
+            Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next();//lruEntries.eldest();
+            remove(toEvict.getKey());
+        }
+    }
+
+    /**
+     * Closes the cache and deletes all of its stored values. This will delete
+     * all files in the cache directory including files that weren't created by
+     * the cache.
+     */
+    public void delete() throws IOException {
+        close();
+        /*IoUtils.*/deleteContents(directory);
+    }
+
+    private void validateKey(String key) {
+        if (key.contains(" ") || key.contains("\n") || key.contains("\r")) {
+            throw new IllegalArgumentException(
+                    "keys must not contain spaces or newlines: \"" + key + "\"");
+        }
+    }
+
+    private static String inputStreamToString(InputStream in) throws IOException {
+        return /*Streams.*/readFully(new InputStreamReader(in, /*Charsets.*/UTF_8));
+    }
+
+    /**
+     * A snapshot of the values for an entry.
+     */
+    public final class Snapshot implements Closeable {
+        private final String key;
+        private final long sequenceNumber;
+        private final InputStream[] ins;
+
+        private Snapshot(String key, long sequenceNumber, InputStream[] ins) {
+            this.key = key;
+            this.sequenceNumber = sequenceNumber;
+            this.ins = ins;
+        }
+
+        /**
+         * Returns an editor for this snapshot's entry, or null if either the
+         * entry has changed since this snapshot was created or if another edit
+         * is in progress.
+         */
+        public Editor edit() throws IOException {
+            return DiskLruCache.this.edit(key, sequenceNumber);
+        }
+
+        /**
+         * Returns the unbuffered stream with the value for {@code index}.
+         */
+        public InputStream getInputStream(int index) {
+            return ins[index];
+        }
+
+        /**
+         * Returns the string value for {@code index}.
+         */
+        public String getString(int index) throws IOException {
+            return inputStreamToString(getInputStream(index));
+        }
+
+        @Override public void close() {
+            for (InputStream in : ins) {
+                /*IoUtils.*/closeQuietly(in);
+            }
+        }
+    }
+
+    /**
+     * Edits the values for an entry.
+     */
+    public final class Editor {
+        private final Entry entry;
+        private boolean hasErrors;
+
+        private Editor(Entry entry) {
+            this.entry = entry;
+        }
+
+        /**
+         * Returns an unbuffered input stream to read the last committed value,
+         * or null if no value has been committed.
+         */
+        public InputStream newInputStream(int index) throws IOException {
+            synchronized (DiskLruCache.this) {
+                if (entry.currentEditor != this) {
+                    throw new IllegalStateException();
+                }
+                if (!entry.readable) {
+                    return null;
+                }
+                return new FileInputStream(entry.getCleanFile(index));
+            }
+        }
+
+        /**
+         * Returns the last committed value as a string, or null if no value
+         * has been committed.
+         */
+        public String getString(int index) throws IOException {
+            InputStream in = newInputStream(index);
+            return in != null ? inputStreamToString(in) : null;
+        }
+
+        /**
+         * Returns a new unbuffered output stream to write the value at
+         * {@code index}. If the underlying output stream encounters errors
+         * when writing to the filesystem, this edit will be aborted when
+         * {@link #commit} is called. The returned output stream does not throw
+         * IOExceptions.
+         */
+        public OutputStream newOutputStream(int index) throws IOException {
+            synchronized (DiskLruCache.this) {
+                if (entry.currentEditor != this) {
+                    throw new IllegalStateException();
+                }
+                return new FaultHidingOutputStream(new FileOutputStream(entry.getDirtyFile(index)));
+            }
+        }
+
+        /**
+         * Sets the value at {@code index} to {@code value}.
+         */
+        public void set(int index, String value) throws IOException {
+            Writer writer = null;
+            try {
+                writer = new OutputStreamWriter(newOutputStream(index), /*Charsets.*/UTF_8);
+                writer.write(value);
+            } finally {
+                /*IoUtils.*/closeQuietly(writer);
+            }
+        }
+
+        /**
+         * Commits this edit so it is visible to readers.  This releases the
+         * edit lock so another edit may be started on the same key.
+         */
+        public void commit() throws IOException {
+            if (hasErrors) {
+                completeEdit(this, false);
+                remove(entry.key); // the previous entry is stale
+            } else {
+                completeEdit(this, true);
+            }
+        }
+
+        /**
+         * Aborts this edit. This releases the edit lock so another edit may be
+         * started on the same key.
+         */
+        public void abort() throws IOException {
+            completeEdit(this, false);
+        }
+
+        private class FaultHidingOutputStream extends FilterOutputStream {
+            private FaultHidingOutputStream(OutputStream out) {
+                super(out);
+            }
+
+            @Override public void write(int oneByte) {
+                try {
+                    out.write(oneByte);
+                } catch (IOException e) {
+                    hasErrors = true;
+                }
+            }
+
+            @Override public void write(byte[] buffer, int offset, int length) {
+                try {
+                    out.write(buffer, offset, length);
+                } catch (IOException e) {
+                    hasErrors = true;
+                }
+            }
+
+            @Override public void close() {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    hasErrors = true;
+                }
+            }
+
+            @Override public void flush() {
+                try {
+                    out.flush();
+                } catch (IOException e) {
+                    hasErrors = true;
+                }
+            }
+        }
+    }
+
+    private final class Entry {
+        private final String key;
+
+        /** Lengths of this entry's files. */
+        private final long[] lengths;
+
+        /** True if this entry has ever been published */
+        private boolean readable;
+
+        /** The ongoing edit or null if this entry is not being edited. */
+        private Editor currentEditor;
+
+        /** The sequence number of the most recently committed edit to this entry. */
+        private long sequenceNumber;
+
+        private Entry(String key) {
+            this.key = key;
+            this.lengths = new long[valueCount];
+        }
+
+        public String getLengths() throws IOException {
+            StringBuilder result = new StringBuilder();
+            for (long size : lengths) {
+                result.append(' ').append(size);
+            }
+            return result.toString();
+        }
+
+        /**
+         * Set lengths using decimal numbers like "10123".
+         */
+        private void setLengths(String[] strings) throws IOException {
+            if (strings.length != valueCount) {
+                throw invalidLengths(strings);
+            }
+
+            try {
+                for (int i = 0; i < strings.length; i++) {
+                    lengths[i] = Long.parseLong(strings[i]);
+                }
+            } catch (NumberFormatException e) {
+                throw invalidLengths(strings);
+            }
+        }
+
+        private IOException invalidLengths(String[] strings) throws IOException {
+            throw new IOException("unexpected journal line: " + Arrays.toString(strings));
+        }
+
+        public File getCleanFile(int i) {
+            return new File(directory, key + "." + i);
+        }
+
+        public File getDirtyFile(int i) {
+            return new File(directory, key + "." + i + ".tmp");
+        }
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/ImageArrayAdapter.java b/src/com/koushikdutta/urlimageviewhelper/ImageArrayAdapter.java
new file mode 100644
index 0000000..4fbd9a1
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/ImageArrayAdapter.java
@@ -0,0 +1,62 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.CheckedTextView;
+import android.widget.ImageView;
+
+import com.android.settings.R;
+
+/**
+ * The ImageArrayAdapter is the array adapter used for displaying an additional
+ * image to a list preference item.
+ * 
+ * @author Casper Wakkers
+ */
+public class ImageArrayAdapter extends ArrayAdapter<CharSequence> {
+    private int index = 0;
+    private int[] resourceIds = null;
+
+    /**
+     * ImageArrayAdapter constructor.
+     * 
+     * @param context the context.
+     * @param textViewResourceId resource id of the text view.
+     * @param objects to be displayed.
+     * @param ids resource id of the images to be displayed.
+     * @param i index of the previous selected item.
+     */
+    public ImageArrayAdapter(Context context, int textViewResourceId,
+            CharSequence[] objects, int[] ids, int i) {
+        super(context, textViewResourceId, objects);
+
+        index = i;
+        resourceIds = ids;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public View getView(int position, View convertView, ViewGroup parent) {
+        LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
+        View row = inflater.inflate(R.layout.image_list_preference, parent, false);
+
+        ImageView imageView = (ImageView) row.findViewById(R.id.image);
+        imageView.setImageResource(resourceIds[position]);
+
+        // CheckedTextView checkedTextView = (CheckedTextView)row.findViewById(
+        // R.id.check);
+        //
+        // checkedTextView.setText(getItem(position));
+
+        // if (position == index) {
+        // checkedTextView.setChecked(true);
+        // }
+
+        return row;
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/ImageListPreference.java b/src/com/koushikdutta/urlimageviewhelper/ImageListPreference.java
new file mode 100644
index 0000000..d4e5afe
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/ImageListPreference.java
@@ -0,0 +1,74 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.preference.ListPreference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+
+import com.android.settings.R;
+
+public class ImageListPreference extends ListPreference {
+    private int[] resourceIds = null;
+
+    private int mSummaryImageResourceId;
+    /**
+     * Constructor of the ImageListPreference. Initializes the custom images.
+     * 
+     * @param context application context.
+     * @param attrs custom xml attributes.
+     */
+    public ImageListPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+
+        TypedArray typedArray = context.obtainStyledAttributes(attrs,
+                R.styleable.ImageListPreference);
+        mSummaryImageResourceId = typedArray.getResourceId(R.styleable.ImageListPreference_summaryImage, 0);
+
+        String[] imageNames = context.getResources().getStringArray(
+                typedArray.getResourceId(typedArray.getIndexCount() - 1, -1));
+
+        resourceIds = new int[imageNames.length];
+
+        for (int i = 0; i < imageNames.length; i++) {
+            String imageName = imageNames[i].substring(
+                    imageNames[i].indexOf('/') + 1,
+                    imageNames[i].lastIndexOf('.'));
+
+            resourceIds[i] = context.getResources().getIdentifier(imageName,
+                    null, context.getPackageName());
+        }
+
+        typedArray.recycle();
+    }
+
+    @Override
+    protected View onCreateView(ViewGroup parent) {
+
+        View layout = View.inflate(getContext(), R.layout.summary_image_preference, null);
+
+        ImageView mSummaryImage = (ImageView) layout.findViewById(R.id.summary_image);
+        mSummaryImage.setImageResource(mSummaryImageResourceId);
+
+        return layout;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void onPrepareDialogBuilder(Builder builder) {
+        int index = findIndexOfValue(getSharedPreferences().getString(
+                getKey(), "1"));
+
+        ListAdapter listAdapter = new ImageArrayAdapter(getContext(),
+                R.layout.image_list_preference, getEntries(), resourceIds, index);
+
+        // Order matters.
+        builder.setAdapter(listAdapter, this);
+        super.onPrepareDialogBuilder(builder);
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/LruCache.java b/src/com/koushikdutta/urlimageviewhelper/LruCache.java
new file mode 100644
index 0000000..d5de00c
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/LruCache.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.koushikdutta.urlimageviewhelper;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Static library version of {@link android.util.LruCache}. Used to write apps
+ * that run on API levels prior to 12. When running on API level 12 or above,
+ * this implementation is still used; it does not try to switch to the
+ * framework's implementation. See the framework SDK documentation for a class
+ * overview.
+ */
+public class LruCache<K, V> {
+    private final LinkedHashMap<K, V> map;
+
+    /** Size of this cache in units. Not necessarily the number of elements. */
+    private int size;
+    private int maxSize;
+
+    private int putCount;
+    private int createCount;
+    private int evictionCount;
+    private int hitCount;
+    private int missCount;
+
+    /**
+     * @param maxSize for caches that do not override {@link #sizeOf}, this is
+     *     the maximum number of entries in the cache. For all other caches,
+     *     this is the maximum sum of the sizes of the entries in this cache.
+     */
+    public LruCache(int maxSize) {
+        if (maxSize <= 0) {
+            throw new IllegalArgumentException("maxSize <= 0");
+        }
+        this.maxSize = maxSize;
+        this.map = new LinkedHashMap<K, V>(0, 0.75f, true);
+    }
+
+    /**
+     * Returns the value for {@code key} if it exists in the cache or can be
+     * created by {@code #create}. If a value was returned, it is moved to the
+     * head of the queue. This returns null if a value is not cached and cannot
+     * be created.
+     */
+    public final V get(K key) {
+        if (key == null) {
+            throw new NullPointerException("key == null");
+        }
+
+        V mapValue;
+        synchronized (this) {
+            mapValue = map.get(key);
+            if (mapValue != null) {
+                hitCount++;
+                return mapValue;
+            }
+            missCount++;
+        }
+
+        /*
+         * Attempt to create a value. This may take a long time, and the map
+         * may be different when create() returns. If a conflicting value was
+         * added to the map while create() was working, we leave that value in
+         * the map and release the created value.
+         */
+
+        V createdValue = create(key);
+        if (createdValue == null) {
+            return null;
+        }
+
+        synchronized (this) {
+            createCount++;
+            mapValue = map.put(key, createdValue);
+
+            if (mapValue != null) {
+                // There was a conflict so undo that last put
+                map.put(key, mapValue);
+            } else {
+                size += safeSizeOf(key, createdValue);
+            }
+        }
+
+        if (mapValue != null) {
+            entryRemoved(false, key, createdValue, mapValue);
+            return mapValue;
+        } else {
+            trimToSize(maxSize);
+            return createdValue;
+        }
+    }
+
+    /**
+     * Caches {@code value} for {@code key}. The value is moved to the head of
+     * the queue.
+     *
+     * @return the previous value mapped by {@code key}.
+     */
+    public final V put(K key, V value) {
+        if (key == null || value == null) {
+            throw new NullPointerException("key == null || value == null");
+        }
+
+        V previous;
+        synchronized (this) {
+            putCount++;
+            size += safeSizeOf(key, value);
+            previous = map.put(key, value);
+            if (previous != null) {
+                size -= safeSizeOf(key, previous);
+            }
+        }
+
+        if (previous != null) {
+            entryRemoved(false, key, previous, value);
+        }
+
+        trimToSize(maxSize);
+        return previous;
+    }
+
+    /**
+     * @param maxSize the maximum size of the cache before returning. May be -1
+     *     to evict even 0-sized elements.
+     */
+    private void trimToSize(int maxSize) {
+        while (true) {
+            K key;
+            V value;
+            synchronized (this) {
+                if (size < 0 || (map.isEmpty() && size != 0)) {
+                    throw new IllegalStateException(getClass().getName()
+                            + ".sizeOf() is reporting inconsistent results!");
+                }
+
+                if (size <= maxSize || map.isEmpty()) {
+                    break;
+                }
+
+                Map.Entry<K, V> toEvict = map.entrySet().iterator().next();
+                key = toEvict.getKey();
+                value = toEvict.getValue();
+                map.remove(key);
+                size -= safeSizeOf(key, value);
+                evictionCount++;
+            }
+
+            entryRemoved(true, key, value, null);
+        }
+    }
+
+    /**
+     * Removes the entry for {@code key} if it exists.
+     *
+     * @return the previous value mapped by {@code key}.
+     */
+    public final V remove(K key) {
+        if (key == null) {
+            throw new NullPointerException("key == null");
+        }
+
+        V previous;
+        synchronized (this) {
+            previous = map.remove(key);
+            if (previous != null) {
+                size -= safeSizeOf(key, previous);
+            }
+        }
+
+        if (previous != null) {
+            entryRemoved(false, key, previous, null);
+        }
+
+        return previous;
+    }
+
+    /**
+     * Called for entries that have been evicted or removed. This method is
+     * invoked when a value is evicted to make space, removed by a call to
+     * {@link #remove}, or replaced by a call to {@link #put}. The default
+     * implementation does nothing.
+     *
+     * <p>The method is called without synchronization: other threads may
+     * access the cache while this method is executing.
+     *
+     * @param evicted true if the entry is being removed to make space, false
+     *     if the removal was caused by a {@link #put} or {@link #remove}.
+     * @param newValue the new value for {@code key}, if it exists. If non-null,
+     *     this removal was caused by a {@link #put}. Otherwise it was caused by
+     *     an eviction or a {@link #remove}.
+     */
+    protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}
+
+    /**
+     * Called after a cache miss to compute a value for the corresponding key.
+     * Returns the computed value or null if no value can be computed. The
+     * default implementation returns null.
+     *
+     * <p>The method is called without synchronization: other threads may
+     * access the cache while this method is executing.
+     *
+     * <p>If a value for {@code key} exists in the cache when this method
+     * returns, the created value will be released with {@link #entryRemoved}
+     * and discarded. This can occur when multiple threads request the same key
+     * at the same time (causing multiple values to be created), or when one
+     * thread calls {@link #put} while another is creating a value for the same
+     * key.
+     */
+    protected V create(K key) {
+        return null;
+    }
+
+    private int safeSizeOf(K key, V value) {
+        int result = sizeOf(key, value);
+        if (result < 0) {
+            throw new IllegalStateException("Negative size: " + key + "=" + value);
+        }
+        return result;
+    }
+
+    /**
+     * Returns the size of the entry for {@code key} and {@code value} in
+     * user-defined units.  The default implementation returns 1 so that size
+     * is the number of entries and max size is the maximum number of entries.
+     *
+     * <p>An entry's size must not change while it is in the cache.
+     */
+    protected int sizeOf(K key, V value) {
+        return 1;
+    }
+
+    /**
+     * Clear the cache, calling {@link #entryRemoved} on each removed entry.
+     */
+    public final void evictAll() {
+        trimToSize(-1); // -1 will evict 0-sized elements
+    }
+
+    /**
+     * For caches that do not override {@link #sizeOf}, this returns the number
+     * of entries in the cache. For all other caches, this returns the sum of
+     * the sizes of the entries in this cache.
+     */
+    public synchronized final int size() {
+        return size;
+    }
+
+    /**
+     * For caches that do not override {@link #sizeOf}, this returns the maximum
+     * number of entries in the cache. For all other caches, this returns the
+     * maximum sum of the sizes of the entries in this cache.
+     */
+    public synchronized final int maxSize() {
+        return maxSize;
+    }
+
+    /**
+     * Returns the number of times {@link #get} returned a value.
+     */
+    public synchronized final int hitCount() {
+        return hitCount;
+    }
+
+    /**
+     * Returns the number of times {@link #get} returned null or required a new
+     * value to be created.
+     */
+    public synchronized final int missCount() {
+        return missCount;
+    }
+
+    /**
+     * Returns the number of times {@link #create(Object)} returned a value.
+     */
+    public synchronized final int createCount() {
+        return createCount;
+    }
+
+    /**
+     * Returns the number of times {@link #put} was called.
+     */
+    public synchronized final int putCount() {
+        return putCount;
+    }
+
+    /**
+     * Returns the number of values that have been evicted.
+     */
+    public synchronized final int evictionCount() {
+        return evictionCount;
+    }
+
+    /**
+     * Returns a copy of the current contents of the cache, ordered from least
+     * recently accessed to most recently accessed.
+     */
+    public synchronized final Map<K, V> snapshot() {
+        return new LinkedHashMap<K, V>(map);
+    }
+
+    @Override public synchronized final String toString() {
+        int accesses = hitCount + missCount;
+        int hitPercent = accesses != 0 ? (100 * hitCount / accesses) : 0;
+        return String.format("LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]",
+                maxSize, hitCount, missCount, hitPercent);
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/SoftReferenceHashTable.java b/src/com/koushikdutta/urlimageviewhelper/SoftReferenceHashTable.java
new file mode 100644
index 0000000..e376061
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/SoftReferenceHashTable.java
@@ -0,0 +1,33 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import java.lang.ref.SoftReference;
+import java.util.Hashtable;
+
+public class SoftReferenceHashTable<K,V> {
+    Hashtable<K, SoftReference<V>> mTable = new Hashtable<K, SoftReference<V>>();
+    
+    public V put(K key, V value) {
+        SoftReference<V> old = mTable.put(key, new SoftReference<V>(value));
+        if (old == null)
+            return null;
+        return old.get();
+    }
+    
+    public V get(K key) {
+        SoftReference<V> val = mTable.get(key);
+        if (val == null)
+            return null;
+        V ret = val.get();
+        if (ret == null)
+            mTable.remove(key);
+        return ret;
+    }
+    
+    public V remove(K k) {
+        SoftReference<V> v = mTable.remove(k);
+        if (v == null)
+            return null;
+        return v.get();
+    }
+}
+ 
diff --git a/src/com/koushikdutta/urlimageviewhelper/UrlImageCache.java b/src/com/koushikdutta/urlimageviewhelper/UrlImageCache.java
new file mode 100644
index 0000000..8b7ac29
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/UrlImageCache.java
@@ -0,0 +1,14 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import android.graphics.drawable.Drawable;
+
+public final class UrlImageCache extends SoftReferenceHashTable<String, Drawable> {
+    private static UrlImageCache mInstance = new UrlImageCache();
+    
+    public static UrlImageCache getInstance() {
+        return mInstance;
+    }
+    
+    private UrlImageCache() {
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/UrlImageViewCallback.java b/src/com/koushikdutta/urlimageviewhelper/UrlImageViewCallback.java
new file mode 100644
index 0000000..37c8e98
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/UrlImageViewCallback.java
@@ -0,0 +1,8 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import android.graphics.drawable.Drawable;
+import android.widget.ImageView;
+
+public interface UrlImageViewCallback {
+    void onLoaded(ImageView imageView, Drawable loadedDrawable, String url, boolean loadedFromCache);
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/UrlImageViewHelper.java b/src/com/koushikdutta/urlimageviewhelper/UrlImageViewHelper.java
new file mode 100644
index 0000000..c5c7849
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/UrlImageViewHelper.java
@@ -0,0 +1,513 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Hashtable;
+
+import junit.framework.Assert;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.params.HttpClientParams;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapFactory.Options;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.net.http.AndroidHttpClient;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Looper;
+import android.provider.ContactsContract;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.Display;
+import android.view.WindowManager;
+import android.widget.ImageView;
+
+public final class UrlImageViewHelper {
+
+    public static int copyStream(InputStream input, OutputStream output) throws IOException
+    {
+        byte[] stuff = new byte[1024];
+        int read = 0;
+        int total = 0;
+        while ((read = input.read(stuff)) != -1)
+        {
+            output.write(stuff, 0, read);
+            total += read;
+        }
+        return total;
+    }
+
+    static Resources mResources;
+    static DisplayMetrics mMetrics;
+    private static void prepareResources(Context context) {
+        if (mMetrics != null)
+            return;
+        mMetrics = new DisplayMetrics();
+        Activity act = (Activity)context;
+        act.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
+        AssetManager mgr = context.getAssets();
+        mResources = new Resources(mgr, mMetrics, context.getResources().getConfiguration());
+    }
+
+    private static Drawable loadDrawableFromStream(Context context, String url, String filename, int targetWidth, int targetHeight) {
+        prepareResources(context);
+        
+//        Log.v(Constants.LOGTAG,targetWidth);
+//        Log.v(Constants.LOGTAG,targetHeight);
+        try {
+            BitmapFactory.Options o = new BitmapFactory.Options();
+            o.inJustDecodeBounds = true;
+            FileInputStream stream = new FileInputStream(filename);
+            BitmapFactory.decodeStream(stream, null, o);
+            stream.close();
+            stream = new FileInputStream(filename);
+            int scale = 0;
+            while ((o.outWidth >> scale) > targetWidth || (o.outHeight >> scale) > targetHeight) {
+                Log.v(Constants.LOGTAG,"downsampling");
+                scale++;
+            }
+            o = new Options();
+            o.inSampleSize = 1 << scale;
+            final Bitmap bitmap = BitmapFactory.decodeStream(stream, null, o);
+            if (Constants.LOG_ENABLED)
+                Log.i(Constants.LOGTAG, String.format("Loaded bitmap (%dx%d).", bitmap.getWidth(), bitmap.getHeight()));
+            BitmapDrawable bd = new BitmapDrawable(mResources, bitmap);
+            return new ZombieDrawable(url, bd);
+        }
+        catch (IOException e) {
+            return null;
+        }
+    }
+
+    public static final int CACHE_DURATION_INFINITE = Integer.MAX_VALUE;
+    public static final int CACHE_DURATION_ONE_DAY = 1000 * 60 * 60 * 24;
+    public static final int CACHE_DURATION_TWO_DAYS = CACHE_DURATION_ONE_DAY * 2;
+    public static final int CACHE_DURATION_THREE_DAYS = CACHE_DURATION_ONE_DAY * 3;
+    public static final int CACHE_DURATION_FOUR_DAYS = CACHE_DURATION_ONE_DAY * 4;
+    public static final int CACHE_DURATION_FIVE_DAYS = CACHE_DURATION_ONE_DAY * 5;
+    public static final int CACHE_DURATION_SIX_DAYS = CACHE_DURATION_ONE_DAY * 6;
+    public static final int CACHE_DURATION_ONE_WEEK = CACHE_DURATION_ONE_DAY * 7;
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, int defaultResource) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultResource, CACHE_DURATION_THREE_DAYS);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url) {
+        setUrlDrawable(imageView.getContext(), imageView, url, null, CACHE_DURATION_THREE_DAYS, null);
+    }
+
+    public static void loadUrlDrawable(final Context context, final String url) {
+        setUrlDrawable(context, null, url, null, CACHE_DURATION_THREE_DAYS, null);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, Drawable defaultDrawable) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultDrawable, CACHE_DURATION_THREE_DAYS, null);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, int defaultResource, long cacheDurationMs) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultResource, cacheDurationMs);
+    }
+
+    public static void loadUrlDrawable(final Context context, final String url, long cacheDurationMs) {
+        setUrlDrawable(context, null, url, null, cacheDurationMs, null);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, Drawable defaultDrawable, long cacheDurationMs) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultDrawable, cacheDurationMs, null);
+    }
+
+    private static void setUrlDrawable(final Context context, final ImageView imageView, final String url, int defaultResource, long cacheDurationMs) {
+        Drawable d = null;
+        if (defaultResource != 0)
+            d = imageView.getResources().getDrawable(defaultResource);
+        setUrlDrawable(context, imageView, url, d, cacheDurationMs, null);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, int defaultResource, UrlImageViewCallback callback) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultResource, CACHE_DURATION_THREE_DAYS, callback);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, UrlImageViewCallback callback) {
+        setUrlDrawable(imageView.getContext(), imageView, url, null, CACHE_DURATION_THREE_DAYS, callback);
+    }
+
+    public static void loadUrlDrawable(final Context context, final String url, UrlImageViewCallback callback) {
+        setUrlDrawable(context, null, url, null, CACHE_DURATION_THREE_DAYS, callback);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, Drawable defaultDrawable, UrlImageViewCallback callback) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultDrawable, CACHE_DURATION_THREE_DAYS, callback);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, int defaultResource, long cacheDurationMs, UrlImageViewCallback callback) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultResource, cacheDurationMs, callback);
+    }
+
+    public static void loadUrlDrawable(final Context context, final String url, long cacheDurationMs, UrlImageViewCallback callback) {
+        setUrlDrawable(context, null, url, null, cacheDurationMs, callback);
+    }
+
+    public static void setUrlDrawable(final ImageView imageView, final String url, Drawable defaultDrawable, long cacheDurationMs, UrlImageViewCallback callback) {
+        setUrlDrawable(imageView.getContext(), imageView, url, defaultDrawable, cacheDurationMs, callback);
+    }
+
+    private static void setUrlDrawable(final Context context, final ImageView imageView, final String url, int defaultResource, long cacheDurationMs, UrlImageViewCallback callback) {
+        Drawable d = null;
+        if (defaultResource != 0)
+            d = imageView.getResources().getDrawable(defaultResource);
+        setUrlDrawable(context, imageView, url, d, cacheDurationMs, callback);
+    }
+
+    private static boolean isNullOrEmpty(CharSequence s) {
+        return (s == null || s.equals("") || s.equals("null") || s.equals("NULL"));
+    }
+
+    private static boolean mHasCleaned = false;
+
+    public static String getFilenameForUrl(String url) {
+        return "" + url.hashCode() + ".urlimage";
+    }
+
+    private static void cleanup(Context context) {
+        if (mHasCleaned)
+            return;
+        mHasCleaned = true;
+        try {
+            // purge any *.urlimage files over a week old
+            String[] files = context.getFilesDir().list();
+            if (files == null)
+                return;
+            for (String file : files) {
+                if (!file.endsWith(".urlimage"))
+                    continue;
+
+                File f = new File(context.getFilesDir().getAbsolutePath() + '/' + file);
+                if (System.currentTimeMillis() > f.lastModified() + CACHE_DURATION_ONE_WEEK)
+                    f.delete();
+            }
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static void setUrlDrawable(final Context context, final ImageView imageView, final String url, final Drawable defaultDrawable, long cacheDurationMs, final UrlImageViewCallback callback) {
+        cleanup(context);
+        // disassociate this ImageView from any pending downloads
+        if (isNullOrEmpty(url)) {
+            if (imageView != null)
+                imageView.setImageDrawable(defaultDrawable);
+            return;
+        }
+
+        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+        Display display = wm.getDefaultDisplay();
+        final int tw = display.getWidth();
+        final int th = display.getHeight();
+
+        if (mDeadCache == null)
+            mDeadCache = new UrlLruCache(getHeapSize(context) / 8);
+        Drawable drawable;
+        BitmapDrawable zd = mDeadCache.remove(url);
+        if (zd != null) {
+            // this drawable was resurrected, it should not be in the live cache
+            if (Constants.LOG_ENABLED)
+                Log.i(Constants.LOGTAG, "zombie load");
+            Assert.assertTrue(!mAllCache.contains(zd));
+            drawable = new ZombieDrawable(url, zd);
+        }
+        else {
+            drawable = mLiveCache.get(url);
+        }
+
+        if (drawable != null) {
+            if (Constants.LOG_ENABLED)
+                Log.i(Constants.LOGTAG, "Cache hit on: " + url);
+            if (imageView != null)
+                imageView.setImageDrawable(drawable);
+            if (callback != null)
+                callback.onLoaded(imageView, drawable, url, true);
+            return;
+        }
+        
+        // oh noes, at this point we definitely do not have the file available in memory
+        // let's prepare for an asynchronous load of the image.
+
+        final String filename = context.getFileStreamPath(getFilenameForUrl(url)).getAbsolutePath();
+
+        // null it while it is downloading
+        if (imageView != null)
+            imageView.setImageDrawable(defaultDrawable);
+
+        // since listviews reuse their views, we need to 
+        // take note of which url this view is waiting for.
+        // This may change rapidly as the list scrolls or is filtered, etc.
+        if (Constants.LOG_ENABLED)
+            Log.i(Constants.LOGTAG, "Waiting for " + url);
+        if (imageView != null)
+            mPendingViews.put(imageView, url);
+
+        ArrayList<ImageView> currentDownload = mPendingDownloads.get(url);
+        if (currentDownload != null) {
+            // Also, multiple vies may be waiting for this url.
+            // So, let's maintain a list of these views.
+            // When the url is downloaded, it sets the imagedrawable for
+            // every view in the list. It needs to also validate that
+            // the imageview is still waiting for this url.
+            if (imageView != null)
+                currentDownload.add(imageView);
+            return;
+        }
+
+        final ArrayList<ImageView> downloads = new ArrayList<ImageView>();
+        if (imageView != null)
+            downloads.add(imageView);
+        mPendingDownloads.put(url, downloads);
+
+        final int targetWidth = tw <= 0 ? Integer.MAX_VALUE : tw;
+        final int targetHeight = th <= 0 ? Integer.MAX_VALUE : th;
+        final Loader loader = new Loader() {
+            @Override
+            public void run() {
+                try {
+                    result = loadDrawableFromStream(context, url, filename, targetWidth, targetHeight);
+                }
+                catch (Exception ex) {
+                }
+            }
+        };
+
+        final Runnable completion = new Runnable() {
+            @Override
+            public void run() {
+                Assert.assertEquals(Looper.myLooper(), Looper.getMainLooper());
+                Drawable usableResult = loader.result;
+                if (usableResult == null)
+                    usableResult = defaultDrawable;
+                mPendingDownloads.remove(url);
+                mLiveCache.put(url, usableResult);
+                for (ImageView iv: downloads) {
+                    // validate the url it is waiting for
+                    String pendingUrl = mPendingViews.get(iv);
+                    if (!url.equals(pendingUrl)) {
+                        if (Constants.LOG_ENABLED)
+                            Log.i(Constants.LOGTAG, "Ignoring out of date request to update view for " + url);
+                        continue;
+                    }
+                    mPendingViews.remove(iv);
+                    if (usableResult != null) {
+                        //                        System.out.println(String.format("imageView: %dx%d, %dx%d", imageView.getMeasuredWidth(), imageView.getMeasuredHeight(), imageView.getWidth(), imageView.getHeight()));
+                        iv.setImageDrawable(usableResult);
+//                        System.out.println(String.format("imageView: %dx%d, %dx%d", imageView.getMeasuredWidth(), imageView.getMeasuredHeight(), imageView.getWidth(), imageView.getHeight()));
+                        if (callback != null)
+                            callback.onLoaded(iv, loader.result, url, false);
+                    }
+                }
+            }
+        };
+        
+
+        File file = new File(filename);
+        if (file.exists()) {
+            try {
+                if (cacheDurationMs == CACHE_DURATION_INFINITE || System.currentTimeMillis() < file.lastModified() + cacheDurationMs) {
+                    if (Constants.LOG_ENABLED)
+                        Log.i(Constants.LOGTAG, "File Cache hit on: " + url + ". " + (System.currentTimeMillis() - file.lastModified()) + "ms old.");
+                    
+                    AsyncTask<Void, Void, Void> fileloader = new AsyncTask<Void, Void, Void>() {
+                        protected Void doInBackground(Void[] params) {
+                            loader.run();
+                            return null;
+                        }
+                        protected void onPostExecute(Void result) {
+                            completion.run();
+                        }
+                    };
+                    executeTask(fileloader);
+                    return;
+                }
+                else {
+                    if (Constants.LOG_ENABLED)
+                        Log.i(Constants.LOGTAG, "File cache has expired. Refreshing.");
+                }
+            }
+            catch (Exception ex) {
+            }
+        }
+
+        mDownloader.download(context, url, filename, loader, completion);
+    }
+
+    private static abstract class Loader implements Runnable {
+        public Drawable result;
+    }
+
+    public static interface UrlDownloader {
+        public void download(Context context, String url, String filename, Runnable loader, Runnable completion);
+    }
+
+    private static UrlDownloader mDefaultDownloader = new UrlDownloader() {
+        @Override
+        public void download(final Context context, final String url, final String filename, final Runnable loader, final Runnable completion) {
+            AsyncTask<Void, Void, Void> downloader = new AsyncTask<Void, Void, Void>() {
+                @Override
+                protected Void doInBackground(Void... params) {
+                    try {
+                        InputStream is = null;
+                        if (url.startsWith(ContactsContract.Contacts.CONTENT_URI.toString())) {
+                            ContentResolver cr = context.getContentResolver();
+                            is = ContactsContract.Contacts.openContactPhotoInputStream(cr, Uri.parse(url));
+                        }
+                        else {
+                            final AndroidHttpClient client = AndroidHttpClient.newInstance(context.getPackageName());
+                            HttpGet get = new HttpGet(url);
+                            final HttpParams httpParams = new BasicHttpParams();
+                            HttpClientParams.setRedirecting(httpParams, true);
+
+                            if (mRequestPropertiesCallback != null) {
+                                ArrayList<NameValuePair> props = mRequestPropertiesCallback.getHeadersForRequest(context, url);
+                                if (props != null) {
+                                    for (NameValuePair pair: props) {
+                                        httpParams.setParameter(pair.getName(), pair.getValue());
+                                    }
+                                }
+                            }
+
+                            get.setParams(httpParams);
+                            HttpResponse resp = client.execute(get);
+                            int status = resp.getStatusLine().getStatusCode();
+
+                            if (status != HttpURLConnection.HTTP_OK) {
+                                return null;
+                            }
+                            HttpEntity entity = resp.getEntity();
+                            is = entity.getContent();
+                        }
+
+                        if (is != null) {
+                            FileOutputStream fos = new FileOutputStream(filename);
+                            copyStream(is, fos);
+                            fos.close();
+                            is.close();
+                        }
+                        loader.run();
+                        return null;
+                    }
+                    catch (Throwable e) {
+                        e.printStackTrace();
+                        return null;
+                    }
+                }
+
+                protected void onPostExecute(Void result) {
+                    completion.run();
+                }
+            };
+
+            executeTask(downloader);
+        }
+    };
+    
+    static public interface RequestPropertiesCallback {
+        public ArrayList<NameValuePair> getHeadersForRequest(Context context, String url);
+    }
+    
+    static private RequestPropertiesCallback mRequestPropertiesCallback;
+    static public RequestPropertiesCallback getRequestPropertiesCallback() {
+        return mRequestPropertiesCallback;
+    }
+    
+    static public void setRequestPropertiesCallback(RequestPropertiesCallback callback) {
+        mRequestPropertiesCallback = callback;
+    }
+    
+    
+    public static void useDownloader(UrlDownloader downloader) {
+        mDownloader = downloader;
+    }
+
+    public static void useDefaultDownloader() {
+        mDownloader = mDefaultDownloader;
+    }
+    
+    public static UrlDownloader getDefaultDownloader() {
+        return mDownloader;
+    }
+
+    private static UrlImageCache mLiveCache = UrlImageCache.getInstance();
+
+    private static UrlLruCache mDeadCache;
+    private static HashSet<BitmapDrawable> mAllCache = new HashSet<BitmapDrawable>();
+    private static int getHeapSize(Context context) {
+        return ((ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass() * 1024 * 1024;
+    }
+    
+    private static class ZombieDrawable extends WrapperDrawable {
+        public ZombieDrawable(String url, BitmapDrawable drawable) {
+            super(drawable);
+            mUrl = url;
+
+            mAllCache.add(drawable);
+            mDeadCache.remove(url);
+            mLiveCache.put(url, this);
+        }
+        
+        String mUrl;
+        
+        @Override
+        protected void finalize() throws Throwable {
+            super.finalize();
+
+            mDeadCache.put(mUrl, mDrawable);
+            mAllCache.remove(mDrawable);
+            mLiveCache.remove(mUrl);
+            if (Constants.LOG_ENABLED)
+                Log.i(Constants.LOGTAG, "Zombie GC event");
+            System.gc();
+        }
+    }
+
+
+    private static UrlDownloader mDownloader = mDefaultDownloader;
+
+    private static void executeTask(AsyncTask<Void, Void, Void> task) {
+        if (Build.VERSION.SDK_INT < Constants.HONEYCOMB)
+            task.execute();
+        else
+            executeTaskHoneycomb(task);
+    }
+    
+    @TargetApi(Constants.HONEYCOMB)
+    private static void executeTaskHoneycomb(AsyncTask<Void, Void, Void> task) {
+        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+    }
+
+    private static Hashtable<ImageView, String> mPendingViews = new Hashtable<ImageView, String>();
+    private static Hashtable<String, ArrayList<ImageView>> mPendingDownloads = new Hashtable<String, ArrayList<ImageView>>();
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/UrlLruCache.java b/src/com/koushikdutta/urlimageviewhelper/UrlLruCache.java
new file mode 100644
index 0000000..5529739
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/UrlLruCache.java
@@ -0,0 +1,20 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+
+public class UrlLruCache extends LruCache<String, BitmapDrawable> {
+    public UrlLruCache(int maxSize) {
+        super(maxSize);
+    }
+
+    @Override
+    protected int sizeOf(String key, BitmapDrawable value) {
+        if (value != null) {
+            Bitmap b = value.getBitmap();
+            if (b != null)
+                return b.getRowBytes() * b.getHeight();
+        }
+        return 0;
+    }
+} 
diff --git a/src/com/koushikdutta/urlimageviewhelper/WrapperDrawable.java b/src/com/koushikdutta/urlimageviewhelper/WrapperDrawable.java
new file mode 100644
index 0000000..970b02c
--- /dev/null
+++ b/src/com/koushikdutta/urlimageviewhelper/WrapperDrawable.java
@@ -0,0 +1,54 @@
+package com.koushikdutta.urlimageviewhelper;
+
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+
+class WrapperDrawable extends Drawable {
+    public WrapperDrawable(BitmapDrawable drawable) {
+        mDrawable = drawable;
+    }
+    
+    BitmapDrawable mDrawable;
+    
+    public WrapperDrawable(WrapperDrawable drawable) {
+        this(drawable.mDrawable);
+    }
+
+    @Override
+    public void draw(Canvas canvas) {
+        mDrawable.draw(canvas);
+    }
+
+    @Override
+    public int getOpacity() {
+        return mDrawable.getOpacity();
+    }
+
+    @Override
+    public void setAlpha(int alpha) {
+        mDrawable.setAlpha(alpha);
+    }
+
+    @Override
+    public void setColorFilter(ColorFilter cf) {
+        mDrawable.setColorFilter(cf);
+    }
+
+    @Override
+    public void setBounds(int left, int top, int right, int bottom) {
+        mDrawable.setBounds(left, top, right, bottom);
+    }
+    
+    @Override
+    public int getIntrinsicHeight() {
+        return mDrawable.getIntrinsicHeight();
+    }
+    
+    @Override
+    public int getIntrinsicWidth() {
+        // TODO Auto-generated method stub
+        return mDrawable.getIntrinsicWidth();
+    }
+} 
