Filedownload added

This commit is contained in:
Carsten Hilmer 2016-01-22 00:34:27 +01:00
parent 3333e9eb4a
commit d22c3ce5b1
27 changed files with 238 additions and 212 deletions

View File

@ -1,29 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />

View File

@ -1,12 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CUSTOM_FILTER" value="raataar_wrk.db" />
<option name="TOOL_WINDOW_LOG_LEVEL" value="INFO" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
</component>
<component name="ChangeListManager">
<list default="true" id="1a60bf2a-41b9-42f3-a21a-2b8a537063de" name="Default" comment="" />
<list default="true" id="037b53b3-16f7-464c-81ab-ea3c4405c53b" name="Default" comment="" />
<ignored path="android.iws" />
<ignored path=".idea/workspace.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -26,51 +21,11 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="app.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/assets/www/js/app.js">
<file leaf-file-name="controllers.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/assets/www/js/controllers.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="37" column="0" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="AndroidManifest.xml" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.21755028">
<caret line="7" column="65" selection-start-line="7" selection-start-column="65" selection-end-line="7" selection-end-column="65" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="strings.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/res/values/strings.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="billing_key_param.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/res/values/billing_key_param.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="AndroidManifest.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CordovaLib/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<state vertical-scroll-proportion="0.2505669">
<caret line="73" column="7" selection-start-line="73" selection-start-column="7" selection-end-line="73" selection-end-column="7" />
<folding />
</state>
</provider>
@ -1004,7 +959,7 @@
</option>
<option name="modificationStamps">
<map>
<entry key="C:\Ionic\Ionic\git\wolle-rosen-kaufen\platforms\android" value="5807070785220" />
<entry key="C:\Ionic\Ionic\git\wolle-rosen-kaufen\platforms\android" value="5807086803450" />
</map>
</option>
<option name="projectBuildClasspath">
@ -1289,8 +1244,7 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/assets/www/js/app.js" />
<option value="$PROJECT_DIR$/AndroidManifest.xml" />
<option value="$PROJECT_DIR$/assets/www/js/controllers.js" />
</list>
</option>
</component>
@ -1327,20 +1281,9 @@
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane" />
<pane id="Scratches" />
<pane id="AndroidView">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="android" />
<option name="myItemType" value="com.android.tools.idea.navigator.nodes.AndroidViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="Gradle Scripts" />
<option name="myItemType" value="com.android.tools.idea.navigator.nodes.AndroidBuildScriptsGroupNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="android" />
@ -1350,18 +1293,16 @@
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="ProjectPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="android.sdk.path" value="C:/Program Files (x86)/Android/android-sdk" />
<property name="recentsLimit" value="5" />
<property name="ANDROID_EXTENDED_DEVICE_CHOOSER_SERIALS" value="CB5A1UMZYM" />
<property name="ANDROID_EXTENDED_DEVICE_CHOOSER_AVD" value="MyAvd0" />
<property name="last_opened_file_path" value="D:/_PROJEKTE_/Android_NAS/android-playstore-stuff/KeyStoreAPK/raataar.jks" />
<property name="ExportApk.ApkPath" value="C:\Ionic\Ionic\git\wolle-rosen-kaufen\platforms\android" />
<property name="ExportApk.Flavors" value="" />
<property name="ExportApk.BuildType" value="release" />
<property name="FullScreen" value="false" />
</component>
<component name="RunManager" selected="Android Application.android">
<configuration default="true" type="AndroidRunConfigurationType" factoryName="Android Application">
@ -1546,58 +1487,47 @@
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1a60bf2a-41b9-42f3-a21a-2b8a537063de" name="Default" comment="" />
<created>1452811340653</created>
<changelist id="037b53b3-16f7-464c-81ab-ea3c4405c53b" name="Default" comment="" />
<created>1453414443230</created>
<option name="number" value="Default" />
<updated>1452811340653</updated>
<updated>1453414443230</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="1912" y="-8" width="1696" height="1066" extended-state="6" />
<editor active="false" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32941177" sideWeight="0.49573562" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.36813188" sideWeight="0.35268947" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32941177" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32941177" sideWeight="0.4978678" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Android" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.36813188" sideWeight="0.6473105" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Gradle Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32941177" sideWeight="0.5042644" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Android" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Gradle Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.28667483" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Gradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
@ -1606,15 +1536,7 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/assets/www/js/app.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="37" column="0" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/AndroidManifest.xml">
<entry file="file://$PROJECT_DIR$/assets/www/js/controllers.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
@ -1622,73 +1544,10 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/values/strings.xml">
<entry file="file://$PROJECT_DIR$/assets/www/js/controllers.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/values/billing_key_param.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CordovaLib/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/assets/www/js/app.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="37" column="0" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CordovaLib/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/values/strings.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/values/billing_key_param.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/xml/config.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.21755028">
<caret line="7" column="65" selection-start-line="7" selection-start-column="65" selection-end-line="7" selection-end-column="65" />
<state vertical-scroll-proportion="0.2505669">
<caret line="73" column="7" selection-start-line="73" selection-start-column="7" selection-end-line="73" selection-end-column="7" />
<folding />
</state>
</provider>

