Add vanillaplug option to preferences
This commit is contained in:
1 parent
bfea91f7cf
commit
d4f17d2c9a
3 files changed
+51
-2
No files matched your search
@@ -56,6 +56,7 @@ THE SOFTWARE.
|
||||
<string name="create">Create</string>
|
||||
<string name="overwrite">Overwrite</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="yes">Yes</string>
|
||||
|
||||
<string name="delete_playlist">Delete playlist %s?</string>
|
||||
|
||||
@@ -160,8 +161,9 @@ THE SOFTWARE.
|
||||
<string name="headset_only_summary">Prevents music from being played through the internal speakers.</string>
|
||||
<string name="headset_pause_title">Pause When Unplugged</string>
|
||||
<string name="headset_pause_summary">Pause when the headphones are unplugged.</string>
|
||||
<string name="headset_play_title">Play When Plugged</string>
|
||||
<string name="headset_play_summary">Play when the headphones are plugged in. (Only works when the service is running.)</string>
|
||||
<string name="headset_launch_title">Play When Plugged</string>
|
||||
<string name="headset_launch_summary">Play when the headphones are plugged in. (Requires the \'Headphone detector\' app to be installed.)</string>
|
||||
<string name="headset_launch_app_missing">This features requires the \'Headphone detector\' app to be installed.\nWould you like to open the Play Store to install the application?</string>
|
||||
|
||||
<string name="replaygain">Replay Gain</string>
|
||||
<string name="replaygain_title">Enable Replay Gain</string>
|
||||
|
||||
@@ -60,6 +60,10 @@ THE SOFTWARE.
|
||||
android:title="@string/headset_pause_title"
|
||||
android:defaultValue="true"
|
||||
android:summary="@string/headset_pause_summary" />
|
||||
<PreferenceScreen
|
||||
android:fragment="ch.blinkenlights.android.vanilla.PreferencesActivity$HeadsetLaunchFragment"
|
||||
android:title="@string/headset_launch_title"
|
||||
android:summary="@string/headset_launch_summary" />
|
||||
<CheckBoxPreference
|
||||
android:key="cycle_continuous_shuffling"
|
||||
android:title="@string/cycle_continuous_shuffling"
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
package ch.blinkenlights.android.vanilla;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -50,6 +53,12 @@ import java.util.List;
|
||||
* The preferences activity in which one can change application preferences.
|
||||
*/
|
||||
public class PreferencesActivity extends PreferenceActivity {
|
||||
|
||||
/**
|
||||
* The package name of our external helper app
|
||||
*/
|
||||
private static final String VPLUG_PACKAGE_NAME = "ch.blinkenlights.android.vanillaplug";
|
||||
|
||||
/**
|
||||
* Initialize the activity, loading the preference specifications.
|
||||
*/
|
||||
@@ -227,6 +236,40 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public static class HeadsetLaunchFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Activity activity = getActivity();
|
||||
Intent intent = activity.getPackageManager().getLaunchIntentForPackage(VPLUG_PACKAGE_NAME);
|
||||
|
||||
if (intent != null) {
|
||||
startActivity(intent);
|
||||
activity.finish();
|
||||
} else {
|
||||
// package is not installed, ask user to install it
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.headset_launch_title)
|
||||
.setMessage(R.string.headset_launch_app_missing)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
|
||||
marketIntent.setData(Uri.parse("market://details?id="+VPLUG_PACKAGE_NAME));
|
||||
startActivity(marketIntent);
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
|
||||
Reference in new issue
Block a user