Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/build.gradle
  • Loading branch information
zorgluf committed Aug 7, 2022
2 parents cfff2d9 + 5d56970 commit 2700b42
Show file tree
Hide file tree
Showing 60 changed files with 1,031 additions and 1,246 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId "fr.nuage.souvenirs"
minSdkVersion 24
targetSdkVersion 30
versionCode 22
versionName "2.6.1"
versionCode 23
versionName "2.7.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "souvenirs-$versionName")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,22 @@
import android.os.Bundle;
import android.widget.ProgressBar;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavDeepLinkBuilder;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import fr.nuage.souvenirs.model.Album;
import fr.nuage.souvenirs.model.PageBuilder;
import fr.nuage.souvenirs.model.TilePageBuilder;
import fr.nuage.souvenirs.view.AlbumsRecyclerViewAdapter;
import fr.nuage.souvenirs.view.EditAlbumFragmentArgs;
import fr.nuage.souvenirs.viewmodel.AlbumListViewModel;
import fr.nuage.souvenirs.viewmodel.AlbumListViewModelFactory;
import fr.nuage.souvenirs.viewmodel.AlbumViewModel;
import fr.nuage.souvenirs.viewmodel.utils.NCUtils;

public class AddImageToAlbumActivity extends AppCompatActivity implements AlbumsRecyclerViewAdapter.OnListFragmentInteractionListener{

Expand Down Expand Up @@ -85,13 +79,13 @@ public void onListFragmentInteraction(AlbumViewModel album, boolean editMode, bo
.setView(new ProgressBar(this,null,android.R.attr.progressBarStyleLarge)).create();
dialog.show();
//create page according to style
PageBuilder pageBuilder = (album.getDefaultStyle().equals(Album.STYLE_TILE)) ? new TilePageBuilder() : new PageBuilder();
TilePageBuilder pageBuilder = new TilePageBuilder();
pageBuilder.create(album,-1,imageUris, null);

//dismiss progress
dialog.dismiss();
//start edit activity
EditAlbumFragmentArgs editAlbumFragmentArgs = new EditAlbumFragmentArgs.Builder(album.getAlbumPath(),album.getPage(-1).getId().toString()).build();
EditAlbumFragmentArgs editAlbumFragmentArgs = new EditAlbumFragmentArgs.Builder(album.getAlbumPath(),album.getAlbum().getPage(-1).getId().toString()).build();
new NavDeepLinkBuilder(this)
.setGraph(R.navigation.nav_main)
.setDestination(R.id.nav_album_edit)
Expand Down
26 changes: 2 additions & 24 deletions app/src/main/java/fr/nuage/souvenirs/model/Album.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public class Album {
public static final String DATA_DIR = "data";
public static final String CONFFILE = "album.json";

public static final String STYLE_FREE = "FREE";
public static final String STYLE_TILE = "TILE";

private String albumPath;
private MutableLiveData<String> ldName = new MutableLiveData<>();
private String name;
Expand All @@ -50,8 +47,6 @@ public class Album {
private UUID id;
private String albumImage;
private MutableLiveData<String> ldAlbumImage = new MutableLiveData<>();
private String defaultStyle = STYLE_TILE;
private MutableLiveData<String> ldDefaultStyle = new MutableLiveData<>();
private boolean unsavedModifications = false;


Expand All @@ -73,7 +68,6 @@ public void updateAllLiveDataObject() {
ldPages.postValue(pages);
ldDate.postValue(date);
ldAlbumImage.postValue(albumImage);
ldDefaultStyle.postValue(defaultStyle);
}

public String getName(){
Expand Down Expand Up @@ -116,17 +110,13 @@ public JSONObject toJSON() {
if (getAlbumImage() != null) {
json.put("albumImage", Utils.getRelativePath(getAlbumPath(),getAlbumImage()));
}
json.put("defaultStyle",getDefaultStyle());
} catch (JSONException e) {
e.printStackTrace();
return null;
}
return json;
}

public String getDefaultStyle() {
return defaultStyle;
}


public boolean load() {
Expand Down Expand Up @@ -183,11 +173,6 @@ public boolean load() {
} else {
lastEditDate = new Date();
}
if (json.has("defaultStyle")) {
defaultStyle = json.getString("defaultStyle");
} else {
defaultStyle = STYLE_FREE;
}
JSONArray jPages = json.getJSONArray("pages");
ArrayList<Page> pages = new ArrayList<Page>();
for (int i=0;i<jPages.length();i++) {
Expand Down Expand Up @@ -469,13 +454,6 @@ public void setAlbumImage(String albumImage) {
onChange();
}

public void setDefaultStyle(String style) {
defaultStyle = style;
ldDefaultStyle.postValue(defaultStyle);
setLastEditDate(new Date());
onChange();
}

public File createEmptyDataFile(String mimeType) {
//generate file name
String ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
Expand Down Expand Up @@ -554,7 +532,7 @@ public LiveData<Date> getLdDate() {
return ldDate;
}

public MutableLiveData<String> getLdDefaultStyle() {
return ldDefaultStyle;
public int getSize() {
return pages.size();
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/fr/nuage/souvenirs/model/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void moveToPreviousPage() {
Page previousPage = album.getPage(album.getIndex(actualPage)-1);
previousPage.addElement(this);
actualPage.delElement(this);
PageBuilder pageBuilder = (album.getDefaultStyle().equals(Album.STYLE_TILE)) ? new TilePageBuilder() : new PageBuilder();
TilePageBuilder pageBuilder = new TilePageBuilder();
pageBuilder.applyDefaultStyle(actualPage);
pageBuilder.applyDefaultStyle(previousPage);
}
Expand All @@ -211,7 +211,7 @@ public void moveToNextPage() {
Page nextPage = album.getPage(album.getIndex(actualPage)+1);
nextPage.addElement(this);
actualPage.delElement(this);
PageBuilder pageBuilder = (album.getDefaultStyle().equals(Album.STYLE_TILE)) ? new TilePageBuilder() : new PageBuilder();
TilePageBuilder pageBuilder = new TilePageBuilder();
pageBuilder.applyDefaultStyle(actualPage);
pageBuilder.applyDefaultStyle(nextPage);
}
Expand Down
Loading

0 comments on commit 2700b42

Please sign in to comment.