Skip to content

Commit

Permalink
added status history viewer, layout update, bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Oct 23, 2023
1 parent 6124810 commit 11512a3
Show file tree
Hide file tree
Showing 34 changed files with 891 additions and 75 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId 'org.nuclearfog.twidda'
minSdkVersion 21
targetSdkVersion 34
versionCode 100
versionName '3.4.4'
versionCode 101
versionName '3.4.5'
resConfigs 'en', 'es', 'de-rDE', 'zh-rCN'
}

Expand Down Expand Up @@ -48,7 +48,7 @@ android {

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

<activity
android:name=".ui.activities.EditHistoryActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

<receiver
android:name=".notification.PushNotificationReceiver"
android:enabled="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.nuclearfog.twidda.model.lists.Notifications;
import org.nuclearfog.twidda.model.lists.Rules;
import org.nuclearfog.twidda.model.lists.ScheduledStatuses;
import org.nuclearfog.twidda.model.lists.StatusEditHistoy;
import org.nuclearfog.twidda.model.lists.StatusEditHistory;
import org.nuclearfog.twidda.model.lists.Statuses;
import org.nuclearfog.twidda.model.lists.UserLists;
import org.nuclearfog.twidda.model.lists.Users;
Expand Down Expand Up @@ -290,7 +290,7 @@ public interface Connection {
* @param id ID of the status
* @return list of edited posts
*/
StatusEditHistoy getStatusEditHistory(long id) throws ConnectionException;
StatusEditHistory getStatusEditHistory(long id) throws ConnectionException;

/**
* get trending hashtags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import org.nuclearfog.twidda.model.lists.Notifications;
import org.nuclearfog.twidda.model.lists.Rules;
import org.nuclearfog.twidda.model.lists.ScheduledStatuses;
import org.nuclearfog.twidda.model.lists.StatusEditHistoy;
import org.nuclearfog.twidda.model.lists.StatusEditHistory;
import org.nuclearfog.twidda.model.lists.Statuses;
import org.nuclearfog.twidda.model.lists.UserLists;
import org.nuclearfog.twidda.model.lists.Users;
Expand Down Expand Up @@ -476,7 +476,7 @@ public Statuses searchStatuses(String search, long minId, long maxId) throws Mas
else if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_REMOTE))
params.add("remote=true");
if (search.matches("#\\S+")) {
return getStatuses(ENDPOINT_HASHTAG_TIMELINE + search.substring(1), params, minId, maxId);
return getStatuses(ENDPOINT_HASHTAG_TIMELINE + StringUtils.encode(search.substring(1)), params, minId, maxId);
} else {
params.add("q=" + StringUtils.encode(search));
params.add("type=statuses");
Expand All @@ -497,9 +497,9 @@ else if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_REMOTE))


@Override
public StatusEditHistoy getStatusEditHistory(long id) throws ConnectionException {
public StatusEditHistory getStatusEditHistory(long id) throws ConnectionException {
try {
StatusEditHistoy result = new StatusEditHistoy();
StatusEditHistory result = new StatusEditHistory();
Response response = get(ENDPOINT_STATUS + id + "/history", new ArrayList<>());
ResponseBody body = response.body();
if (response.code() == 200 && body != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.nuclearfog.twidda.backend.utils.StringUtils;
import org.nuclearfog.twidda.model.EditedStatus;
import org.nuclearfog.twidda.model.Emoji;
import org.nuclearfog.twidda.model.Location;
import org.nuclearfog.twidda.model.Media;
import org.nuclearfog.twidda.model.Poll;
import org.nuclearfog.twidda.model.User;
Expand Down Expand Up @@ -38,9 +39,8 @@ public EditedMastodonStatus(JSONObject json, long currentUserId) throws JSONExce
JSONArray mediaArray = json.optJSONArray("media_attachments");
JSONArray emojiArray = json.optJSONArray("emojis");
String content = json.optString("content", "");
String spoilerText = json.optString("spoiler_text", "");
text = StringUtils.extractText(content);
spoiler = !content.equals(spoilerText);
spoiler = json.optBoolean("spoiler_text", false);
sensitive = json.optBoolean("sensitive", false);
timestamp = StringUtils.getIsoTime(json.optString("created_at"));
author = new MastodonUser(json.getJSONObject("account"), currentUserId);
Expand Down Expand Up @@ -112,4 +112,11 @@ public Media[] getMedia() {
public Emoji[] getEmojis() {
return emojis;
}


@Nullable
@Override
public Location getLocation() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.nuclearfog.twidda.backend.async;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.nuclearfog.twidda.backend.api.Connection;
import org.nuclearfog.twidda.backend.api.ConnectionException;
import org.nuclearfog.twidda.backend.api.ConnectionManager;
import org.nuclearfog.twidda.model.lists.StatusEditHistory;

/**
* Async loader for {@link org.nuclearfog.twidda.ui.fragments.EditHistoryFragment}
*
* @author nuclearfog
*/
public class EditHistoryLoader extends AsyncExecutor<Long, EditHistoryLoader.Result> {

private Connection connection;

/**
*
*/
public EditHistoryLoader(Context context) {
connection = ConnectionManager.getDefaultConnection(context);
}


@Override
protected Result doInBackground(@NonNull Long param) {
try {
StatusEditHistory history = connection.getStatusEditHistory(param);
return new Result(history, null);
} catch (ConnectionException exception) {
return new Result(null, exception);
}
}

/**
*
*/
public static class Result {

@Nullable
public final StatusEditHistory history;
@Nullable
public final ConnectionException exception;

Result(@Nullable StatusEditHistory history, @Nullable ConnectionException exception) {
this.history = history;
this.exception = exception;
}
}
}
16 changes: 15 additions & 1 deletion app/src/main/java/org/nuclearfog/twidda/model/EditedStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @author nuclearfog
*/
public interface EditedStatus extends Serializable {
public interface EditedStatus extends Serializable, Comparable<EditedStatus> {

/**
* @return timestamp of this revision
Expand Down Expand Up @@ -51,4 +51,18 @@ public interface EditedStatus extends Serializable {
* @return array of emojis used in the text
*/
Emoji[] getEmojis();

/**
* @return location associated with this status
*/
@Nullable
Location getLocation();

/**
*
*/
@Override
default int compareTo(EditedStatus status) {
return Long.compare(status.getTimestamp(), getTimestamp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @author nuclearfog
*/
public interface ScheduledStatus extends Serializable {
public interface ScheduledStatus extends Serializable, Comparable<ScheduledStatus> {

/**
* @return ID of the scheduled status
Expand Down Expand Up @@ -56,4 +56,11 @@ public interface ScheduledStatus extends Serializable {
* @return true if status contains spoiler information
*/
boolean isSpoiler();

/**
*
*/
default int compareTo(ScheduledStatus status) {
return Long.compare(status.getId(), getId());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.nuclearfog.twidda.model.lists;

import androidx.annotation.NonNull;

import org.nuclearfog.twidda.model.Account;

import java.util.LinkedList;
Expand All @@ -24,4 +26,11 @@ public Accounts() {
public Accounts(Accounts accounts) {
super(accounts);
}


@NonNull
@Override
public String toString() {
return "item_count=" + size();
}
}
27 changes: 26 additions & 1 deletion app/src/main/java/org/nuclearfog/twidda/model/lists/Domains.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.nuclearfog.twidda.model.lists;

import androidx.annotation.NonNull;

import java.util.LinkedList;

/**
Expand Down Expand Up @@ -69,12 +71,35 @@ public void addAll(int index, Domains list) {
super.addAll(index, list);
}


/**
* get previous cursor of this list
*
* @return cursor or 0L if not set
*/
public long getPreviousCursor() {
return prevCursor;
}

/**
* get cursor for next items
* get next cursor of this list
*
* @return cursor or 0L if not set
*/
public long getNextCursor() {
return nextCursor;
}


@Override
@NonNull
public String toString() {
int itemCount = 0;
for (String item : this) {
if (item != null) {
itemCount++;
}
}
return "item_count=" + itemCount + " previous=" + getPreviousCursor() + " next=" + getNextCursor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public Fields(Field[] fields) {
@NonNull
@Override
public String toString() {
return "size=" + size();
return "item_count=" + size();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.nuclearfog.twidda.model.lists;

import androidx.annotation.NonNull;

import org.nuclearfog.twidda.model.Filter;

import java.util.LinkedList;
Expand All @@ -15,4 +17,11 @@ public class Filters extends LinkedList<Filter> {
public Filters() {
super();
}


@NonNull
@Override
public String toString() {
return "item_count=" + size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public void replaceAll(Hashtags hashtags) {
@Override
@NonNull
public String toString() {
return "size=" + size() + " min_id=" + prevCursor + " max_id=" + nextCursor;
int itemCount = 0;
for (Hashtag item : this) {
if (item != null) {
itemCount++;
}
}
return "item_count=" + itemCount + " previous=" + getPreviousCursor() + " next=" + getNextCursor();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.nuclearfog.twidda.model.lists;

import androidx.annotation.NonNull;

import org.nuclearfog.twidda.model.Notification;

import java.util.LinkedList;
Expand All @@ -24,4 +26,17 @@ public Notifications() {
public Notifications(Notifications notifications) {
super(notifications);
}


@NonNull
@Override
public String toString() {
int itemCount = 0;
for (Notification item : this) {
if (item != null) {
itemCount++;
}
}
return "item_count=" + itemCount;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.nuclearfog.twidda.model.lists;

import androidx.annotation.NonNull;

import org.nuclearfog.twidda.model.Rule;

import java.util.ArrayList;
Expand All @@ -23,4 +25,11 @@ public Rules() {
public Rules(int cap) {
super(cap);
}


@NonNull
@Override
public String toString() {
return "item_count=" + size();
}
}
Loading

0 comments on commit 11512a3

Please sign in to comment.