How to resize PIP mode in android - android-layout

I'm trying to implement a picture-in-picture mode in my app. I'm Implementing google Maps on PIP mode but I can't resize the full-screen map. It always zooms on the map center point. I have done R&D related to this issue but not finding any proper answer. Basically, I need the layout like Whatsapp app pip Screen on my app how to implement it? And my code is here:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Display display=getWindowManager().getDefaultDisplay();
Point size=new Point();
display.getSize(size);
int width=size.x;
int height=size.y;
Rational aspectRatio=new Rational(width,height);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);
}
and here is Manifest code:
<activity android:name=".activities.MainActivity"
android:supportsPictureInPicture="true"
android:resizeableActivity="true"
android:launchMode="singleTask"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>
In this code, I have the screen like
and I want
How can I solve this?
Thanks in advance!!

Just Change Your this code
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Display display=getWindowManager().getDefaultDisplay();
Point size=new Point();
display.getSize(size);
int width=size.x;
int height=size.y;
Rational aspectRatio=new Rational(width,height);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);
}
To
Rational aspectRatio = new Rational(3, 4);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);

Related

Xamarin iOS: BarTintColor not working in iOS 15

I came across a similar issue in this post.
I tried to convert iOS native code into Xamarin.iOS C#.
iOS Native Code:
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = <your tint color>
navigationBar.standardAppearance = appearance;
navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance
my own code for Xamarin.iOS C#
if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0))
{
var appearance = new UITabBarAppearance();
appearance.ConfigureWithOpaqueBackground();
appearance.BackgroundColor = UIColor.FromRGB((float)rgbColorBackground.R, (float)rgbColorBackground.G, (float)rgbColorBackground.B);
this.TabBarController.TabBar.StandardAppearance = appearance;
}
else
TabBar.BarTintColor = UIColor.FromRGB((float)rgbColorBackground.R, (float)rgbColorBackground.G, (float)rgbColorBackground.B);
However, there is no reference to "scrollEdgeAppearance" in Xamarin.iOS C#, and it seems important to add this to solve the issue. I'd be grateful if someone can give me some advice or point out my mistakes.
I did this to solve transparent tabbar in IOS 15.
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
// Color of the selected tab icon:
UITabBar.Appearance.SelectedImageTintColor = AppColors.Primary500Color.ToUIColor();
UITabBar.Appearance.BackgroundColor = AppColors.WhiteColor.ToUIColor();
if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0))
UITabBar.Appearance.ScrollEdgeAppearance = new UITabBar().StandardAppearance;
Regards Joacim

Selecting a UI element not on the screen of native android app using Appium, Selenium web driver, Node js, Mocha etc

I'm testing a native Android app and need to click on a button that is off the bottom of the screen. I've seen tons of examples of this using Java and Javascript but I'm using Node.js and nothing seems to work. I'm pretty new to this stuff and have wasted far too much time on something so simple.
For example to click on an onscreen element this works:
it("Select Button Test",function(){
return driver
.setImplicitWaitTimeout(timeoutWait)
.elementByXPath('//android.widget.TextView[#text=\'My Button\']').click();
});
Also the full xpath works for onscreen elements - in this case:
var myButton ='//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.TableLayout[1]/android.widget.TableRow[10]');
it("Select Button Test",function(){
return driver
.setImplicitWaitTimeout(timeoutWait)
.elementByXPath(myButton).click();
});
I found the full xpath for this button by scrolling to it while the test was running and firing up the screen in appium inspector. I've tried various scroll, touch, and swipe methods from the webdriver docs but nothing is available so apparently I've wandered off the ponderosa...
So how can I access a button that is not on the screen?
I'm sure its some mundane detail. Thanks!
try the below scroll function to scroll using dimensions
public void scroll() throws IOException {
Dimension dimensions = driver.manage().window().getSize();
System.out.println("Size of Window= " +dimensions);
int scrollStart = (int) (dimensions.getHeight() * 0.5);
System.out.println("Size of scrollStart= " +scrollStart);
int scrollEnd = (int) (dimensions.getHeight() * 0.2);
System.out.println("Size of scrollEnd= " + scrollEnd);
driver.swipe(0,scrollStart,0,scrollEnd,1000); }
and then use your locator strategy to find the element
I'm use node.js to test react native app solve this problem .
The appium node.js sample code have scroll feature.First,you need import all what sample imported.Then there's the codeļ¼š
it("should scroll", function () {
return driver
.elementByXPath('//android.widget.TextView[#text=\'Animation\']')//change your element which doesn't cover it.
.elementsByXPath('//android.widget.TextView')
.then(function (els) {
return Q.all([
els[7].getLocation(),
els[3].getLocation()
]).then(function (locs) {
console.log('locs -->', locs);
return driver.swipe({
startX: locs[0].x, startY: locs[0].y,
endX: locs[1].x, endY: locs[1].y,
duration: 800
});
});
});
});
good luck !!

