public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.preference_fragment, container, false);

            themeSwitcher         = view.FindViewById <Switch>(Resource.Id.switcher);
            materialCard          = view.FindViewById <MaterialCardView>(Resource.Id.donationCard);
            donationTextView      = view.FindViewById <TextView>(Resource.Id.donationTextView);
            donationRefreshButton = view.FindViewById <Button>(Resource.Id.donationRefreshButton);
            aboutButton           = view.FindViewById <Google.Android.Material.Button.MaterialButton>(Resource.Id.aboutButton);
            reportButton          = view.FindViewById <Google.Android.Material.Button.MaterialButton>(Resource.Id.reportButton);

            donationRefreshButton.Click += DonationRefreshButton_Click;
            aboutButton.Click           += AboutButton_Click;
            reportButton.Click          += ReportButton_Click;
            themeSwitcher.SetOnCheckedChangeListener(this);

            sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this.Context);

            var stateIsChecked = sharedPreferences.GetBoolean("Saved_Switch", false);

            if (themeSwitcher != null)
            {
                themeSwitcher.Checked = stateIsChecked;

                if (stateIsChecked)
                {
                    themeSwitcher.Text = "Toggle to turn off the lights";
                }
                else
                {
                    themeSwitcher.Text = "Toogle to turn the lights on";
                }
            }
            var userHasDonated = ExtractRAdManager.UserHasDonated(this.Context);

            if (!userHasDonated)
            {
                materialCard.SetBackgroundColor(Android.Graphics.Color.DarkRed);
                donationTextView.SetTextColor(Android.Graphics.Color.GhostWhite);
                donationTextView.Text            = Context.GetString(Resource.String.user_no_donation);
                donationRefreshButton.Visibility = ViewStates.Visible;
            }
            else
            {
                materialCard.SetBackgroundColor(Android.Graphics.Color.DarkGreen);
                donationTextView.SetTextColor(Android.Graphics.Color.GhostWhite);
                donationTextView.Text            = Context.GetString(Resource.String.user_donated);
                donationRefreshButton.Visibility = ViewStates.Gone;
            }

            return(view);
        }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            newTaskFragment    = new NewTaskFragment(this);
            historyFragment    = new HistoryFragment(this);
            donationFragment   = new DonationFragment();
            preferenceFragment = new PreferenceFragment(this);

            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mainToolBar);
            SetSupportActionBar(toolbar);


            navigation = FindViewById <Google.Android.Material.BottomNavigation.BottomNavigationView>(Resource.Id.navigation);
            navigation.SetOnNavigationItemSelectedListener(this);

            ChangeFragment(newTaskFragment);

            MobileAds.Initialize(this);

            if (!ExtractRAdManager.UserHasDonated(this))
            {
                interstitialAd = ExtractRAdManager.LoadAdInBackground(this);
            }

            if (AppCompatDelegate.DefaultNightMode == AppCompatDelegate.ModeNightYes)
            {
                navigation.ItemIconTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.GhostWhite);
                navigation.ItemTextColor    = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.GhostWhite);
            }
            else if (AppCompatDelegate.DefaultNightMode == AppCompatDelegate.ModeNightNo)
            {
                string accentColorString           = "#" + GetColor(Resource.Color.colorAccent).ToString("X");
                Android.Graphics.Color accentColor = Android.Graphics.Color.ParseColor(accentColorString);

                navigation.ItemIconTintList = Android.Content.Res.ColorStateList.ValueOf(accentColor);
                navigation.ItemTextColor    = Android.Content.Res.ColorStateList.ValueOf(accentColor);
            }
        }
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.export_activity);
            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.exportToolbar);
            adView  = FindViewById <AdView>(Resource.Id.adView);
            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true);

            double count    = 0;
            var    getExtra = Intent.Extras.Get("itemCount");

            if (getExtra != null)
            {
                count = (double)getExtra;
            }

            SupportActionBar.Title = $"Export {count} Items";

            SupportFragmentManager.BeginTransaction()
            .Add(Resource.Id.exportPlaceholder, new NewExportFragment(this))
            .Commit();


            //Present simple banner ads.
            AdRequest adRequest = new AdRequest.Builder().Build();

            //Load ad if the user has not donated.
            if (!ExtractRAdManager.UserHasDonated(this))
            {
                adView.LoadAd(adRequest);
            }
        }