Skip to content

Commit

Permalink
tried to upload aar file to fix android 6 crash
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-LittleMonkey committed Oct 25, 2016
1 parent 4e3c6d0 commit f4c0cfe
Show file tree
Hide file tree
Showing 65 changed files with 6,289 additions and 1 deletion.
Binary file added ZBarScannerLibrary.aar
Binary file not shown.
Binary file added ZBarScannerLibrary_old.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion codenameone_library_appended.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#is an appended type property.
#
#Wed Jan 09 17:59:31 IST 2013
codename1.arg.android.xapplication=<activity android\:name\="com.dm.zbar.android.scanner.ZBarScannerActivity" android\:screenOrientation\="landscape" android\:label\="@string/app_name" />
codename1.arg.android.xapplication=<activity android\:name\="com.dm.zbar.android.scanner.ZBarScannerActivity" android\:screenOrientation\="landscape"/>
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.CAMERA"/><uses-feature android\:name\="android.hardware.camera" android\:required\="false"/>
codename1.arg.android.proguardKeep=\ -keep class net.sourceforge.zbar.** {*;}
Binary file removed lib/cn1-codescan.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified native/android/ZBarScannerLibrary.aar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.codename1.ext.codescan;

import android.app.Activity;
import android.content.Intent;
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.CodenameOneActivity;
import com.codename1.impl.android.IntentIntegrator;
import com.codename1.impl.android.IntentResultListener;
import com.codename1.ui.Display;
import java.util.Arrays;
import java.util.Collection;

