database fix, adapter bug fix, readme update

This commit is contained in:
nuclearfog 2022-12-04 12:14:52 +01:00
parent effb3f0bdb
commit eb3f445552
No known key found for this signature in database
GPG Key ID: 03488A185C476379
5 changed files with 37 additions and 54 deletions

View File

@ -8,14 +8,14 @@
## Features ## Features
- fast access to tweets, userprofiles and trends - access to statuses, users and trends
- tweet, directmessage and userlist editor - real timeline (chronological order)
- status, list and profile editor
- customizable theme - customizable theme
- image/video preview - media preview
- GPS locale support - GPS locale support
- proxy support - multi account support (experimental support for Mastodon)
- multi account support - no ads, no app tracking, proxy support
- custom API key support
## Screenshots ## Screenshots
@ -30,6 +30,7 @@ If you have any questions or if you have found a bug, please open an issue.
## 3rd party libraries and licenses ## 3rd party libraries and licenses
- <a href="https://github.com/square/picasso">picasso 2.8</a> - <a href="https://github.com/square/picasso">picasso 2.8</a>
- <a href="https://github.com/QuadFlask/colorpicker">QuadFlask colorpicker</a> - <a href="https://github.com/QuadFlask/colorpicker">QuadFlask colorpicker</a>
- <a href="https://github.com/MichaelRocks/paranoid">String obfuscation</a> - <a href="https://github.com/MichaelRocks/paranoid">String obfuscation</a>
@ -41,13 +42,14 @@ If you have any questions or if you have found a bug, please open an issue.
- <a href="https://github.com/nuclearfog/ZoomView">ZoomView</a> - <a href="https://github.com/nuclearfog/ZoomView">ZoomView</a>
- <a href="https://github.com/nuclearfog/Tagger">Tagger</a> - <a href="https://github.com/nuclearfog/Tagger">Tagger</a>
- <a href="https://github.com/nuclearfog/LinkAndScrollMovement">LinkAndScrollMovement</a> - <a href="https://github.com/nuclearfog/LinkAndScrollMovement">LinkAndScrollMovement</a>
- Version 1.x: <a href="https://github.com/Twitter4J/Twitter4J">Twitter4J 4.0.7</a>
## Graphics ## Graphics
- SVG Icons from <a href="http://www.entypo.com">Entypo</a> & <a href="https://www.svgrepo.com">SVG Repo</a> - SVG Icons from <a href="http://www.entypo.com">Entypo</a> & <a href="https://www.svgrepo.com">SVG Repo</a>
- logo and app icon design by <a href="https://github.com/Tobaloidee">@Tobaloidee</a> - logo and app icon design by <a href="https://github.com/Tobaloidee">@Tobaloidee</a>
- Twitter4J logo (version 1.x) from <a href="https://twitter4j.org/en/powered-by.html">Twitter4J website</a> - Twitter4J logo (version 1.x) from <a href="https://twitter4j.org/en/powered-by.html">Twitter4J website</a>
## Thanks to ## Thanks to
- <a href="https://github.com/Tobaloidee">@Tobaloidee</a> - <a href="https://github.com/Tobaloidee">@Tobaloidee</a>
- <a href="https://github.com/lehmaning">@lehmaning</a> - <a href="https://github.com/lehmaning">@lehmaning</a>

View File

@ -91,7 +91,7 @@ public class MessageHolder extends ViewHolder implements OnClickListener, OnTagC
} else if (v == delete) { } else if (v == delete) {
listener.onItemClick(position, OnItemClickListener.MESSAGE_DELETE); listener.onItemClick(position, OnItemClickListener.MESSAGE_DELETE);
} else if (v == profile) { } else if (v == profile) {
listener.onItemClick(position, OnItemClickListener.PROFILE_CLICK); listener.onItemClick(position, OnItemClickListener.MESSAGE_PROFILE);
} else if (v == mediaButton) { } else if (v == mediaButton) {
listener.onItemClick(position, OnItemClickListener.MESSAGE_MEDIA); listener.onItemClick(position, OnItemClickListener.MESSAGE_MEDIA);
} }

View File

