Android/iOS keyboard: stickers API - android

I was searching for a way to create a custom keyboard to add custom emoji and stickers.
So far I've figured out that emoji are just unicode characters and in order to add custom emoji one should supply a custom font with the dedicated emoji mapped to a predefined unicode character inside the font. This font should be available across users of the app in order for the custom emoji to display correctly.
The question arises when it comes to stickers (those big images available to add for example in Facebook comments). I can't find any useful information on how they work and what is the interface to embed them in the custom keyboard and to paste further to a text. There are apps available on Google Play and AppStore that does it (like "Go Keyboard" app for example)
Can anyone point me in the right direction?
So the question is:
How to embed stickers into a text to share further to 3rd-party apps? My main idea is to understand if there is a common standard or API for stickers (like for emoji)? Or the only way to use stickers is to use/build a custom chat API with a backend server which means only apps that use the same service will reliably decode the shared text to display stickers correctly?

I've been working in an iOS project to prove this concept of using emojis and stickers in chat conversations.
You can check it out in my GitHub repository and contribute if you want (review and improvement are welcome).
What I done was, use the NSTextAttachment to attach an image within an UITextView, using the NSAttributedString object type.
To show a image as an emoji, within in an UITextView:
// initialize object with the content of textView
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithAttributedString:textview.attributedText];
// initialize selected image to be used as emoji
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = [UIImage imageNamed:#"MicheyMouse"];
textAttachment.image = [UIImage imageWithCGImage:textAttachment.image.CGImage scale:25 orientation:UIImageOrientationUp];
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
[attributeString appendAttributedString:attrStringWithImage];
// blank space after the image
NSAttributedString *blank = [[NSAttributedString alloc] initWithString:#" "];
[attributeString appendAttributedString:blank];
textview.attributedText = attributeString;
And if you wanna use the image as a sticker, follow this lines:
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = [UIImage imageNamed:sticker];
textAttachment.image = [UIImage imageWithCGImage:textAttachment.image.CGImage scale:12 orientation:UIImageOrientationUp]; // --> change de scale, to change image size (or create the image in size that you want)
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
cell.textLabel.attributedText = attrStringWithImage
In this example, I attached the image as a sticker directly in a cell (you can do this cell as a chat ballon).
In other words, in the first code lines, I basically showed the image in an UITextView, and in the second I put the image directly in chat lines.
I had to do my own sticker/emoji keyboard and I also made some work to handle the switching between emoji keyboard and typing keyboard.
This is the GitHub repository for the project example: https://github.com/cairano/CIStickerFacilities

Related

Android mapbox v10 - dynamically change the source url

We have a usual source url of something like https://my-source/{x}/{y}/{z}. When the user selects filtering options, we'd like to add these params to the url as something like https://my-source/{x}/{y}/{z}?my-param=true and instantly update the map.
Is this possible to achieve in mapbox?
Turns out this is relatively simple! If a little difficult to find, the code below will update the tile url dynamically:
val source = style.getSourceAs<VectorSource>(CHARGE_POINT_SOURCE_ID)
source?.tiles(listOf(newSourceUrl))

Here-SDK: How to show the default HereWeGo-Positionindicator?

How do i show the standard PositionIndicator from the HereWeGo-App in my MapActivity?
This one:
When i use this Code:
mPositioningManager = PositioningManager.getInstance()
mPositioningManager.addListener(
newWeakReference<PositioningManager.OnPositionChangedListener>(MyActivity.this));
if (mPositioningManager.start(PositioningManager.LocationMethod.GPS_NETWORK_INDOOR))
{
mapFragment.getPositionIndicator().setVisible(true);
}
i get this Indicator:
Is there some other way to create the "HereWeGo-Indicator"? As i know if you implement the Indicator iOS you get by default the "HereWeGo-Indicator".
If you want to use image than do like below
Image img_current_location = new Image();
img_current_location.setImageResource(R.drawable.custom_img);
after that set on PositionIndicator.
Map.getPositionIndicator().setMarker(img_current_location);
And if you dont want to use image at all than create compass header. sample example can downloaded from the below link.
https://tcs.ext.here.com/sdk_examples/CustomPositionMarker.zip
some discussion can be found on this post.
It does not fit in your requirement but you can modify it.

disable css animation on mobile devices

I am working on a horizontal scrolling site and to add to it it has a couple of CSS animations that totally crash all the browsers on the ipad i am testing on, so I am wondering if there is a way for the code to detect mobile devices (iOs, Android..) over and above screen sizes, to just disable animation for it?
Thanks for all your help in advance.
I haven't attached any code to it because, I really do not know what I would use to detect the Os, I am aware of using media queries but as I said window size is not what I am looking for its the Mobile OS that I want to target.
You can use the navigator.platform property to check the device type, then use some javascript to add the stylesheet containing your CSS animations if it's not one of the excluded platforms.
For example, to load the animations for all devices besides iPads, you could do:
if(navigator.platform != 'iPad')
{
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'animations.css';
document.getElementsByTagName('head')[0].appendChild(link);
}
For a list of platform values, refer here:
What is the list of possible values for navigator.platform as of today?
For more info on loading a stylesheet with JS, look here:
How to load up CSS files using Javascript?

How to create a location input bar in ios/Android?

Looking for some clue to build a location input bar just above keyboard and user can tap location icon to input a location, similar as what Fb/twitter has on their mobile apps when click new post/tweet.
Are there any existing library that support this? Should I create a customized keyboard with this bar?
Many thanks for any clues!
Assuming you are simply looking to create the bar above the keyboard, inputAccessoryView, a property of both UITextFields and UITextViews, is what you are looking for. This allows you to add a UIToolbar to the top of the keyboard similar to what both Twitter and Facebook do.
You can read further in the Apple documentation here.
A simple implementation of this is as follows -
UIToolbar *locationToolbar = [[UIToolbar alloc] init];
locationToolbar.frame = CGRectMake(320, 384, 320, 53);
// Add location button to UIToolbar as desired
self.textField.inputAccessoryView = locationToolbar;
If you are looking to create a map to select the location from, MKMapView would be a good place to start.

using WebView to view map and set marker (pin) on android

I'm making an app on android, using webview to load google map (using this url for my webview: http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html).
but i can't put a marker on that webview, can't somebody tell me how?
http://maps.google.com/maps?saddr=37.423156,-122.084917
The above simply shows the directions screen with missing destination field. If you want the pin to show on a simple map screen do this instead:
http://www.google.com/maps?q=37.423156,-122.084917
Clearly lots of ways to skin a cat - but I am loving the Google Static Maps API.
It generates a standard image (of desired size) and you can add points/lines/polygons all from a URL.
Whilst I haven't checked the terms, it is clearly possible to cache/store the result.
Documentation: http://code.google.com/apis/maps/documentation/staticmaps/
Example: http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
http://maps.google.com/maps?saddr=NJ
load URL like this pass address where you want to put the pin

Categories

Resources