How can I access a Google Home devices screen dimensions? - actions-on-google

I am trying to add image views for my Google action, however the images I have supplied do not always fit the screen. I noticed that the image reference says I can supply a height and width in pixels - however I need to know what their screen dimensions are to make it fit! Is there a way I can access this?
Here is my current implementation:
'use strict';
const { dialogflow } = require("actions-on-google");
const functions = require("firebase-functions");
const app = dialogflow();
app.intent('Default Welcome Intent', (conv) => {
conv.ask("testing....");
conv.ask(
new Image({
url: 'https://myurl.com/someimage.jpg',
alt: 'some image',
// width: NEED THIS VALUE
// height: NEED THIS VALUE
})
);
conv.ask("bla bla bla. ");
});
exports.yourAction = functions.https.onRequest(app);

There is currently no way of getting the screen dimensions for the device.
You can set the image to a reasonable size through device testing then use ImageDisplayOptions to adjust the behavior of the image resizing for different screen sizes.

Related

H3 - Show hexagons all over India

I am trying to show the hexagons all over the world, (at least all over India) using H3 on my Leaflet map.
I have tried the below logic but it doesn't work:
Logic:
const boundingBoxIndia = [
[38.11727165830543, 76.37695312500001],
[23.785344805941214, 67.41210937500001],
[6.293458760393985, 77.16796875000001],
[28.51696944040106, 98.525390625],
];
const cellIdsInIndia = h3.polyfill(boundingBoxIndia, 13, true);
const hexagonsInIndia = [];
const hexagonInIndia = cellIdsInIndia?.map((cellId, i) => {
const polygon = h3.h3ToGeoBoundary(cellId, false);
return [polygon];
});
hexagonsInIndia.push(hexagonInIndia);
In render:
<IndiaCells cellGroups={hexagonsInIndia} />
Component
const IndiaCells = (props) => {
if (props.cellGroups?.length) {
return props.cellGroups.map((cells, index) => {
return cells.map(([polygon], groupIndex) => {
return (
<div key={groupIndex}>
<Polygon
positions={polygon}
pathOptions={{...}}
></Polygon>
</div>
);
});
});
} else {
return null;
}
};
I am able to render other hexagons for a smaller sample by the same logic. Also the above code takes a lot of time to load the map but hexagons aren't visible. Looks like size might be an issue here.
Is there any better way to show the H3 hexagon grids all over the map? Something like this:
I think you simply have too many H3 cells for the map to handle. Using your bounding box above, h3.polyfill(boundingBoxIndia, 8, true) yields over 1.5M cells - at resolution 13, you're looking at that number times 7^5, or roughly 25.4 billion cells. I'm guessing that you don't see any cells because the polyfill operation runs out of memory, though I'm somewhat surprised that the page doesn't hang completely.
In general, if you want to render cell boundaries at some fine grain, you need to render only the current viewport (and stop rendering when the expected count gets too high, e.g. when you zoom out). See this h3-viewer project for an example of per-viewport rendering using Leaflet.

Ionic Capacitor camera how to reduce image size before uploading

I have set the Capacitor camera plugin with the following options
const image = await Camera.getPhoto({
quality: 20,
width : 200,
height : 200,
allowEditing: false,
source: CameraSource.Camera,
resultType: CameraResultType.Base64
});
After that I take the base64 and upload it to the server. However I am getting images in the 2-5MB range of size (Android). Is there any way of reducing/compressing the size further?
Already checked this and other similar postings but they seem to adjust the size by reducing the quality param and the width and height (which are already low in my case)

How Should i add camera plugin with image suggestions like below image in ionic 3

