<commit_before>﻿using Crystal3;
using Crystal3.UI;
using Neptunium.ViewModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace Neptunium.View
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    [Crystal3.Navigation.NavigationViewModel(typeof(Neptunium.ViewModel.SettingsPageViewModel))]
    public sealed partial class SettingsPage : Page
    {
        public SettingsPage()
        {
            this.InitializeComponent();
        }

        private async void SelectBluetoothButton_Click(object sender, RoutedEventArgs e)
        {
            SelectBluetoothButton.IsEnabled = false;
            var device = await NepApp.MediaPlayer.Bluetooth.DeviceCoordinator.SelectDeviceAsync(Window.Current.Bounds);
            if (device != null)
            {
                this.GetViewModel<SettingsPageViewModel>().SelectedBluetoothDeviceName = device.Name;
            }
            SelectBluetoothButton.IsEnabled = true;
        }

        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (CrystalApplication.GetDevicePlatform() != Crystal3.Core.Platform.Xbox)
            {
                //only show bluetooth settings on devices that have bluetooth.
                bluetoothPivot.IsEnabled = await NepApp.MediaPlayer.Bluetooth.DeviceCoordinator.HasBluetoothRadiosAsync();

                UpdateLockScreenSwitch.Visibility = Visibility.Visible;
            }
        }

        private async void SetFallBackLockScreenBtn_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();
            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
            if (file != null)
            {
                // Application now has read/write access to the picked file

                //todo check if less or equal to 2MB on mobile before proceeding.

                await NepApp.UI.LockScreen.SetFallbackImageAsync(file);
            }
            else
            {
                //cancelled
            }
        }
    }
}<commit_msg>Force focus on the settings page on Xbox.<commit_after>﻿using Crystal3;
using Crystal3.UI;
using Neptunium.Glue;
using Neptunium.ViewModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace Neptunium.View
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    [Crystal3.Navigation.NavigationViewModel(typeof(Neptunium.ViewModel.SettingsPageViewModel))]
    public sealed partial class SettingsPage : Page, IXboxInputPage
    {
        public SettingsPage()
        {
            this.InitializeComponent();
        }

        private async void SelectBluetoothButton_Click(object sender, RoutedEventArgs e)
        {
            SelectBluetoothButton.IsEnabled = false;
            var device = await NepApp.MediaPlayer.Bluetooth.DeviceCoordinator.SelectDeviceAsync(Window.Current.Bounds);
            if (device != null)
            {
                this.GetViewModel<SettingsPageViewModel>().SelectedBluetoothDeviceName = device.Name;
            }
            SelectBluetoothButton.IsEnabled = true;
        }

        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (CrystalApplication.GetDevicePlatform() != Crystal3.Core.Platform.Xbox)
            {
                //only show bluetooth settings on devices that have bluetooth.
                bluetoothPivot.IsEnabled = await NepApp.MediaPlayer.Bluetooth.DeviceCoordinator.HasBluetoothRadiosAsync();

                UpdateLockScreenSwitch.Visibility = Visibility.Visible;
            }
            else
            {
                //force focus on Xbox.
                RootPivot.Focus(FocusState.Keyboard);
            }
        }

        private async void SetFallBackLockScreenBtn_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();
            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
            if (file != null)
            {
                // Application now has read/write access to the picked file

                //todo check if less or equal to 2MB on mobile before proceeding.

                await NepApp.UI.LockScreen.SetFallbackImageAsync(file);
            }
            else
            {
                //cancelled
            }
        }

        public void SetLeftFocus(UIElement elementToTheLeft)
        {
            
        }

        public void SetRightFocus(UIElement elementToTheRight)
        {
            
        }

        public void SetTopFocus(UIElement elementAbove)
        {
            
        }

        public void SetBottomFocus(UIElement elementBelow)
        {
            
        }

        public void RestoreFocus()
        {
            
        }

        public void PreserveFocus()
        {
            
        }
    }
}
{'fraction_non_alphanumeric': 0.08212121212121212, 'fraction_numerical': 0.0033333333333333335, 'mean_word_length': 2.1766121270452357, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3616527', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1664, 'n_words': 372}