Here I am trying to create an application that works and I want the same code to run the application in a android tablet.
But impossible to run because he told me that my views are not defined, but I do not understand because it works in ipad and android should logically work.
My project structure
ressouces
apps.js => (here I instanced, but views and it is here that I but which are not defined)
pages
base => (I have my views with all the contained)
Helpers => ()
pictures
android => (or the images there)
So apps.js fetches seen in "pages / base /" and then I have all but seen in javascript.
here is my code in apps.js
Titanium.include("helpers/helpers.js")
//Default locale
opened_tab = true;
Titanium.include("i18n/fr.js");
var win = Titanium.UI.createWindow({
backgroundColor:'#333',
//orientationModes:Titanium.UI.LANDSCAPE_LEFT
});
if(Titanium.Platform.osname=="ipad")
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;
if(Titanium.Platform.osname=="android")
Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;
var rotate = Ti.UI.create2DMatrix().rotate(90);
var counterRotate = rotate.rotate(-180);
var pages_references_ios = [
{title:"Couverture",slug:"couverture"},
{title:"Présentation concept",slug:"presentation"},
{title:"Un monde de réussites",slug:"metiers_numeriques"},
{title:"sign of success",slug:"sign_of_success"},
{title:"1000 facons de devenir",slug:"1000_ways"},
{title:"Pédagogie labos",slug:"labs"},
{title:"Partenariats entreprise",slug:"enterprise"},
{title:"la vie étudiante",slug:"student_life"},
{title:"Campus map",slug:"map"},
{title:"open campus",slug:"open_campus"},
{title:"Chaine videos",slug:"video_channel"},
{title:"Réseaux sociaux",slug:"social_networks"}
];
var pages_references_android = [
{title:"Couverture",slug:"couverture"},
{title:"Présentation concept",slug:"presentation"},
{title:"Un monde de réussites",slug:"metiers_numeriques"},
{title:"sign of success",slug:"sign_of_success"},
{title:"1000 facons de devenir",slug:"1000_ways"},
{title:"Pédagogie labos",slug:"labs"},
{title:"Partenariats entreprise",slug:"enterprise"},
{title:"Community awards",slug:"community"},
{title:"la vie étudiante",slug:"student_life"},
{title:"Campus map",slug:"map"},
{title:"open campus",slug:"open_campus"},
{title:"Chaine videos",slug:"video_channel"},
{title:"Réseaux sociaux",slug:"social_networks"}
];
if(Titanium.Platform.osname=="ipad")
pages_references = pages_references_ios;
else if(Titanium.Platform.osname=="android")
pages_references = pages_references_android;
Ti.include("pages/topBar.js")
Ti.include("pages/bottomBar.js")
var scrollView = Titanium.UI.createScrollableView({
views:[cover, presentation_view,metiers_numeriques,
sign_of_success_view,thousands_ways_view,
labs_view,enterprise_view,student_life_view,
map_view,open_campus_view,video_channel,social_view],
maxZoomScale:1.0,
currentPage:0,
showPagingControl:false,
cacheSize:5,
zIndex:-100
});
if (Ti.Platform.name == 'android') {
win.navBarHidden = true;
}
win.add(tabMenu);
//win.add(thumbnailsButtonView);
win.add(scrollView);
win.open();
sorry for my english.
thank you
Related
I'm making an app capable of take photos and upload them to a server. The phone will save the id generated.
I made a class abstractApp that creates an App object with a couple of helpers and variables. I'm using Framework7.
var App;
document.addEventListener("deviceready", function() {
App = new abstractApp();
var i;
App.f7Ref = new Framework7({init: false});
for (i = 0; i < App.constants.views.length; i++)
{
if (i==0)
App.mainView = App.f7Ref.addView (
App.constants.views[i].selector,
App.constants.views[i].settings );
else
App.f7Ref.addView (
App.constants.views[i].selector,
App.constants.views[i].settings );
}
// Checks if there exists register of remote photos
if ( App.local.get('remotephotos', false) == null || App.local.get('remotephotos', false) == '' )
{
App.remotephotos = [];
App.local.set('remotephotos', []);
}
else
{
App.remotephotos = App.local.get('remotephotos');
}
// Checks if there exists register of local photos
if ( App.local.get('localphotos', false) == null || App.local.get('localphotos', false) == '' )
{
App.localphotos = [];
App.local.set('localphotos', []);
}
else
{
App.localphotos = App.local.get('localphotos');
}
for (i = 0; i < appControllers.length; i++)
{
appControllers[i].apply(App);
}
console.log(App);
}, false);
In appControllers I'm saving functions related to each page (so it is a bit more organized). With only index and new-photo controllers I have no problem, I can attach events to elements and navigate between views. The problem is calling the camera object.
window.appControllers.push(function()
{
var $$ = Dom7;
var Ref = this.f7Ref;
var server = new serverInterface();
var photos = this.remotephotos;
var App = this;
Ref.onPageInit('new', function (page) {
Ref.alert('entra', 'entra');
$$('.capture').on('click', function () {
Ref.alert('Click', 'Click detected');
navigator.camera.getPicture(onSuccess, onFail,
{
quality: 20,
destinationType: destinationType.FILE_URI
});
function onSuccess(imageURI) {
Ref.alert('Photo captured.', 'Bien');
}
function onFail(message) {
Ref.alert('There was a problem.', 'Ups');
}
});
});
});
So, I enter the new page and I click the button with cass capture and the alert (click detected) appears, but it doesn't show the camera to take the photo.
I'm using Phonegap Build and an android phone, do you have any idea of what's happening?
Thank you very much in advance
The problem wasn't the javascript code I quoted.
I was loading the camera plugin in the config.xml like this
<gap:plugin name="org.apache.cordova.camera" />
But it should be loaded this way:
<plugin name="cordova-plugin-camera" />
If the plugin is not loaded correctly, in Phonegap Build appears: version n/a installed. In this case, when it is correctly loaded, appears: version 2.1.0 installed.
More information about this thread can be found here: http://phonegap.com/blog/2015/11/19/config_xml_changes_part_two/
Hope it helps someone else too
Regards
I am attempting(and failing) to insert elements into every page visited. I am only able to insert elements into the initial page(the page displayed after the add-on has been installed). The code snippet below demonstrates this behaviour.
I have tried placing the logic that inserts the H1 element within onOpenWindow(), although that doesn't seem to make any difference.
NOTE: The code below is in addition to template boilerplate code
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import('resource://gre/modules/Services.jsm');
function loadIntoWindow(window) {
if (!window)
return;
window.NativeWindow.toast.show("Inserting script", "short");
var contentWindow = window.BrowserApp.selectedBrowser.contentWindow;
var document = contentWindow.document;
document.body.innerHTML = "<h1>THIS TEXT WAS INSERTED</h1>";
}
var DOMWindows = Services.wm.getEnumerator('navigator:browser');
while (DOMWindows.hasMoreElements()) {
var aDOMWindow = DOMWindows.getNext();
var allTabs = aDOMWindow.BrowserApp._tabs;
for (var i=0; i<allTabs.length; i++) {
var aContentWindow = allTabs[i].window;
}
}
Good day folks.
I am stuck with a strange problem and after lots of googling I couldn't find the solution/answer
I am creating and Sencha +cordova app for android.
It simply display 10 images in loop.
my code works fine on Chrome browser in desktop.
It fails On android 4.4.2 device when I install as APK.
Please help to fix the code for android.
init: function () {
this.callParent(arguments);
//console.log('init');
if(Ext.os.name == 'Android')
baseurl = baseAndroidUrl;
else
baseurl = baseDesktopUrl;
//alert('baseurl ' + baseurl);
}
var baseurl;
var baseAndroidUrl = 'file:///android_asset/www/resources/resources/images/';
var baseDesktopUrl = '/resources/resources/images/';
var imageArray =
['page00.jpg',
'page01.jpg',
'page02.jpg',
'page03.jpg',
'page04.jpg',
'page05.jpg',
'page06.jpg',
'page07.jpg',
'page08.jpg',
'page09.jpg',
'page10.jpg'];
var counter = 0;
-----------------------------------------------
onPrePageCommand: function () {
console.log('onPrePageCommand');
if( counter === 0 )
return ;
counter--;
// Folloing dynamic updation doesn't work in android , works perfectly on desktop
Ext.getCmp('pageID').setSrc(baseurl+imageArray[counter]);
//Ext.getCmp('pageID ').doLayout();
},
onNextPageCommand: function () {
console.log('onNextPageCommand');
if( counter === imageArray.length-1 )
return ;
counter++;
Ext.getCmp('pageID').setSrc(baseurl+imageArray[counter]);
},
------------------------------------------
//initial view : work perfect for both Desktop browser and APK
{
xtype: 'image',
src:'resources/images/Page00.jpg',
id:'pageID',
mode:'image'
height:'100%',
width:'100%'
}
--------------------------------------------
Try to use a Framework for that like http://wowslider.com/ this worked great for me the last time. You can also scroll the images with your fingers (swipe them).
I'm trying to prepare mobile app that runs on Android and iOS using Titanium Appcelerator
In one of the view, i'll send a request to server, get response and after parsing it, i'll create a scroll view with internal views and populate the data accordingly. The app is working fine on iPhone. But in Android, its not working peoperly. Unless and until i add the controls to windows, they are not being shown in Android.
I'd like to know if I've to set any thing to work properly in android. The following code is used to add the subviews to scroll view:
var xPos = 0;
for (var i = 0; i < cityCodes.length; i++)
{
xPos = i*320;
var cityImg = require('screens/views').cityDataView(xPos, cityClicked,
cityCodes.item(i).text,
cityNames.item(i).text,
cityExportQuantities.item(i).text,
exportPercentages.item(i).text,
populationCount.item(i).text,
popultionPercentages.item(i).text,
rates.item(i).text
);
scrlView.add(cityImg);
}
I'm creating the scroll view as following:
scrlView = Titanium.UI.createScrollView({
contentWidth:'auto',
contentHeight:'auto',
top:'40%',
height:'155dp',
showVerticalScrollIndicator:true,
showHorizontalScrollIndicator:false
});
I'm creating the city data view as following:
cityDataView: function(xPos, showCityDetails, cityCode, cityName, exportQuantity, exportPercent, popCount, popPercent, rate)
{
var tempLabel = function(topPos,txt){
// Ti.API.log(topPos);
var custLabel = Ti.UI.createLabel({
color:'#000',
text:txt,
right:'55%',
top:topPos,
font:{
fontSize:14,
fontFamily:'GE SS Text Light'
},
textAlign:Titanium.UI.TEXT_ALIGNMENT_RIGHT,
width:'auto'
});
return custLabel;
};
var cityImg = Ti.UI.createImageView({
left:xPos,
height : '155dp',
width : '100%',
image : '/images/citydetails.png'
});
cityImg.addEventListener('singletap', function(){
Ti.API.log(cityCode);
showCityDetails(cityCode);
});
var cityNameLbl = Ti.UI.createLabel({
color:'#ffffff',
text:cityName,
height:'15dp',
top:'6%',
font:{
fontSize:14,
fontFamily:'GE SS Text Light'
},
textAlign:Titanium.UI.TEXT_ALIGNMENT_RIGHT,
width:'auto'
});
cityImg.add(cityNameLbl);
var exportQtyLbl = tempLabel('19%',exportQuantity);
cityImg.add(exportQtyLbl);
var overallProd = tempLabel('35%',exportPercent);
cityImg.add(overallProd);
var populationCount = tempLabel('53%',popCount);
cityImg.add(populationCount);
var populationPercent = tempLabel('69%',popPercent);
cityImg.add(populationPercent);
var rateText = tempLabel('85%',rate);
cityImg.add(rateText);
// var totalExportText = tempLabel('95%',totalExport);
// cityImg.add(totalExportText);
return cityImg;
}
I've created one App using Phonegap and HTML5 (jqueryMobile). I've put rotate3D for one div,
it is working fine in google chrome and Safari, but it is not working in Android 2.3+
Any suggestion?
I think It is a bug of android browser. I make a function to test if rotate3d is supported and it says Yes:
function styleSupport( prop )
{
var vendorProp;
var supportedProp;
// capitalize first character of the prop to test vendor prefix
var capProp = prop.charAt(0).toUpperCase() + prop.slice(1);
var prefixes = [ "Moz", "Webkit", "O", "ms" ];
var div = document.createElement( "div" );
if ( prop in div.style )
{
//browser supports standard CSS property name
supportedProp = prop;
}
else
{
//otherwise test support for vendor-prefixed property names
for ( var i = 0; i < prefixes.length; i++ )
{
vendorProp = prefixes[i] + capProp;
if ( vendorProp in div.style )
{
supportedProp = vendorProp;
break;
}
}
}
// avoid memory leak in IE
div = null;
return supportedProp;
}
alert(styleSupport('perspective'));
alert(styleSupport('transform'));
As you can see her, CSS transforms3D are not supported by Android 2.3 :
http://caniuse.com/#feat=transforms3d
try to upgrade to Android 4 (it works for me)