12
12
using Windows . UI . Xaml ;
13
13
using Windows . UI . Xaml . Controls ;
14
14
using Windows . UI . Xaml . Navigation ;
15
+ using Microsoft . QueryStringDotNET ;
15
16
16
17
namespace Signal_Windows
17
18
{
@@ -28,6 +29,7 @@ sealed partial class App : Application
28
29
public static bool MainPageActive = false ;
29
30
public static string USER_AGENT = "Signal-Windows" ;
30
31
public static uint PREKEY_BATCH_SIZE = 100 ;
32
+ public static bool WindowActive = false ;
31
33
private Task < SignalStore > Init ;
32
34
33
35
/// <summary>
@@ -60,8 +62,29 @@ public App()
60
62
/// </summary>
61
63
/// <param name="e">Details über Startanforderung und -prozess.</param>
62
64
protected override async void OnLaunched ( LaunchActivatedEventArgs e )
65
+ {
66
+ await OnLaunchedOrActivated ( e ) ;
67
+ }
68
+
69
+ protected override async void OnActivated ( IActivatedEventArgs args )
70
+ {
71
+ await OnLaunchedOrActivated ( args , false ) ;
72
+ }
73
+
74
+ /// <summary>
75
+ ///
76
+ /// </summary>
77
+ /// <param name="e"></param>
78
+ /// <param name="launched">
79
+ /// If OnLaunched this is true
80
+ /// If OnActivated this is false
81
+ /// </param>
82
+ /// <returns></returns>
83
+ private async Task OnLaunchedOrActivated ( IActivatedEventArgs e , bool launched = true )
63
84
{
64
85
Debug . WriteLine ( "Signal-Windows " + LocalFolder . Path . ToString ( ) ) ;
86
+ Window . Current . Activated += Current_Activated ;
87
+ WindowActive = true ;
65
88
Frame rootFrame = Window . Current . Content as Frame ;
66
89
67
90
// App-Initialisierung nicht wiederholen, wenn das Fenster bereits Inhalte enthält.
@@ -82,25 +105,53 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e)
82
105
Window . Current . Content = rootFrame ;
83
106
}
84
107
85
- if ( e . PrelaunchActivated == false )
108
+ if ( launched )
86
109
{
87
- if ( rootFrame . Content == null )
110
+ LaunchActivatedEventArgs args = e as LaunchActivatedEventArgs ;
111
+ if ( args . PrelaunchActivated == false )
88
112
{
89
- // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren
90
- // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter
91
- // übergeben werden
92
- Store = await Init ;
93
- if ( Store == null || ! Store . Registered )
113
+ if ( rootFrame . Content == null )
94
114
{
95
- rootFrame . Navigate ( typeof ( StartPage ) , e . Arguments ) ;
115
+ // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren
116
+ // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter
117
+ // übergeben werden
118
+ Store = await Init ;
119
+ if ( Store == null || ! Store . Registered )
120
+ {
121
+ rootFrame . Navigate ( typeof ( StartPage ) , args . Arguments ) ;
122
+ }
123
+ else
124
+ {
125
+ rootFrame . Navigate ( typeof ( MainPage ) , args . Arguments ) ;
126
+ }
96
127
}
97
- else
128
+ }
129
+ }
130
+ else
131
+ {
132
+ if ( e is ToastNotificationActivatedEventArgs )
133
+ {
134
+ var args = e as ToastNotificationActivatedEventArgs ;
135
+ QueryString queryString = QueryString . Parse ( args . Argument ) ;
136
+ if ( ! ( rootFrame . Content is MainPage ) )
98
137
{
99
- rootFrame . Navigate ( typeof ( MainPage ) , e . Arguments ) ;
138
+ rootFrame . Navigate ( typeof ( MainPage ) , queryString ) ;
100
139
}
101
140
}
102
- // Sicherstellen, dass das aktuelle Fenster aktiv ist
103
- Window . Current . Activate ( ) ;
141
+ }
142
+ // Sicherstellen, dass das aktuelle Fenster aktiv ist
143
+ Window . Current . Activate ( ) ;
144
+ }
145
+
146
+ private void Current_Activated ( object sender , Windows . UI . Core . WindowActivatedEventArgs e )
147
+ {
148
+ if ( e . WindowActivationState == Windows . UI . Core . CoreWindowActivationState . Deactivated )
149
+ {
150
+ WindowActive = false ;
151
+ }
152
+ else
153
+ {
154
+ WindowActive = true ;
104
155
}
105
156
}
106
157
0 commit comments