Skip to content

Commit 6de9871

Browse files
committedJan 22, 2021
Merge branch 'dev' into main
# Conflicts: # app/build.gradle
2 parents eda92b6 + 47b3abd commit 6de9871

35 files changed

+1065
-207
lines changed
 

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ Android application for Souvenirs albums
55
Make photo albums, add text and handwritten annotations.
66
Upload them on Nextcloud server and share with friends/family.
77

8+
[<img src="https://img.shields.io/f-droid/v/fr.nuage.souvenirs.svg">](https://f-droid.org/packages/fr.nuage.souvenirs/)
9+
10+
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
11+
alt="Get it on F-Droid"
12+
height="80">](https://f-droid.org/packages/fr.nuage.souvenirs/)
13+
814
## Upload your album to a Nextcloud instance
915

1016
Install the [Souvenir application](https://github.com/zorgluf/souvenirs-nextcloud) on your Nextcloud serveur.
1117

1218
You will need the Nextcloud android client installed and configured on your phone. Then go to the parameters of the Souvenirs app and select your Nextcloud account.
1319

20+
## Permission explained
21+
22+
The application need the following permissions : "INTERNET", "GET_ACCOUNTS". These permissions are used exclusively to upload/download albums from the nextcloud server and using the nextcloud account on the device.
23+
1424
## Found it useful ?
1525

1626
If you found this project valuable, and want to encourage the author, you can donate at :

‎app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ android {
2121
applicationId "fr.nuage.souvenirs"
2222
minSdkVersion 24
2323
targetSdkVersion 29
24-
versionCode 8
25-
versionName "1.3.2"
24+
versionCode 9
25+
versionName "1.4.0"
2626
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2727
setProperty("archivesBaseName", "souvenirs-$versionName")
2828
}

‎app/src/main/java/fr/nuage/souvenirs/AddImageToAlbumActivity.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import java.util.ArrayList;
1818
import java.util.List;
1919

20+
import fr.nuage.souvenirs.model.Album;
2021
import fr.nuage.souvenirs.model.PageBuilder;
22+
import fr.nuage.souvenirs.model.TilePageBuilder;
2123
import fr.nuage.souvenirs.view.AlbumsRecyclerViewAdapter;
2224
import fr.nuage.souvenirs.view.EditAlbumFragmentArgs;
2325
import fr.nuage.souvenirs.viewmodel.AlbumListViewModel;
@@ -91,7 +93,9 @@ public void onListFragmentInteraction(AlbumViewModel album, boolean editMode, bo
9193
.setView(new ProgressBar(this,null,android.R.attr.progressBarStyleLarge)).create();
9294
dialog.show();
9395
//create page according to style
94-
PageBuilder.create(album,-1,imageUris,null);
96+
PageBuilder pageBuilder = (album.getDefaultStyle().equals(Album.STYLE_TILE)) ? new TilePageBuilder() : new PageBuilder();
97+
pageBuilder.create(album,-1,imageUris, null);
98+
9599
//dismiss progress
96100
dialog.dismiss();
97101
//start edit activity

‎app/src/main/java/fr/nuage/souvenirs/model/Album.java

+21
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class Album {
3232
public static final String DATA_DIR = "data";
3333
public static final String CONFFILE = "album.json";
3434

35+
public static final String STYLE_FREE = "FREE";
36+
public static final String STYLE_TILE = "TILE";
37+
3538
private String albumPath;
3639
private MutableLiveData<String> ldName = new MutableLiveData<String>();
3740
private String name;
@@ -47,9 +50,11 @@ public class Album {
4750
private UUID id;
4851
private String albumImage;
4952
private MutableLiveData<String> ldAlbumImage = new MutableLiveData<>();
53+
private String defaultStyle = STYLE_TILE;
5054
private boolean unsavedModifications = false;
5155

5256

57+
5358
public Album(String albumPath) {
5459
this.albumPath = albumPath;
5560
load();
@@ -109,13 +114,18 @@ public JSONObject toJSON() {
109114
if (getAlbumImage() != null) {
110115
json.put("albumImage", Utils.getRelativePath(getAlbumPath(),getAlbumImage()));
111116
}
117+
json.put("defaultStyle",getDefaultStyle());
112118
} catch (JSONException e) {
113119
e.printStackTrace();
114120
return null;
115121
}
116122
return json;
117123
}
118124

125+
public String getDefaultStyle() {
126+
return defaultStyle;
127+
}
128+
119129
public void reload() {
120130
if (!unsavedModifications) {
121131
load();
@@ -176,6 +186,11 @@ public boolean load() {
176186
} else {
177187
lastEditDate = new Date();
178188
}
189+
if (json.has("defaultStyle")) {
190+
defaultStyle = json.getString("defaultStyle");
191+
} else {
192+
defaultStyle = STYLE_FREE;
193+
}
179194
JSONArray jPages = json.getJSONArray("pages");
180195
ArrayList<Page> pages = new ArrayList<Page>();
181196
for (int i=0;i<jPages.length();i++) {
@@ -457,6 +472,12 @@ public void setAlbumImage(String albumImage) {
457472
onChange();
458473
}
459474

475+
public void setDefaultStyle(String style) {
476+
defaultStyle = style;
477+
setLastEditDate(new Date());
478+
onChange();
479+
}
480+
460481
public String createDataFile(InputStream inputStream, String mimeType) {
461482
//if input null, do nothing (blank image)
462483
if (inputStream != null) {

‎app/src/main/java/fr/nuage/souvenirs/model/Element.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ public void moveToPreviousPage() {
197197
if (!album.FirstPage(actualPage)) {
198198
Page previousPage = album.getPage(album.getIndex(actualPage)-1);
199199
previousPage.addElement(this);
200-
PageBuilder.applyDefaultStyle(previousPage);
201200
actualPage.delElement(this);
202-
PageBuilder.applyDefaultStyle(actualPage);
201+
PageBuilder pageBuilder = (album.getDefaultStyle().equals(Album.STYLE_TILE)) ? new TilePageBuilder() : new PageBuilder();
202+
pageBuilder.applyDefaultStyle(actualPage);
203+
pageBuilder.applyDefaultStyle(previousPage);
203204
}
204205
}
205206

@@ -209,9 +210,10 @@ public void moveToNextPage() {
209210
if (!album.isLastPage(actualPage)) {
210211
Page nextPage = album.getPage(album.getIndex(actualPage)+1);
211212
nextPage.addElement(this);
212-
PageBuilder.applyDefaultStyle(nextPage);
213213
actualPage.delElement(this);
214-
PageBuilder.applyDefaultStyle(actualPage);
214+
PageBuilder pageBuilder = (album.getDefaultStyle().equals(Album.STYLE_TILE)) ? new TilePageBuilder() : new PageBuilder();
215+
pageBuilder.applyDefaultStyle(actualPage);
216+
pageBuilder.applyDefaultStyle(nextPage);
215217
}
216218
}
217219

‎app/src/main/java/fr/nuage/souvenirs/model/ImageElement.java

+101
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fr.nuage.souvenirs.model;
22

3+
import android.graphics.BitmapFactory;
4+
35
import androidx.lifecycle.MutableLiveData;
46

57
import org.json.JSONException;
@@ -12,11 +14,18 @@ public class ImageElement extends Element {
1214

1315
public static final int FIT = 0;
1416
public static final int CENTERCROP = 1;
17+
public static final int ZOOM_OFFSET = 2;
1518

1619
private MutableLiveData<String> ldImagePath = new MutableLiveData<String>();
1720
private MutableLiveData<Integer> ldTransformType = new MutableLiveData<>();
21+
private MutableLiveData<Integer> ldZoom = new MutableLiveData<>();
22+
private MutableLiveData<Integer> ldOffsetX = new MutableLiveData<>();
23+
private MutableLiveData<Integer> ldOffsetY = new MutableLiveData<>();
1824
private String imagePath;
1925
private String mimeType;
26+
private int zoom = 100;
27+
private int offsetX = 0;
28+
private int offsetY = 0;
2029
private int transformType = FIT;
2130

2231
public ImageElement() {
@@ -103,6 +112,9 @@ public JSONObject completeToJSON(JSONObject json) throws JSONException {
103112
json.put("image",Utils.getRelativePath(pageParent.getAlbum().getAlbumPath(),imagePath));
104113
json.put("mime",mimeType);
105114
json.put("transformType",transformType);
115+
json.put("zoom",zoom);
116+
json.put("offsetX",offsetX);
117+
json.put("offsetY",offsetY);
106118
return json;
107119
}
108120

@@ -122,6 +134,15 @@ public void completeFromJSON(JSONObject jsonObject) throws JSONException {
122134
if (jsonObject.has("transformType")) {
123135
setTransformType(jsonObject.getInt("transformType"),false);
124136
}
137+
if (jsonObject.has("zoom")) {
138+
setZoom(jsonObject.getInt("zoom"),false);
139+
}
140+
if (jsonObject.has("offsetX")) {
141+
setOffsetX(jsonObject.getInt("offsetX"),false);
142+
}
143+
if (jsonObject.has("offsetY")) {
144+
setOffsetY(jsonObject.getInt("offsetY"),false);
145+
}
125146
}
126147

127148
public String getImagePath() {
@@ -163,4 +184,84 @@ public void delete() {
163184
public void setAsAlbumImage() {
164185
pageParent.getAlbum().setAlbumImage(getImagePath());
165186
}
187+
188+
public int getZoom() {
189+
return zoom;
190+
}
191+
192+
public void setZoom(int zoom) {
193+
setZoom(zoom,true);
194+
}
195+
196+
public void setZoom(int zoom, boolean save) {
197+
this.zoom = zoom;
198+
ldZoom.postValue(zoom);
199+
if (save) {
200+
onChange();
201+
}
202+
}
203+
204+
public int getOffsetX() {
205+
return offsetX;
206+
}
207+
208+
public void setOffsetX(int offsetX) {
209+
setOffsetX(offsetX,true);
210+
}
211+
212+
public void setOffsetX(int offsetX, boolean save) {
213+
this.offsetX = offsetX;
214+
ldOffsetX.postValue(offsetX);
215+
if (save) {
216+
onChange();
217+
}
218+
}
219+
220+
public int getOffsetY() {
221+
return offsetY;
222+
}
223+
224+
public void setOffsetY(int offsetY) {
225+
setOffsetY(offsetY,true);
226+
}
227+
228+
public void setOffsetY(int offsetY, boolean save) {
229+
this.offsetY = offsetY;
230+
ldOffsetY.postValue(offsetY);
231+
if (save) {
232+
onChange();
233+
}
234+
}
235+
236+
public MutableLiveData<Integer> getLdZoom() {
237+
return ldZoom;
238+
}
239+
240+
public MutableLiveData<Integer> getLdOffsetX() {
241+
return ldOffsetX;
242+
}
243+
244+
public MutableLiveData<Integer> getLdOffsetY() {
245+
return ldOffsetY;
246+
}
247+
248+
public int getImageWidth() {
249+
if ((imagePath == null) || (imagePath.equals(""))) {
250+
return 0;
251+
}
252+
BitmapFactory.Options options = new BitmapFactory.Options();
253+
options.inJustDecodeBounds = true;
254+
BitmapFactory.decodeFile(imagePath, options);
255+
return options.outWidth;
256+
}
257+
258+
public int getImageHeight() {
259+
if ((imagePath == null) || (imagePath.equals(""))) {
260+
return 0;
261+
}
262+
BitmapFactory.Options options = new BitmapFactory.Options();
263+
options.inJustDecodeBounds = true;
264+
BitmapFactory.decodeFile(imagePath, options);
265+
return options.outHeight;
266+
}
166267
}

0 commit comments

Comments
 (0)
Failed to load comments.