@ -11,35 +11,33 @@ public interface OnHolderClickListener {
int LIST_CLICK = 1; int LIST_CLICK = 1;
int PROFILE_CLICK = 2; int USER_CLICK = 2;
int USER_CLICK = 3; int USER_REMOVE = 3;
int USER_REMOVE = 4; int STATUS_CLICK = 4;
int STATUS_CLICK = 5; int STATUS_LABEL = 5;
int STATUS_LABEL = 6; int LIST_PROFILE = 6;
int LIST_PROFILE = 7; int MESSAGE_VIEW = 7;
int MESSAGE_VIEW = 8; int MESSAGE_ANSWER = 8;
int MESSAGE_ANSWER = 9; int MESSAGE_PROFILE = 9;
int MESSAGE_PROFILE = 10; int MESSAGE_MEDIA = 10;
int MESSAGE_MEDIA = 11; int MESSAGE_DELETE = 11;
int MESSAGE_DELETE = 12; int ACCOUNT_SELECT = 12;
int ACCOUNT_SELECT = 13; int ACCOUNT_REMOVE = 13;
int ACCOUNT_REMOVE = 14; int IMAGE_CLICK = 14;
int IMAGE_CLICK = 15; int IMAGE_SAVE = 15;
int IMAGE_SAVE = 16;
/** /**
* called when an item was clicked * called when an item was clicked

View File

@ -33,8 +33,6 @@ import org.nuclearfog.twidda.model.User;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/** /**
* SQLite database class to store and load status, messages, trends and user information * SQLite database class to store and load status, messages, trends and user information
@ -205,6 +203,10 @@ public class AppDatabase {
* SQL query to get current user's messages * SQL query to get current user's messages
*/ */
private static final String MESSAGE_QUERY = "SELECT * FROM " + MessageTable.NAME private static final String MESSAGE_QUERY = "SELECT * FROM " + MessageTable.NAME
+ " INNER JOIN " + UserTable.NAME
+ " ON " + MessageTable.NAME + "." + MessageTable.FROM + "=" + UserTable.NAME + "." + UserTable.ID
+ " INNER JOIN " + UserRegisterTable.NAME
+ " ON " + MessageTable.NAME + "." + MessageTable.FROM + "=" + UserRegisterTable.NAME + "." + UserRegisterTable.ID
+ " WHERE " + MessageTable.FROM + "=? OR " + MessageTable.TO + "=?" + " WHERE " + MessageTable.FROM + "=? OR " + MessageTable.TO + "=?"
+ " ORDER BY " + MessageTable.SINCE + " DESC LIMIT ?;"; + " ORDER BY " + MessageTable.SINCE + " DESC LIMIT ?;";
@ -706,27 +708,16 @@ public class AppDatabase {
* @return list of direct messages * @return list of direct messages
*/ */
public Messages getMessages() { public Messages getMessages() {
String homeIdStr = Long.toString(settings.getLogin().getId()); long currentId = settings.getLogin().getId();
String homeIdStr = Long.toString(currentId);
String[] args = {homeIdStr, homeIdStr, Integer.toString(settings.getListSize())}; String[] args = {homeIdStr, homeIdStr, Integer.toString(settings.getListSize())};
Messages result = new Messages(null, null); Messages result = new Messages(null, null);
SQLiteDatabase db = getDbRead(); SQLiteDatabase db = getDbRead();
Map<Long, User> userCache = new TreeMap<>();
Cursor cursor = db.rawQuery(MESSAGE_QUERY, args); Cursor cursor = db.rawQuery(MESSAGE_QUERY, args);
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
do do
{ {
User sender; result.add(new MessageImpl(cursor, currentId));
MessageImpl message = new MessageImpl(cursor);
if (userCache.containsKey(message.getSenderId())) {
sender = userCache.get(message.getSenderId());
} else {
sender = getUser(message.getSenderId());
userCache.put(message.getSenderId(), sender);
}
if (sender != null) {
message.setSender(sender);
result.add(message);
}
} while (cursor.moveToNext()); } while (cursor.moveToNext());
} }
cursor.close(); cursor.close();

View File

@ -19,18 +19,20 @@ public class MessageImpl implements Message {
private long id; private long id;
private long time; private long time;
private long senderId;
private long receiverId; private long receiverId;
private String text; private String text;
private User sender; private User sender;
private String media; private String media;
/**
public MessageImpl(Cursor cursor) { * @param cursor database cursor containing UserTable column
* @param currentId Id of the current user
*/
public MessageImpl(Cursor cursor, long currentId) {
sender = new UserImpl(cursor, currentId);
text = cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.MESSAGE)); text = cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.MESSAGE));
time = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.SINCE)); time = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.SINCE));
id = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.ID)); id = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.ID));
senderId = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.FROM));
receiverId = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.TO)); receiverId = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.TO));
media = cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.MEDIA)); media = cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.MEDIA));
} }
@ -88,14 +90,4 @@ public class MessageImpl implements Message {
public String toString() { public String toString() {
return "from=" + sender + " message=\"" + text + "\""; return "from=" + sender + " message=\"" + text + "\"";
} }
public void setSender(User sender) {
this.sender = sender;
}
public long getSenderId() {
return senderId;
}
} }