diff --git a/project.properties b/project.properties
index 75b478c9..98f2ce64 100644
--- a/project.properties
+++ b/project.properties
@@ -10,5 +10,5 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
-target=android-14
+target=android-15
proguard.config=proguard.config
diff --git a/res/values/translatable.xml b/res/values/translatable.xml
index c01f3449..5c0d94cf 100644
--- a/res/values/translatable.xml
+++ b/res/values/translatable.xml
@@ -174,6 +174,11 @@ THE SOFTWARE.
Emulate Stock Broadcasts
Send broadcasts emulating those sent by the stock music player to work with 3rd party lockscreen controls, widgets, etc.
+ Refresh Library
+ Click to scan external storage for music
+ Scan in progress…
+ Finished scanning. Click to scan again.
+
Last used action
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 6dc966c2..1edc0334 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -158,5 +158,6 @@ THE SOFTWARE.
android:title="@string/stock_broadcast_title"
android:summary="@string/stock_broadcast_summary"
android:defaultValue="false" />
+
diff --git a/src/org/kreed/vanilla/ScanPreference.java b/src/org/kreed/vanilla/ScanPreference.java
new file mode 100644
index 00000000..46a0c6c4
--- /dev/null
+++ b/src/org/kreed/vanilla/ScanPreference.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 Christopher Eby
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package org.kreed.vanilla;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.Uri;
+import android.os.Environment;
+import android.preference.Preference;
+import android.util.AttributeSet;
+
+/**
+ * A preference that allows the MediaScanner to be triggered.
+ */
+public class ScanPreference extends Preference {
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ android.util.Log.i("VanillaMusic", "receive: " + intent);
+ String action = intent.getAction();
+ if (action.equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) {
+ setSummary(R.string.scan_in_progress);
+ setEnabled(false);
+ } else if (intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
+ setSummary(R.string.finished_scanning);
+ setEnabled(true);
+ }
+ }
+ };
+
+ public ScanPreference(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ setTitle(R.string.media_scan);
+ setSummary(R.string.click_to_scan);
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
+ intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
+ intentFilter.addDataScheme("file");
+ context.registerReceiver(mReceiver, intentFilter);
+ }
+
+ @Override
+ public void onClick()
+ {
+ Uri storage = Uri.parse("file://" + Environment.getExternalStorageDirectory());
+ getContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, storage));
+ }
+}