Example #1
0
        private void MaxDownloadClick(object sender, Preference.PreferenceClickEventArgs e)
        {
            View pickerView = LayoutInflater.Inflate(Resource.Layout.NumberPicker, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
            builder.SetTitle(Resources.GetString(Resource.String.max_download_dialog));
            builder.SetView(pickerView);
            NumberPicker picker = (NumberPicker)pickerView;

            picker.MinValue = 1;
            picker.MaxValue = 10;
            picker.Value    = int.Parse(FindPreference("maxDownload").Summary);

            builder.SetPositiveButton(Resources.GetString(Resource.String.apply), (s, eventArg) =>
            {
                ISharedPreferences pref         = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                ISharedPreferencesEditor editor = pref.Edit();
                editor.PutInt("maxDownload", picker.Value);
                editor.Apply();

                Preference prefButton = FindPreference("maxDownload");
                prefButton.Summary    = pref.GetInt("maxDownload", 2).ToString();

                if (Downloader.instance != null && Downloader.queue.Count > 0)
                {
                    Downloader.instance.maxDownload = pref.GetInt("maxDownload", 4);
                }
            });
            builder.SetNegativeButton(Resources.GetString(Resource.String.cancel), (s, eventArg) => { });
            builder.Show();
        }
Example #2
0
        private void DownloadFolderBack()
        {
            ISharedPreferences       prefManager = PreferenceManager.GetDefaultSharedPreferences(this);
            ISharedPreferencesEditor editor      = prefManager.Edit();

            editor.PutString("downloadPath", DownloadFragment.instance.path);
            editor.Apply();
            Preference downloadPref = PreferencesFragment.instance.PreferenceScreen.FindPreference("downloadPath");

            downloadPref.Summary = DownloadFragment.instance.path ?? Environment.GetExternalStoragePublicDirectory(Environment.DirectoryMusic).ToString();
            PreferencesFragment.instance.path = DownloadFragment.instance.path;

            DownloadFragment.instance = null;
            SupportFragmentManager.PopBackStack();
        }
Example #3
0
        private void KeepDeletedClick(object sender, Preference.PreferenceClickEventArgs e)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
            builder.SetTitle("Delete song when removing them from a synced playlist:");
            builder.SetItems(new string[] { "True", "False" }, (s, args) =>
            {
                ISharedPreferences pref         = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                ISharedPreferencesEditor editor = pref.Edit();
                editor.PutBoolean("keepDeleted", args.Which == 1);
                editor.Apply();

                Preference prefButton = FindPreference("keepDeleted");
                prefButton.Summary    = args.Which == 0 ? "True" : "False";
            });
            builder.Show();
        }
Example #4
0
        private void ChangeTheme(object sender, Preference.PreferenceClickEventArgs e)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
            builder.SetTitle(Resources.GetString(Resource.String.theme_dialog));
            builder.SetItems(new[] { Resources.GetString(Resource.String.white_theme), Resources.GetString(Resource.String.dark_theme), Resources.GetString(Resource.String.black_theme) }, (s, args) =>
            {
                ISharedPreferences pref         = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                ISharedPreferencesEditor editor = pref.Edit();
                editor.PutInt("theme", args.Which);
                editor.Apply();

                Preference prefButton = FindPreference("theme");
                prefButton.Summary    = args.Which == 0 ? Resources.GetString(Resource.String.white_theme) : Resources.GetString(Resource.String.dark_theme);

                MainActivity.LoadTheme(MainActivity.instance);
                MainActivity.instance.Recreate();
                Activity.Recreate();
            });
            builder.Show();
        }
Example #5
0
        public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            instance = this;
            SetPreferencesFromResource(Resource.Layout.Preferences, rootKey);
            ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            //Download Path
            Preference downloadPref = PreferenceScreen.FindPreference("downloadPath");

            downloadPref.IconSpaceReserved = false;
            downloadPref.PreferenceClick  += DownloadClick;
            downloadPref.Summary           = prefManager.GetString("downloadPath", Environment.GetExternalStoragePublicDirectory(Environment.DirectoryMusic).ToString());
            path = prefManager.GetString("downloadPath", Environment.GetExternalStoragePublicDirectory(Environment.DirectoryMusic).ToString());

            //Maximum Download
            Preference maxDlPref = PreferenceScreen.FindPreference("maxDownload");

            maxDlPref.IconSpaceReserved = false;
            maxDlPref.PreferenceClick  += MaxDownloadClick;
            maxDlPref.Summary           = prefManager.GetInt("maxDownload", 4).ToString();

            //Keep Deleted
            Preference keepDeletedPref = PreferenceScreen.FindPreference("keepDeleted");

            keepDeletedPref.IconSpaceReserved = false;
            keepDeletedPref.PreferenceClick  += KeepDeletedClick;
            keepDeletedPref.Summary           = (!prefManager.GetBoolean("keepDeleted", true)).ToString();

            //Theme
            Preference themePreference = PreferenceScreen.FindPreference("theme");

            themePreference.IconSpaceReserved = false;
            themePreference.PreferenceClick  += ChangeTheme;
            switch (prefManager.GetInt("theme", 0))
            {
            case 0:
            default:
                themePreference.Summary = Resources.GetString(Resource.String.white_theme);
                break;

            case 1:
                themePreference.Summary = Resources.GetString(Resource.String.dark_theme);
                break;

            case 2:
                themePreference.Summary = Resources.GetString(Resource.String.black_theme);
                break;
            }

            //Check For Update
            Preference updatePreference = PreferenceScreen.FindPreference("update");

            updatePreference.IconSpaceReserved = false;
            updatePreference.PreferenceClick  += UpdatePreference_PreferenceClick;

            //Version Number
            Preference   versionPreference = PreferenceScreen.FindPreference("version");
            string       VersionAsset;
            string       Beta;
            AssetManager assets = Application.Context.Assets;

            using (StreamReader sr = new StreamReader(assets.Open("Version.txt")))
            {
                VersionAsset = sr.ReadLine();
                Beta         = sr.ReadLine();
            }

            string version = VersionAsset.Substring(9, 5);

            if (version.EndsWith(".0"))
            {
                version = version.Substring(0, 3);
            }
            bool beta = false;

            if (Beta.Substring(6, 1) == "T")
            {
                beta = true;
            }

            versionPreference.Summary           = "v" + version + (beta ? "-Beta" : "");
            versionPreference.IconSpaceReserved = false;
            versionPreference.PreferenceClick  += About;

            //Account
            Preference accountPreference = PreferenceScreen.FindPreference("account");

            accountPreference.IconSpaceReserved = false;

            if (MainActivity.account != null)
            {
                accountPreference.Title   = Resources.GetString(Resource.String.logged_in);
                accountPreference.Summary = MainActivity.account.DisplayName;
            }
        }