Search in sources :

Example 1 with LocalDataService

use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.

the class FeatherActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    onPreCreate();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.feather_main);
    onInitializeUtils();
    initializeUI();
    onRegisterReceiver();
    // initiate the filter manager
    mUIHandler = new MyUIHandler(this);
    mFilterManager = new FilterManager(this, mUIHandler, getApiKey());
    mFilterManager.setOnToolListener(this);
    mFilterManager.setOnBitmapChangeListener(this);
    mFilterManager.setDragLayer(mDragLayer);
    // first check the validity of the incoming intent
    Uri srcUri = handleIntent(getIntent());
    if (srcUri == null) {
        onSetResult(RESULT_CANCELED, null);
        finish();
        return;
    }
    LocalDataService data = mFilterManager.getService(LocalDataService.class);
    data.setSourceImageUri(srcUri);
    // download the requested image
    loadImage(srcUri);
    // initialize filters
    delayedInitializeTools();
    logger.error("MAX MEMORY", mFilterManager.getApplicationMaxMemory());
    Tracker.recordTag("feather: opened");
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) Uri(android.net.Uri)

Example 2 with LocalDataService

use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.

the class FeatherActivity method saveExif.

protected void saveExif(String path) {
    logger.log("saveExif: " + path);
    if (null == path) {
        return;
    }
    LocalDataService data = mFilterManager.getService(LocalDataService.class);
    ExifInterfaceWrapper newexif = null;
    if (null != data) {
        try {
            newexif = new ExifInterfaceWrapper(path);
        } catch (IOException e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            return;
        }
        ;
        Bundle bundle = data.getOriginalExifBundle();
        if (null != bundle) {
            try {
                newexif.copyFrom(bundle);
                newexif.setAttribute(ExifInterfaceWrapper.TAG_ORIENTATION, "0");
                newexif.setAttribute(ExifInterfaceWrapper.TAG_SOFTWARE, "Aviary for Android " + SDK_VERSION);
                // implements this to include your own tags
                onSaveCustomTags(newexif);
                newexif.saveAttributes();
            } catch (Throwable t) {
                t.printStackTrace();
                logger.error(t.getMessage());
            }
        }
    }
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) Bundle(android.os.Bundle) ExifInterfaceWrapper(com.aviary.android.feather.library.media.ExifInterfaceWrapper) IOException(java.io.IOException)

Example 3 with LocalDataService

use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.

the class FeatherActivity method handleIntent.

/**
	 * Handle the original received intent.
	 * 
	 * @param intent
	 *           the intent
	 * @return the uri
	 */
protected Uri handleIntent(Intent intent) {
    LocalDataService service = mFilterManager.getService(LocalDataService.class);
    if (intent != null && intent.getData() != null) {
        Uri data = intent.getData();
        if (SystemUtils.isIceCreamSandwich()) {
            if (data.toString().startsWith("content://com.android.gallery3d.provider")) {
                // use the com.google provider, not the com.android provider ( for ICS only )
                data = Uri.parse(data.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
            }
        }
        Bundle extras = intent.getExtras();
        if (extras != null) {
            Uri destUri = (Uri) extras.getParcelable(Constants.EXTRA_OUTPUT);
            if (destUri != null) {
                service.setDestImageUri(destUri);
                String outputFormatString = extras.getString(Constants.EXTRA_OUTPUT_FORMAT);
                if (outputFormatString != null) {
                    CompressFormat format = Bitmap.CompressFormat.valueOf(outputFormatString);
                    service.setOutputFormat(format);
                }
            }
            if (extras.containsKey(Constants.EXTRA_TOOLS_LIST)) {
                mToolList = Arrays.asList(extras.getStringArray(Constants.EXTRA_TOOLS_LIST));
            }
            if (extras.containsKey(Constants.EXTRA_HIDE_EXIT_UNSAVE_CONFIRMATION)) {
                mHideExitAlertConfirmation = extras.getBoolean(Constants.EXTRA_HIDE_EXIT_UNSAVE_CONFIRMATION);
            }
        }
        return data;
    }
    return null;
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) CompressFormat(android.graphics.Bitmap.CompressFormat) Bundle(android.os.Bundle) Uri(android.net.Uri)

Example 4 with LocalDataService

use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.

the class FeatherActivity method onRevert.

/**
	 * Revert the original image.
	 */
private void onRevert() {
    Tracker.recordTag("feather: reset image");
    LocalDataService service = mFilterManager.getService(LocalDataService.class);
    loadImage(service.getSourceImageUri());
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService)

Example 5 with LocalDataService

use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.

the class FeatherActivity method loadExif.

/**
	 * load the original file EXIF data and store the result into the local data instance
	 */
protected void loadExif() {
    logger.log("loadExif");
    final LocalDataService data = mFilterManager.getService(LocalDataService.class);
    ThreadPoolService thread = mFilterManager.getService(ThreadPoolService.class);
    if (null != data && thread != null) {
        final String path = data.getSourceImagePath();
        FutureListener<Bundle> listener = new FutureListener<Bundle>() {

            @Override
            public void onFutureDone(Future<Bundle> future) {
                try {
                    Bundle result = future.get();
                    if (null != result) {
                        data.setOriginalExifBundle(result);
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        };
        if (null != path) {
            thread.submit(new ExifTask(), listener, path);
        } else {
            logger.warning("orinal file path not available");
        }
    }
}
Also used : FutureListener(com.aviary.android.feather.library.services.FutureListener) LocalDataService(com.aviary.android.feather.library.services.LocalDataService) Bundle(android.os.Bundle) ThreadPoolService(com.aviary.android.feather.library.services.ThreadPoolService) Future(java.util.concurrent.Future) ExifTask(com.aviary.android.feather.async_tasks.ExifTask)

Aggregations

LocalDataService (com.aviary.android.feather.library.services.LocalDataService)11 Bundle (android.os.Bundle)5 Uri (android.net.Uri)4 Intent (android.content.Intent)2 FeatherIntent (com.aviary.android.feather.library.content.FeatherIntent)2 HiResService (com.aviary.android.feather.library.services.HiResService)2 IOException (java.io.IOException)2 Bitmap (android.graphics.Bitmap)1 CompressFormat (android.graphics.Bitmap.CompressFormat)1 ExifTask (com.aviary.android.feather.async_tasks.ExifTask)1 ExifInterfaceWrapper (com.aviary.android.feather.library.media.ExifInterfaceWrapper)1 FutureListener (com.aviary.android.feather.library.services.FutureListener)1 ThreadPoolService (com.aviary.android.feather.library.services.ThreadPoolService)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Future (java.util.concurrent.Future)1