Sunday, September 13, 2020

Script to check Titanium modules for references to UIWebView

 

  1. Create a file called check-modules.sh and copy the above contents into the file
  2. Ensure that file has executable permissions chmod +x <path>
  3. Run the file against each module ./check-modules <path> where path is the full path of a module including the platform and version. Making sure to either escape the spaces (like below) or wrapping your path in quotes
  • For example ./check-module.sh /Users/awam/Library/Application\ Support/Titanium/modules/iphone/ti.googlesignin/2.0.4

If the module contains UIWebView references then that will be logged


Code: https://gist.github.com/ewanharris/bf7aa969dd0a99cd83c019feb512e800

Tuesday, February 4, 2020

How to to handle app's orientation properly.


The app's "alloy.js" is listening to the "orientationchange" event to re-layout content. The problem with this is that the "orientationchange" event provides the orientation of the "device", not the "app". The native device orientation change event will always occur before the app is rotated by the OS. And some devices will be faster or slower to respond to the device orientation change before rotating the app.
Also note that the "device" orientation and "app" orientation can differ as well. Especially when using split-screen mode on a tablet, because when you hold the tablet "landscape", both of the displayed apps will be in "portrait" form. The attached app code mishandles this case.
What you should be doing is listening to the window's "postlayout" event, fetch the window's width/height, and determine if it is portrait/landscape. This will also handle the split-screen case.

//////////////
var window = Ti.UI.createWindow();
window.addEventListener("postlayout", function() {
 var windowSize = window.size;
 var isPortrait = (windowSize.height >= windowSize.width);
 if (isPortrait) {
  Ti.API.info("### Window is in portrait form.");
 } else {
  Ti.API.info("### Window is in landscape form.");
 }
});
window.open();

//////////////
Note that the use-case for "device" orientation is for fixed orientation apps (ex: portrait-only) that want to rotate the UI manually based on device orientation. Camera apps do this.


I hope this helps.

Tuesday, November 5, 2019

remote image best practices

You can check out this sample code for remote image
https://gist.github.com/MotiurRahman/57535845ebf40bd2041448991ebd92fc

Secondly, If you would like to resize image before adding it to the window then you can use httpclient the response will be a blob, for instance, this.responseData inside the onLoad callback. Sample code - https://gist.github.com/MotiurRahman/130b7f232a74956b0c26d7ddf4ac6b34

Hope this helps.

Wednesday, October 9, 2019

Monday, April 29, 2019

Social share for android

Sample code


========
 var share_body = "https://play.google.com/store/apps/details?id=motiur_bdresult.bd.com.bdresult";
        var share_subject = "Please download it from the below link";

        var intent = Ti.Android.createIntent({
            action: Ti.Android.ACTION_SEND,
            type: "text/plain"
        });

        intent.putExtra(Ti.Android.EXTRA_SUBJECT, share_subject);
        intent.putExtra(Ti.Android.EXTRA_TEXT, share_body);
        intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
        Ti.Android.currentActivity.startActivity(intent);

========

Hope this help.

Tuesday, March 19, 2019

Thursday, January 24, 2019

Monday, January 14, 2019