forked from purplecabbage/phonegap-plugins
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'CoreDump' of https://github.com/purplecabbage/phonegap-…
…plugins into CoreDump
- Loading branch information
Showing
169 changed files
with
1,155 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
.svn | ||
*/.svn/* | ||
*/.svn/* | ||
build |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
// | ||
// SAiOSAdPlugin.m | ||
// Ad Plugin for PhoneGap | ||
// | ||
// Created by shazron on 10-07-12. | ||
// Copyright 2010 Shazron Abdullah. All rights reserved. | ||
// | ||
|
||
#import "SAiOSAdPlugin.h" | ||
|
||
@interface SAiOSAdPlugin(PrivateMethods) | ||
|
||
- (void) __prepare:(BOOL)atBottom; | ||
- (void) __showAd:(BOOL)show; | ||
|
||
@end | ||
|
||
|
||
@implementation SAiOSAdPlugin | ||
|
||
@synthesize bannerView; | ||
@synthesize bannerIsVisible; | ||
@synthesize bannerIsInitialized; | ||
@synthesize bannerIsAtBottom; | ||
@synthesize portraitContentIndentifier; | ||
@synthesize landscapeContentIndentifier; | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Public Methods | ||
|
||
- (void) prepare:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options | ||
{ | ||
|
||
// [[NSNotificationCenter defaultCenter] addObserver:self | ||
// selector:@selector(onOrientationChange) | ||
// name:@"UIDeviceOrientationDidChangeNotification" object:nil]; | ||
|
||
NSUInteger argc = [arguments count]; | ||
if (argc > 1) { | ||
return; | ||
} | ||
|
||
NSString* atBottomValue = [arguments objectAtIndex:0]; | ||
[self __prepare:[atBottomValue boolValue]]; | ||
} | ||
|
||
- (void) showAd:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options | ||
{ | ||
NSUInteger argc = [arguments count]; | ||
if (argc > 1) { | ||
return; | ||
} | ||
|
||
NSString* showValue = [arguments objectAtIndex:0]; | ||
[self __showAd:[showValue boolValue]]; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Private Methods | ||
|
||
-(NSString*) getADBannerContentSizeIdentifierPortrait | ||
{ | ||
if ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 4.2 ) | ||
{ | ||
return ADBannerContentSizeIdentifierPortrait; | ||
} | ||
|
||
return ADBannerContentSizeIdentifier320x50; | ||
} | ||
|
||
-(NSString*) getADBannerContentSizeIdentifierLandscape | ||
{ | ||
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.2) | ||
{ | ||
return ADBannerContentSizeIdentifierLandscape; | ||
} | ||
|
||
return ADBannerContentSizeIdentifier480x32; | ||
} | ||
|
||
- (void) __prepare:(BOOL)atBottom | ||
{ | ||
NSLog(@"SAiOSAdPlugin Prepare Ad At Bottom: %d", atBottom); | ||
|
||
self.portraitContentIndentifier = [self getADBannerContentSizeIdentifierPortrait]; | ||
self.landscapeContentIndentifier = [self getADBannerContentSizeIdentifierLandscape]; | ||
|
||
Class adBannerViewClass = NSClassFromString(@"ADBannerView"); | ||
if (adBannerViewClass && !self.bannerView) | ||
{ | ||
bannerView = [[ADBannerView alloc] initWithFrame:CGRectZero]; | ||
|
||
bannerView.requiredContentSizeIdentifiers = [NSSet setWithObjects: self.portraitContentIndentifier, self.landscapeContentIndentifier, nil]; | ||
|
||
bannerView.delegate = self; | ||
|
||
self.bannerIsAtBottom = atBottom; | ||
self.bannerIsVisible = NO; | ||
self.bannerIsInitialized = YES; | ||
} | ||
} | ||
|
||
- (void) __showAd:(BOOL)show | ||
{ | ||
NSLog(@"SAiOSAdPlugin Show Ad: %d", show); | ||
|
||
if (!self.bannerIsInitialized) | ||
{ | ||
[self __prepare:NO]; | ||
} | ||
|
||
if (!(NSClassFromString(@"ADBannerView") && self.bannerView)) | ||
{ // ad classes not available | ||
return; | ||
} | ||
|
||
if (show == self.bannerIsVisible) { // same state, nothing to do | ||
return; | ||
} | ||
|
||
CGRect bannerViewFrame = bannerView.frame; | ||
CGRect webViewFrame = webView.frame; | ||
CGRect screenFrame = [ [ UIScreen mainScreen ] applicationFrame ]; | ||
|
||
//CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height; | ||
|
||
[UIView beginAnimations:@"blah" context:NULL]; | ||
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; | ||
|
||
if (show) | ||
{ | ||
CGFloat bannerHeight = 50.0; | ||
|
||
// First, setup the banner's content size and adjustment based on the current orientation | ||
if(UIInterfaceOrientationIsLandscape(self.appViewController.interfaceOrientation)) | ||
{ | ||
bannerView.currentContentSizeIdentifier = self.landscapeContentIndentifier; | ||
bannerHeight = 32.0; | ||
} | ||
else | ||
{ | ||
bannerView.currentContentSizeIdentifier = self.portraitContentIndentifier; | ||
} | ||
|
||
bannerViewFrame.size.height = bannerHeight; | ||
bannerViewFrame.size.width = screenFrame.size.width; | ||
|
||
if (self.bannerIsAtBottom) | ||
{ | ||
bannerViewFrame.origin.y = screenFrame.size.height - bannerViewFrame.size.height; | ||
} | ||
else // aka: at the top | ||
{ | ||
webViewFrame.origin.y += bannerViewFrame.size.height; | ||
} | ||
|
||
webViewFrame.size.height -= bannerViewFrame.size.height; | ||
webView.frame = webViewFrame; | ||
|
||
[ webView.superview addSubview:self.bannerView]; | ||
|
||
self.bannerView.frame = bannerViewFrame; | ||
|
||
bannerView.backgroundColor = [UIColor blackColor]; | ||
|
||
self.bannerIsVisible = YES; | ||
} | ||
else | ||
{ | ||
if (self.bannerIsAtBottom) | ||
{ | ||
|
||
} | ||
else // aka: at the top | ||
{ | ||
webViewFrame.origin.y = screenFrame.origin.y; | ||
} | ||
|
||
|
||
webViewFrame.size.height += bannerViewFrame.size.height; | ||
|
||
webView.frame = webViewFrame; | ||
[ bannerView removeFromSuperview]; | ||
|
||
|
||
self.bannerIsVisible = NO; | ||
} | ||
|
||
[UIView commitAnimations]; | ||
} | ||
|
||
//-(void)onOrientationChange | ||
//{ | ||
// self.bannerIsVisible = !self.bannerIsVisible; | ||
// [ self __showAd:(!self.bannerIsVisible)]; | ||
// | ||
//} | ||
|
||
#pragma mark - | ||
#pragma ADBannerViewDelegate | ||
|
||
- (void)bannerViewDidLoadAd:(ADBannerView *)banner | ||
{ | ||
Class adBannerViewClass = NSClassFromString(@"ADBannerView"); | ||
if (adBannerViewClass) | ||
{ | ||
NSString* jsString = | ||
@"(function(){" | ||
"var e = document.createEvent('Events');" | ||
"e.initEvent('iAdBannerViewDidLoadAdEvent');" | ||
"document.dispatchEvent(e);" | ||
"})();"; | ||
|
||
[super writeJavascript:jsString]; | ||
} | ||
} | ||
|
||
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError*)error | ||
{ | ||
Class adBannerViewClass = NSClassFromString(@"ADBannerView"); | ||
if (adBannerViewClass) | ||
{ | ||
NSString* jsString = | ||
@"(function(){" | ||
"var e = document.createEvent('Events');" | ||
"e.initEvent('iAdBannerViewDidFailToReceiveAdWithErrorEvent');" | ||
"e.error = '%@';" | ||
"document.dispatchEvent(e);" | ||
"})();"; | ||
|
||
[super writeJavascript:[NSString stringWithFormat:jsString, [error description]]]; | ||
} | ||
} | ||
|
||
- (void)bannerViewActionDidFinish:(ADBannerView *)banner | ||
{ | ||
|
||
} | ||
|
||
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave | ||
{ | ||
NSLog(@"Banner view is beginning an ad action"); | ||
BOOL shouldExecuteAction = YES;//[self allowActionToRun]; // your application implements this method | ||
if (!willLeave && shouldExecuteAction) | ||
{ | ||
// insert code here to suspend any services that might conflict with the advertisement | ||
} | ||
return shouldExecuteAction; | ||
} | ||
|
||
@end |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Phonegap ClipboardManager plugin | ||
* Omer Saatcioglu 2011 | ||
* | ||
*/ | ||
|
||
package com.saatcioglu.phonegap.clipboardmanager; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
|
||
import android.content.Context; | ||
import android.text.ClipboardManager; | ||
|
||
import com.phonegap.DroidGap; | ||
import com.phonegap.api.Plugin; | ||
import com.phonegap.api.PluginResult; | ||
|
||
public class ClipboardManagerPlugin extends Plugin { | ||
private static final String actionCopy = "copy"; | ||
private static final String actionPaste = "paste"; | ||
private static final String errorParse = "Couldn't get the text to copy"; | ||
private static final String errorUnknown = "Unknown Error"; | ||
|
||
private ClipboardManager mClipboardManager; | ||
|
||
public void setContext(DroidGap ctx) { | ||
super.setContext(ctx); | ||
mClipboardManager = (ClipboardManager) ctx | ||
.getSystemService(Context.CLIPBOARD_SERVICE); | ||
} | ||
|
||
/** | ||
* Executes the request and returns PluginResult. | ||
* | ||
* @param action | ||
* The action to execute. | ||
* @param args | ||
* JSONArry of arguments for the plugin. | ||
* @param callbackId | ||
* The callback id used when calling back into JavaScript. | ||
* @return A PluginResult object with a status and message. | ||
*/ | ||
public PluginResult execute(String action, JSONArray args, String callbackId) { | ||
if (action.equals(actionCopy)) { | ||
String arg = ""; | ||
try { | ||
arg = (String) args.get(0); | ||
mClipboardManager.setText(arg); | ||
} catch (JSONException e) { | ||
return new PluginResult(PluginResult.Status.ERROR, errorParse); | ||
} catch (Exception e) { | ||
return new PluginResult(PluginResult.Status.ERROR, errorUnknown); | ||
} | ||
return new PluginResult(PluginResult.Status.OK, arg); | ||
} else if (action.equals(actionPaste)) { | ||
String arg = (String) mClipboardManager.getText(); | ||
if (arg == null) { | ||
arg = ""; | ||
} | ||
return new PluginResult(PluginResult.Status.OK, arg); | ||
} else { | ||
return new PluginResult(PluginResult.Status.INVALID_ACTION); | ||
} | ||
} | ||
} |
Oops, something went wrong.