I added ionic native camera plugin it's working fine.
But i want the camera plugin like whatsapp. because i want to show gallery image suggestion in camera plugin below section it self
Check above image fro reference.
As there is no native plugin for your requirements and also what you are looking is custom things which you need to write above Native plugin.
But as many developer have this kind of requirements.
Please find below Github link for Customized camera.
Link : https://github.com/rossmartin/cordova-plugin-instagram-assets-picker
Sample Code to use plugin method for Gallery:
InstagramAssetsPicker.getMedia(
function(result) { // success cb
console.log('getMedia success, result: ', JSON.stringify(result, null, 2));
// result will be an object with at least a phAssetId, filePath, and type property
// you will only get the rect object when 'cropAfterSelect' is false
// the rect object is required for the cropAsset function documented below
/* example of result when the 'cropAfterSelect' option is set to false
{
phAssetId: "A1785F1A-EF0F-458C-9AF9-C439981CE0FB/L0/001",
type: "video",
rect: {
Width: 0.5625000293366611,
Height: 0.9999999823048711,
Y: 0,
X: 0.2496093880181434
},
filePath: "file:///Users/rossmartin/Library/Developer/CoreSimulator/Devices/6465544C-C262-4EA8-BA7C-8BAB4AB98597/data/Media/DCIM/100APPLE/IMG_0006.m4v"
}
*/
},
function(err) { // error cb
console.log('getMedia error, err: ', err);
},
{ // options
type: 'video', // accepts 'photo', 'video', or 'all' - defaults to all
cropAfterSelect: false, // see the note above for when this is false - defaults to false
showGrid: false // determines whether to show the grid for cropping - defaults to false
}
);
You can use it directly or take fork edit as per your requirements.
Hope this will helps.

Sencha Fullscreen Panel that detects Home Screen Bookmark?

When using Sencha Touch to create a panel - you can tell the panel to enable a fullscreen property. THe panel will fill the space available by the device.
It seems to have a bug or not deal with a bookmark that has been saved to the home screen - and floats underneath the status bar at the top.
Is there a property or setting to manage this behaviour OR are am I going to have to program the logic to determine how much padding is required dependent on device and orientation ?
Example below will fit nicely in mobile Safari, but if you save to Home Screen and load it up - the Toolbar sits underneath the Status Bar.
var buttons = [
{text: 'Button'},
{xtype: 'spacer'},
{text: 'Blue', ui: 'action'},
];
var toolbar1 = new Ext.Toolbar({
dock: 'top',
title: 'Panel',
items: buttons
});
var windowHeight = Ext.Element.getViewportHeight();
var windowWidth = Ext.Element.getViewportWidth();
var homePage = new Ext.Panel ({
fullscreen: true,
cls: 'homePage',
dockedItems: [toolbar1],
layout: 'fit',
html: '<h2>Testing Ext.js Panel</h2><p>Height:' + windowHeight +'</p><p> Width:' + windowWidth +'</p>',
animation: 'slide'
});
Thanks in advance.
Hi Ket — This is actually the default behavior... The status bar is always visible, even in a fullscreen web app. There are three tips you may find useful:
You can use a translucent statusbar, which is still there but will overlay your content. To do this, in Ext.setup(), you can use "statusBarStyle: 'black-translucent'"
"window.navigator.standalone" will detect whether you're in fullscreen mode or not.
Instead of measuring window width/height, you could break your H2 and P into separate components, and give the P area a layout of 'fit'
Hope that helps-

Appcelerator - Newbie in the mix!

Quick one for any developers using appcelerator out there. I have two labels (This may even bew wrong) which are populated from an RSS feed. One label houses the title and another the description. The content for these comes from an RSS list which all works fine. THe issue I'm having is that some titles are longer than others so I cant fix label heights or it just wont work.
So with that in mind I set the titles height to be auto. The only problem is I cant reference this height from my second label to use the top: property to space it correctly.
Has anyone got any good suggestions?, Am I using the wrong type of Titanium UI method?
My current code is as follows
try
{
var current = Titanium.UI.currentWindow;
var selectedItem = current.item;
var description = selectedItem.getElementsByTagName("description");
var story = description.item(0).text;
var label = Ti.UI.createLabel({
text:selectedItem.getElementsByTagName("title").item(0).text,
left:5,
top:0,
height:"auto",
font:{fontSize:40}
});
current.add(label);
var story = Ti.UI.createLabel({
text:story,
left:5,
top:label.height,
height:"auto"
});
label.add(story);
}
catch(E)
{
alert(E)
}
minimumFontSize
the minimum size of the font when the font is sized based on the contents. Enables font scaling to fit and forces the label content to be limited to a single line
On the containing window / view, set the layout property to 'vertical' - this means the views are stacked on top of one another so your top value doesn't have to know the height of the previous component.
// Windows
var window = Ti.UI.createWindow({
layout: 'vertical',
backgroundColor: '#FFF'
});
var label = Ti.UI.createLabel({
width: 200,
height: 'auto',
text: 'some long text'
});
var label2 = Ti.UI.createLabel({
width: 200,
height: 'auto',
text: 'more long text',
top: 10 // This just adds some padding between the two labels
});
window.add(label);
window.add(label2);
window.open();