mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Test search
This commit is contained in:
parent
08135c06eb
commit
ad9344567c
5 changed files with 94 additions and 2 deletions
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
2
AideDeJeu/AideDeJeu.Android/testsearch.bat
Normal file
2
AideDeJeu/AideDeJeu.Android/testsearch.bat
Normal 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
|
||||
|
|
@ -16,7 +16,7 @@ namespace AideDeJeu
|
|||
public partial class App : Application
|
||||
{
|
||||
|
||||
public App ()
|
||||
public App (string search = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
|
@ -38,6 +38,10 @@ namespace AideDeJeu
|
|||
Routing.RegisterRoute("item", typeof(Views.Library.ItemPage));
|
||||
//MainPage = mainNavigationPage;
|
||||
//mainNavigationPage.Navigation.PushAsync(new MainPage());
|
||||
if (search != null)
|
||||
{
|
||||
Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,18 @@ namespace AideDeJeu.Views.Library
|
|||
BindingContext = new DeepSearchViewModel();
|
||||
}
|
||||
|
||||
public DeepSearchPage(string search = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = new DeepSearchViewModel();
|
||||
|
||||
if (search != null)
|
||||
{
|
||||
(BindingContext as DeepSearchViewModel).ExecuteSearchCommandAsync(search);
|
||||
}
|
||||
}
|
||||
|
||||
private async void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e)
|
||||
{
|
||||
var searchedItem = e.Item as SearchedItem;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue