Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaexplorer74 committed Feb 15, 2022
1 parent 510b3ee commit 4764abb
Show file tree
Hide file tree
Showing 14 changed files with 509 additions and 241 deletions.
86 changes: 71 additions & 15 deletions Andro2UWP/Andro2UWP.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,15 @@ public static async System.Threading.Tasks.Task<bool> initODandDict(bool bMsg)
{
p.k.DebugOut("initODandDict(" + bMsg.ToString());

/*

//ProgresywnyRing(true);
if (bMsg) p.k.ProgRingShow(true);

//if (bMsg)
//{
// p.k.ProgRingShow(true);
//}

/*
// Ensure thet OneDrive is open ...
if (!await EnsureOneDriveOpen(bMsg))
{
Expand All @@ -698,8 +703,12 @@ public static async System.Threading.Tasks.Task<bool> initODandDict(bool bMsg)

p.k.SetSettingsBool("pkarMode", await CheckPkarFile());

//ProgresywnyRing(false);
if (bMsg) p.k.ProgRingShow(false);
// ProgresywnyRing(false);

//if (bMsg)
//{
// p.k.ProgRingShow(false);
//}

p.k.SetSettingsBool("wasInit", true);

Expand All @@ -726,7 +735,10 @@ private async static System.Threading.Tasks.Task LoadNew(bool bMsg)
return;
}

if (bMsg) p.k.ProgRingShow(true);
if (bMsg)
{
p.k.ProgRingShow(true);
}

// RnD: call on Android or.. not?
// load the list from OneDrive - for now on a button,
Expand All @@ -738,7 +750,10 @@ private async static System.Threading.Tasks.Task LoadNew(bool bMsg)
// and their contents - from progressbar
await ReadContents(bMsg);

if (bMsg) p.k.ProgRingShow(false);
if (bMsg)
{
p.k.ProgRingShow(false);
}

}//LoadNew end

Expand All @@ -760,6 +775,7 @@ private static async System.Threading.Tasks.Task ReadToastsList(bool bMsg)
return;
}

// NOTE: for ANDROID - don't show the whole list of notifications (skip already sended toasts)
#if !__ANDROID__
if (!p.od.IsOneDriveOpened())
await p.od.OpenOneDrive(true, bMsg);
Expand Down Expand Up @@ -848,8 +864,17 @@ private static async System.Threading.Tasks.Task ReadContents(bool bMsg)
}
}

if (bMsg) p.k.ProgRingShow(true, false, 0, iToBeRead);
if (bMsg) p.k.ProgRingVal(0);
if (bMsg)
{
p.k.ProgRingShow(true, false, 0, iToBeRead);
}

if (bMsg)
{
p.k.ProgRingVal(0);
}

// RnD
//uiProgBar.Maximum = iToBeRead;
//uiProgBar.Value = 0;
//uiProgBar.Visibility = Visibility.Visible;
Expand Down Expand Up @@ -891,11 +916,19 @@ private static async System.Threading.Tasks.Task ReadContents(bool bMsg)
}

// uiProgBar.Value = ++iToBeRead;
if (bMsg) p.k.ProgRingInc();
if (bMsg)
{
p.k.ProgRingInc();
}
}
}
#endif
if (bMsg) p.k.ProgRingShow(false);
if (bMsg)
{
p.k.ProgRingShow(false);
}

// RnD
//uiProgBar.Visibility = Visibility.Collapsed;

}//ReadContents end
Expand Down Expand Up @@ -1087,11 +1120,21 @@ public async void WriteToast(JedenToast toast)

await AddLogEntry("Try to start renovating OneDrive toastfile...", false);

bool oResult = await p.od.ReplaceOneDriveFileContent
(
"Apps/Andro2UWP/" + oItem.sFileName,
oItem.sMessage // "\n1\n2\n3"
);
bool oResult = false;

try
{
oResult = await p.od.ReplaceOneDriveFileContent
(
"Apps/Andro2UWP/" + oItem.sFileName,
oItem.sMessage // "\n1\n2\n3"
);
}
catch (Exception ex)
{
await AddLogEntry("[ex] ReplaceOneDriveFileContent exception: "+ ex.Message, false);
oResult = false;
}

if (oResult == false)
{
Expand Down Expand Up @@ -1410,6 +1453,19 @@ public override void OnAccessibilityEvent(Android.Views.Accessibility.Accessibil

((App)App.Current).WriteToast(toastek);

//bad case
//MainPage.ListRefresh();
// RnD: Redirect to MainPage from here...
//Frame
Frame rootFrame = Window.Current.Content as Frame;

//
// just ensure that the window is active
if (rootFrame != null)
{
rootFrame.Navigate(typeof(MainPage));//, e.Arguments);
}

}//OnAccessibilityEvent end


Expand Down
2 changes: 1 addition & 1 deletion Andro2UWP/Andro2UWP.Shared/AppLog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<TextBlock FontSize="18" HorizontalAlignment="Center" Text="App log" />
<TextBox Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="uiLog" Margin="5" AcceptsReturn="True" IsReadOnly="true"/> <!-- IsReadOnly="true" -->
<Button Grid.Row="2" HorizontalAlignment="Left" Margin="5" Click="uiReload_Click" x:Uid="uiReload" Content="Reload"/>
<Button Grid.Row="2" HorizontalAlignment="Left" Margin="5" Click="uiReloadLog_Click" x:Uid="uiReload" Content="Reload"/>
<Button Grid.Row="2" HorizontalAlignment="Center" Margin="5" Click="uiOk_Click" x:Uid="uiOk" Content="Ok"/>
<Button Grid.Row="2" HorizontalAlignment="Right" Margin="5" Click="uiClearLog_Click" x:Uid="uiClearLog" Content="Clear"/>
</Grid>
Expand Down
74 changes: 53 additions & 21 deletions Andro2UWP/Andro2UWP.Shared/AppLog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public AppLog()
this.InitializeComponent();
}

//private void ProgresywnyRing(bool sStart)
//private void ProgresywnyRing(bool sActive)
//{
// if (sStart)
// if (sActive)
// {
// double dVal;
// dVal = Math.Min(uiGrid.ActualHeight, uiGrid.ActualWidth) / 2;
Expand All @@ -47,19 +47,24 @@ public AppLog()
//}



// ReloadLogFile
private async void ReloadLogFile()
{
//ProgresywnyRing(true);

p.k.ProgRingShow(true);

var plik = await App.GetLogFile();

if (plik != null)
Windows.Storage.StorageFile file = await App.GetLogFile();

if (file != null)
{
#if !__WASM__
string logText = "ReloadLogFile - TODO";//await plik.ReadAllTextAsync(); // Windows.Storage.FileIO.ReadTextAsync(plik);

// TEMP
string logText = "";
//logText = "ReloadLogFile - TODO";
//logText = await plik.OpenReadAsync();//.ReadAllTextAsync();
logText = await Windows.Storage.FileIO.ReadTextAsync(file);//Windows.Storage.FileIO.ReadTextAsync(plik);


uiLog.Text = logText;
Expand All @@ -70,48 +75,75 @@ private async void ReloadLogFile()

// ProgresywnyRing(false);
p.k.ProgRingShow(false);
}

}//ReloadLogFile end


// uiPage_Loaded
private void uiPage_Loaded(object sender, RoutedEventArgs e)
{
// ?
p.k.ProgRingInit(true, false);

ReloadLogFile();
}

}//uiPage_Loaded end


// uiOk_Click
private void uiOk_Click(object sender, RoutedEventArgs e)
{
Frame.GoBack();
}
}//uiOk_Click end

private void uiReload_Click(object sender, RoutedEventArgs e)
// uiReloadLog_Click
private void uiReloadLog_Click(object sender, RoutedEventArgs e)
{
ReloadLogFile();
}

// uiClearLog_Click
private async void uiClearLog_Click(object sender, RoutedEventArgs e)
{
if(await p.k.DialogBoxResYNAsync("msgSureDeleteLog"))
if (await p.k.DialogBoxResYNAsync("msgSureDeleteLog"))
{

if(await p.k.DialogBoxResYNAsync("msgSendLogEmail"))
if (await p.k.DialogBoxResYNAsync("msgSendLogEmail"))
{
try
{
Windows.ApplicationModel.Email.EmailMessage oMsg = new Windows.ApplicationModel.Email.EmailMessage();
Windows.ApplicationModel.Email.EmailMessage oMsg
= new Windows.ApplicationModel.Email.EmailMessage();

oMsg.Subject = "Log Andro2UWP, " + DateTime.Now.ToString("yyyy.MM.dd HH:mm");
oMsg.Body = uiLog.Text;

await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(oMsg);
}
catch
catch (Exception ex)
{
p.k.DialogBoxRes("msgComposingError");
//RnD: case 1
await p.k.DialogBoxRes("msgComposingError: " + ex.Message);

//RnD: case 2
uiLog.Text = ex.Message;

return;
}
}

var plik = await App.GetLogFile();
if (plik != null) await plik.DeleteAsync();
Windows.Storage.StorageFile file = await App.GetLogFile();

if (file != null)
{
await file.DeleteAsync();
}

uiLog.Text = "";
}
}
}
}

}//uiClearLog_Click end

}//AppLog class end

} //Andro2UWP namespace end
61 changes: 47 additions & 14 deletions Andro2UWP/Andro2UWP.Shared/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
<!-- Android commandbar -->
</Grid.RowDefinitions>

<!-- <ProgressRing Name="uiProcesuje" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed" Grid.RowSpan="4"/>-->
<!-- RnD-->
<ProgressRing Name="uiProcesuje"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Visibility="Collapsed"
Grid.RowSpan="4"/>

<TextBlock Text="Andro2UWP" FontSize="30" HorizontalAlignment="Center"/>
<TextBlock Text="" FontSize="10" HorizontalAlignment="Center" Grid.Row="1" Margin="5" Name="uiVersion"/>
Expand All @@ -39,10 +44,13 @@

<!-- TEMP controls -->
<Button x:Uid="uiTestToast"
Content="Send test toast" Click="uiTestToast_Click"
Content="Send test toast"
HorizontalAlignment="Right"
Name="uiTestToast"
Grid.Row="2" Margin="5"
Name="uiTestToast"/>
Click="uiTestToast_Click"
win:Visibility="Collapsed"
/>

<!-- common controls -->
<!--Button Content="Refresh" x:Uid="uiRefreshList" HorizontalAlignment="Right" Grid.Row="2" Click="uiRefreshList_Click" Name="uiRefreshList" not_win:Visibility="Collapsed" /-->
Expand Down Expand Up @@ -104,35 +112,60 @@
<!--<ProgressBar x:Name="uiProgBar" Grid.Row="3" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Visibility="Collapsed" /> -->
<not_win:Grid Grid.Row="4" Name="uiAndroBottom" Margin="0,10,0,0">
<StackPanel Orientation="Horizontal" >
<AppBarButton Icon="Refresh" x:Uid="uiRefresh" Name="uiRefresh" Label="Refresh list" Click="uiRefreshList_Click"/>
<AppBarButton Icon="Refresh" x:Uid="uiRefresh" Name="uiRefresh"
Label="Refresh list"
Click="uiRefreshList_Click"/>

<AppBarSeparator/>

<!--AppBarButton Icon="Delete" x:Uid="uiClearList" Label="Clear list" Click="uiClearList_Click"/>
<!--AppBarSeparator/-->

<AppBarButton Icon="Delete" x:Uid="uiClearList" Name="uiClearList"
Label="Clear toast list"
Click="uiClearList_Click"/>

<AppBarSeparator/-->
<AppBarSeparator/>

<AppBarButton Icon="Setting" x:Uid="uiSettings" Name="uiSettings"
Label="Settings"
Click="uiSettings_Click"/>

<AppBarButton Icon="Setting" x:Uid="uiSettings" Name="uiSettings" Label="Settings" Click="uiSettings_Click"/>
<AppBarButton Icon="List" x:Uid="uiShowLog" Name="uiShowLog"
Label="Show log"
Click="uiShowLog_Click"/>

<AppBarButton Icon="List" x:Uid="uiShowLog" Name="uiShowLog" Label="Show log" Click="uiShowLog_Click"/>
<AppBarButton Icon="Help" x:Uid="uiAbout" Name="uiAbout"
Label="About"
Click="uiAbout_Click"/>
</StackPanel>

</not_win:Grid>
</Grid>
<Page.BottomAppBar>
<win:CommandBar>
<AppBarButton Icon="Refresh" x:Uid="uiRefresh" Name="uiRefresh" Label="Refresh list" Click="uiRefreshList_Click"/>
<AppBarButton Icon="Refresh" x:Uid="uiRefresh" Name="uiRefresh"
Label="Refresh list"
Click="uiRefreshList_Click"/>

<!--AppBarSeparator/-->

<AppBarToggleButton Icon="Clock" x:Uid="uiAutoRefresh" Name="uiAutoRefresh" Label="Auto refresh" Click="uiAutoRefresh_Click" />
<AppBarToggleButton Icon="Clock" x:Uid="uiAutoRefresh" Name="uiAutoRefresh"
Label="Auto refresh"
Click="uiAutoRefresh_Click" />

<AppBarSeparator/>

<AppBarButton Icon="Setting" x:Uid="uiSettings" Name="uiSettings" Label="Settings" Click="uiSettings_Click"/>
<AppBarButton Icon="Setting" x:Uid="uiSettings" Name="uiSettings"
Label="Settings"
Click="uiSettings_Click"/>

<AppBarButton Icon="List" x:Uid="uiShowLog" Name="uiShowLog" Label="Show log" Click="uiShowLog_Click"/>
<AppBarButton Icon="List" x:Uid="uiShowLog" Name="uiShowLog"
Label="Show log"
Click="uiShowLog_Click"/>

<!--AppBarSeparator/>
<AppBarButton Icon="XboxOneConsole" x:Uid="uiAuth" Label="Auth." Click="uiAuth_Click"/-->
<AppBarButton Icon="Help" x:Uid="uiAbout" Name="uiAbout"
Label="About"
Click="uiAbout_Click"/>
</win:CommandBar>

</Page.BottomAppBar>
Expand Down
Loading

0 comments on commit 4764abb

Please sign in to comment.