コード例 #1
0
ファイル: ListScreen.cpp プロジェクト: GregorGullwi/MoSync
/**
 * This method is called when an item's delete button is clicked.
 * The list type must be segmented and in editing mode.
 * Platform: iOS
 * @param listView The list view object that generated the event.
 * @param listViewSection The ListViewSection object that contains the item.
 * @param listViewItem The item objet whose delete button was clicked.
 */
void ListScreen::segmentedListViewItemDelete(
	ListView* listView,
	ListViewSection* listViewSection,
	ListViewItem* listViewItem)
{
	maAlert("List View", "Delete button was clicked", "Ok", NULL, NULL);
}
コード例 #2
0
/**
 * Show currently used selection style for an list view item.
 * Works on iOS platform.
 */
void SettingsScreen::showSelectionStyleMessageBox()
{
	MAUtil::String textToShow;
	if (mListView->countChildWidgets() == 0)
	{
		textToShow = "The list view section does not have sections.";
	}
	else
	{
		ListViewSection* section = (ListViewSection*) mListView->getChild(0);
		if (section->countChildWidgets() == 0)
		{
			textToShow = "The list view section does not have items.";
		}
		else
		{
			ListViewItem* item = (ListViewItem*) section->getChild(0);
			ListViewItemSelectionStyle selectionStyle =
				item->getSelectionStyle();
			textToShow = "The selection style is: " +
				getSelectionStyleString(selectionStyle);
		}
	}
	maAlert("ListViewItem selection style", textToShow.c_str(), "OK", NULL, NULL);
}
コード例 #3
0
/**
 * Get the index for the selected product to buy.
 * @return The product ID.
 */
MAUtil::String MainScreen::getSelectedAvailableProduct()
{
	/**
	 * Check which check box was selected, and purchase the corresponding item.
	 * If no check box is selected, display a warning message
	 * Until the purchase is completed, Disable buy button.
	 */
	bool noItemSelected = true;
	int itemSelectedIndex = -1;
	for (int i=0 ; i < mItemsCheckBoxes.size(); i++)
	{
		if ( mItemsCheckBoxes[i]->isChecked() )
		{
			noItemSelected = false;
			itemSelectedIndex = i;
			mBuyButton->setEnabled(false);
			break;
		}
	}
	if ( noItemSelected )
	{
		maAlert("Purchase","You need to select an item first!","OK","","");
		return "";
	}

	return mProductIdList[itemSelectedIndex];
}
コード例 #4
0
ファイル: AppController.cpp プロジェクト: GregorGullwi/MoSync
	/**
	 * Show previous set image path.
	 * From PathPropertyScreenListener.
	 */
	void AppController::showImagePath()
	{
		MAUtil::String path = mTestScreen->getImagePath();
		maAlert("Image path is",
				path.c_str(),
				"OK",
				NULL,
				NULL);
	}
コード例 #5
0
	/**
	 * Constructor.
	 */
	ApplicationController::ApplicationController() :
		mMainScreen(NULL),
		mDatabase(NULL),
		mCountSucceededTests(0)
	{
		mMainScreen = new MainScreen();
		mMainScreen->show();

		this->log("Application started!");

		mDatabase = new DatabaseManager();
		DatabaseProduct* dbProduct = new DatabaseProduct();

		int platform = getPlatform();
		if (platform != IOS &&
			platform != ANDROID)
		{
			maAlert("Error", "This program runs only on Android and iOS devices",
				"OK", NULL, NULL);
		}
		else if ( PurchaseManager::getInstance()->checkPurchaseSupported() != MA_PURCHASE_RES_OK )
		{
			maAlert("Error", "Billing is not supported on this device",
				"OK", NULL, NULL);
		}
		else
		{
			MAUtil::String developerKey = DEVELOPER_PUBLIC_KEY;
			if ( developerKey.size() == 0 &&
				 platform == ANDROID )
			{
				maAlert("Error", "You need to set developer key in Config.h ",
					"OK", NULL, NULL);
			}
			else
			{
				this->log("Creating tests...");
				this->createTests();
				this->log("Tests are created!");
				this->runNextTest();
			}
		}
	}
コード例 #6
0
/**
 * Notifies that a purchase has been refunded.
 * Platform: Android.
 * @param purchase The purchase that has been refunded.
 */