public class NativeCodeScannerImpl implements IntentResultListener {

public void scanQRCode() {
Activity activity = AndroidNativeUtil.getActivity();
if (activity instanceof CodenameOneActivity) {
((CodenameOneActivity) activity).setIntentResultListener(this);
}
//this.callback = callback;
IntentIntegrator in = new IntentIntegrator(activity);
if(!in.initiateScan(IntentIntegrator.QR_CODE_TYPES, "QR_CODE_MODE")){
CodeScanner.scanErrorCallback(-1, "no scan app");

if (activity instanceof CodenameOneActivity) {
((CodenameOneActivity) activity).restoreIntentResultListener();
}
}
}

public void scanBarCode() {
Activity activity = AndroidNativeUtil.getActivity();
if (activity instanceof CodenameOneActivity) {
((CodenameOneActivity) activity).setIntentResultListener(this);
}
IntentIntegrator in = new IntentIntegrator(activity);
Collection<String> types = IntentIntegrator.PRODUCT_CODE_TYPES;
if(Display.getInstance().getProperty("scanAllCodeTypes", "false").equals("true")) {
types = IntentIntegrator.ALL_CODE_TYPES;
}
if(Display.getInstance().getProperty("android.scanTypes", null) != null) {
String[] arr = Display.getInstance().getProperty("android.scanTypes", null).split(";");
types = Arrays.asList(arr);
}

if(!in.initiateScan(types, "ONE_D_MODE")){
// restore old activity handling
CodeScanner.scanErrorCallback(-1, "no scan app");
if (activity instanceof CodenameOneActivity) {
((CodenameOneActivity) activity).restoreIntentResultListener();
}
}
}

public void onActivityResult(int requestCode, final int resultCode, Intent data) {
Activity activity = AndroidNativeUtil.getActivity();
if (requestCode == IntentIntegrator.REQUEST_CODE) {

if (resultCode == Activity.RESULT_OK) {
final String contents = data.getStringExtra("SCAN_RESULT");
final String formatName = data.getStringExtra("SCAN_RESULT_FORMAT");
final byte[] rawBytes = data.getByteArrayExtra("SCAN_RESULT_BYTES");
CodeScanner.scanCompletedCallback(contents, formatName, rawBytes);

} else if(resultCode == Activity.RESULT_CANCELED) {
CodeScanner.scanCanceledCallback();

} else {
CodeScanner.scanErrorCallback(resultCode, null);

}
}

// restore old activity handling
if (activity instanceof CodenameOneActivity) {
((CodenameOneActivity) activity).restoreIntentResultListener();
}
}

public boolean isSupported() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.sourceforge.zbar.Symbol;
import com.dm.zbar.android.scanner.*;


public class NativeScannerImpl {

public void scanQRCode() {
Expand All @@ -28,7 +29,11 @@ private void scanCode(boolean qrCode) {
}
com.codename1.impl.android.AndroidNativeUtil.startActivityForResult(intent, new IntentResultListener() {
public void onActivityResult(int requestCode, int resultCode, Intent data) {

Log.p( "res code:"+resultCode);
if (resultCode == Activity.RESULT_OK) {
String resultStr = data.getStringExtra(ZBarConstants.SCAN_RESULT);
Log.p("res string:"+resultStr);
QRScanner.getCallback().scanCompleted(data.getStringExtra(ZBarConstants.SCAN_RESULT), "QRCODE", data.getStringExtra(ZBarConstants.SCAN_RESULT).getBytes());
} else if (resultCode == Activity.RESULT_CANCELED) {
if (data != null) {
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions native/ios/CVZBarReaderViewControllerExt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import <Foundation/Foundation.h>
#if !TARGET_IPHONE_SIMULATOR
#import "ZBarReaderViewController.h"

@interface CVZBarReaderViewControllerExt : ZBarReaderViewController
@end
#endif
14 changes: 14 additions & 0 deletions native/ios/CVZBarReaderViewControllerExt.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import "CVZBarReaderViewControllerExt.h"
#if !TARGET_IPHONE_SIMULATOR

@implementation CVZBarReaderViewControllerExt
- (void) loadView
{
#ifdef CN1_USE_ARC
self.view = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)];
#else
self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)] autorelease];
#endif
}
@end
#endif
202 changes: 202 additions & 0 deletions native/ios/Decoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
//------------------------------------------------------------------------
// Copyright 2007-2010 (c) Jeff Brown <[email protected]>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_DECODER_H_
#define _ZBAR_DECODER_H_

/// @file
/// Decoder C++ wrapper

#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Decoder.h"
#endif

#include <string>

namespace zbar {

/// low-level bar width stream decoder interface.
/// identifies symbols and extracts encoded data

class Decoder {
public:

/// Decoder result handler.
/// applications should subtype this and pass an instance to
/// set_handler() to implement result processing
class Handler {
public:
virtual ~Handler() { }

/// invoked by the Decoder as decode results become available.
virtual void decode_callback(Decoder &decoder) = 0;
};

/// constructor.
Decoder ()
: _handler(NULL)
{
_decoder = zbar_decoder_create();
}

~Decoder ()
{
zbar_decoder_destroy(_decoder);
}

/// clear all decoder state.
/// see zbar_decoder_reset()
void reset ()
{
zbar_decoder_reset(_decoder);
}

/// mark start of a new scan pass.
/// see zbar_decoder_new_scan()
void new_scan ()
{
zbar_decoder_new_scan(_decoder);
}

/// process next bar/space width from input stream.
/// see zbar_decode_width()
zbar_symbol_type_t decode_width (unsigned width)
{
return(zbar_decode_width(_decoder, width));
}

/// process next bar/space width from input stream.
/// see zbar_decode_width()
Decoder& operator<< (unsigned width)
{
zbar_decode_width(_decoder, width);
return(*this);
}

/// retrieve color of @em next element passed to Decoder.
/// see zbar_decoder_get_color()
zbar_color_t get_color () const
{
return(zbar_decoder_get_color(_decoder));
}

/// retrieve last decoded symbol type.
/// see zbar_decoder_get_type()
zbar_symbol_type_t get_type () const
{
return(zbar_decoder_get_type(_decoder));
}

/// retrieve string name of last decoded symbol type.
/// see zbar_get_symbol_name()
const char *get_symbol_name () const
{
return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder)));
}

/// retrieve string name for last decode addon.
/// see zbar_get_addon_name()
/// @deprecated in 0.11
const char *get_addon_name () const
{
return(zbar_get_addon_name(zbar_decoder_get_type(_decoder)));
}

/// retrieve last decoded data in ASCII format as a char array.
/// see zbar_decoder_get_data()
const char *get_data_chars() const
{
return(zbar_decoder_get_data(_decoder));
}

/// retrieve last decoded data as a std::string.
/// see zbar_decoder_get_data()
const std::string get_data_string() const
{
return(std::string(zbar_decoder_get_data(_decoder),
zbar_decoder_get_data_length(_decoder)));
}

/// retrieve last decoded data as a std::string.
/// see zbar_decoder_get_data()
const std::string get_data() const
{
return(get_data_string());
}

/// retrieve length of decoded binary data.
/// see zbar_decoder_get_data_length()
int get_data_length() const
{
return(zbar_decoder_get_data_length(_decoder));
}

/// retrieve last decode direction.
/// see zbar_decoder_get_direction()
/// @since 0.11
int get_direction() const
{
return(zbar_decoder_get_direction(_decoder));
}

/// setup callback to handle result data.
void set_handler (Handler &handler)
{
_handler = &handler;
zbar_decoder_set_handler(_decoder, _cb);
zbar_decoder_set_userdata(_decoder, this);
}

/// set config for indicated symbology (0 for all) to specified value.
/// @see zbar_decoder_set_config()
/// @since 0.4
int set_config (zbar_symbol_type_t symbology,
zbar_config_t config,
int value)
{
return(zbar_decoder_set_config(_decoder, symbology, config, value));
}

/// set config parsed from configuration string.
/// @see zbar_decoder_parse_config()
/// @since 0.4
int set_config (std::string cfgstr)
{
return(zbar_decoder_parse_config(_decoder, cfgstr.c_str()));
}

private:
friend class Scanner;
zbar_decoder_t *_decoder;
Handler *_handler;

static void _cb (zbar_decoder_t *cdcode)
{
Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode);
if(dcode && dcode->_handler)
dcode->_handler->decode_callback(*dcode);
}
};

}

#endif
Loading

0 comments on commit f4c0cfe

Please sign in to comment.