diff --git a/Yeeemp/app/src/androidTest/java/art/pegasko/yeeemp/DBImplTest.java b/Yeeemp/app/src/androidTest/java/art/pegasko/yeeemp/DBImplTest.java
deleted file mode 100644
index 5576625..0000000
--- a/Yeeemp/app/src/androidTest/java/art/pegasko/yeeemp/DBImplTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Copyright 2024 pegasko
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- package art.pegasko.yeeemp;
-
-import android.database.sqlite.SQLiteDatabase;
-import android.provider.CalendarContract;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import art.pegasko.yeeemp.base.Event;
-import art.pegasko.yeeemp.base.Queue;
-import art.pegasko.yeeemp.base.Tag;
-import art.pegasko.yeeemp.impl.QueueMakerImpl;
-import art.pegasko.yeeemp.impl.TagMakerImpl;
-
-@RunWith(AndroidJUnit4.class)
-public class DBImplTest {
-
- private SQLiteDatabase db;
-
- @Before
- public void setUp() {
- db = SQLiteDatabase.create(null);
-// db = SQLiteDatabase.openDatabase("test.db", SQLiteDatabase.OpenParams);
- }
-
- @After
- public void tearDown() {
- db.close();
- }
-
- @Test
- public void testQueueMakerImpl() {
- SQLiteDatabase db = SQLiteDatabase.create(null);
- QueueMakerImpl queueMaker = new QueueMakerImpl(db);
-
- Queue q = queueMaker.create();
-
- // check initial ID
- assert q.getId() == 0;
-
- // check null name
- assert q.getName() == null;
-
- // check no events
- Event[] events = q.getEvents();
- assert events != null;
- assert events.length == 0;
-
- // check no tags
- Tag[] tags = q.getGlobalTags();
- assert tags != null;
- assert tags.length == 0;
-
- // Check name set
- q.setName("aboba");
- assert q.getName() == "aboba";
- }
-
- @Test
- public void testTagMakerImpl() {
- }
-}
diff --git a/Yeeemp/app/src/androidTest/java/art/pegasko/yeeemp/ExampleInstrumentedTest.java b/Yeeemp/app/src/androidTest/java/art/pegasko/yeeemp/ExampleInstrumentedTest.java
deleted file mode 100644
index 2fb2e34..0000000
--- a/Yeeemp/app/src/androidTest/java/art/pegasko/yeeemp/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2024 pegasko
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package art.pegasko.yeeemp;
-
-import android.content.Context;
-
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- assertEquals("art.pegasko.yeeemp", appContext.getPackageName());
- }
-}
\ No newline at end of file
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Event.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Event.java
index 2c315f7..ce6a1ad 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Event.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Event.java
@@ -18,12 +18,20 @@ package art.pegasko.yeeemp.base;
public interface Event {
int getId();
+
long getTimestamp();
+
void setTimestamp(long timestamp);
+
String getComment();
+
void setComment(String comment);
+
void addTag(Tag tag);
+
void removeTag(Tag tag);
+
void removeTags();
+
Tag[] getTags();
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/EventMaker.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/EventMaker.java
index 34a30e0..6eacef5 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/EventMaker.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/EventMaker.java
@@ -18,6 +18,8 @@ package art.pegasko.yeeemp.base;
public interface EventMaker {
Event create();
+
void delete(Event event);
+
Event getById(int id);
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Queue.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Queue.java
index 8295d98..f7af19e 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Queue.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Queue.java
@@ -18,11 +18,18 @@ package art.pegasko.yeeemp.base;
public interface Queue {
int getId();
+
String getName();
+
void setName(String name);
+
Event[] getEvents();
+
int getEventCount();
+
void addEvent(Event event);
+
void removeEvent(Event event);
- Tag[] getGlobalTags();
+
+ TagStat[] getGlobalTags();
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/QueueMaker.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/QueueMaker.java
index 52b1a70..0c826cb 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/QueueMaker.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/QueueMaker.java
@@ -18,7 +18,10 @@ package art.pegasko.yeeemp.base;
public interface QueueMaker {
Queue getById(int id);
+
Queue create();
+
void delete(Queue queue);
+
Queue[] list();
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Tag.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Tag.java
index b9239be..cb5ccb5 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Tag.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Tag.java
@@ -18,5 +18,6 @@ package art.pegasko.yeeemp.base;
public interface Tag {
int getId();
+
String getName();
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/TagMaker.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/TagMaker.java
index d63d3e4..79fec81 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/TagMaker.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/TagMaker.java
@@ -17,6 +17,5 @@
package art.pegasko.yeeemp.base;
public interface TagMaker {
- /** Get or Create distinct name Tag in Queue */
Tag getOrCreateInQueue(Queue queue, String name);
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Wrapper.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Wrapper.java
index b5517fc..bdb9bce 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Wrapper.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/base/Wrapper.java
@@ -40,6 +40,8 @@ public abstract class Wrapper {
}
public abstract QueueMaker queueMaker();
+
public abstract EventMaker eventMaker();
+
public abstract TagMaker tagMaker();
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/DBWrapper.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/DBWrapper.java
index 84e0df1..f4b5e8b 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/DBWrapper.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/DBWrapper.java
@@ -129,7 +129,7 @@ public class DBWrapper extends Wrapper {
try {
new File(context.getFilesDir(), DB_PATH).delete();
} catch (Exception e) {
- Log.wtf(DBWrapper.TAG, e);
+ Log.wtf(TAG, e);
}
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventImpl.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventImpl.java
index d6fab96..6eea11a 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventImpl.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventImpl.java
@@ -46,14 +46,8 @@ public class EventImpl implements Event {
@Override
public long getTimestamp() {
synchronized (this.db) {
- Cursor cursor = db.query(
- "event",
- new String[] { "timestamp" },
- "id = ?",
- new String[] { Integer.toString(this.getId()) },
- null,
- null,
- null
+ Cursor cursor = db.query("event", new String[] { "timestamp" }, "id = ?",
+ new String[] { Integer.toString(this.getId()) }, null, null, null
);
if (Utils.findResult(cursor)) {
@@ -69,26 +63,15 @@ public class EventImpl implements Event {
synchronized (this.db) {
ContentValues cv = new ContentValues();
cv.put("timestamp", timestamp);
- db.update(
- "event",
- cv,
- "id = ?",
- new String[] { Integer.toString(this.getId()) }
- );
+ db.update("event", cv, "id = ?", new String[] { Integer.toString(this.getId()) });
}
}
@Override
public String getComment() {
synchronized (this.db) {
- Cursor cursor = db.query(
- "event",
- new String[] { "comment" },
- "id = ?",
- new String[] { Integer.toString(this.getId()) },
- null,
- null,
- null
+ Cursor cursor = db.query("event", new String[] { "comment" }, "id = ?",
+ new String[] { Integer.toString(this.getId()) }, null, null, null
);
if (Utils.findResult(cursor)) {
@@ -104,27 +87,18 @@ public class EventImpl implements Event {
synchronized (this.db) {
ContentValues cv = new ContentValues();
cv.put("comment", comment);
- db.update(
- "event",
- cv,
- "id = ?",
- new String[] { Integer.toString(this.getId()) }
- );
+ db.update("event", cv, "id = ?", new String[] { Integer.toString(this.getId()) });
}
}
- /** !synchronized */
+ /**
+ * !synchronized
+ */
protected boolean hasTag(Tag tag) {
synchronized (this.db) {
- Cursor cursor = db.query(
- "event_tag",
- new String[] { "1" },
- "event_id = ? AND tag_id = ?",
- new String[] { Integer.toString(this.getId()), Integer.toString(tag.getId()) },
- null,
- null,
- null
- );
+ Cursor cursor = db.query("event_tag", new String[] { "1" }, "event_id = ? AND tag_id = ?", new String[] {
+ Integer.toString(this.getId()), Integer.toString(tag.getId())
+ }, null, null, null);
return Utils.findResult(cursor);
}
@@ -133,11 +107,9 @@ public class EventImpl implements Event {
@Override
public void addTag(Tag tag) {
synchronized (this.db) {
- if (tag == null)
- return;
+ if (tag == null) return;
- if (this.hasTag(tag))
- return;
+ if (this.hasTag(tag)) return;
try {
ContentValues cv = new ContentValues();
@@ -153,18 +125,14 @@ public class EventImpl implements Event {
@Override
public void removeTag(Tag tag) {
synchronized (this.db) {
- if (tag == null)
- return;
+ if (tag == null) return;
- if (!this.hasTag(tag))
- return;
+ if (!this.hasTag(tag)) return;
try {
- db.delete(
- "event_tag",
- "event_id = ? AND tag_id = ?",
- new String[] { Integer.toString(this.getId()), Integer.toString(tag.getId()) }
- );
+ db.delete("event_tag", "event_id = ? AND tag_id = ?", new String[] {
+ Integer.toString(this.getId()), Integer.toString(tag.getId())
+ });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
@@ -175,11 +143,7 @@ public class EventImpl implements Event {
public void removeTags() {
synchronized (this.db) {
try {
- db.delete(
- "event_tag",
- "event_id = ?",
- new String[] { Integer.toString(this.getId()) }
- );
+ db.delete("event_tag", "event_id = ?", new String[] { Integer.toString(this.getId()) });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
@@ -189,14 +153,8 @@ public class EventImpl implements Event {
@Override
public Tag[] getTags() {
synchronized (this.db) {
- Cursor cursor = db.query(
- "event_tag",
- new String[] { "tag_id" },
- "event_id = ?",
- new String[] { Integer.toString(this.getId()) },
- null,
- null,
- null
+ Cursor cursor = db.query("event_tag", new String[] { "tag_id" }, "event_id = ?",
+ new String[] { Integer.toString(this.getId()) }, null, null, "tag_id desc"
);
if (cursor == null) {
@@ -207,10 +165,7 @@ public class EventImpl implements Event {
int index = 0;
while (cursor.moveToNext()) {
- tags[index++] = new TagImpl(
- this.db,
- cursor.getInt(0)
- );
+ tags[index++] = new TagImpl(this.db, cursor.getInt(0));
}
return tags;
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventMakerImpl.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventMakerImpl.java
index b389d9d..c609d7f 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventMakerImpl.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/EventMakerImpl.java
@@ -49,8 +49,7 @@ public class EventMakerImpl implements EventMaker {
null
);
- if (Utils.findResult(cursor))
- return new EventImpl(this.db, id);
+ if (Utils.findResult(cursor)) return new EventImpl(this.db, id);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
@@ -67,10 +66,7 @@ public class EventMakerImpl implements EventMaker {
ContentValues cv = new ContentValues();
cv.put("id", (Integer) null);
long rowId = db.insertOrThrow("event", null, cv);
- return new EventImpl(
- this.db,
- (int) rowId
- );
+ return new EventImpl(this.db, (int) rowId);
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
@@ -84,25 +80,13 @@ public class EventMakerImpl implements EventMaker {
synchronized (this.db) {
try {
// Delete queue <-> event
- db.delete(
- "queue_event",
- "event_id = ?",
- new String[] { Integer.toString(event.getId()) }
- );
+ db.delete("queue_event", "event_id = ?", new String[] { Integer.toString(event.getId()) });
// Delete event <-> tag
- db.delete(
- "event_tag",
- "event_id = ?",
- new String[] { Integer.toString(event.getId()) }
- );
+ db.delete("event_tag", "event_id = ?", new String[] { Integer.toString(event.getId()) });
// Delete event
- db.delete(
- "event",
- "id = ?",
- new String[] { Integer.toString(event.getId()) }
- );
+ db.delete("event", "id = ?", new String[] { Integer.toString(event.getId()) });
} catch (SQLiteException e) {
Log.wtf(TAG, e);
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueImpl.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueImpl.java
index 65efba2..37192e2 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueImpl.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueImpl.java
@@ -27,6 +27,7 @@ import androidx.annotation.NonNull;
import art.pegasko.yeeemp.base.Event;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.Tag;
+import art.pegasko.yeeemp.base.TagStat;
import kotlin.NotImplementedError;
public class QueueImpl implements Queue {
@@ -131,7 +132,9 @@ public class QueueImpl implements Queue {
}
}
- /** !synchronized */
+ /**
+ * !synchronized
+ */
protected boolean hasEvent(Event event) {
synchronized (this.db) {
Cursor cursor = db.query(
@@ -190,30 +193,60 @@ public class QueueImpl implements Queue {
}
@Override
- public Tag[] getGlobalTags() {
+ public TagStat[] getGlobalTags() {
synchronized (this.db) {
- Cursor cursor = db.query(
- "tag",
- new String[] { "id" },
- "queue_id = ?",
- new String[] { Integer.toString(this.getId()) },
- null,
- null,
- null
+ Cursor cursor = db.rawQuery(
+ "select" +
+ " tag_id,\n" +
+ " count(*) as cnt\n" +
+ "from (\n" +
+ " select\n" +
+ " event_id,\n" +
+ " tag_id\n" +
+ " from (\n" +
+ " select\n" +
+ " event_tag.event_id as event_id,\n" +
+ " event_tag.tag_id as tag_id\n" +
+ " from (\n" +
+ " select\n" +
+ " event_id\n" +
+ " from\n" +
+ " queue_event\n" +
+ " where\n" +
+ " queue_id = ?\n" +
+ " ) as queue_event_temp\n" +
+ " inner join\n" +
+ " event_tag\n" +
+ " on\n" +
+ " (event_tag.event_id = queue_event_temp.event_id)\n" +
+ " )\n" +
+ " group by\n" +
+ " event_id,\n" +
+ " tag_id\n" +
+ ")\n" +
+ "group by\n" +
+ " tag_id\n" +
+ "order by\n" +
+ " cnt desc",
+ new String[] { Integer.toString(this.getId()) }
);
if (cursor == null) {
- return new Tag[0];
+ return new TagStat[0];
}
- Tag[] tags = new Tag[cursor.getCount()];
+ TagStat[] tags = new TagStat[cursor.getCount()];
int index = 0;
while (cursor.moveToNext()) {
- tags[index++] = new TagImpl(
+ TagStat tagStat = new TagStat();
+ tags[index++] = tagStat;
+
+ tagStat.tag = new TagImpl(
this.db,
cursor.getInt(0)
);
+ tagStat.count = cursor.getInt(1);
}
return tags;
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueMakerImpl.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueMakerImpl.java
index 208bf2a..e94e655 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueMakerImpl.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/QueueMakerImpl.java
@@ -50,11 +50,16 @@ public class QueueMakerImpl implements QueueMaker {
null
);
- if (Utils.findResult(cursor))
- return new QueueImpl(this.db, id);
+ if (Utils.findResult(cursor)) return new QueueImpl(
+ this.db,
+ id
+ );
} catch (SQLiteException e) {
- Log.wtf(TAG, e);
+ Log.wtf(
+ TAG,
+ e
+ );
}
return null;
@@ -66,14 +71,24 @@ public class QueueMakerImpl implements QueueMaker {
synchronized (this.db) {
try {
ContentValues cv = new ContentValues();
- cv.put("id", (Integer) null);
- long rowId = db.insertOrThrow("queue", null, cv);
+ cv.put(
+ "id",
+ (Integer) null
+ );
+ long rowId = db.insertOrThrow(
+ "queue",
+ null,
+ cv
+ );
return new QueueImpl(
this.db,
(int) rowId
);
} catch (SQLiteException e) {
- Log.wtf(TAG, e);
+ Log.wtf(
+ TAG,
+ e
+ );
}
return null;
@@ -117,7 +132,7 @@ public class QueueMakerImpl implements QueueMaker {
// Drop events
try {
- for (Event event: queue.getEvents()) {
+ for (Event event : queue.getEvents()) {
db.delete(
"event",
"id = ?",
@@ -125,7 +140,10 @@ public class QueueMakerImpl implements QueueMaker {
);
}
} catch (SQLiteException e) {
- Log.wtf(TAG, e);
+ Log.wtf(
+ TAG,
+ e
+ );
return;
}
@@ -137,7 +155,10 @@ public class QueueMakerImpl implements QueueMaker {
new String[] { Integer.toString(queue.getId()) }
);
} catch (SQLiteException e) {
- Log.wtf(TAG, e);
+ Log.wtf(
+ TAG,
+ e
+ );
}
// Drop queue
@@ -148,7 +169,10 @@ public class QueueMakerImpl implements QueueMaker {
new String[] { Integer.toString(queue.getId()) }
);
} catch (SQLiteException e) {
- Log.wtf(TAG, e);
+ Log.wtf(
+ TAG,
+ e
+ );
}
}
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/Utils.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/Utils.java
index ef03098..be2244c 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/Utils.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/impl/Utils.java
@@ -21,8 +21,7 @@ import android.database.sqlite.SQLiteDatabase;
public class Utils {
public static boolean findResult(Cursor cursor) {
- if (cursor == null)
- return false;
+ if (cursor == null) return false;
cursor.moveToFirst();
return cursor.getCount() != 0;
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/base/Potato.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/base/Potato.java
index 05c4f0c..3399ef4 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/base/Potato.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/base/Potato.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
- package art.pegasko.yeeemp.okand.base;
+package art.pegasko.yeeemp.okand.base;
public abstract class Potato {
private static Potato instance;
@@ -28,6 +28,8 @@ public abstract class Potato {
}
public abstract Event getById(int id);
+
public abstract void save(Event container);
+
public abstract void delete(Event container);
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/impl/DBPotato.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/impl/DBPotato.java
index 551a304..8cc4381 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/impl/DBPotato.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/okand/impl/DBPotato.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
- package art.pegasko.yeeemp.okand.impl;
+package art.pegasko.yeeemp.okand.impl;
import art.pegasko.yeeemp.okand.base.Event;
import art.pegasko.yeeemp.okand.base.Potato;
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditActivity.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditActivity.java
index 560aa0c..1c5b2da 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditActivity.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditActivity.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
- package art.pegasko.yeeemp.ui.activity;
+package art.pegasko.yeeemp.ui.activity;
import androidx.appcompat.app.AppCompatActivity;
@@ -24,9 +24,14 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.util.TimeUtils;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.DatePicker;
+import android.widget.MultiAutoCompleteTextView;
import android.widget.TextView;
import android.widget.TimePicker;
@@ -39,12 +44,16 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
+import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
import art.pegasko.yeeemp.base.Queue;
import art.pegasko.yeeemp.base.Tag;
+import art.pegasko.yeeemp.base.TagStat;
import art.pegasko.yeeemp.databinding.ActivityEventEditBinding;
import art.pegasko.yeeemp.R;
@@ -59,8 +68,11 @@ public class EventEditActivity extends AppCompatActivity {
private Event event;
private EventContainer eventContainer;
private ActivityEventEditBinding binding;
+ private TagStat[] tagStat;
- /** Store values for edited or new event */
+ /**
+ * Store values for edited or new event
+ */
private static class EventContainer {
public String comment;
public long timestamp;
@@ -82,21 +94,33 @@ public class EventEditActivity extends AppCompatActivity {
// Get Queue ID from Intent
Bundle extras = getIntent().getExtras();
if (extras == null) {
- Log.e(TAG, "Missing Intent arguments (queue_id)");
+ Log.e(
+ TAG,
+ "Missing Intent arguments (queue_id)"
+ );
finish();
return;
}
- int queue_id = extras.getInt("queue_id", -1);
+ int queue_id = extras.getInt(
+ "queue_id",
+ -1
+ );
if (queue_id == -1) {
- Log.e(TAG, "Missing Intent arguments (queue_id)");
+ Log.e(
+ TAG,
+ "Missing Intent arguments (queue_id)"
+ );
finish();
return;
}
queue = Wrapper.getQueueMaker().getById(queue_id);
if (queue == null) {
- Log.e(TAG, "Missing Intent arguments (queue_id)");
+ Log.e(
+ TAG,
+ "Missing Intent arguments (queue_id)"
+ );
finish();
return;
}
@@ -107,12 +131,15 @@ public class EventEditActivity extends AppCompatActivity {
// Get Event ID from Intent (optional)
extras = getIntent().getExtras();
if (extras != null) {
- int event_id = extras.getInt("event_id", -1);
+ int event_id = extras.getInt(
+ "event_id",
+ -1
+ );
if (event_id != -1) {
this.event = Wrapper.getEventMaker().getById(event_id);
this.eventContainer.timestamp = this.event.getTimestamp();
this.eventContainer.comment = this.event.getComment();
- for (Tag tag: this.event.getTags()) {
+ for (Tag tag : this.event.getTags()) {
this.eventContainer.tags.add(tag.getName());
}
}
@@ -121,7 +148,8 @@ public class EventEditActivity extends AppCompatActivity {
binding = ActivityEventEditBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
- getSupportActionBar().setTitle(getSupportActionBar().getTitle() + " / " + (event == null ? "Create" : "Edit") + " Event");
+ getSupportActionBar().setTitle(
+ getSupportActionBar().getTitle() + " / " + (event == null ? "Create" : "Edit") + " Event");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
@@ -131,6 +159,17 @@ public class EventEditActivity extends AppCompatActivity {
if (this.eventContainer.comment != null)
binding.eventEditContent.eventEditComment.setText(this.eventContainer.comment);
+ /* Comment Listeners */
+
+ // Request focus on click
+ this.binding.eventEditContent.eventEditContainerComment.setOnClickListener((View view) -> {
+ this.binding.eventEditContent.eventEditComment.requestFocus();
+ this.binding.eventEditContent.eventEditComment.setSelection(
+ EventEditActivity.this.binding.eventEditContent.eventEditComment.getText().length());
+ });
+
+ /* Timestamp Listeners */
+
binding.eventEditContent.eventEditContainerTimestamp.setOnClickListener((View view) -> {
Date date;
if (this.eventContainer.timestamp != 0)
@@ -153,21 +192,34 @@ public class EventEditActivity extends AppCompatActivity {
newDate.setSeconds(0);
this.eventContainer.timestamp = newDate.getTime();
- binding.eventEditContent.eventEditTimestamp.setText(Utils.formatTs(this.eventContainer.timestamp));
+ binding.eventEditContent.eventEditTimestamp.setText(
+ Utils.formatTs(this.eventContainer.timestamp));
},
- date.getHours(), date.getMinutes(), true
+ date.getHours(),
+ date.getMinutes(),
+ true
);
timePickerDialog.show();
- }, date.getYear() + 1900, date.getMonth(), date.getDate()
+ },
+ date.getYear() + 1900,
+ date.getMonth(),
+ date.getDate()
);
datePickerDialog.show();
});
/* FAB Listeners */
binding.fab.setOnLongClickListener((View view) -> {
- Snackbar.make(view, "Save Event", Snackbar.LENGTH_LONG)
+ Snackbar.make(
+ view,
+ "Save Event",
+ Snackbar.LENGTH_LONG
+ )
.setAnchorView(R.id.fab)
- .setAction("Action", null).show();
+ .setAction(
+ "Action",
+ null
+ ).show();
return true;
});
@@ -175,20 +227,75 @@ public class EventEditActivity extends AppCompatActivity {
// Finalize values
this.eventContainer.comment = this.binding.eventEditContent.eventEditComment.getText().toString().trim();
+ String[] tags = EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().toString().split(
+ ",");
+ tags = Utils.orderedDeduplicateIgnoreCaseAndTrim(tags);
+ this.eventContainer.tags.clear();
+ for (String tag : tags) {
+ this.eventContainer.tags.add(tag);
+ }
+
// Fill event
+ boolean hasEvent = this.event != null;
if (this.event == null)
this.event = Wrapper.getEventMaker().create();
this.event.setTimestamp(this.eventContainer.timestamp);
this.event.removeTags();
- for (String tag: this.eventContainer.tags) {
- this.event.addTag(Wrapper.getTagMaker().getOrCreateInQueue(this.queue, tag));
+ for (String tag : this.eventContainer.tags) {
+ this.event.addTag(Wrapper.getTagMaker().getOrCreateInQueue(
+ this.queue,
+ tag
+ ));
}
this.event.setComment(this.eventContainer.comment);
+ if (!hasEvent) {
+ this.queue.addEvent(event);
+ }
+
finish();
});
+ /* Tags list + input */
+ this.tagStat = this.queue.getGlobalTags();
+
+ ArrayAdapter adapter = new EventEditTagsAdapter(
+ this,
+ android.R.layout.simple_dropdown_item_1line,
+ 0,
+ new ArrayList<>(Arrays.asList(this.tagStat))
+ );
+ this.binding.eventEditContent.eventEditTags.setAdapter(adapter);
+ this.binding.eventEditContent.eventEditTags.setThreshold(1);
+ this.binding.eventEditContent.eventEditTags.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
+ this.binding.eventEditContent.eventEditTags.setOnItemClickListener((parent, view, position, id) -> {
+ String[] tags = EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().toString().split(
+ ",");
+ tags = Utils.orderedDeduplicateIgnoreCaseAndTrim(tags);
+
+ EventEditActivity.this.binding.eventEditContent.eventEditTags.setText(String.join(
+ ", ",
+ tags
+ ));
+ EventEditActivity.this.binding.eventEditContent.eventEditTags.setSelection(
+ EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().length());
+ });
+
+ // Request focus on click
+ this.binding.eventEditContent.eventEditContainerTags.setOnClickListener((View view) -> {
+ this.binding.eventEditContent.eventEditTags.requestFocus();
+ this.binding.eventEditContent.eventEditTags.setSelection(
+ EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().length());
+ });
+
+ // Fill
+ this.binding.eventEditContent.eventEditTags.setText(String.join(
+ ", ",
+ this.eventContainer.tags
+ ));
+ this.binding.eventEditContent.eventEditTags.setSelection(
+ EventEditActivity.this.binding.eventEditContent.eventEditTags.getText().length());
}
@Override
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditTagsAdapter.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditTagsAdapter.java
new file mode 100644
index 0000000..a2975a6
--- /dev/null
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventEditTagsAdapter.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2024 pegasko
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package art.pegasko.yeeemp.ui.activity;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Filter;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import art.pegasko.yeeemp.base.TagStat;
+
+public class EventEditTagsAdapter extends ArrayAdapter {
+ public static final String TAG = EventEditTagsAdapter.class.getSimpleName();
+
+ private ArrayList items;
+ private ArrayList itemsAll;
+ private ArrayList suggestions;
+ private int viewResourceId;
+ private int viewFieldId;
+ private LayoutInflater inflater;
+
+ @SuppressWarnings("unchecked")
+ public EventEditTagsAdapter(Context context, int viewResourceId, int viewFieldId, ArrayList items) {
+ super(context, viewResourceId, items);
+ this.items = items;
+ this.itemsAll = (ArrayList) items.clone();
+ this.suggestions = new ArrayList();
+ this.viewResourceId = viewResourceId;
+ this.viewFieldId = viewFieldId;
+ this.inflater = LayoutInflater.from(context);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) convertView = inflater.inflate(this.viewResourceId, parent, false);
+
+ TextView text;
+ try {
+ if (this.viewFieldId == 0) {
+ text = (TextView) convertView;
+ } else {
+ text = convertView.findViewById(this.viewFieldId);
+ }
+
+ if (text == null) {
+ Log.e(TAG, "Failed attach text to view");
+ throw new RuntimeException("Failed attach text to view");
+ }
+ } catch (ClassCastException e) {
+ Log.e(TAG, "You must supply a resource ID for a TextView");
+ throw new RuntimeException("You must supply a resource ID for a TextView");
+ }
+
+ text.setText(items.get(position).tag.getName() + " (" + Integer.toString(items.get(position).count) + ")");
+
+ return convertView;
+ }
+
+ @Override
+ public Filter getFilter() {
+ return nameFilter;
+ }
+
+ Filter nameFilter = new Filter() {
+ public String convertResultToString(Object resultValue) {
+ String str = ((TagStat) (resultValue)).tag.getName();
+ return str;
+ }
+
+ @Override
+ protected FilterResults performFiltering(CharSequence constraint) {
+ if (constraint != null) {
+ suggestions.clear();
+ for (TagStat product : itemsAll) {
+ if (product.tag.getName().contains(constraint.toString().toLowerCase())) {
+ suggestions.add(product);
+ }
+ }
+ FilterResults filterResults = new FilterResults();
+ filterResults.values = suggestions;
+ filterResults.count = suggestions.size();
+ return filterResults;
+ } else {
+ return new FilterResults();
+ }
+ }
+
+ @Override
+ protected void publishResults(CharSequence constraint, FilterResults results) {
+ @SuppressWarnings("unchecked") ArrayList filteredList = (ArrayList) results.values;
+ if (results != null && results.count > 0) {
+ clear();
+ for (TagStat c : filteredList) {
+ add(c);
+ }
+ notifyDataSetChanged();
+ }
+ }
+ };
+}
\ No newline at end of file
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventListActivity.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventListActivity.java
index 8417950..2fc15cc 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventListActivity.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventListActivity.java
@@ -63,21 +63,33 @@ public class EventListActivity extends AppCompatActivity {
// Get Queue ID from Intent
Bundle extras = getIntent().getExtras();
if (extras == null) {
- Log.e(TAG, "Missing Intent arguments (queue_id)");
+ Log.e(
+ TAG,
+ "Missing Intent arguments (queue_id)"
+ );
finish();
return;
}
- int queue_id = extras.getInt("queue_id", -1);
+ int queue_id = extras.getInt(
+ "queue_id",
+ -1
+ );
if (queue_id == -1) {
- Log.e(TAG, "Missing Intent arguments (queue_id)");
+ Log.e(
+ TAG,
+ "Missing Intent arguments (queue_id)"
+ );
finish();
return;
}
queue = Wrapper.getQueueMaker().getById(queue_id);
if (queue == null) {
- Log.e(TAG, "Missing Intent arguments (queue_id)");
+ Log.e(
+ TAG,
+ "Missing Intent arguments (queue_id)"
+ );
finish();
return;
}
@@ -116,31 +128,33 @@ public class EventListActivity extends AppCompatActivity {
/* FAB Listeners */
binding.fab.setOnLongClickListener((View view) -> {
- Snackbar.make(view, "Create Event", Snackbar.LENGTH_LONG)
+ Snackbar.make(
+ view,
+ "Create Event",
+ Snackbar.LENGTH_LONG
+ )
.setAnchorView(R.id.fab)
- .setAction("Action", null).show();
+ .setAction(
+ "Action",
+ null
+ ).show();
return true;
});
binding.fab.setOnClickListener(view -> {
Bundle extra = new Bundle();
- extra.putInt("queue_id", this.queue.getId());
+ extra.putInt(
+ "queue_id",
+ this.queue.getId()
+ );
- Intent intent = new Intent(view.getContext(), EventEditActivity.class);
+ Intent intent = new Intent(
+ view.getContext(),
+ EventEditActivity.class
+ );
intent.putExtras(extra);
view.getContext().startActivity(intent);
-
-// Log.w(TAG, "TODO: Open editor");
-//
-// Event event = Wrapper.getEventMaker().create();
-// event.setTimestamp(System.currentTimeMillis());
-// event.setComment("Lobster number " + System.currentTimeMillis());
-// queue.addEvent(event);
-//
-// Log.w(TAG, "Create: " + event.toString() + " in " + queue);
-
-// updateList();
});
/* Fill lists */
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventRecyclerViewAdapter.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventRecyclerViewAdapter.java
index 870f33b..fb95b97 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventRecyclerViewAdapter.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/EventRecyclerViewAdapter.java
@@ -59,7 +59,11 @@ class EventRecyclerViewAdapter extends RecyclerView.Adapter {
- PopupMenu popupMenu = new PopupMenu(view.getContext(), viewHolder.getBinding().eventListItemItem);
- popupMenu.getMenuInflater().inflate(R.menu.event_list_item_action_menu, popupMenu.getMenu());
+ PopupMenu popupMenu = new PopupMenu(
+ view.getContext(),
+ viewHolder.getBinding().eventListItemItem
+ );
+ popupMenu.getMenuInflater().inflate(
+ R.menu.event_list_item_action_menu,
+ popupMenu.getMenu()
+ );
popupMenu.setOnMenuItemClickListener((MenuItem menuItem) -> {
if (menuItem.getItemId() == R.id.event_list_item_action_menu_delete) {
new AlertDialog.Builder(view.getContext())
.setTitle("Delete event")
.setMessage("Are you sure you want to delete this event?")
- .setPositiveButton(android.R.string.yes, (dialog, which) -> {
- Wrapper.getEventMaker().delete(events[position]);
+ .setPositiveButton(
+ android.R.string.yes,
+ (dialog, which) -> {
+ Wrapper.getEventMaker().delete(events[position]);
- reloadItems();
- })
- .setNegativeButton(android.R.string.no, null)
+ reloadItems();
+ }
+ )
+ .setNegativeButton(
+ android.R.string.no,
+ null
+ )
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
@@ -115,10 +137,19 @@ class EventRecyclerViewAdapter extends RecyclerView.Adapter {
Bundle extra = new Bundle();
- extra.putInt("event_id", this.events[position].getId());
- extra.putInt("queue_id", this.queue.getId());
+ extra.putInt(
+ "event_id",
+ this.events[position].getId()
+ );
+ extra.putInt(
+ "queue_id",
+ this.queue.getId()
+ );
- Intent intent = new Intent(view.getContext(), EventEditActivity.class);
+ Intent intent = new Intent(
+ view.getContext(),
+ EventEditActivity.class
+ );
intent.putExtras(extra);
view.getContext().startActivity(intent);
@@ -147,19 +178,4 @@ class EventRecyclerViewAdapter extends RecyclerView.Adapter scheduleDeleteAt(int position) {
-// ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
-// ScheduledFuture> future = scheduledExecutorService.schedule(() -> {
-// try {
-// Wrapper.getEventMaker().delete(this.events[position]);
-// } catch (Exception e) {
-// Log.wtf(TAG, e);
-// }
-// }, 5, TimeUnit.SECONDS);
-//
-// // Hide item from list
-//
-// return future;
-// }
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueListActivity.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueListActivity.java
index 8c6726f..cb9e6c6 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueListActivity.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueListActivity.java
@@ -17,7 +17,9 @@
package art.pegasko.yeeemp.ui.activity;
import android.os.Bundle;
+
import com.google.android.material.snackbar.Snackbar;
+
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
@@ -66,16 +68,20 @@ public class QueueListActivity extends AppCompatActivity {
/* FAB Listeners */
binding.fab.setOnLongClickListener((View view) -> {
- Snackbar.make(view, "Create Queue", Snackbar.LENGTH_LONG)
- .setAnchorView(R.id.fab)
- .setAction("Action", null).show();
+ Snackbar.make(
+ view,
+ "Create Queue",
+ Snackbar.LENGTH_LONG
+ ).setAnchorView(R.id.fab).setAction(
+ "Action",
+ null
+ ).show();
return true;
});
binding.fab.setOnClickListener(view -> {
Queue q = Wrapper.getQueueMaker().create();
q.setName("New Queue");
- Log.w(TAG, "Create: " + q.toString());
updateList();
});
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueRecyclerViewAdapter.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueRecyclerViewAdapter.java
index 9165378..0b4d5d0 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueRecyclerViewAdapter.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/QueueRecyclerViewAdapter.java
@@ -50,7 +50,11 @@ class QueueRecyclerViewAdapter extends RecyclerView.Adapter {
- PopupMenu popupMenu = new PopupMenu(view.getContext(), viewHolder.getBinding().queueListItemItem);
- popupMenu.getMenuInflater().inflate(R.menu.queue_list_item_action_menu, popupMenu.getMenu());
+ PopupMenu popupMenu = new PopupMenu(
+ view.getContext(),
+ viewHolder.getBinding().queueListItemItem
+ );
+ popupMenu.getMenuInflater().inflate(
+ R.menu.queue_list_item_action_menu,
+ popupMenu.getMenu()
+ );
popupMenu.setOnMenuItemClickListener((MenuItem menuItem) -> {
if (menuItem.getItemId() == R.id.queue_list_item_action_menu_delete) {
new AlertDialog.Builder(view.getContext())
.setTitle("Delete queue")
.setMessage("Are you sure you want to delete this queue?")
- .setPositiveButton(android.R.string.yes, (dialog, which) -> {
- Wrapper.getQueueMaker().delete(queues[position]);
+ .setPositiveButton(
+ android.R.string.yes,
+ (dialog, which) -> {
+ Wrapper.getQueueMaker().delete(queues[position]);
- reloadItems();
- })
- .setNegativeButton(android.R.string.no, null)
+ reloadItems();
+ }
+ )
+ .setNegativeButton(
+ android.R.string.no,
+ null
+ )
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
} else if (menuItem.getItemId() == R.id.queue_list_item_action_menu_rename) {
@@ -85,13 +101,19 @@ class QueueRecyclerViewAdapter extends RecyclerView.Adapter {
- String name = input.getText().toString().trim();
- queues[position].setName(name);
+ builder.setPositiveButton(
+ "OK",
+ (dialog, which) -> {
+ String name = input.getText().toString().trim();
+ queues[position].setName(name);
- reloadItems();
- });
- builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
+ reloadItems();
+ }
+ );
+ builder.setNegativeButton(
+ "Cancel",
+ (dialog, which) -> dialog.cancel()
+ );
builder.show();
}
@@ -104,9 +126,15 @@ class QueueRecyclerViewAdapter extends RecyclerView.Adapter {
Bundle extra = new Bundle();
- extra.putInt("queue_id", queues[position].getId());
+ extra.putInt(
+ "queue_id",
+ queues[position].getId()
+ );
- Intent intent = new Intent(view.getContext(), EventListActivity.class);
+ Intent intent = new Intent(
+ view.getContext(),
+ EventListActivity.class
+ );
intent.putExtras(extra);
view.getContext().startActivity(intent);
@@ -115,35 +143,11 @@ class QueueRecyclerViewAdapter extends RecyclerView.Adapter {
- Intent intent = new Intent(view.getContext(), EventEditActivity.class);
+ Intent intent = new Intent(
+ view.getContext(),
+ EventEditActivity.class
+ );
view.getContext().startActivity(intent);
-
-// Log.w(TAG, "TODO: Open editor");
-//
-// Event event = Wrapper.getEventMaker().create();
-// event.setTimestamp(System.currentTimeMillis());
-// event.setComment("Lobster number " + System.currentTimeMillis() + "\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
-// queues[position].addEvent(event);
-//
-// Tag[] tags = new Tag[] {
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_cum"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_poo"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_fart"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_penis"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_dick"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_cock"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_zalupa"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_ololo"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_owo"),
-// Wrapper.getTagMaker().getOrCreateInQueue(queues[position], "tag_" + position + "_uwu"),
-// };
-// for (Tag tag: tags) {
-// event.addTag(tag);
-// }
-//
-// Log.w(TAG, "Create: " + event.toString() + " in " + queues[position]);
-//
-// reloadItems();
});
}
diff --git a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/Utils.java b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/Utils.java
index 7810dbf..8d91f67 100644
--- a/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/Utils.java
+++ b/Yeeemp/app/src/main/java/art/pegasko/yeeemp/ui/activity/Utils.java
@@ -17,7 +17,10 @@
package art.pegasko.yeeemp.ui.activity;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
public class Utils {
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
@@ -26,4 +29,24 @@ public class Utils {
SimpleDateFormat sdf = new SimpleDateFormat(Utils.DATE_FORMAT);
return sdf.format(timestamp);
}
+
+ public static String[] orderedDeduplicateIgnoreCaseAndTrim(String[] items) {
+ Set duplicates = new HashSet();
+ ArrayList reverseOrderedItems = new ArrayList();
+
+ for (int index = items.length - 1; index >= 0; --index) {
+ String item = items[index].toLowerCase().trim();
+ if (!duplicates.contains(item) && !item.isEmpty()) {
+ duplicates.add(item);
+ reverseOrderedItems.add(item);
+ }
+ }
+
+ String[] finalItems = new String[reverseOrderedItems.size()];
+ for (int index = 0; index < finalItems.length; ++index) {
+ finalItems[finalItems.length - index - 1] = reverseOrderedItems.get(index);
+ }
+
+ return finalItems;
+ }
}
diff --git a/Yeeemp/app/src/main/res/layout/content_event_edit.xml b/Yeeemp/app/src/main/res/layout/content_event_edit.xml
index f0d02bc..3c60482 100644
--- a/Yeeemp/app/src/main/res/layout/content_event_edit.xml
+++ b/Yeeemp/app/src/main/res/layout/content_event_edit.xml
@@ -5,77 +5,124 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pegasko_black"
- android:orientation="vertical"
- app:layout_behavior="@string/appbar_scrolling_view_behavior">
+ android:orientation="vertical">
-
+ android:layout_height="match_parent">
-
+ android:layout_height="match_parent"
+ android:background="@color/pegasko_black"
+ android:orientation="vertical">
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Yeeemp/app/src/main/res/layout/event_edit_tag.xml b/Yeeemp/app/src/main/res/layout/event_edit_tag.xml
new file mode 100644
index 0000000..1cce0db
--- /dev/null
+++ b/Yeeemp/app/src/main/res/layout/event_edit_tag.xml
@@ -0,0 +1,11 @@
+
+
+
+
\ No newline at end of file
diff --git a/Yeeemp/app/src/main/res/layout/event_list_item.xml b/Yeeemp/app/src/main/res/layout/event_list_item.xml
index 4dce8a1..52d7f19 100644
--- a/Yeeemp/app/src/main/res/layout/event_list_item.xml
+++ b/Yeeemp/app/src/main/res/layout/event_list_item.xml
@@ -40,7 +40,6 @@
android:layout_margin="@dimen/event_list_item_comment_margin"
android:fontFamily="monospace"
android:text="TextView"
- android:textAlignment="center"
android:visibility="gone"
android:padding="@dimen/event_list_item_comment_padding"
android:textColor="@color/pegasko_white"
diff --git a/Yeeemp/app/src/main/res/values/dimens.xml b/Yeeemp/app/src/main/res/values/dimens.xml
index 5eb42c3..086f33d 100644
--- a/Yeeemp/app/src/main/res/values/dimens.xml
+++ b/Yeeemp/app/src/main/res/values/dimens.xml
@@ -53,5 +53,13 @@
8dp
4dp
- 12sp
+ 24sp
+
+ 8dp
+ 4dp
+ 24sp
+
+ 4dp
+ 8dp
+ 24sp
\ No newline at end of file
diff --git a/Yeeemp/app/src/test/java/art/pegasko/yeeemp/ExampleUnitTest.java b/Yeeemp/app/src/test/java/art/pegasko/yeeemp/ExampleUnitTest.java
deleted file mode 100644
index 1ddb4b2..0000000
--- a/Yeeemp/app/src/test/java/art/pegasko/yeeemp/ExampleUnitTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2024 pegasko
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- package art.pegasko.yeeemp;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file