qreal AsemanDevices::density() const { #ifdef Q_OS_ANDROID qreal ratio = isTablet()? 1.28 : 1; // if( isLargeTablet() ) // ratio = 1.6; return p->java_layer->density()*ratio; #else #ifdef Q_OS_IOS qreal ratio = isTablet()? 1.28 : 1; return ratio*densityDpi()/180.0; #else #ifdef Q_OS_LINUX #ifdef Q_OS_UBUNTUTOUCH return screen()->logicalDotsPerInch()/UTOUCH_DEFAULT_DPI; #else return screen()->logicalDotsPerInch()/LINUX_DEFAULT_DPI; #endif #else #ifdef Q_OS_WIN32 return 0.95*screen()->logicalDotsPerInch()/WINDOWS_DEFAULT_DPI; #else return 1; #endif #endif #endif #endif }
bool AsemanDevices::isLargeTablet() const { #ifdef Q_OS_ANDROID return isTablet() && p->java_layer->getSizeName() == 3; #else return isTouchDevice() && lcdPhysicalSize() >= 9; #endif }
void ofApp::deviceOrientationChanged(int newOrientation) { ofLogNotice() << "Detected orientation change " << newOrientation; if (isPhone()) { ofLogNotice() << "Ignoring orientation change since it's a phone"; return; } if (newOrientation == OF_ORIENTATION_UNKNOWN) { return; } if (isTablet() && appState != APP) { if (newOrientation == OF_ORIENTATION_DEFAULT || newOrientation == OF_ORIENTATION_180) { ofLogNotice() << "!!!Ignoring orientation change in tablet in app "; return; } } // upside down is no good for anything if (isPhone() && newOrientation == OF_ORIENTATION_180) ofSetOrientation(OF_ORIENTATION_DEFAULT); else { ofLogNotice() << "Changing orientation change"; ofSetOrientation(ofOrientation(newOrientation)); } // it transitioning to landscape, activate back all modules if (newOrientation == OF_ORIENTATION_90_LEFT || newOrientation == OF_ORIENTATION_90_RIGHT) { //imgAbout.rotate90(3); for (unsigned int i = 0; i < modules.size(); i++) modules[i]->activate(); } // it transitioning to portrait, deactivate all modules, except the one with which last interacted else { //imgAbout.rotate90(1); for (unsigned int i = 0; i < modules.size(); i++) { if (i == moduleActive) { ofLogNotice() << "Activating module " << i; modules[i]->activate(); } else { ofLogNotice() << "Deactivating module " << i; modules[i]->deactivate(); } } } setupModules(); }
QAndroidConfiguration::QAndroidConfiguration(QObject * parent) : QObject(parent) , screen_size_(ScreenSizeUndefined) { QAndroidQPAPluginGap::Context activity; QScopedPointer<QJniObject> resources(activity.callObject("getResources", "android/content/res/Resources")); QScopedPointer<QJniObject> configuration(resources->callObject("getConfiguration", "android/content/res/Configuration")); int screenLayout = configuration->getIntField("screenLayout") & ANDROID_SCREENLAYOUT_SIZE_MASK; switch(screenLayout) { case ANDROID_SCREENLAYOUT_SIZE_SMALL: screen_size_ = ScreenSizeSmall; break; case ANDROID_SCREENLAYOUT_SIZE_NORMAL: screen_size_ = ScreenSizeNormal; break; case ANDROID_SCREENLAYOUT_SIZE_LARGE: screen_size_ = ScreenSizeLarge; break; case ANDROID_SCREENLAYOUT_SIZE_XLARGE: screen_size_ = ScreenSizeXLarge; break; case ANDROID_SCREENLAYOUT_SIZE_UNDEFINED: screen_size_ = ScreenSizeUndefined; break; default: Q_ASSERT(screen_size_ > ScreenSizeXLarge); screen_size_ = ScreenSizeXLarge; } //! \todo Add reading of more fields here. qDebug()<<"QAndroidConfiguration: screen layout is"<<screenLayout<<"=>"<<screen_size_<<"("<<screenSizeName()<<")" <<", a tablet size:"<<isTablet(); }
bool AsemanDevices::isMobile() const { return isTouchDevice() && !isTablet(); }
void ofApp::draw() { ofBackground(BACKGROUND_COLOR); if (appState == SPLASH_SCREEN) { imgSplashScreen.draw(0, 0, ofGetWidth(), ofGetHeight()); if (ofGetElapsedTimeMillis() > 1500) appState = SPLASH_FADE; return; } else if (appState == SPLASH_FADE) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, 255); if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, 0.0f, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, 0, ofGetWidth(), ofGetHeight()); } splashAlpha -= 2; ofSetColor(255, 255, 255, splashAlpha); imgSplashScreen.draw(0, 0, ofGetWidth(), ofGetHeight()); ofDisableAlphaBlending(); ofPopStyle(); if (splashAlpha <= 0) appState = ABOUT; return; } else if (appState == ABOUT) { if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, 0.0f, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, 0, ofGetWidth(), ofGetHeight()); } setLanguageBBoxes(); drawBouncingArrow(); return; } drawModules(); drawLines(); drawParticles(); drawTouches(); if (showSwipeInfo) { ofPushStyle(); if (isTablet()) ofSetColor(47); // NOTE: previous white font color wasn't readable on iPad; else ofSetHexColor(CONSOLE_COLOR); int swipeSize = 150; int padding = 80; imgSwipeInfo.draw(ofGetWidth()/2-swipeSize/2, ofGetHeight()/2, swipeSize, swipeSize); string s1 = ofApp::translations["SWIPE_INFO_TOP_LINE"]; int s1w = swipeFont.getStringBoundingBox(s1, 0, 0).width; int s1x = (ofGetWidth() - s1w) / 2; int s1y = ofGetHeight()/2 - padding; swipeFont.drawString(s1, s1x, s1y); string s2; if (ofApp::isPhone()) s2 = ofApp::translations["SWIPE_INFO_BOTTOM_LINE_PHONE"]; else s2 = ofApp::translations["SWIPE_INFO_BOTTOM_LINE_TABLET"]; int s2w = swipeFont.getStringBoundingBox(s2, 0, 0).width; int s2x = (ofGetWidth() - s2w)/2; int s2y = ofGetHeight()/2 + swipeSize + padding; swipeFont.drawString(s2, s2x, s2y); ofPopStyle(); } if (appState == BAR) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, DEFAULT_ALPHA); if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight()); } ofDisableAlphaBlending(); drawArrow(false); ofPopStyle(); } else if (appState == ABOUT_ASCENDING) { if (aboutY < 15) { aboutY = 0; appState = ABOUT; } else { aboutY -= 15; } if (currentAlpha < 255) currentAlpha += 3; ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, currentAlpha); if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight()); } ofDisableAlphaBlending(); ofPopStyle(); } else if (appState == ABOUT_DESCENDING) { aboutY += 20; if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight()); } } else if (appState == BAR_ASCENDING) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, DEFAULT_ALPHA); aboutY -= 5; if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight()); } drawArrow(false); ofDisableAlphaBlending(); ofPopStyle(); } else if (appState == BAR_DESCENDING) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, DEFAULT_ALPHA); aboutY += 5; if(ofApp::isPhone()){ imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop); } else { imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight()); } drawArrow(true); ofDisableAlphaBlending(); ofPopStyle(); } else if (appState == APP) { if (isOsx()) { currentAlpha = DEFAULT_ALPHA; drawArrow(true); ofPushStyle(); ofSetColor(IMAGE_COLOR, DEFAULT_ALPHA); ofEnableAlphaBlending(); ofDrawRectangle(barRect); ofDisableAlphaBlending(); ofPopStyle(); } } }
void ofApp::setup() { ofSetLogLevel(OF_LOG_NOTICE); ofLogNotice() << "setup()"; if (ofApp::isSemibreve()) ofLogNotice() << "Going to run Semibreve version"; if (ofApp::isOsx()) ofLogNotice() << "OSX detected"; if (ofApp::isIos()) ofLogNotice() << "iOS detected"; if (ofApp::isAndroid()) ofLogNotice() << "Android detected"; if (ofApp::isPhone()) ofLogNotice() << "Phone detected"; if (ofApp::isTablet()) ofLogNotice() << "Tablet detected"; // if (ofApp::isIphone()) ofLogNotice() << "iPhone detected"; // if (ofApp::isIpad()) ofLogNotice() << "iPad detected"; // if (ofApp::isAndroidPhone()) ofLogNotice() << "Android phone detected"; // if (ofApp::isAndroidTablet()) ofLogNotice() << "Android tablet detected"; #if defined TARGET_OSX ofLogNotice() << "Running OSX version"; ofSetDataPathRoot("../Resources/data/"); #endif #if defined TARGET_SEMIBREVE ofLogNotice() << "Running SEMIBREVE version"; oscReceiver.setup(RECEIVE_PORT); oscSender.setup(HOST, SEND_PORT); #endif #if defined TARGET_OF_IOS if (ofApp::isTablet()) { ofSetOrientation(OF_ORIENTATION_90_LEFT); swiper.setup(); ofAddListener(swiper.swipeRecognized, this, &ofApp::onSwipe); swiping = false; } else { swiper.setup(); ofAddListener(swiper.swipeRecognized, this, &ofApp::onSwipe); swiping = false; } #endif #ifndef TARGET_OSX if (isAndroid() || isIos()) { ofxAccelerometer.setup(); accelCount = 0; crop = 0; } #endif if (!ofApp::isIos()) { ofLogNotice() << "Registering for touch events if not ios"; ofRegisterTouchEvents(this); } ofSetFrameRate(FRAME_RATE); ofSetCircleResolution(CIRCLE_RESOLUTION); if (multitouch) ofHideCursor(); ofApp::language = ofApp::getSystemLanguage(); ofLogNotice() << "Language is " << ofApp::language; initTranslations(); initModules(); setupModules(); loadModuleSounds(); initImages(); appState = ABOUT; inactivityState = ACTIVE; // init global vars aboutY = 0; splashAlpha = 255; arrowDownY = ofGetHeight()/3*2; arrowDownYBase = arrowDownY; arrowDownDir = 1; showSwipeInfo = true; ofApp::maxParticleY = round(ofGetHeight() * (1-LIMIT_PARTICLE)); uint swipeFontSize; if (isTablet()) swipeFontSize = 26; else swipeFontSize = 20; swipeFont.load(UI_FONT_FACE, swipeFontSize); }