How to create a button with an icon iside?

as stated in the title question, I want to create a button that uses an icon as background.
I am using the wearable circle emulator with 360x360.
I tried a lot of code and examples but with no success.
Last code used:
static void
create_base_gui(appdata_s *ad)
{
/* Window */
ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
elm_win_autodel_set(ad->win, EINA_TRUE);
if (elm_win_wm_rotation_supported_get(ad->win))
{
int rots[4] = { 0, 90, 180, 270 };
elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
}
eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
/*Box*/
ad->box = elm_box_add(ad->win);
evas_object_size_hint_weight_set(ad->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(ad->box);
elm_win_resize_object_add(ad->win, ad->box);
ad->button2 = elm_button_add(ad->box);
elm_object_text_set(ad->button2, "Click me");
evas_object_size_hint_weight_set(ad->button2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ad->button2, EVAS_HINT_FILL, EVAS_HINT_FILL);
ad->icon2 = elm_icon_add(ad->box);
elm_image_file_set(ad->icon2, "C/Tizen/testWorkspace/BasicUI/shared/res/basicui.png", NULL);
elm_image_resizable_set(ad->icon2, EINA_TRUE, EINA_TRUE);
elm_object_part_content_set(ad->button2, "icon", ad->icon2);
elm_object_content_set(ad->button2, ad->icon2);
elm_box_pack_end(ad->box, ad->button2);
evas_object_show(ad->button2);
/* Show window after base gui is set up */
evas_object_show(ad->win);
}
The button is created and it's clickable (no behaviour defined yet).
The icon is not displayed.
What am I doing wrong ?
Thanks
PS: based on https://developer.tizen.org/ko/development/ui-practices/native-application/efl/ui-components/wearable-ui-components/creating-wearable-buttons?langredirect=1
and on the default BasicUI example
You need to declare the path from the tizen system point of view.
The correct path is then
/opt/usr/apps/org.somepackage.yourapp/shared/res/youricon.png
needless to say that org.somepackage.yourapp is the package path to your app and youricon.png is your icon.
You can even check the location of your icon in the device manager.
On the following image it is
/opt/usr/apps/org.example.settingsui/shared/res/settingsui.png
This is not imho very good solution, but there is a better way of doing this:
You can use either function
app_get_shared_resource_path();
app_get_resource_path();
You can write method like this:
static void
app_get_shared_resource(const char *file_in, char *path_out, int path_max)
{
char *res_path = app_get_shared_resource_path();
if (res_path) {
snprintf(path_out, path_max, "%s%s", res_path, file_in);
free(res_path);
}
}
and then use it like this
char icon_path[128] = {0,};
app_get_shared_resource("youricon.png", icon_path, 128);
// create your button and stuff and then
elm_image_file_set(ic, icon_path, NULL);
All these are more valuable for tizen 2.3.X and lower. Since Tizen 2.4 you can use Resource Manager
My guess is that the icon should be added on button control instead of box control.
So this:
ad->icon2 = elm_icon_add(ad->box);
should be:
ad->icon2 = elm_icon_add(ad->button);
Hope that helps!

Admob issues on Xamarin iOS apps with Admob SDK version 6.12.0

I am currently using the Google AdMob Xamarin component (version 6.12.0 - see https://components.xamarin.com/view/googleadmob) to display DFP interstitials and banner ads (displayed at different points within a tableview) on an iOS app. When I am debugging in Visual Studio 2013 I get the following output:
<Google:HTML> You are currently using version 6.12.0 of the SDK, which doesn't
officially support iOS 8. Please consider updating your SDK to the most recent
sdk version, 6.12.2, to get iOS 8 support, including a fix for smart banner
rendering in landscape mode. The latest SDK can be downloaded from
http://goo.gl/iGzfsP. A full list of release notes is available at
https://developers.google.com/mobile-ads-sdk/docs/admob/ios/rel-notes.
According to the Xamarin component's page, 6.12.0 does actually support iOS 8. Should I ignore the warning that I am getting? If not, how do I go about using 6.12.2 when the newest version of the component is only 6.12.0? Is it OK to stay with 6.12.0 or will it cause issues?
I have noticed that the banner ads aren't really displaying in the correct location on iOS8, they are slightly to the right and down from where they should be. Is this because of the SDK or some other change in iOS8 regarding how cells are displayed?
Below is how I display the banner ad:
public void InitialiseBanner(AdMobView property)
{
_bannerViewDelegate = new AdMobBannerViewDelegate();
_bannerView = new DFPBannerView();
float x = (CurrentWidth/2) - (AdvertWidth/2);
_bannerView.RootViewController = this;
_bannerView.BackgroundColor = UIColor.White;
_bannerView.Delegate = _bannerViewDelegate;
_bannerView.Frame = new RectangleF(x, 5, AdvertWidth, 50);
View.Frame = new RectangleF(0, 0, CurrentWidth, 50);
View.AddSubview(_bannerView);
_bannerView.AdUnitID = "/**UNITIDREMOVED**/" + property.AdAlias;
GADRequest request = GADRequest.Request;
.
.
.
_bannerView.LoadRequest(request);
View.BringSubviewToFront(_bannerView);
if (DeviceHelper.IsIos8OrGreater && RespondsToSelector(new Selector("separatorInset")))
{
_bannerView.LayoutMargins = UIEdgeInsets.Zero;
}
}
As for a normal banner, try loading your AdView Like this:
(This is my working example)
As a class level declaration, type this:
GADBannerView adView;
bool viewOnScreen = false;
// Get you own AdmobId from: http://www.google.com/ads/admob/
const string AdmobId = "<your admob id>";
Then in your viewDidLoad you can specify position of your banner and load it:
adView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (0, UIScreen.MainScreen.Bounds.Height-100)) {
AdUnitID = AdmobId,
RootViewController = this
};
adView.DidReceiveAd += (sender, args) => {
if (!viewOnScreen) View.AddSubview (adView);
viewOnScreen = true;
};
adView.LoadRequest (GADRequest.Request);
I get the same error as well, but it doesn't actually matter. I also thought first that this was the issue but my setup was a bit wrong, i think that is the same for your code. In my example i just added my AdView to the MainView, but using custom cells you should be able to implement it in your UITable View. Also, have a look at the example provided in the components section. As for displaying DFP interstitials: There has to be something wrong with the setup as well, but i can't see it in the code you provided.

How to flip an image in Xamarin Android?

I'm creating Poker game. So initially I'm showing back face of playing cards and then I need to add flip animation on the cards to show the value of cards. I've searched the net but I didn't find anything that could have helped me.
my code is as follows.
void LoadBacksideOfCards()
{
player1Card1.SetImageResource(Resource.Drawable.backside);
player1Card2.SetImageResource(Resource.Drawable.backside);
player2Card1.SetImageResource(Resource.Drawable.backside);
player2Card2.SetImageResource(Resource.Drawable.backside);
player3Card1.SetImageResource(Resource.Drawable.backside);
player3Card2.SetImageResource(Resource.Drawable.backside);
player4Card1.SetImageResource(Resource.Drawable.backside);
player4Card2.SetImageResource(Resource.Drawable.backside);
centerCard1.SetImageResource(Resource.Drawable.backside);
centerCard2.SetImageResource(Resource.Drawable.backside);
centerCard3.SetImageResource(Resource.Drawable.backside);
centerCard4.SetImageResource(Resource.Drawable.backside);
centerCard5.SetImageResource(Resource.Drawable.backside);
}
And showing the cards using following code
void ShowCenterCardNumber(int cardNumber)
{
if (cardNumber == 3)
{
centerCard4.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[3].CardNumber + _shuffledCardsData.CenterCardsData[3].CardType]);
}
else
{
centerCard5.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[4].CardNumber + _shuffledCardsData.CenterCardsData[4].CardType]);
}
}
void ShowFirstThreeCenterCards()
{
centerCard1.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[0].CardNumber + _shuffledCardsData.CenterCardsData[0].CardType]);
centerCard2.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[1].CardNumber + _shuffledCardsData.CenterCardsData[1].CardType]);
centerCard3.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[2].CardNumber + _shuffledCardsData.CenterCardsData[2].CardType]);
}
I want to add some flip functionality to make it more interactive to users.
I'm using simple XML (without MONO Games).
any help in this regard will be much appreciated.
A few suggestions:
http://developer.android.com/training/animation/cardflip.html
http://2cupsoftech.wordpress.com/2012/09/18/3d-flip-between-two-view-or-viewgroup-on-android/
Android flip image animation
https://github.com/castorflex/FlipImageView

Resources