1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2026-02-06 08:33:43 +00:00

Test search

This commit is contained in:
Yan Maniez 2019-09-30 16:27:29 +02:00
parent 08135c06eb
commit ad9344567c
5 changed files with 94 additions and 2 deletions

View file

@ -11,8 +11,9 @@ using System.Diagnostics;
namespace AideDeJeu.Droid
{
[IntentFilter(new[] { Android.Content.Intent.ActionAssist }, Categories = new[] { Android.Content.Intent.CategoryDefault })]
//[Activity(Label = "Aide de Jeu", Icon = "@drawable/black_book", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Label = "Beta Haches & Dés", Icon = "@drawable/battle_axe", Theme = "@style/MyTheme.Splash", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Name = "com.nioux.aidedejeu.MainActivity", Label = "Beta Haches & Dés", Icon = "@drawable/battle_axe", Theme = "@style/MyTheme.Splash", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
@ -22,6 +23,9 @@ namespace AideDeJeu.Droid
base.OnCreate(bundle);
// Application Level Assistance
//Application.RegisterOnProvideAssistDataListener(new AndroidListener());
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
@ -38,9 +42,37 @@ namespace AideDeJeu.Droid
DisplayCrashReport();
//// Verify the action and get the query
//if (Android.Content.Intent.ActionSearch == Intent.Action)
//{
// var query = Intent.GetStringExtra(SearchManager.Query);
//}
LoadApplication(new App());
}
protected override void OnNewIntent(Android.Content.Intent intent)
{
base.OnNewIntent(intent);
Intent = intent;
}
protected override void OnPostResume()
{
base.OnPostResume();
if (Intent.Extras != null)
{
string search = Intent.Extras.GetString("search");
if (!string.IsNullOrEmpty(search))
{
Xamarin.Forms.Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(search));
}
Intent.RemoveExtra("search");
}
}
public override void OnBackPressed()
{
if (Rg.Plugins.Popup.Popup.SendBackPressed(base.OnBackPressed))
@ -126,5 +158,41 @@ namespace AideDeJeu.Droid
}
}
[IntentFilter(new[] { Android.Content.Intent.ActionAssist }, Categories = new[] { Android.Content.Intent.CategoryDefault })]
//[Activity(Label = "Aide de Jeu", Icon = "@drawable/black_book", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Name = "com.nioux.aidedejeu.SearchActivity")]
public class SearchActivity : Android.App.Activity // global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Application Level Assistance
//Application.RegisterOnProvideAssistDataListener(new AndroidListener());
// Android.Content.Intent.ActionSearch.Equals
// Verify the action and get the query
if ("com.google.android.gms.actions.SEARCH_ACTION".Equals(Intent.Action))
{
var query = Intent.GetStringExtra(SearchManager.Query);
System.Diagnostics.Debug.WriteLine(query);
var intent = new Android.Content.Intent(Android.App.Application.Context, typeof(MainActivity));
intent.AddFlags(Android.Content.ActivityFlags.NewTask);
intent.PutExtra("search", query);
intent.AddFlags(Android.Content.ActivityFlags.ReorderToFront);
Android.App.Application.Context.StartActivity(intent);
}
this.FinishActivity(0);
}
}
public class AndroidListener : Java.Lang.Object, Application.IOnProvideAssistDataListener
{
public void OnProvideAssistData(Android.App.Activity activity, Bundle data)
{
System.Diagnostics.Debug.WriteLine("OnProvideAssistData");
}
}
}

View file

@ -5,5 +5,11 @@
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.nioux.aidedejeu.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>
<activity android:name=".SearchActivity">
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -0,0 +1,2 @@
"C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" shell am start -a com.google.android.gms.actions.SEARCH_ACTION -e query "barde" com.nioux.aidedejeu
pause