Skip to content

Commit 7cc63f1

Browse files
committed
Conflicts: build.gradle
2 parents 51922eb + 16d89f5 commit 7cc63f1

21 files changed

Lines changed: 184 additions & 107 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,18 @@ The `response` instance holds a reference to the paths where the images were per
123123
When asking RxPaparazzo for an image -whether it was retrieved using the built-in camera or via gallery, it's possible to apply some configurations to the action.
124124

125125
### Size options
126-
`Size` values `enum` can be used to set the size of the image to retrieve. There are 3 options:
126+
[Size](https://github.com/FuckBoilerplate/RxPaparazzo/blob/master/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/entities/size/Size.java) values can be used to set the size of the image to retrieve. There are 4 options:
127127

128-
* Small: 1/8 aprox. of the screen resolution
129-
* Screen: The size image matches aprox. the screen resolution.
130-
* Original: The original size of the image.
128+
* [SmallSize](https://github.com/FuckBoilerplate/RxPaparazzo/blob/master/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/entities/size/SmallSize.java): 1/8 aprox. of the screen resolution
129+
* [ScreenSize](https://github.com/FuckBoilerplate/RxPaparazzo/blob/master/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/entities/size/ScreenSize.java): The size image matches aprox. the screen resolution.
130+
* [OriginalSize](https://github.com/FuckBoilerplate/RxPaparazzo/blob/master/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/entities/size/OriginalSize.java): The original size of the image.
131+
* [CustomMaxSize](https://github.com/FuckBoilerplate/RxPaparazzo/blob/master/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/entities/size/CustomMaxSize.java): Yot can specify max size you want and image will be scaled proportionally.
131132

132-
`Screen` value will be set as default.
133+
[ScreenSize](https://github.com/FuckBoilerplate/RxPaparazzo/blob/master/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/entities/size/ScreenSize.java) value will be set as default.
133134

134135
```java
135136
RxPaparazzo.takeImages(activityOrFragment)
136-
.size(Size.Small)
137+
.size(new ScreenSize())
137138
.usingGallery()
138139
```
139140

app/src/androidTest/java/com/fuck_boilerplate/rx_paparazzo/sample/ApplicationTest.java

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import android.widget.ImageView;
2020

2121
import com.fuck_boilerplate.rx_paparazzo.entities.Config;
22-
import com.fuck_boilerplate.rx_paparazzo.entities.Size;
2322
import com.fuck_boilerplate.rx_paparazzo.entities.TargetUi;
23+
import com.fuck_boilerplate.rx_paparazzo.entities.size.Size;
2424
import com.fuck_boilerplate.rx_paparazzo.interactors.DownloadImage;
2525
import com.fuck_boilerplate.rx_paparazzo.interactors.GetDimens;
2626
import com.fuck_boilerplate.rx_paparazzo.interactors.GetPath;
@@ -65,56 +65,67 @@ public class ApplicationTest {
6565
private UiDevice uiDevice;
6666
private int[] imageDimens = {0, 0};
6767

68-
@Before public void init() {
68+
@Before
69+
public void init() {
6970
uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
7071
}
7172

72-
@Test public void _01_CancelUserActionActivity() {
73+
@Test
74+
public void _01_CancelUserActionActivity() {
7375
onView(withId(R.id.bt_activity)).perform(click());
7476
cancelUserAction();
7577
}
7678

77-
@Test public void _02_CancelUserActionFragment() {
79+
@Test
80+
public void _02_CancelUserActionFragment() {
7881
onView(withId(R.id.bt_fragment)).perform(click());
7982
cancelUserAction();
8083
}
8184

82-
@Test public void _03_TakePhotoActivity() {
85+
@Test
86+
public void _03_TakePhotoActivity() {
8387
onView(withId(R.id.bt_activity)).perform(click());
8488
takePhoto(false);
8589
}
8690

87-
@Test public void _04_TakePhotoFragment() {
91+
@Test
92+
public void _04_TakePhotoFragment() {
8893
onView(withId(R.id.bt_fragment)).perform(click());
8994
takePhoto(false);
9095
}
9196

92-
@Test public void _05_TakePhotoActivityCrop() {
97+
@Test
98+
public void _05_TakePhotoActivityCrop() {
9399
onView(withId(R.id.bt_activity)).perform(click());
94100
takePhoto(true);
95101
}
96102

97-
@Test public void _06_TakePhotoFragmentCrop() {
103+
@Test
104+
public void _06_TakePhotoFragmentCrop() {
98105
onView(withId(R.id.bt_fragment)).perform(click());
99106
takePhoto(true);
100107
}
101108

102-
@Test public void _07_PickUpPhotoActivityCrop() {
109+
@Test
110+
public void _07_PickUpPhotoActivityCrop() {
103111
onView(withId(R.id.bt_activity)).perform(click());
104112
pickUpPhoto(true);
105113
}
106114

107-
@Test public void _08_PickUpPhotoFragmentCrop() {
115+
@Test
116+
public void _08_PickUpPhotoFragmentCrop() {
108117
onView(withId(R.id.bt_fragment)).perform(click());
109118
pickUpPhoto(true);
110119
}
111120

112-
@Test public void _09_PickUpPhotosActivityCrop() {
121+
@Test
122+
public void _09_PickUpPhotosActivityCrop() {
113123
onView(withId(R.id.bt_activity)).perform(click());
114124
pickUpPhoto(false);
115125
}
116126

117-
@Test public void _10_PickUpPhotosFragmentCrop() {
127+
@Test
128+
public void _10_PickUpPhotosFragmentCrop() {
118129
onView(withId(R.id.bt_fragment)).perform(click());
119130
pickUpPhoto(false);
120131
}
@@ -212,8 +223,8 @@ private void checkDimensions() {
212223
}
213224

214225
private int[] getDimensionsPortrait(int width, int height) {
215-
if (width < height) return new int [] {width, height};
216-
else return new int [] {height, width};
226+
if (width < height) return new int[]{width, height};
227+
else return new int[]{height, width};
217228
}
218229

219230
private GetDimens getDimens(Size size) {
@@ -235,12 +246,14 @@ private void cancelUserAction() {
235246
uiDevice.pressBack();
236247

237248
onView(withId(R.id.iv_image)).check(matches(new BoundedMatcher<View, ImageView>(ImageView.class) {
238-
@Override public void describeTo(Description description) {
239-
imageDimens = new int[] {0, 0};
249+
@Override
250+
public void describeTo(Description description) {
251+
imageDimens = new int[]{0, 0};
240252
description.appendText("has not drawable");
241253
}
242254

243-
@Override public boolean matchesSafely(ImageView imageView) {
255+
@Override
256+
public boolean matchesSafely(ImageView imageView) {
244257
return imageView.getDrawable() == null;
245258
}
246259
}));
@@ -279,7 +292,7 @@ private void clickImagesOnScreen(int imagesToPick) {
279292
int height = screenDimens[1];
280293
int y = 0;
281294

282-
for (int i = 0; i < imagesToPick ; i++) {
295+
for (int i = 0; i < imagesToPick; i++) {
283296
int widthQuarter = width / 4;
284297
int x = (i % 2 == 0) ? widthQuarter : widthQuarter * 3;
285298
y += (i % 2 == 0) ? height / 4 : 0;
@@ -295,11 +308,14 @@ private int[] getScreenDimensions() {
295308
Display display = wm.getDefaultDisplay();
296309
Point size = new Point();
297310
display.getSize(size);
298-
return new int[] {size.x, size.y};
311+
return new int[]{size.x, size.y};
299312
}
300313

301314
private void waitTime() {
302-
try {Thread.sleep(3000);}
303-
catch (InterruptedException e) { e.printStackTrace();}
315+
try {
316+
Thread.sleep(3000);
317+
} catch (InterruptedException e) {
318+
e.printStackTrace();
319+
}
304320
}
305321
}

app/src/main/java/com/fuck_boilerplate/rx_paparazzo/sample/activities/HostActivitySampleFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import android.os.Bundle;
44
import android.support.v7.app.AppCompatActivity;
55

6-
import com.fuck_boilerplate.rx_paparazzo.entities.Size;
6+
import com.fuck_boilerplate.rx_paparazzo.entities.size.Size;
77
import com.fuck_boilerplate.rx_paparazzo.sample.R;
88
import com.fuck_boilerplate.rx_paparazzo.sample.fragments.SampleFragment;
99

app/src/main/java/com/fuck_boilerplate/rx_paparazzo/sample/activities/SampleActivity.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
import android.widget.Toast;
1313

1414
import com.fuck_boilerplate.rx_paparazzo.RxPaparazzo;
15-
import com.fuck_boilerplate.rx_paparazzo.entities.Size;
15+
import com.fuck_boilerplate.rx_paparazzo.entities.size.CustomMaxSize;
16+
import com.fuck_boilerplate.rx_paparazzo.entities.size.OriginalSize;
17+
import com.fuck_boilerplate.rx_paparazzo.entities.size.Size;
18+
import com.fuck_boilerplate.rx_paparazzo.entities.size.SmallSize;
1619
import com.fuck_boilerplate.rx_paparazzo.sample.R;
1720
import com.fuck_boilerplate.rx_paparazzo.sample.adapters.ImagesAdapter;
1821
import com.squareup.picasso.Picasso;
@@ -28,16 +31,18 @@ public class SampleActivity extends AppCompatActivity implements Testable {
2831
private List<String> filesPaths;
2932
private Size size;
3033

31-
@Override protected void onCreate(Bundle savedInstanceState) {
34+
@Override
35+
protected void onCreate(Bundle savedInstanceState) {
3236
super.onCreate(savedInstanceState);
3337
setContentView(R.layout.sample_layout);
3438
configureToolbar();
3539
initViews();
3640
filesPaths = new ArrayList<>();
37-
size = Size.Original;
41+
size = new OriginalSize();
3842
}
3943

40-
@Override public void onConfigurationChanged(Configuration newConfig) {
44+
@Override
45+
public void onConfigurationChanged(Configuration newConfig) {
4146
super.onConfigurationChanged(newConfig);
4247
}
4348

@@ -63,7 +68,7 @@ private void initViews() {
6368
}
6469

6570
private void captureImage() {
66-
size = Size.Small;
71+
size = new CustomMaxSize(512);
6772
RxPaparazzo.takeImage(SampleActivity.this)
6873
.size(size)
6974
.usingCamera()
@@ -89,7 +94,7 @@ private void captureImageWithCrop() {
8994
UCrop.Options options = new UCrop.Options();
9095
options.setToolbarColor(ContextCompat.getColor(SampleActivity.this, R.color.colorAccent));
9196

92-
size = Size.Original;
97+
size = new OriginalSize();
9398
RxPaparazzo.takeImage(SampleActivity.this)
9499
.size(size)
95100
.crop(options)
@@ -111,7 +116,7 @@ private void pickupImage() {
111116
UCrop.Options options = new UCrop.Options();
112117
options.setToolbarColor(ContextCompat.getColor(SampleActivity.this, R.color.colorPrimaryDark));
113118

114-
size = Size.Small;
119+
size = new SmallSize();
115120
RxPaparazzo.takeImage(SampleActivity.this)
116121
.useInternalStorage()
117122
.crop(options)
@@ -131,7 +136,7 @@ private void pickupImage() {
131136
}
132137

133138
private void pickupImages() {
134-
size = Size.Small;
139+
size = new SmallSize();
135140
RxPaparazzo.takeImages(SampleActivity.this)
136141
.useInternalStorage()
137142
.crop()
@@ -143,7 +148,8 @@ private void pickupImages() {
143148
return;
144149
}
145150

146-
if (response.data().size() == 1) response.targetUI().loadImage(response.data().get(0));
151+
if (response.data().size() == 1)
152+
response.targetUI().loadImage(response.data().get(0));
147153
else response.targetUI().loadImages(response.data());
148154
}, throwable -> {
149155
throwable.printStackTrace();
@@ -180,11 +186,13 @@ private void showUserDidNotGrantPermissions() {
180186
Toast.makeText(this, getString(R.string.user_did_not_grant_permissions), Toast.LENGTH_SHORT).show();
181187
}
182188

183-
@Override public List<String> getFilePaths() {
189+
@Override
190+
public List<String> getFilePaths() {
184191
return filesPaths;
185192
}
186193

187-
@Override public Size getSize() {
194+
@Override
195+
public Size getSize() {
188196
return size;
189197
}
190198
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.fuck_boilerplate.rx_paparazzo.sample.activities;
22

3-
import com.fuck_boilerplate.rx_paparazzo.entities.Size;
3+
4+
import com.fuck_boilerplate.rx_paparazzo.entities.size.Size;
45

56
import java.util.List;
67

78
public interface Testable<T> {
89
List<String> getFilePaths();
10+
911
Size getSize();
1012
}

app/src/main/java/com/fuck_boilerplate/rx_paparazzo/sample/fragments/SampleFragment.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
import com.fuck_boilerplate.rx_paparazzo.RxPaparazzo;
1616
import com.fuck_boilerplate.rx_paparazzo.entities.Options;
17-
import com.fuck_boilerplate.rx_paparazzo.entities.Size;
17+
import com.fuck_boilerplate.rx_paparazzo.entities.size.OriginalSize;
18+
import com.fuck_boilerplate.rx_paparazzo.entities.size.Size;
19+
import com.fuck_boilerplate.rx_paparazzo.entities.size.SmallSize;
1820
import com.fuck_boilerplate.rx_paparazzo.sample.R;
1921
import com.fuck_boilerplate.rx_paparazzo.sample.activities.Testable;
2022
import com.fuck_boilerplate.rx_paparazzo.sample.adapters.ImagesAdapter;
@@ -31,16 +33,18 @@ public class SampleFragment extends Fragment implements Testable {
3133
private List<String> filesPaths;
3234
private Size size;
3335

34-
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
36+
@Override
37+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
3538
View view = inflater.inflate(R.layout.sample_layout, container, false);
3639
return view;
3740
}
3841

39-
@Override public void onActivityCreated(Bundle savedInstanceState) {
42+
@Override
43+
public void onActivityCreated(Bundle savedInstanceState) {
4044
super.onActivityCreated(savedInstanceState);
4145
initViews();
4246
filesPaths = new ArrayList<>();
43-
size = Size.Original;
47+
size = new OriginalSize();
4448
}
4549

4650
private void initViews() {
@@ -59,7 +63,7 @@ private void initViews() {
5963
}
6064

6165
private void captureImage() {
62-
size = Size.Small;
66+
size = new SmallSize();
6367
RxPaparazzo.takeImage(this)
6468
.size(size)
6569
.usingCamera()
@@ -79,7 +83,7 @@ private void captureImageWithCrop() {
7983
options.setToolbarColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
8084
options.setAspectRatio(25, 75);
8185

82-
size = Size.Original;
86+
size = new OriginalSize();
8387
RxPaparazzo.takeImage(this)
8488
.size(size)
8589
.crop(options)
@@ -98,7 +102,7 @@ private void pickupImage() {
98102
UCrop.Options options = new UCrop.Options();
99103
options.setToolbarColor(ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
100104

101-
size = Size.Small;
105+
size = new SmallSize();
102106
RxPaparazzo.takeImage(this)
103107
.useInternalStorage()
104108
.crop(options)
@@ -115,7 +119,7 @@ private void pickupImage() {
115119
}
116120

117121
private void pickupImages() {
118-
size = Size.Small;
122+
size = new SmallSize();
119123
RxPaparazzo.takeImages(this)
120124
.useInternalStorage()
121125
.crop()
@@ -127,7 +131,8 @@ private void pickupImages() {
127131
return;
128132
}
129133

130-
if (response.data().size() == 1) response.targetUI().loadImage(response.data().get(0));
134+
if (response.data().size() == 1)
135+
response.targetUI().loadImage(response.data().get(0));
131136
else response.targetUI().loadImages(response.data());
132137
});
133138
}
@@ -155,11 +160,13 @@ private void showUserCanceled() {
155160
Toast.makeText(getActivity(), getString(R.string.user_canceled), Toast.LENGTH_SHORT).show();
156161
}
157162

158-
@Override public List<String> getFilePaths() {
163+
@Override
164+
public List<String> getFilePaths() {
159165
return filesPaths;
160166
}
161167

162-
@Override public Size getSize() {
168+
@Override
169+
public Size getSize() {
163170
return size;
164171
}
165172
}

0 commit comments

Comments
 (0)