0

I've been working on an wallpaper app, which fetches some set of wallpapers (through an api of my choice), gives users features of sharing, setting as wallpaper directly (scrollable if it supports) or edit and set the picture.

This edit screen is where I face some bugs/issues.

I need the user to be able to crop/zoom/pan the image to their liking and set it as the wallpaper. Similar to how Nova wallpaper does it, where if the crop selection is reduced, the entire images zooms in accordingly to that selection. All this happens in a single imageview I believe.

But, in my case, I happen to use two imageviews, one for cropping and the other for zooming. crop library: github-dot-com/edmodo/cropper/

Once, user crops, the second imageview is populated with the bitmap of selection from cropper. This imageview is used for zooming or panning. zoom/pan library: github-dot-com/jasonpolites/gesture-imageview

Here is layout for that screen: https://i.stack.imgur.com/wnjcP.jpg

And the code:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:gesture-image="http://schemas.polites.com/android"
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout 
android:id="@+id/mylayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"

tools:context=".MainActivity" >

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/Button_crop"
        style="@style/RoboTheme"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="25dp"
        android:paddingRight="25dp"
        android:text="@string/crop"
        android:textColor="#33B5E5"
        android:textSize="12sp" />

    <ImageButton
        android:id="@+id/Button_rotate_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/rotate_left" />

    <ImageButton
        android:id="@+id/Button_rotate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/rotate_right" />

     <Button
        android:id="@+id/Button_setother"
        style="@style/RoboTheme"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="25dp"
        android:paddingRight="25dp"
        android:text="@string/setother"
        android:textColor="#33B5E5"
        android:textSize="12sp" />


</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:id="@+id/checkboxlayout">

     <CheckBox
         android:id="@+id/scrollable"
         style="@style/RoboTheme"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textColor="#33B5E5"
         android:textSize="12sp"
         android:checked="false"
         android:text="Scrollable" />



     <Button
        android:id="@+id/Button_setwallpaper"
        style="@style/RoboTheme"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="25dp"
        android:paddingRight="25dp"
        android:text="@string/setwallpaper"
        android:textColor="#33B5E5"
        android:textSize="12sp" />

 </LinearLayout>


 <com.edmodo.cropper.CropImageView
         xmlns:custom="http://schemas.android.com/apk/res-auto"
         android:id="@+id/CropImageView"
         android:layout_width="wrap_content"
         android:layout_height="0dp"
         android:layout_weight="1"
         android:layout_gravity="center"

         android:adjustViewBounds="true" />

<com.polites.android.GestureImageView
    android:id="@+id/croppedImageView"

    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:adjustViewBounds="true"
    android:contentDescription="@string/croppedImageDesc"
    gesture-image:max-scale="10.0"
    gesture-image:min-scale="0.1"
    gesture-image:strict="false" />

 </LinearLayout>

</ScrollView>

Whereas, I would like to some assistance in getting this layout efficient. Where I'm not required to scroll in different devices or base it on something similar to Nova Launcher's "Set Wallpaper" screen like:

https://i.stack.imgur.com/WaJRO.png

Any assistance is much appreciated!

Thanks,

Arnab

Arnab Saha
  • 511
  • 6
  • 15
  • try combining this library with https://github.com/chrisbanes/PhotoView this library – Illegal Argument May 28 '14 at 12:25
  • Well, I've tried this library too. It's pretty much what https://github.com/jasonpolites/gesture-imageview offers which I have already included. And I'm looking for a way where I can achieve both crop & zoom effect in one imageview, similar to how Nova Launcher has their "Set Wallpaper" screen to behave, screenshot in OP. – Arnab Saha May 28 '14 at 13:32
  • https://github.com/biokys/cropimage I used this library in my project it does what you want but in its own activity that you have to declare i your manifest – Illegal Argument May 28 '14 at 13:37
  • Hey! @IllegalArgument Thanks! This library is exactly what I was looking, integrating and functioning well in my project as of now! – Arnab Saha May 30 '14 at 08:31
  • I am glad that it works for you the UI of the library is not so good as cropper but it is a solid performer. – Illegal Argument May 30 '14 at 10:02
  • Hey @IllegalArgument Do you have any idea of how to achieve 2 rectangle perpendicular to each other on top of selected photo like in the screenshot here http://awesomescreenshot.com/0722wkzhfa with this library? – Arnab Saha Jun 06 '14 at 14:07

1 Answers1

0

Nova Launcher's cropping activity is based on the CropImage.java from AOSP Gallery2 https://android.googlesource.com/platform/packages/apps/Gallery2/ . It's a bit of work to bring in all the required dependencies and then fix all the build issues for building against the SDK (like they might use mLeft in a view and you have to replace it with getLeft()).

Kevin TeslaCoil
  • 10,037
  • 1
  • 39
  • 33