main
pzvjlefpx 3 weeks ago
parent bca738318e
commit 02dc9b28bf

@ -0,0 +1,84 @@
package Bin;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class System {
private Map<String, Note> notesMap;
private int storageLimit; // in bytes
public System(int storageLimit) {
this.notesMap = new HashMap<>();
this.storageLimit = storageLimit;
}
public List<Note> getDeletedNotes() {
List<Note> deletedNotes = new ArrayList<>();
for (Note note : notesMap.values()) {
if (note.isDeleted()) {
deletedNotes.add(note);
}
}
return deletedNotes;
}
public void restoreNote(String noteId) {
Note note = notesMap.get(noteId);
if (note != null && note.isDeleted()) {
note.setDeletedAt(null);
}
}
public void permanentlyDeleteNote(String noteId) {
notesMap.remove(noteId);
}
public void cleanUpOldNotes() {
notesMap.entrySet().removeIf(entry -> entry.getValue().isDeleted());
}
public void checkStorageLimit() {
long totalSize = 0;
for (Note note : notesMap.values()) {
for (Image image : note.getImages()) {
// Here you would need some way to determine the size of each file.
// For demonstration purposes, let's assume each image path represents 1MB.
totalSize += 1024 * 1024;
}
}
if (totalSize > storageLimit) {
System.out.println("Storage limit exceeded.");
} else {
System.out.println("Storage within limits.");
}
}
public boolean validateImage(String imagePath) {
// Implement actual image validation logic here
return true; // Placeholder implementation
}
public Blob generateThumbnail(String imagePath) {
// Implement actual thumbnail generation logic here
byte[] thumbnailData = new byte[0]; // Placeholder data
return new Blob(thumbnailData);
}
public void saveImageWithNoteBinding(String noteId, String imagePath) {
Note note = notesMap.get(noteId);
if (note != null && validateImage(imagePath)) {
Blob thumbnail = generateThumbnail(imagePath);
Image image = new Image(imagePath, thumbnail, new Date());
note.getImages().add(image);
}
}
}

@ -38,6 +38,11 @@ public class Note {
private ContentValues mNoteDiffValues;
private NoteData mNoteData;
private static final String TAG = "Note";
private String id;
private String content;
private Date deletedAt;
private List<Image> images;
/**
* Create a new note id for adding a new note to databases
*/
@ -68,6 +73,7 @@ public class Note {
public Note() {
mNoteDiffValues = new ContentValues();
mNoteData = new NoteData();
images = new ArrayList<>();
}
public void setNoteValue(String key, String value) {
@ -130,6 +136,41 @@ public class Note {
return true;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Date deletedAt) {
this.deletedAt = deletedAt;
}
public List<Image> getImages() {
this.images = images;
}
public void addImage(Image image) {
if (image != null) {
images.add(image);
}
}
private class NoteData {
private long mTextDataId;

@ -0,0 +1,66 @@
package net.micode.notes.model;
class Blob {
private byte[] data;
public Blob(byte[] data) {
this.data = data;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
}
public class Image {
private String path;
private Blob thumbnail;
private Date uploadTime;
public Image(String path, Blob thumbnail, Date uploadTime) {
this.path = path;
this.thumbnail = thumbnail;
this.uploadTime = uploadTime;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Blob getThumbnail() {
return thumbnail;
}
public void setThumbnail(Blob thumbnail) {
this.thumbnail = thumbnail;
}
public Date getUploadTime() {
return uploadTime;
}
public void setUploadTime(Date uploadTime) {
this.uploadTime = uploadTime;
}
public Blob getPreview() {
// Return the thumbnail as the preview
return thumbnail;
}
public Object getMetadata() {
// Create a metadata object with relevant information
Map<String, Object> metadata = new HashMap<>();
metadata.put("path", path);
metadata.put("uploadTime", uploadTime);
// Add more metadata fields if necessary
return metadata;
}
}
Loading…
Cancel
Save