View File

@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer) {
$scope.preis="";
$scope.name="";
@ -74,6 +74,45 @@ angular.module('starter.controllers', [])
}
alert("SUCCESS: \r\n"+strResult );
*/
var link = 'http://api.raataar.de/rosen/kauf.php';
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
$scope.filetodownload = res.data;
// File for download
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
alert(url);
// File name only
var filename = url.split("/").pop();
alert(filename);
// Save location
//var targetPath = cordova.file.externalRootDirectory + filename;
var targetPath = cordova.file.applicationStorageDirectory + filename;
alert(targetPath);
$scope.targetPath='';
$scope.targetPath=targetPath;
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
$scope.item={name: $scope.name, bild: $scope.targetPath};
$scope.items.push($scope.item);
alert ($scope.targetPath);
$database.setBuys($scope.name,$scope.targetPath);
}, function (error) {
console.log('Error');
}, function (progress) {
// PROGRESS HANDLING GOES HERE
});
return false;
});
}
function errorBuyHandler (error) {

View File

@ -7,7 +7,7 @@
<div class="item item-divider oleo">Hier können Sie Ihre gekauften Rosen ansehen oder nochmals versenden!</div>
<a class="item item-thumbnail-left item-button-right" href="#" ng-repeat="i in items" ng-model="items">
<img src="img/rose1.png">
<img ng-src="{{i.bild}}>
<h1>{{i.name}}</h1>
<p>{{i.freitext}} </p>
<div class="buttons" style="margin-top:30px;">

View File

@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer) {
$scope.preis="";
$scope.name="";
@ -74,6 +74,45 @@ angular.module('starter.controllers', [])
}
alert("SUCCESS: \r\n"+strResult );
*/
var link = 'http://api.raataar.de/rosen/kauf.php';
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
$scope.filetodownload = res.data;
// File for download
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
alert(url);
// File name only
var filename = url.split("/").pop();
alert(filename);
// Save location
//var targetPath = cordova.file.externalRootDirectory + filename;
var targetPath = cordova.file.applicationStorageDirectory + filename;
alert(targetPath);
$scope.targetPath='';
$scope.targetPath=targetPath;
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
$scope.item={name: $scope.name, bild: $scope.targetPath};
$scope.items.push($scope.item);
alert ($scope.targetPath);
$database.setBuys($scope.name,$scope.targetPath);
}, function (error) {
console.log('Error');
}, function (progress) {
// PROGRESS HANDLING GOES HERE
});
return false;
});
}
function errorBuyHandler (error) {

View File

@ -7,7 +7,7 @@
<div class="item item-divider oleo">Hier können Sie Ihre gekauften Rosen ansehen oder nochmals versenden!</div>
<a class="item item-thumbnail-left item-button-right" href="#" ng-repeat="i in items" ng-model="items">
<img src="img/rose1.png">
<img ng-src="{{i.bild}}>
<h1>{{i.name}}</h1>
<p>{{i.freitext}} </p>
<div class="buttons" style="margin-top:30px;">

View File

@ -14,6 +14,10 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
$rootScope.storeinit=99;
$ionicPlatform.registerBackButtonAction(function(event) {
// Handle Android back button to avoid the application exits accidentaly
@ -56,6 +60,7 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
function successHandler (result) {
/*
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
@ -63,10 +68,13 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
*/
$rootScope.storeinit=1;
}
function errorHandler (error) {
alert("ERROR: \r\n"+error );
//alert("ERROR: \r\n"+error );
$rootScope.storeinit=0;
}

View File

@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer) {
$scope.preis="";
$scope.name="";
@ -25,6 +25,7 @@ angular.module('starter.controllers', [])
};
$scope.loaddata = function() {
$scope.items=[];
$database.getAllBuys().then(function (result) {
@ -51,6 +52,7 @@ angular.module('starter.controllers', [])
};
function successBuyHandler (result) {
/*
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
@ -58,10 +60,12 @@ angular.module('starter.controllers', [])
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
$timeout(buysuccessHandler, 1000);
*/
$timeout(consumesuccessHandler, 1000);
}
function successConsumeHandler (result) {
/*
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
@ -69,26 +73,73 @@ angular.module('starter.controllers', [])
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
*/
var link = 'http://api.raataar.de/rosen/kauf.php';
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
$scope.filetodownload = res.data;
// File for download
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
alert(url);
// File name only
var filename = url.split("/").pop();
alert(filename);
// Save location
//var targetPath = cordova.file.externalRootDirectory + filename;
var targetPath = cordova.file.applicationStorageDirectory + filename;
alert(targetPath);
$scope.targetPath='';
$scope.targetPath=targetPath;
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
$scope.item={name: $scope.name, bild: $scope.targetPath};
$scope.items.push($scope.item);
alert ($scope.targetPath);
$database.setBuys($scope.name,$scope.targetPath);
}, function (error) {
console.log('Error');
}, function (progress) {
// PROGRESS HANDLING GOES HERE
});
return false;
});
}
function errorBuyHandler (error) {
alert("ERROR: \r\n"+error );
var alertPopup = $ionicPopup.alert({
title: 'Oh Nein',
template: 'Der Kauf konnte nicht durchgeführt werden.'
});
alertPopup.then(function(res) {
console.log('Der Kauf konnte nicht durchgeführt werden');
});
}
function errorConsumeHandler (error) {
alert("ERROR: \r\n"+error );
var alertPopup = $ionicPopup.alert({
title: 'Oh Nein',
template: 'Der Kauf wurde durchgeführt, aber deine Rosen konnten freigeschaltet werden.'
});
alertPopup.then(function(res) {
console.log('Der Kauf wurde durchgeführt, aber deine Rosen konnten freigeschaltet werden');
});
}
function buysuccessHandler (result) {
function consumesuccessHandler (result) {
inappbilling.consumePurchase(successConsumeHandler, errorConsumeHandler, $scope.preis);
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
}
$scope.buyRose = function() {
@ -96,8 +147,23 @@ angular.module('starter.controllers', [])
//alert($scope.preis);
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
if ($rootScope.storeinit==1){
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
}
else{
var alertPopup = $ionicPopup.alert({
title: 'Achtung',
template: 'Der Google-Store konnte nicht initialisiert werden.'
});
alertPopup.then(function(res) {
console.log('Store steht nicht zur Verfuegung');
});
}
}
}
})

