<commit_before>﻿using Android.App;
using Android.OS;
using MediaManager.Sample.Core;
using Android.Support.V7.App;
using Android.Content.PM;
using Android.Widget;
using System;
using System.Text.RegularExpressions;
using Android.Graphics;
using Newtonsoft.Json.Serialization;
using Plugin.MediaManager.Abstractions.Implementations;
using Plugin.MediaManager.ExoPlayer;
using Plugin.MediaManager;
using System.Collections.Generic;
using Plugin.MediaManager.Abstractions;

namespace MediaSample.Droid
{

    using Plugin.MediaManager.Abstractions.Enums;

    [Activity(Label = "MediaSample.Droid",
         MainLauncher = true,
         Icon = "@drawable/icon_play",
         Theme = "@style/AppTheme",
         LaunchMode = LaunchMode.SingleTop,
         ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)]
    public class MainActivity : AppCompatActivity
    {
        private MediaPlayerViewModel ViewModel { get; set; }

        private IMediaManager MediaManager => ViewModel.MediaPlayer;

        private IPlaybackController PlaybackController => MediaManager.PlaybackController;

        private Android.Support.V7.Widget.Toolbar toolbar;

        private const bool ShouldUseExoPlayer = true;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            ViewModel = new MediaPlayerViewModel();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);
            }

            if (ShouldUseExoPlayer)
            {
                var exoPlayer = new ExoPlayerAudioImplementation(((MediaManagerImplementation)CrossMediaManager.Current).MediaSessionManager);
                CrossMediaManager.Current.AudioPlayer = exoPlayer;
            }

            CrossMediaManager.Current.AudioPlayer.RequestHeaders = new Dictionary<string, string> { { "Test", "1234" } };

            var previous = FindViewById<ImageButton>(Resource.Id.btnPrevious);
            previous.Click += async (sender, args) =>
            {
                await PlaybackController.PlayPreviousOrSeekToStart();
            };

            var playpause = FindViewById<ToggleButton>(Resource.Id.btnPlayPause);
            playpause.Click += async (sender, args) =>
            {<commit_msg>Updated Android sample app to make notifications buttons work.<commit_after>﻿using Android.App;
using Android.OS;
using MediaManager.Sample.Core;
using Android.Support.V7.App;
using Android.Content.PM;
using Android.Widget;
using System;
using System.Text.RegularExpressions;
using Android.Graphics;
using Newtonsoft.Json.Serialization;
using Plugin.MediaManager.Abstractions.Implementations;
using Plugin.MediaManager.ExoPlayer;
using Plugin.MediaManager;
using System.Collections.Generic;
using Plugin.MediaManager.Abstractions;

namespace MediaSample.Droid
{

    using Plugin.MediaManager.Abstractions.Enums;
    using Plugin.MediaManager.MediaSession;

    [Activity(Label = "MediaSample.Droid",
         MainLauncher = true,
         Icon = "@drawable/icon_play",
         Theme = "@style/AppTheme",
         LaunchMode = LaunchMode.SingleTop,
         ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)]
    public class MainActivity : AppCompatActivity
    {
        private MediaPlayerViewModel ViewModel { get; set; }

        private IMediaManager MediaManager => ViewModel.MediaPlayer;

        private IPlaybackController PlaybackController => MediaManager.PlaybackController;

        private Android.Support.V7.Widget.Toolbar toolbar;

        private const bool ShouldUseExoPlayer = true;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            ViewModel = new MediaPlayerViewModel();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);
            }

            if (ShouldUseExoPlayer)
            {
                ((MediaManagerImplementation)CrossMediaManager.Current).MediaSessionManager = new MediaSessionManager(Application.Context, typeof(ExoPlayerAudioService));
                var exoPlayer = new ExoPlayerAudioImplementation(((MediaManagerImplementation)CrossMediaManager.Current).MediaSessionManager);
                CrossMediaManager.Current.AudioPlayer = exoPlayer;
            }

            CrossMediaManager.Current.AudioPlayer.RequestHeaders = new Dictionary<string, string> { { "Test", "1234" } };

            var previous = FindViewById<ImageButton>(Resource.Id.btnPrevious);
            previous.Click += async (sender, args) =>
            {
                await PlaybackController.PlayPreviousOrSeekToStart();
            };

            var playpause = FindViewById<ToggleButton>(Resource.Id.btnPlayPause);
            playpause.Click += async (sender, args) =>
            {
{'fraction_non_alphanumeric': 0.08453757225433527, 'fraction_numerical': 0.0025289017341040463, 'mean_word_length': 2.8938115330520393, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1782478', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1330, 'n_words': 270}