How does Jetpack Glance widget works without XML? How does it convert to RemoteViews? - android-layout

Jetpack released a tool called "Glance" that we can replace RemoteViews XML widgets.
I wonder how it converts compose layouts to RemoteViews.

It does use XML underneath. It uses compose runtime to parse the node-tree, then it takes the corresponding pre-generated XML file and uses remoteviews to modify it's attributes. Then it composes everything into a single RemoteView that is sent to the AppWidget manager.
You can dive in into the code yourself. It's open source ;)
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:glance

Related

Selectpdf html to pdf conversion - svg patterntransform rotate attribute not working

I'm using selectPDF html to pdf converter to convert an svg document to pdf. I'm using the webkitRestricted browser engine to ensure it runs correctly on azure. Generally speaking, everything is working correctly, including using pattern definitions. I recently added the use of the patternTransform attribute with the rotate option. This does not appear to be recognized by the webkitrestricted engine and is not working. If i take the underlying html into either firefox or chrome latest versions, the patternTransform attribute does function correctly. Is there a way to overcome this issue using selectpdf ? I'm not clear which version of webkit is being called by selectpdf and whether i can control this in any fashion ?

Recognised file types for image preview?

Is it possible to add additional file types to be recognised as images and thus trigger automatic creation of an image view when a resource is uploaded?
SVG files will preview in CKAN, but we have to manually add the image view e.g.
https://datastore.landcareresearch.co.nz/dataset/novel-yeasts-from-new-zealand-forests/resource/3812ee6b-dd45-45c9-b425-6a18375e5727
With text (for example) we can specify file format extensions to recognise as text and automatically create a text preview (ckan.preview.text_formats...). Is there an equivalent for images?
Thanks
It would only be possible by modifying the source code for your instance:
https://github.com/ckan/ckan/blob/master/ckanext/imageview/plugin.py#L9
Seems like a great idea to have the image view on a par with the text view in this regard, so I made a pull request:
https://github.com/ckan/ckan/pull/3380

How to print a pdf file from windows store application

I am creating a windows 8 app in c# and xaml.
How can i print a pdf file on my system from this app without launching the pdf reader of windows.
If a commercial library is an option, you could try Amyuni PDF Creator for WinRT.
From the documentation, the code for printing a PDF file in C# using this library would look like this:
// Printing on a XAML Windows Store Application
// The field AmyuniPDFCreator.PDFCreator m_pdfCreator; contains an instance of the PDFCreator control
TypedEventHandler<PrintManager, PrintTaskRequestedEventArgs> m_printTaskRequestedEventToken;
// Registering the Application View for printing
void RegisterForPrinting()
{
// Request a PrintManager instance
PrintManager printMan = PrintManager.GetForCurrentView();
// Add a handler for printing events.
m_printTaskRequestedEventToken = printMan.PrintTaskRequested += m_pdfCreator.Document.PrintTaskRequestedEventHandler;
}
// Unregistering the Application View for printing
void UnregisterForPrinting()
{
// Remove the handler for printing events.
PrintManager printMan = PrintManager.GetForCurrentView();
printMan.PrintTaskRequested -= m_printTaskRequestedEventToken;
}
More details about the library can be found here.
Disclaimer: I currently work as a developer of the library
It is possible to achieve this without any third party library if you want to print it with a device.
This isn't working to create or write a ".pdf"[Pdf File). To make this happen without another library you could maybe try to write images directly into a pdf, but i can only reference here the Pdf Documentation.
First of all you have to render your pdf. You can do this with Windows.Data.Pdf.
You can take a look at an example here. The libary will handle the Pdf and you get some BitmapImages rendered.
This library can read, but not write ".pdf"
Now you have to print your Images(rendered pdf pages). For this you take the Windows.Graphics.Printing.PrintManager.
I would not recommend the msdn example in this case.
So have a first look at Windows Store Apps and XAML Based Printing.
And you will find another printing example with MVVM here: Printing from MVVM XAML Windows 8 Store apps.
If you just follow the examples you will achieve to print a pdf on paper some trouble.
How to add custom settings for your printer is explained at How to add custom settings to the print preview UI (XAML)!
Windows 8 doesn't have an API to do this, so you'll have to acquire one elsewhere - something that's capable of properly rendering a PDF for you, and that's going to mean a full-blown PDF API with all the bells and whistles (I'm not aware of any of these for Windows 8 that only supports printing).
If only PDF Sharp had a WinRT version, I'd recommend it in a heartbeat... unfortunately it doesn't (yet). Only ones I know of that have an API for WinRT are Foxit and Siberix Report Writer.

Inserting a news-feed widget to a page

I have a page I'd like to embed a news-feed widget into (so that the feed from some remote site will be displayed in my site).
While there are quite a few free news-feed widgets available out there (a partial list is here: http://allwebco-templates.com/support/S_script_newsfeed.htm), They all require insertion of complex code into the html page, while all the parameters are hard-coded into the generated code, which looks something like this:
insertedWidgetText = "<script id=\"scrnewsblock10795953\" type=\"text/javascript\">...script specific parameters go here...</script>"
let feedWidget = toWidgetBody [hamlet|#{preEscapedText insertedWidgetText}|]
This doesn't integrate well with Yesod's approach as it requires specifying to Hamlet that the content is preEscapedText, which in turn disables the ability to use Hamlet's processing to alter parameters of the widget dynamically (So in case I want the widget to use a different source, for example, I need to statically change the quoted text and cannot use Hamlet's variable substitution).
Of course I could do some text manipulation myself, tailor built for the widget I'm using, but that doesn't seem like the "right" solution (especially if I want to have the embedded text in some external file and not in the middle of my code as in the example above).
Can the above mentioned issue have a better solution than the one I thought about?
Is there an implementation of a news-feed widget in Haskell/Yesod that I can use as a plugin?
Note: I'm a very poor javascript programmer, but solutions in that direction are also welcomed.
Thanks,

How to generate and handle dynamic layouts and symbols in JSF/Richfaces?

My objective is to generate a graphic layout (made of Richfaces components) based on some input configuration (like an XML file) and display it in my web app. The layout is composed of graphic symbols representing various entities in the system: each symbol should be mapped to an entity in the system, in order to display its state. The XML configuration file is used to define the symbol connections and positions within the layout, and their mapping rules to an entity. How can I achieve this?
I was thinking to create a symbol library in a technology such as SVG, where you can define both the aspect and the behaviour, and then simply "wrap" each SVG symbol in a dynamically created richfaces component, which would allow me to handle both the user interactions and the mapping rules defined in the symbol. Unfortunately JSF/Richfaces don't support SVG images, therefore I would have to use plain HTML without Richfaces features.
Another way to achieve that would be to simply define generic symbols in the XML file, each one of them with an attribute specifying the related image, the mapping rule, etc., and then generate the corresponding richfaces component from within the web-app. By doing so, would I be able to then display all the symbols in the right position and therefore generate the complete dynamic layout?
Could you suggest a better approach? Thank you very much.
I believe that HTML5 has direct support for SVG images, however it is still an embedded object in regular HTML after all. This too is something I have been waiting for however I don't believe any of the current JSF2 component libraries have an offerring for this yet.
Here is a good explanation of a possible workaround:
Getting started with SVG graphics objects in JSF 2.0 pages
Potentially you could build a custom facelet component utilizing this workaround?
My thought though is that when your only tool is a hammer, everything looks like a nail. I would try to utilize an RIA (Rich Internet Application) technology better suited for display and manipulation of vector graphics like HTML5, Flash+Flex, Silverlight, etc..

Resources