Skip to content

Commit

Permalink
added public timeline selector, version upgrade, settings page layout…
Browse files Browse the repository at this point in the history
… fix. removed unused settings
  • Loading branch information
nuclearfog committed Oct 12, 2023
1 parent b07e27f commit 504f400
Show file tree
Hide file tree
Showing 17 changed files with 326 additions and 368 deletions.
4 changes: 2 additions & 2 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 99
versionName '3.4.3'
versionCode 100
versionName '3.4.4'
resConfigs 'en', 'es', 'de-rDE', 'zh-rCN'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,10 @@ public Relation unmuteUser(long id) throws MastodonException {
@Override
public Statuses searchStatuses(String search, long minId, long maxId) throws MastodonException {
List<String> params = new ArrayList<>();
if (settings.useLocalTimeline())
if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_LOCAL))
params.add("local=true");
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);
} else {
Expand All @@ -482,8 +484,10 @@ public Statuses searchStatuses(String search, long minId, long maxId) throws Mas
@Override
public Statuses getPublicTimeline(long minId, long maxId) throws MastodonException {
List<String> params = new ArrayList<>();
if (settings.useLocalTimeline())
if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_LOCAL))
params.add("local=true");
else if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_REMOTE))
params.add("remote=true");
return getStatuses(ENDPOINT_PUBLIC_TIMELINE, params, minId, maxId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ public boolean isProtected() {
}


@Override
public boolean followRequested() {
return false;
}


@Override
public int getFollowing() {
return following;
Expand Down
68 changes: 29 additions & 39 deletions app/src/main/java/org/nuclearfog/twidda/config/GlobalSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ public class GlobalSettings {
*/
public static final float[] FONT_SCALES = {0.5f, 0.8f, 1.0f, 1.5f, 2.0f};

/**
* indicates a remote public timelines only
*/
public static final String TIMELINE_REMOTE = "public_timeline_remote";

/**
* indicates a local public timeline only
*/
public static final String TIMELINE_LOCAL = "public_timeline_local";

/**
* indicates all public timelines (local&remote)
*/
public static final String TIMELINE_COMBINED = "public_timeline_all";

/**
* singleton instance
*/
Expand All @@ -63,7 +78,6 @@ public class GlobalSettings {
private static final String RT_COLOR = "retweet_color";
private static final String FV_COLOR = "favorite_color";
private static final String FOLLOW_COLOR = "following_color";
private static final String F_REQ_COLOR = "following_pending_color";
private static final String INDEX_FONT = "index_font";
private static final String INDEX_SCALE = "index_scale";
private static final String LIST_SIZE = "preload";
Expand All @@ -79,7 +93,7 @@ public class GlobalSettings {
private static final String PROXY_WARNING = "proxy_warning";
private static final String ENABLE_LIKE = "like_enable";
private static final String FILTER_RESULTS = "filter_results";
private static final String MASTODON_LOCAL_TIMELINE = "mastodon_local_timeline";
private static final String PUBLIC_TIMELINE = "public_timeline";
private static final String HIDE_SENSITIVE = "hide_sensitive";
private static final String FLOATING_BUTTON = "floating_button_enabled";
private static final String PUSH_ENABLED = "push_enabled";
Expand Down Expand Up @@ -126,7 +140,6 @@ public class GlobalSettings {
private static final int DEFAULT_ICON_COLOR = Color.WHITE;
private static final int DEFAULT_RT_ICON_COLOR = Color.GREEN;
private static final int DEFAULT_FV_ICON_COLOR = Color.YELLOW;
private static final int DEFAULT_FR_ICON_COLOR = Color.YELLOW;
private static final int DEFAULT_FW_ICON_COLOR = Color.CYAN;

private SharedPreferences settings;
Expand All @@ -136,6 +149,7 @@ public class GlobalSettings {
private String proxyHost, proxyPort;
private String proxyUser, proxyPass;
private String pushInstance;
private String publicTimeline;
private boolean loadImage;
private boolean loggedIn;
private boolean push_enabled;
Expand All @@ -146,7 +160,6 @@ public class GlobalSettings {
private boolean showStatusIcons;
private boolean filterResults;
private boolean enableLike;
private boolean localOnly;
private boolean hideSensitive;
private boolean floatingEnabled;
private int background_color;
Expand All @@ -157,7 +170,6 @@ public class GlobalSettings {
private int popup_color;
private int repost_color;
private int favorite_color;
private int request_color;
private int follow_color;
private int indexFont;
private int indexScale;
Expand Down Expand Up @@ -362,28 +374,6 @@ public void setRepostIconColor(int color) {
edit.apply();
}

/**
* get icon color of the follow button
*
* @return icon color
*/
public int getFollowPendingColor() {
return request_color;
}

/**
* set icon color of the follow button
*
* @param color icon color
*/
public void setFollowPendingColor(int color) {
request_color = color;

Editor edit = settings.edit();
edit.putInt(F_REQ_COLOR, color);
edit.apply();
}

/**
* get icon color for the follow button
*
Expand Down Expand Up @@ -417,7 +407,7 @@ public int[] getAllColors() {
popup_color, highlight_color,
card_color, icon_color,
repost_color, favorite_color,
request_color, follow_color
follow_color
};
}

Expand Down Expand Up @@ -716,23 +706,24 @@ public void enableLike(boolean enableLike) {
}

/**
* use public Mastodon timeline of the local server only
* get public timeline type
*
* @return true to use local timeline only
* @return type {@link #TIMELINE_LOCAL,#TIMELINE_REMOTE,#TIMELINE_COMBINED}
*/
public boolean useLocalTimeline() {
return localOnly;
public String getPublicTimeline() {
return publicTimeline;
}

/**
* set public Mastodon timeline
* set public timeline type
*
* @param enable true to use local timeline only
* @param publicTimeline type {@link #TIMELINE_LOCAL,#TIMELINE_REMOTE,#TIMELINE_COMBINED}
*/
public void setLocalTimeline(boolean enable) {
localOnly = enable;
public void setPublicTimeline(String publicTimeline) {
this.publicTimeline = publicTimeline;

Editor edit = settings.edit();
edit.putBoolean(MASTODON_LOCAL_TIMELINE, enable);
edit.putString(PUBLIC_TIMELINE, publicTimeline);
edit.apply();
}

Expand Down Expand Up @@ -1009,7 +1000,6 @@ private void initialize() {
icon_color = settings.getInt(ICON_COLOR, DEFAULT_ICON_COLOR);
repost_color = settings.getInt(RT_COLOR, DEFAULT_RT_ICON_COLOR);
favorite_color = settings.getInt(FV_COLOR, DEFAULT_FV_ICON_COLOR);
request_color = settings.getInt(F_REQ_COLOR, DEFAULT_FR_ICON_COLOR);
follow_color = settings.getInt(FOLLOW_COLOR, DEFAULT_FW_ICON_COLOR);
indexFont = settings.getInt(INDEX_FONT, DEFAULT_FONT_INDEX);
indexScale = settings.getInt(INDEX_SCALE, DEFAULT_SCALE_INDEX);
Expand All @@ -1023,11 +1013,11 @@ private void initialize() {
toolbarOverlap = settings.getBoolean(PROFILE_OVERLAP, true);
filterResults = settings.getBoolean(FILTER_RESULTS, true);
enableLike = settings.getBoolean(ENABLE_LIKE, false);
localOnly = settings.getBoolean(MASTODON_LOCAL_TIMELINE, false);
hideSensitive = settings.getBoolean(HIDE_SENSITIVE, true);
floatingEnabled = settings.getBoolean(FLOATING_BUTTON, true);
proxyWarning = settings.getBoolean(PROXY_WARNING, true);
pushInstance = settings.getString(PUSH_INSTANCE, ConstantsKt.INSTANCE_DEFAULT);
publicTimeline = settings.getString(PUBLIC_TIMELINE, TIMELINE_COMBINED);
proxyHost = settings.getString(PROXY_ADDR, "");
proxyPort = settings.getString(PROXY_PORT, "");
proxyUser = settings.getString(PROXY_USER, "");
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ public class AppDatabase {
*/
public static final int MASK_USER_PRIVATE = 1 << 1;

/**
* flag indicates that the current user has sent a follow request to an user
*/
public static final int MASK_USER_FOLLOW_REQUESTED = 1 << 2;

/**
* flag indicates that the statuses of an user are excluded from timeline
*/
Expand Down Expand Up @@ -1357,11 +1352,6 @@ private void saveUser(User user, SQLiteDatabase db, int mode) {
} else {
flags &= ~MASK_USER_PRIVATE;
}
if (user.followRequested()) {
flags |= MASK_USER_FOLLOW_REQUESTED;
} else {
flags &= ~MASK_USER_FOLLOW_REQUESTED;
}
if (user.hasDefaultProfileImage()) {
flags |= MASK_USER_DEFAULT_IMAGE;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DatabaseUser implements User, UserTable, UserRegisterTable {

private long id, createdAt;
private int following, follower, statusCount, favorCount;
private boolean isCurrentUser, isVerified, isLocked, followReqSent, defaultImage;
private boolean isCurrentUser, isVerified, isLocked, defaultImage;
private String username = "";
private String screen_name = "";
private String bio = "";
Expand Down Expand Up @@ -62,7 +62,6 @@ public DatabaseUser(Cursor cursor, Account account) {
int register = cursor.getInt(cursor.getColumnIndexOrThrow(REGISTER));
isVerified = (register & AppDatabase.MASK_USER_VERIFIED) != 0;
isLocked = (register & AppDatabase.MASK_USER_PRIVATE) != 0;
followReqSent = (register & AppDatabase.MASK_USER_FOLLOW_REQUESTED) != 0;
defaultImage = (register & AppDatabase.MASK_USER_DEFAULT_IMAGE) != 0;

if (username != null)
Expand Down Expand Up @@ -169,12 +168,6 @@ public boolean isProtected() {
}


@Override
public boolean followRequested() {
return followReqSent;
}


@Override
public int getFollowing() {
return following;
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/org/nuclearfog/twidda/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public interface User extends Serializable, Comparable<User> {
*/
boolean isProtected();

/**
* @return true if current user has requested a follow
*/
boolean followRequested();

/**
* @return number of following
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@ public boolean onPrepareOptionsMenu(@NonNull Menu m) {
reportItem.setVisible(!user.isCurrentUser());
break;
}
if (user.followRequested()) {
MenuItem followIcon = m.findItem(R.id.profile_follow);
AppStyles.setMenuItemColor(followIcon, settings.getFollowPendingColor());
followIcon.setTitle(R.string.menu_follow_requested);
}
if (!user.isCurrentUser()) {
MenuItem followIcon = m.findItem(R.id.profile_follow);
MenuItem blockIcon = m.findItem(R.id.profile_block);
Expand Down
Loading

0 comments on commit 504f400

Please sign in to comment.