void ApplicationController::purchaseRefunded(Purchase& purchase)
{
	MAUtil::String refundString = "You received a refund for " + purchase.getProductId();
	maAlert("Product refunded", refundString.c_str(), "OK", NULL,NULL);
	Purchase* restoredItem = new Purchase(purchase.getProductId(), this);
	mPurchases.add(restoredItem);
	mCurrentPurchase = mPurchases.size()-1;

	// Notify The UI.
	mMainScreen->productRefunded(purchase.getProductId());
}
コード例 #7
0
	void MoSyncCamController::snapshotFinished( const NativeUI::CameraSnapshotData& imageData )
	{
		bool snapshotIsAvailable = true;
		if ( imageData.resultCode != MA_CAMERA_RES_OK )
		{
			maAlert("Camera", "Snapshot failed", "OK", NULL, NULL);
			snapshotIsAvailable = false;

			if ( mLastSnapshotDataHandle > 0 )
			{
				maDestroyPlaceholder(mLastSnapshotDataHandle);
				mLastSnapshotDataHandle = 0;
			}
		}
		mCameraScreen->hideSnapshotInProgress(snapshotIsAvailable);
	}
コード例 #8
0
/**
 * This method is called when a screen has been popped from a stack
 * screen.
 * @param stackScreen The stack screen object that generated the event.
 * @param fromScreen The screen that was popped from the stack screen.
 * @param toScreen The screen that will be shown.
 */
void MainScreen::stackScreenScreenPopped(
    StackScreen* stackScreen,
    Screen* fromScreen,
    Screen* toScreen)
{
    if (this == stackScreen)
    {
        printf("stack screen event");
        if(mFirstScreen == toScreen && mSecondScreen == fromScreen)
        {
            printf("screen test param is ok!");
        }
        else
        {
            maAlert("Error", "Wrong callback parameter(s)", "OK", NULL, NULL);
        }
    }
}
コード例 #9
0
ファイル: NativeScreen.cpp プロジェクト: GregorGullwi/MoSync
int NativeScreen::handleImageData(MAHandle myImageData)
{
	printf("handleImageData(%d)", myImageData);

	int resCode = -1;

	MAHandle hImage = maCreatePlaceholder();
	int dataSize = maGetDataSize(myImageData);
	int createImageRes = maCreateImageFromData(hImage, myImageData, 0, dataSize);

	// Used for testing only.
	MAUtil::String info = "Ready.Size = " + MAUtil::integerToString(dataSize)
			            + " res = " + MAUtil::integerToString(createImageRes);
	printf("\n%s\n", info.c_str());

	if (createImageRes != RES_OK) {
		// If the Android VM gets an out of memory exception, get the image handle instead.
		maAlert("Memory Warning", " The image cannot be created. Try again", NULL, NULL, NULL);
		maWidgetSetProperty(mEventReturnTypeCheckbox, MAW_CHECK_BOX_CHECKED, "false");
		maImagePickerOpen();
	} else {
		char imgHandle[256];
		sprintf(imgHandle, "%d", hImage);
		printf("imgHandle=%s---hImage=%d", imgHandle, hImage);

		// display the preview
		resCode = maWidgetSetProperty(mPreview, MAW_IMAGE_IMAGE, imgHandle);
	}

	// at this point the new selected image is either displayed or non-existent (out of memory)
	// the former displayed image (if exists) can be now safely deleted and reused
	if (mLastDisplayedImageHandle != -1) {
		maDestroyPlaceholder(mLastDisplayedImageHandle);
	}
	mLastDisplayedImageHandle = hImage;

	return resCode;
}
コード例 #10
0
/**
 * This method is called if the touch-up event was inside the
 * bounds of the button.
 * @param button The button object that generated the event.
 */
void MainScreen::buttonClicked(Widget* button)
{
    if (button == mSetDate)
    {
        Date date;
        date.day = 17;
        date.month = 8;
        date.year = 2011;
        mDatePicker->setDate(date);
		mDisplayedDate->setText(
			MAUtil::integerToString(date.day) + "-" +
			MAUtil::integerToString(date.month)+ "-" +
			MAUtil::integerToString(date.year));
    }
    else if (button == mSetMaxDate)
    {
		if( mYearValueMaxDate->getText().size() != 0 &&
			mMonthValueMaxDate->getText().size() != 0 &&
			mDayValueMaxDate->getText().size() != 0)
		{
			Date date;
			date.year = atoi(mYearValueMaxDate->getText().c_str());
			date.month = atoi(mMonthValueMaxDate->getText().c_str());
			date.day = atoi(mDayValueMaxDate->getText().c_str());

			mDatePicker->setMaxDate(date);
		}
		else
		{
			maAlert("Error", "Please fill all the required fields.", "OK", "", "");
		}
    }
	else if (button == mGetMaxDate)
    {
        struct Date theDate = mDatePicker->getMaxDate();

        mGetMaxDateValue->setText("MaxDate: " + MAUtil::integerToString(theDate.day)+ "-" +
		MAUtil::integerToString(theDate.month) + "-" + MAUtil::integerToString(theDate.year));
        printf("get max date : %d-%d-%d", theDate.day, theDate.month, theDate.year);
    }
    else if (button == mSetMinDate)
    {
		if( mYearValueMinDate->getText().size() != 0 &&
			mMonthValueMinDate->getText().size() != 0 &&
			mDayValueMinDate->getText().size() != 0)
		{
			Date date;
			date.year = atoi(mYearValueMinDate->getText().c_str());
			date.month = atoi(mMonthValueMinDate->getText().c_str());
			date.day = atoi(mDayValueMinDate->getText().c_str());

			mDatePicker->setMinDate(date);
		}
		else
		{
			maAlert("Error", "Please fill all the required fields.", "OK", "", "");
		}
    }
    else if (button == mGetMinDate)
    {
        struct Date theDate = mDatePicker->getMinDate();
        mGetMinDateValue->setText("MinDate: " + MAUtil::integerToString(theDate.day)+ "-" +
		MAUtil::integerToString(theDate.month) + "-" + MAUtil::integerToString(theDate.year));
        printf("get min date : %d-%d-%d", theDate.day, theDate.month, theDate.year);
    }
}
コード例 #11
0
	void MoSyncCamController::exportImageToGalleryRequested()
	{
		maAlert("Save image", "Image saving is not yet available", "OK", NULL, NULL);
	}