View File

@ -7,7 +7,7 @@
<div class="item item-divider oleo">Hier können Sie Ihre gekauften Rosen ansehen oder nochmals versenden!</div>
<a class="item item-thumbnail-left item-button-right" href="#" ng-repeat="i in items" ng-model="items">
<img src="img/rose1.png">
<img ng-src="{{i.bild}}>
<h1>{{i.name}}</h1>
<p>{{i.freitext}} </p>
<div class="buttons" style="margin-top:30px;">

View File

@ -18,7 +18,7 @@ document.getElementById(id+'Link').style.display = 'none';
<body>
<h1>Lint Report</h1>
<div class="titleSeparator"></div>
Check performed at Thu Jan 21 22:01:40 CET 2016.<br/>
Check performed at Fri Jan 22 00:13:17 CET 2016.<br/>
0 errors and 0 warnings found:<br/><br/>
Congratulations!
</body>

View File

@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Jan 21 22:00:45 CET 2016
#Fri Jan 22 00:12:54 CET 2016
sdk.dir=C\:\\Program Files (x86)\\Android\\android-sdk

View File

@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer) {
$scope.preis="";
$scope.name="";
@ -74,6 +74,45 @@ angular.module('starter.controllers', [])
}
alert("SUCCESS: \r\n"+strResult );
*/
var link = 'http://api.raataar.de/rosen/kauf.php';
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
$scope.filetodownload = res.data;
// File for download
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
alert(url);
// File name only
var filename = url.split("/").pop();
alert(filename);
// Save location
//var targetPath = cordova.file.externalRootDirectory + filename;
var targetPath = cordova.file.applicationStorageDirectory + filename;
alert(targetPath);
$scope.targetPath='';
$scope.targetPath=targetPath;
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
$scope.item={name: $scope.name, bild: $scope.targetPath};
$scope.items.push($scope.item);
alert ($scope.targetPath);
$database.setBuys($scope.name,$scope.targetPath);
}, function (error) {
console.log('Error');
}, function (progress) {
// PROGRESS HANDLING GOES HERE
});
return false;
});
}
function errorBuyHandler (error) {

View File

@ -7,7 +7,7 @@
<div class="item item-divider oleo">Hier können Sie Ihre gekauften Rosen ansehen oder nochmals versenden!</div>
<a class="item item-thumbnail-left item-button-right" href="#" ng-repeat="i in items" ng-model="items">
<img src="img/rose1.png">
<img ng-src="{{i.bild}}>
<h1>{{i.name}}</h1>
<p>{{i.freitext}} </p>
<div class="buttons" style="margin-top:30px;">