コード例 #1
0
 public override void OnResume()
 {
     base.OnResume();
     instance = this;
 }
コード例 #2
0
 public override void OnDestroy()
 {
     base.OnDestroy();
     instance = null;
 }
コード例 #3
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;
            }
        }