un positionnement de paramètre workflow des pros
This commit is contained in:
parent
fbd352e788
commit
96746fcc0b
322 changed files with 25893 additions and 3844 deletions
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Android.Accounts;
|
||||
|
||||
namespace BookAStar.Droid.Accounts
|
||||
{
|
||||
class YavscAccountAuthenticator : AbstractAccountAuthenticator
|
||||
{
|
||||
public YavscAccountAuthenticator(Context context): base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Bundle ConfirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Bundle EditProperties(AccountAuthenticatorResponse response, string accountType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Bundle GetAuthToken(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string GetAuthTokenLabel(string authTokenType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Bundle HasFeatures(AccountAuthenticatorResponse response, Account account, string[] features)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Bundle UpdateCredentials(AccountAuthenticatorResponse response, Account account, string authTokenType, Bundle options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;DEV</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
|
||||
|
|
@ -328,6 +328,7 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Accounts\YavscAccountAuthenticator.cs" />
|
||||
<Compile Include="Helpers\Settings.cs" />
|
||||
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
|
||||
<Compile Include="Helpers\YavscHelpers.cs" />
|
||||
|
|
@ -342,11 +343,14 @@
|
|||
<Compile Include="Markdown\MarkdownViewModel.cs" />
|
||||
<Compile Include="Markdown\MarkdownViewRenderer.cs" />
|
||||
<Compile Include="Markdown\MarkdownWebChromeClient.cs" />
|
||||
<Compile Include="Markdown\MDContextMenu.cs" />
|
||||
<Compile Include="Markdown\MDWebView.cs" />
|
||||
<Compile Include="OAuth2\YaOAuth2Authenticator.cs" />
|
||||
<Compile Include="Rendering\ImageButtonRenderer.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SendFilesActivity.cs" />
|
||||
<Compile Include="Services\AccountChooserService.cs" />
|
||||
<Compile Include="Services\YavscChooserTargetService.cs" />
|
||||
<Compile Include="Services\GcmListenerService.cs" />
|
||||
<Compile Include="Services\GcmRegistrationIntentService.cs" />
|
||||
|
|
@ -372,6 +376,9 @@
|
|||
<AndroidResource Include="Resources\layout\EditEstimate.axml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
<AndroidResource Include="Resources\menu\md_menu.axml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\icon.png" />
|
||||
|
|
@ -381,15 +388,17 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Tabbar.axml" />
|
||||
<AndroidResource Include="Resources\layout\Toolbar.axml" />
|
||||
<AndroidResource Include="Resources\layout\Toolbar.axml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
<AndroidResource Include="Resources\values\styles.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Yavsc.Client\Yavsc.Client.csproj">
|
||||
<ProjectReference Include="..\..\YavscLib\YavscLib.csproj">
|
||||
<Project>{67f9d3a8-f71e-4428-913f-c37ae82cdb24}</Project>
|
||||
<Name>Yavsc.Client</Name>
|
||||
<Name>YavscLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\BookAStar\BookAStar.csproj">
|
||||
<Project>{A0815650-0A0A-47B0-8826-771F0E1AD137}</Project>
|
||||
|
|
@ -474,7 +483,9 @@
|
|||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
<AndroidResource Include="Resources\values\dimens.xml" />
|
||||
<AndroidResource Include="Resources\values\strings.xml" />
|
||||
<AndroidResource Include="Resources\values\strings.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
<AndroidResource Include="Resources\drawable\glyphish_07_map_marker.png" />
|
||||
<AndroidResource Include="Resources\drawable\glyphish_13_target.png" />
|
||||
<AndroidResource Include="Resources\drawable\glyphish_74_location.png" />
|
||||
|
|
@ -499,6 +510,14 @@
|
|||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\peer_to_peer.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\xml\authenticator.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\xml\account_preferences.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ namespace BookAStar.Droid
|
|||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
App.ShowBookQuery(
|
||||
await DataManager.Current.BookQueries.Get(queryId));
|
||||
var query = DataManager.Instance.BookQueries.LocalGet(queryId);
|
||||
App.ShowBookQuery(query);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -319,15 +319,16 @@ namespace BookAStar.Droid
|
|||
return manager.FindAccountsForService(Constants.ApplicationName);
|
||||
});
|
||||
}
|
||||
YaOAuth2Authenticator auth = new YaOAuth2Authenticator(
|
||||
clientId: "d9be5e97-c19d-42e4-b444-0e65863b19e1",
|
||||
clientSecret: "blouh",
|
||||
scope: "profile",
|
||||
authorizeUrl: new Uri("http://dev.pschneider.fr/authorize"),
|
||||
redirectUrl: new Uri("http://dev.pschneider.fr/oauth/success"),
|
||||
accessTokenUrl: new Uri("http://dev.pschneider.fr/token"));
|
||||
|
||||
public void AddAccount()
|
||||
{
|
||||
var auth = new YaOAuth2Authenticator(
|
||||
clientId: "d9be5e97-c19d-42e4-b444-0e65863b19e1",
|
||||
clientSecret: "blouh",
|
||||
scope: "profile",
|
||||
authorizeUrl: new Uri(Constants.AuthorizeUrl),
|
||||
redirectUrl: new Uri(Constants.RedirectUrl),
|
||||
accessTokenUrl: new Uri(Constants.AccessTokenUrl));
|
||||
Intent loginIntent = auth.GetUI(this);
|
||||
var accStore = AccountStore.Create(this);
|
||||
auth.Completed += (sender, eventArgs) =>
|
||||
|
|
@ -348,65 +349,48 @@ namespace BookAStar.Droid
|
|||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
||||
// get me
|
||||
// var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, eventArgs.Account);
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, Constants.UserInfoUrl);
|
||||
|
||||
request.Headers.Authorization =
|
||||
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokens.AccessToken);
|
||||
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string userJson = await response.Content.ReadAsStringAsync();
|
||||
JObject jactiveUser = JObject.Parse(userJson);
|
||||
Account acc = eventArgs.Account;
|
||||
|
||||
var uid = jactiveUser["Id"].Value<string>();
|
||||
var username = jactiveUser["UserName"].Value<string>();
|
||||
var roles = jactiveUser["Roles"].Values<string>().ToList();
|
||||
var emails = jactiveUser["EMails"].Values<string>().ToList();
|
||||
|
||||
|
||||
var newuser = new User
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, Constants.UserInfoUrl))
|
||||
{
|
||||
UserName = username,
|
||||
EMails = emails,
|
||||
Roles = roles,
|
||||
Id = uid,
|
||||
YavscTokens = tokens
|
||||
};
|
||||
request.Headers.Authorization =
|
||||
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokens.AccessToken);
|
||||
|
||||
MainSettings.SaveUser(newuser);
|
||||
accStore.Save(acc, Constants.ApplicationName);
|
||||
using (var response = await client.SendAsync(request))
|
||||
{
|
||||
response.EnsureSuccessStatusCode();
|
||||
string userJson = await response.Content.ReadAsStringAsync();
|
||||
JObject jactiveUser = JObject.Parse(userJson);
|
||||
Account acc = eventArgs.Account;
|
||||
|
||||
var uid = jactiveUser["Id"].Value<string>();
|
||||
var username = jactiveUser["UserName"].Value<string>();
|
||||
var roles = jactiveUser["Roles"].Values<string>().ToList();
|
||||
var emails = jactiveUser["EMails"].Values<string>().ToList();
|
||||
var avatar = jactiveUser["Avatar"].Value<string>();
|
||||
var address = jactiveUser["Avatar"].Value<string>();
|
||||
var newuser = new User
|
||||
{
|
||||
UserName = username,
|
||||
EMails = emails,
|
||||
Roles = roles,
|
||||
Id = uid,
|
||||
YavscTokens = tokens,
|
||||
Avatar = avatar,
|
||||
Address = address
|
||||
};
|
||||
|
||||
MainSettings.SaveUser(newuser);
|
||||
accStore.Save(acc, Constants.ApplicationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
auth.Error += Auth_Error;
|
||||
StartActivity(loginIntent);
|
||||
}
|
||||
|
||||
public static void PopulateUserWithAccount(User u, Account a)
|
||||
{
|
||||
u.YavscTokens = new Model.Auth.Account.Tokens
|
||||
{
|
||||
AccessToken =
|
||||
a.Properties["access_token"],
|
||||
RefreshToken =
|
||||
a.Properties["refresh_token"],
|
||||
ExpiresIn =
|
||||
int.Parse(a.Properties["expires_in"]),
|
||||
TokenType = a.Properties["token_type"]
|
||||
};
|
||||
u.UserName = a.Username;
|
||||
}
|
||||
|
||||
private void Auth_Error(object sender, AuthenticatorErrorEventArgs e)
|
||||
{
|
||||
// TODO handle
|
||||
|
|
|
|||
73
BookAStar/BookAStar.Droid/Markdown/MDContextMenu.cs
Normal file
73
BookAStar/BookAStar.Droid/Markdown/MDContextMenu.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Android.Support.V7.App;
|
||||
using XLabs.Ioc;
|
||||
using XLabs.Platform.Mvvm;
|
||||
using XLabs.Forms;
|
||||
using static Android.Views.View;
|
||||
|
||||
namespace BookAStar.Droid.Markdown
|
||||
{
|
||||
class MDContextMenu : AppCompatDialog
|
||||
{
|
||||
private ActionMode mActionMode = null;
|
||||
public MDContextMenu(Context context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
public override void OnActionModeStarted(ActionMode mode)
|
||||
{
|
||||
if (mActionMode == null)
|
||||
{
|
||||
mActionMode = mode;
|
||||
var menu = mode.Menu;
|
||||
// Remove the default menu items (select all, copy, paste, search)
|
||||
menu.Clear();
|
||||
|
||||
// If you want to keep any of the defaults,
|
||||
// remove the items you don't want individually:
|
||||
// menu.removeItem(android.R.id.[id_of_item_to_remove])
|
||||
|
||||
// Inflate your own menu items
|
||||
mode.MenuInflater.Inflate(Resource.Menu.md_menu, menu);
|
||||
|
||||
}
|
||||
mActionMode = mode;
|
||||
base.OnActionModeStarted(mode);
|
||||
}
|
||||
public override void OnActionModeFinished(ActionMode mode)
|
||||
{
|
||||
base.OnActionModeFinished(mode);
|
||||
}
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
}
|
||||
public void OnCreateContextMenu(IContextMenu menu, View v, IContextMenuContextMenuInfo menuInfo)
|
||||
{
|
||||
/* if (menuInfo!=null)
|
||||
{
|
||||
var info = menuInfo.ToString();
|
||||
}
|
||||
menu.Add(0, 0, 0, "test");
|
||||
var subMenu = menu.AddSubMenu(
|
||||
0, 1, 1, "...");
|
||||
subMenu.Add(0, 3, 0, "nkjnkjn");
|
||||
var app = Resolver.Resolve<IXFormsApp>() as IXFormsApp<XFormsCompatApplicationDroid>;
|
||||
|
||||
var mgr = ClipboardManager.FromContext(app.AppContext);
|
||||
if (mgr.HasText)
|
||||
menu.Add(0, 0, 0, "Coller!");*/
|
||||
//base.OnCreateContextMenu(menu, v, menuInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
BookAStar/BookAStar.Droid/Markdown/MDWebView.cs
Normal file
28
BookAStar/BookAStar.Droid/Markdown/MDWebView.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Android.Webkit;
|
||||
|
||||
namespace BookAStar.Droid.Markdown
|
||||
{
|
||||
class MDWebView : WebView
|
||||
{
|
||||
public MDWebView (Context context) : base (context)
|
||||
{
|
||||
}
|
||||
|
||||
public override ActionMode StartActionMode(ActionMode.ICallback callback)
|
||||
{
|
||||
return base.StartActionMode(callback);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorTemplatePreprocessor", "4.2.0.703")]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorTemplatePreprocessor", "4.2.1.62")]
|
||||
public partial class MarkdownEditor : MarkdownEditorBase
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using Android.OS;
|
|||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Android.Graphics;
|
||||
|
||||
namespace BookAStar.Droid.Markdown
|
||||
{
|
||||
|
|
@ -17,6 +18,7 @@ namespace BookAStar.Droid.Markdown
|
|||
protected static MarkdownDeep.Markdown markdown = new MarkdownDeep.Markdown();
|
||||
public string Content { get; set; }
|
||||
public bool Editable { get; set; }
|
||||
|
||||
public string GetHtml()
|
||||
{
|
||||
return markdown.Transform(Content);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ using Android.Views;
|
|||
namespace BookAStar.Droid
|
||||
{
|
||||
using Markdown;
|
||||
using XLabs.Forms;
|
||||
using XLabs.Ioc;
|
||||
using XLabs.Platform.Mvvm;
|
||||
using static View;
|
||||
|
||||
public class MarkdownViewRenderer : ViewRenderer<MarkdownView, WebView>
|
||||
{
|
||||
private WebView editorView;
|
||||
|
|
@ -35,7 +40,9 @@ namespace BookAStar.Droid
|
|||
{
|
||||
if (view == null || xview == null) return;
|
||||
var vch = view.ContentHeight;
|
||||
xview.HeightRequest = vch > xview.MinimumHeightRequest ? vch : xview.MinimumHeightRequest;
|
||||
// var oldH = xview.Height;
|
||||
var newH = vch > xview.MinimumHeightRequest ? vch : xview.MinimumHeightRequest;
|
||||
xview.HeightRequest = newH;
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<MarkdownView> e)
|
||||
|
|
@ -55,10 +62,14 @@ namespace BookAStar.Droid
|
|||
{
|
||||
// Subscribe
|
||||
editorTemplate.Model = new Markdown.MarkdownViewModel
|
||||
{ Content = e.NewElement.Markdown, Editable = e.NewElement.Editable };
|
||||
{
|
||||
Content = e.NewElement.Markdown, Editable = e.NewElement.Editable
|
||||
};
|
||||
var html = editorTemplate.GenerateString();
|
||||
EditorView.LoadDataWithBaseURL("file:///android_asset/",
|
||||
html, "text/html", "utf-8", null);
|
||||
EditorView.SetBackgroundColor(e.NewElement.BackgroundColor.ToAndroid());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +80,7 @@ namespace BookAStar.Droid
|
|||
Control.LoadUrl(string.Format("javascript: {0}", script));
|
||||
}
|
||||
}
|
||||
|
||||
MDContextMenu contextMenu;
|
||||
private WebView CreateNativeControl()
|
||||
{
|
||||
editorView = new WebView(Context);
|
||||
|
|
@ -89,9 +100,18 @@ namespace BookAStar.Droid
|
|||
EditorView.Settings.DomStorageEnabled = true;
|
||||
EditorView.AddJavascriptInterface(new JsBridgeMarkdown(this), "jsBridge");
|
||||
EditorView.ViewTreeObserver.PreDraw += ViewTreeObserver_PreDraw;
|
||||
//var app = Resolver.Resolve<IXFormsApp>() as IXFormsApp<XFormsCompatApplicationDroid>;
|
||||
//contextMenu = new MDContextMenu(app.AppContext);
|
||||
//EditorView.SetOnCreateContextMenuListener(contextMenu);
|
||||
|
||||
return EditorView;
|
||||
}
|
||||
|
||||
private void EditorView_Touch(object sender, TouchEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ViewTreeObserver_PreDraw(object sender, ViewTreeObserver.PreDrawEventArgs e)
|
||||
{
|
||||
AdjustHeightRequest(Element, Control);
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ public class YaOAuth2Authenticator : WebRedirectAuthenticator
|
|||
var query = queryValues.FormEncode();
|
||||
|
||||
var req = WebRequest.Create(accessTokenUrl);
|
||||
// (req as HttpWebRequest).Accept = "application/json";
|
||||
(req as HttpWebRequest).Accept = "application/json";
|
||||
req.Method = "POST";
|
||||
var body = Encoding.UTF8.GetBytes(query);
|
||||
req.ContentLength = body.Length;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@
|
|||
<action android:name="android.service.chooser.ChooserTargetService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name="fr.pschneider.bas.AccountChooserService">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator" />
|
||||
</service>
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAVE_LOCK" />
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ namespace BookAStar.Rendering
|
|||
var uriImageLoader = imagesource as UriImageSource;
|
||||
if (uriImageLoader != null && uriImageLoader.Uri != null)
|
||||
{
|
||||
using (var client = UserHelpers.CreateClient())
|
||||
using (var client = UserHelpers.CreateJsonClient())
|
||||
{
|
||||
using (var response = await client.GetAsync(uriImageLoader.Uri))
|
||||
{
|
||||
|
|
|
|||
3864
BookAStar/BookAStar.Droid/Resources/Resource.Designer.cs
generated
3864
BookAStar/BookAStar.Droid/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
|
@ -8,4 +8,4 @@
|
|||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabGravity="fill"
|
||||
app:tabMode="fixed" />
|
||||
app:tabMode="fixed" />
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
android:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
|
||||
tools:context=".MainActivity"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
/>
|
||||
33
BookAStar/BookAStar.Droid/Resources/menu/md_menu.axml
Normal file
33
BookAStar/BookAStar.Droid/Resources/menu/md_menu.axml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/copy"
|
||||
android:title="@string/copy"/>
|
||||
<group android:id="@+id/group">
|
||||
<item android:id="@+id/past"
|
||||
android:title="@string/past"
|
||||
android:showAsAction="ifRoom|withText"/>
|
||||
</group>
|
||||
<item android:id="@+id/submenu_character"
|
||||
android:title="@string/character" >
|
||||
<menu>
|
||||
<item android:id="@+id/bold"
|
||||
android:title="@string/bold" />
|
||||
<item android:id="@+id/italic"
|
||||
android:title="@string/italic" />
|
||||
<item android:id="@+id/underline"
|
||||
android:title="@string/underline" />
|
||||
</menu>
|
||||
</item>
|
||||
<item android:id="@+id/submenu_paragraph"
|
||||
android:title="@string/paragraph" >
|
||||
<menu>
|
||||
|
||||
<item android:id="@+id/header1"
|
||||
android:onClick="onGroupItemClick"
|
||||
android:title="@string/header1" />
|
||||
<item android:id="@+id/header2"
|
||||
android:onClick="onGroupItemClick"
|
||||
android:title="@string/header2" />
|
||||
</menu>
|
||||
</item>
|
||||
</menu>
|
||||
|
|
@ -14,5 +14,25 @@
|
|||
<string name="url">url</string>
|
||||
<string name="url_hint">url_hint</string>
|
||||
<string name="picture">picture</string>
|
||||
<string name="google_app_id">325408689282</string>
|
||||
<string name="google_app_id">325408689282</string>
|
||||
<string name="pref_screen_title">Comptes Booking Star</string>
|
||||
<string name="account_authenticator_label">Comptes Booking Star</string>
|
||||
|
||||
<string name="copy">Copier</string>
|
||||
<string name="past">Coller</string>
|
||||
|
||||
<string name="character">Caractère</string>
|
||||
<string name="bold">Gras</string>
|
||||
<string name="italic">Italique</string>
|
||||
<string name="underline">Sousligné</string>
|
||||
|
||||
<string name="paragraph">Paragraphe</string>
|
||||
<string name="header1">Titre</string>
|
||||
<string name="header2">Sous-titre</string>
|
||||
|
||||
|
||||
<string name="accounts">Comptes</string>
|
||||
<string name="bookingstar_accounts_pref_screen_summary">
|
||||
Préférences des comptes Booking Star
|
||||
</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/accounts" />
|
||||
<PreferenceScreen
|
||||
android:key="bookingstar_accounts_pref_screen"
|
||||
android:title="@string/pref_screen_title"
|
||||
android:summary="@string/bookingstar_accounts_pref_screen_summary">
|
||||
<intent
|
||||
android:action="bookingstar_accounts_pref_screen.ACTION"
|
||||
android:targetPackage="bookingstar_accounts_pref_screen.package"
|
||||
android:targetClass="bookingstar_accounts_pref_screen.class" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:accountType="typeOfAuthenticator"
|
||||
android:icon="@drawable/icon"
|
||||
android:smallIcon="@drawable/icon"
|
||||
android:label="@string/account_authenticator_label"
|
||||
android:accountPreferences="@xml/account_preferences"
|
||||
/>
|
||||
41
BookAStar/BookAStar.Droid/Services/AccountChooserService.cs
Normal file
41
BookAStar/BookAStar.Droid/Services/AccountChooserService.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using BookAStar.Droid.OAuth;
|
||||
|
||||
namespace BookAStar.Droid.Services
|
||||
{
|
||||
[Service(
|
||||
Name = "fr.pschneider.bas.AccountChooserService",
|
||||
Label = "Yavsc accounts service",
|
||||
Icon = "@drawable/icon",
|
||||
Exported = true,
|
||||
Enabled = true
|
||||
)]
|
||||
[IntentFilter(new String[] { "android.accounts.AccountAuthenticator" })]
|
||||
|
||||
class AccountChooserService : Service
|
||||
{
|
||||
public static YaOAuth2Authenticator authenticator;
|
||||
public override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override IBinder OnBind(Intent intent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,9 @@ namespace BookAStar.Droid.Services
|
|||
using Model.Social;
|
||||
using Newtonsoft.Json;
|
||||
using Model;
|
||||
using Model.Social;
|
||||
using Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace ClientApp
|
||||
{
|
||||
|
|
@ -44,18 +47,27 @@ namespace BookAStar.Droid.Services
|
|||
if (topic == "BookQuery")
|
||||
{
|
||||
DateTime eventdate;
|
||||
|
||||
var sdatestr = data.GetString("EventDate");
|
||||
DateTime.TryParse(sdatestr, out eventdate);
|
||||
|
||||
var locationJson = data.GetString("Location");
|
||||
var location = JsonConvert.DeserializeObject<Location>(locationJson);
|
||||
var cid = long.Parse(data.GetString("Id"));
|
||||
var bq = new BookQueryData
|
||||
var clientJson = data.GetString("Client");
|
||||
var client = JsonConvert.DeserializeObject<ClientProviderInfo>(clientJson);
|
||||
var bq = new BookQuery
|
||||
{
|
||||
Id = cid,
|
||||
Location = location
|
||||
Location = location,
|
||||
Client = client,
|
||||
Reason = data.GetString("Reason")
|
||||
};
|
||||
var dateString = data.GetString("EventDate");
|
||||
DateTime evDate;
|
||||
if (DateTime.TryParse(dateString, out evDate))
|
||||
{
|
||||
bq.EventDate = evDate;
|
||||
}
|
||||
|
||||
SendBookQueryNotification(bq);
|
||||
}
|
||||
|
|
@ -82,14 +94,17 @@ namespace BookAStar.Droid.Services
|
|||
notificationManager.Notify(0, notificationBuilder.Build());
|
||||
}
|
||||
|
||||
void SendBookQueryNotification(BookQueryData bquery)
|
||||
void SendBookQueryNotification(BookQuery bquery)
|
||||
{
|
||||
var bookquerynotifications = MainSettings.AddBookQueryNotification(bquery);
|
||||
DataManager.Instance.BookQueries.Merge(bquery);
|
||||
var bookquerynotifications = DataManager.Instance.BookQueries.Where(
|
||||
q=> ! q.Read && q.EventDate > DateTime.Now
|
||||
).ToArray();
|
||||
var count = bookquerynotifications.Length;
|
||||
var multiple = count > 1;
|
||||
var title =
|
||||
multiple ? $"{count} demandes" : bquery.Client.UserName;
|
||||
var message = $"{bquery.EventDate} {bquery.Client.UserName} {bquery.Location.Address}";
|
||||
var message = $"{bquery.EventDate} {bquery.Client.UserName} {bquery.Location.Address}\n {bquery.Reason}";
|
||||
|
||||
var intent = new Intent(this, typeof(MainActivity));
|
||||
intent.AddFlags(ActivityFlags.ClearTop);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using Android.Widget;
|
|||
|
||||
namespace BookAStar.Droid
|
||||
{
|
||||
|
||||
[Service]
|
||||
public class MyGcmIntentService : IntentService
|
||||
{
|
||||
|
|
@ -31,6 +30,7 @@ namespace BookAStar.Droid
|
|||
intent.SetClass(context, typeof(MyGcmIntentService));
|
||||
context.StartService(intent);
|
||||
}
|
||||
|
||||
static object locker = new object();
|
||||
|
||||
protected override void OnHandleIntent(Intent intent)
|
||||
|
|
@ -74,16 +74,28 @@ namespace BookAStar.Droid
|
|||
|
||||
void SendNotification (string message)
|
||||
{
|
||||
var intent = new Intent (this, typeof(MainActivity));
|
||||
/* Bundle valuesForActivity = new Bundle();
|
||||
valuesForActivity.PutInt("count", count); */
|
||||
|
||||
var intent = new Intent (this, typeof(MainActivity));
|
||||
intent.AddFlags (ActivityFlags.ClearTop);
|
||||
var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);
|
||||
// Construct a back stack for cross-task navigation:
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
|
||||
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
|
||||
stackBuilder.AddNextIntent(intent);
|
||||
|
||||
var notificationBuilder = new Notification.Builder(this)
|
||||
// Create the PendingIntent with the back stack:
|
||||
PendingIntent resultPendingIntent =
|
||||
stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent);
|
||||
|
||||
var notificationBuilder = new Notification.Builder(this)
|
||||
.SetAutoCancel(true)
|
||||
.SetSmallIcon (Resource.Drawable.icon)
|
||||
.SetContentTitle ("GCM Message")
|
||||
.SetContentText (message)
|
||||
.SetAutoCancel (true)
|
||||
.SetContentIntent (pendingIntent);
|
||||
.SetContentIntent(resultPendingIntent) // Start 2nd activity when the intent is clicked.
|
||||
;
|
||||
|
||||
var notificationManager = (NotificationManager) GetSystemService(Context.NotificationService);
|
||||
notificationManager.Notify (0, notificationBuilder.Build());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue