<|start_filename|>demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/demo/platforms/ios/www/plugins/org.pbernasconi.activityIndicator/www/activityIndicator.js<|end_filename|>
cordova.define("org.pbernasconi.activityIndicator.ActivityIndicator", function(require, exports, module) { var ActivityIndicator = {
  // 1. type    @string
  // 2. dim     @bool
  // 3. text    @string
  // 4. detail  @string
    show: function (type, dim, text, detail) {

    	text = text || "Please wait...";
      detail = detail || '';

        cordova.exec(null, null, "ActivityIndicator", "show", [type, dim, text, detail]);
    },
    hide: function () {
        cordova.exec(null, null, "ActivityIndicator", "hide", []);
    }
};

module.exports = ActivityIndicator;
});


<|start_filename|>demo/plugins/org.pbernasconi.progressIndicator/package.json<|end_filename|>
{
    "version": "1.1.0",
    "name": "org.pbernasconi.progressindicator",
    "cordova_name": "Progress Indicator",
    "description": "Progress Indicator plugin for Cordova 3.X that allows you to show a loading spinner in your Cordova's app.",
    "license": "Apache 2.0 License",
    "repo": "https://github.com/pbernasconi/cordova-progressIndicator.git",
    "keywords": [
        "progress",
        "indicator",
        "activity",
        "loading",
        "load",
        "progressindicator"
    ],
    "platforms": [
        "ios",
        "android"
    ],
    "engines": [
        {
            "name": "cordova",
            "version": ">=3.0.0"
        }
    ]
}

<|start_filename|>demo/plugins/org.pbernasconi.progressIndicator/src/android/ProgressIndicator.java<|end_filename|>
package org.apache.cordova.plugin;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.app.ProgressDialog;

public class ProgressIndicator extends CordovaPlugin {

    private ProgressDialog progressIndicator = null;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("show")) {
            String text = args.getString(0);
            show(text);
            callbackContext.success();
            return true;
        } else if (action.equals("hide")) {
            hide();
            callbackContext.success();
            return true;
        }

        return false;
    }

    /**
     * This show the ProgressDialog
     *
     * @param text - Message to display in the Progress Dialog
     */
    public void show(String text) {
        progressIndicator = ProgressDialog.show(this.cordova.getActivity(), "", text);
    }

    /**
     * This hide the ProgressDialog
     */
    public void hide() {
        if (progressIndicator != null) {
            progressIndicator.dismiss();
            progressIndicator = null;
        }
    }
}


<|start_filename|>demo/www/js/app.js<|end_filename|>
angular.module('starter', ['ionic'])

    .run(function ($ionicPlatform) {
        $ionicPlatform.ready(function () {

            if (window.cordova && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            }
            if (window.StatusBar) {
                StatusBar.styleDefault();
            }
        });
    })

    .controller('AppCtrl', function ($scope, $timeout) {
        console.log('AppCtrl');

        $scope.loadProgressIndicator = function (type) {
            switch (type) {
                case  'indeterminate-simple':
                    ProgressIndicator.showSimple(true);
                    timeout(5000);
                    break;
                case  'indeterminate-simple-then-hide':
                    ProgressIndicator.showSimple(true);
                    ProgressIndicator.hide();
                    break;
                case  'indeterminate-label':
                    ProgressIndicator.showSimpleWithLabel(false, 'custom Label');
                    timeout(5000);
                    break;
                case  'indeterminate-label-detail':
                    ProgressIndicator.showSimpleWithLabelDetail(false, 'custom Label', 'custom detail');
                    timeout(5000);
                    break;
                case  'determinate-simple':
                    ProgressIndicator.showDeterminate(false);
                    break;
                case  'determinate-simple-label':
                    ProgressIndicator.showDeterminateWithLabel(false, 100000, 'custom label');
                    break;
                case  'determinate-annular':
                    ProgressIndicator.showAnnular(false);
                    break;
                case  'determinate-annular-label':
                    ProgressIndicator.showAnnularWithLabel(false, 50000, 'custom label');
                    break;
                case  'determinate-bar':
                    ProgressIndicator.showBar(false, 100000);
                    break;
                case  'determinate-bar-label':
                    ProgressIndicator.showBarWithLabel(false, 100000, 'custom label');
                    break;
                case 'success':
                    ProgressIndicator.showSuccess(false, 'success');
                    timeout(5000);
                    break;
                case 'text-top':
                    ProgressIndicator.showText(false, 'text at the TOP', 'top');
                    timeout(5000);
                    break;
                case 'text-bottom':
                    ProgressIndicator.showText(false, 'text at the BOTTOM', 'bottom');
                    timeout(5000);
                    break;
            }

            function timeout(time) {
                $timeout(function () {
                    ProgressIndicator.hide();
                }, time);

            }
        }
    });


<|start_filename|>demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.activityIndicator/src/ios/ActivityIndicator.h<|end_filename|>
#import <Cordova/CDV.h>
#import "MBProgressHUD.h"

@interface ActivityIndicator: CDVPlugin {
}

@property (nonatomic, assign) MBProgressHUD* activityIndicator;

- (void)show:(CDVInvokedUrlCommand*)command;
- (void)hide:(CDVInvokedUrlCommand*)command;

@end


<|start_filename|>demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/src/android/ActivityIndicator.java<|end_filename|>
package org.apache.cordova.plugin;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.app.ProgressDialog;

public class ActivityIndicator extends CordovaPlugin {

	private ProgressDialog activityIndicator = null;