コード例 #12
0
ファイル: NativeScreen.cpp プロジェクト: N00bKefka/MoSync
/**
 * Handle widget events.
 * @param event A MoSync event data structure.
 */
void NativeScreen::customEvent(const MAEvent& event)
{
	// Get the information sent by the widget.
	MAWidgetEventData* widgetEventData = (MAWidgetEventData*) event.data;

	if ( event.type == EVENT_TYPE_IMAGE_PICKER)
	{
		if ( event.imagePickerState == 1 )
		{
			// ready, get handle
			MAHandle myImage = event.imagePickerItem;

			char checkboxBuffer[BUF_SIZE];
			maWidgetGetProperty(mEventReturnTypeCheckbox, MAW_CHECK_BOX_CHECKED, checkboxBuffer, BUF_SIZE);
	        MAUtil::String value = MAUtil::lowerString(checkboxBuffer);
	        if ( strcmp(value.c_str(),"true") == 0 )
			{
				MAHandle hImage = maCreatePlaceholder();
				int dataSize = maGetDataSize(event.imagePickerItem);
				int createImageRes= maCreateImageFromData(hImage, event.imagePickerItem, 0, dataSize);

				// Used for testing only.
				MAUtil::String info = "Ready.Size = " + MAUtil::integerToString(dataSize) +
						"res = " + MAUtil::integerToString(createImageRes) +
						", mime type = " + MAUtil::integerToString(event.imagePickerEncodingType);

				if ( createImageRes != RES_OK )
				{
					maAlert("Memory Warning", " The image cannot be created. Try again", NULL, NULL, NULL);
					maWidgetSetProperty(mEventReturnTypeCheckbox, MAW_CHECK_BOX_CHECKED, "false");
					// If the Android VM gets an out of memory exception, get the image handle instead.
					maImagePickerOpen();
				}
				else
				{
					char imgHandle[256];
					sprintf(imgHandle, "%d", hImage);
					int resCode = maWidgetSetProperty(mPreview, MAW_IMAGE_IMAGE, imgHandle);
				}

				maDestroyPlaceholder(hImage);
			}
			else
			{
				char buffer[256];
				sprintf(buffer, "%d", myImage);
				int resCode = maWidgetSetProperty(mPreview, MAW_IMAGE_IMAGE, buffer);
			}

			setLabelText(mLabel, "Preview is available");
		}
		else
		{
			setLabelText(mLabel, "The user canceled the image selection");
		}
	}

	// Check that the event was a click (touch) event.
	if (widgetEventData->eventType == MAW_EVENT_CLICKED)
	{
		// Handle the event emitted by the widget
		widgetClicked(widgetEventData->widgetHandle);
	}
}
コード例 #13
0
/**
 * Notifies that restoreTransactions() has failed.
 * @param errorCode The reason why it failed.
 * Platform: iOS and Android.
 */
void ApplicationController::purchaseRestoreError(int errorCode)
{
	char buffer[BUF_SIZE];
	sprintf(buffer, "Restoring products failed with error code %d", errorCode);
	maAlert("Restore error", "restore failed" , "OK", NULL, NULL);
}
コード例 #14
0
/**
 * Main screen is notified of a purchase error.
 * @param errorMessage.
 */
void MainScreen::productError(MAUtil::String errorMessage)
{
	// Another purchase can now be requested.
	mBuyButton->setEnabled(true);
	maAlert("Purchase error", errorMessage.c_str(), "OK","","");
}