	@Override
	public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
		if (action.equals("show")) {
			String text = args.getString(0);
			show(text);
			callbackContext.success();
			return true;
		} else if (action.equals("hide")) {
			hide();
			callbackContext.success();
			return true;
		}

		return false;
	}

	/**
	 * This show the ProgressDialog
	 * @param text - Message to display in the Progress Dialog
	 */
	public void show(String text) {
		activityIndicator = ProgressDialog.show(this.cordova.getActivity(), "", text);
	}

	/**
	 * This hide the ProgressDialog
	 */
	public void hide() {
		if (activityIndicator != null) {
			activityIndicator.dismiss();
			activityIndicator = null;
		}
	}
}

<|start_filename|>demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/demo/plugins/org.pbernasconi.progressIndicator/demo/www/js/app.js<|end_filename|>
angular.module('starter', ['ionic'])

  .run(function ($ionicPlatform) {
    $ionicPlatform.ready(function () {

      if (window.cordova && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      }
      if (window.StatusBar) {
        StatusBar.styleDefault();
      }
    });
  })

  .controller('AppCtrl', function ($scope, $timeout) {
    console.log('AppCtrl');

    $scope.loadActivityIndicator = function (type) {
      switch (type) {
        case  'indeterminate-simple':
          ActivityIndicator.show('indeterminate-simple', false);
          break;
        case  'indeterminate-label':
          ActivityIndicator.show('indeterminate-label', false, 'custom Label');
          break;
        case  'indeterminate-label-detail':
          ActivityIndicator.show('indeterminate-label', false, 'custom Label', 'custom detail');
          break;
        case  'determinate-simple':
          ActivityIndicator.show('determinate-simple', false);
          break;
        case  'determinate-annular':
          ActivityIndicator.show('determinate-annular', false);
          break;
        case  'determinate-bar':
          ActivityIndicator.show('determinate-bar', false);
          break;
        case 'success':
          ActivityIndicator.show('success', false);
          break;

      }
    }
  });


<|start_filename|>src/android/ProgressIndicator.java<|end_filename|>
package org.apache.cordova.progressindicator;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.app.ProgressDialog;

public class ProgressIndicator extends CordovaPlugin {

    private ProgressDialog progressIndicator = null;
	private static final String LOG_TAG = "ProgressIndicator";

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("show")) {
            show();
            callbackContext.success();
            return true;
        } else if (action.equals("showSimple")) {
            show();
            callbackContext.success();
            return true;
        } else if (action.equals("showSimpleWithLabel")) {
            String title = args.getString(1);
            show(title);
            callbackContext.success();
            return true;
        } else if (action.equals("showSimpleWithLabelDetail")) {
            String title = args.getString(1);
            String text = args.getString(2);
            show(title, text, true);
            callbackContext.success();
            return true;
        } else if (action.equals("showText")) {
            String title = args.getString(1);
			String text = args.getString(2);
            show(title, text, false);
            callbackContext.success();
            return true;
        } else if (action.equals("hide")) {
            hide();
            callbackContext.success();
            return true;
        } else {
            callbackContext.error("Not supported call. On Android we only support show, showSimple, showSimpleWithLabel and showSimpleWithLabelDetail");
		}

        return false;
    }

    /**
     * This show the ProgressDialog
     *
     * @param text - Message to display in the Progress Dialog
     */
    public void show() {
        progressIndicator = new ProgressDialog(cordova.getActivity());
		progressIndicator.show();
    }

    /**
     * This show the ProgressDialog
     *
     * @param text - Message to display in the Progress Dialog
     */
    public void show(String text) {
        progressIndicator = new ProgressDialog(cordova.getActivity());
		progressIndicator.setTitle(text);
		progressIndicator.show();
    }

    /**
     * This show the ProgressDialog
     *
     * @param text - Message to display in the Progress Dialog
     */
    public void show(String title, String detail, Boolean withTitle) {
        progressIndicator = new ProgressDialog(cordova.getActivity());
		if(withTitle)
			progressIndicator.setTitle(title);
		progressIndicator.setMessage(detail);
		progressIndicator.show();
    }

    /**
     * This hide the ProgressDialog
     */
    public void hide() {
        if (progressIndicator != null) {
            progressIndicator.dismiss();
            progressIndicator = null;
        }
    }
}


<|start_filename|>src/ios/ProgressIndicator.h<|end_filename|>
#import <Cordova/CDV.h>
#import "MBProgressHUD.h"

@interface ProgressIndicator: CDVPlugin {
}

@property (nonatomic, assign) MBProgressHUD* progressIndicator;

- (void)showSimple:(CDVInvokedUrlCommand*)command;
- (void)showSimpleWithLabel:(CDVInvokedUrlCommand*)command;
- (void)showSimpleWithLabelDetail:(CDVInvokedUrlCommand*)command;
- (void)showText:(CDVInvokedUrlCommand*)command;

- (void)showDeterminate:(CDVInvokedUrlCommand*)command;
- (void)showDeterminateWithLabel:(CDVInvokedUrlCommand*)command;
- (void)showDeterminateAnnular:(CDVInvokedUrlCommand*)command;
- (void)showDeterminateAnnularWithLabel:(CDVInvokedUrlCommand*)command;
- (void)showDeterminateBar:(CDVInvokedUrlCommand*)command;
- (void)showDeterminateBarWithLabel:(CDVInvokedUrlCommand*)command;
- (void)showSuccess:(CDVInvokedUrlCommand*)command;
//- (void)showMultiple:(CDVInvokedUrlCommand*)command;

- (void)hide:(CDVInvokedUrlCommand*)command;

- (void)progressTask:(NSNumber*)increment;

@end