From 504f4003553fb25be9897a3c591d536d54cf53e2 Mon Sep 17 00:00:00 2001 From: nuclearfog Date: Thu, 12 Oct 2023 21:17:08 +0200 Subject: [PATCH] added public timeline selector, version upgrade, settings page layout fix. removed unused settings --- app/build.gradle | 4 +- .../twidda/backend/api/mastodon/Mastodon.java | 8 +- .../api/mastodon/impl/MastodonUser.java | 6 - .../twidda/config/GlobalSettings.java | 68 ++- .../twidda/database/AppDatabase.java | 10 - .../twidda/database/impl/DatabaseUser.java | 9 +- .../org/nuclearfog/twidda/model/User.java | 5 - .../twidda/ui/activities/ProfileActivity.java | 5 - .../ui/activities/SettingsActivity.java | 160 +++---- app/src/main/res/layout/page_settings.xml | 400 +++++++++--------- app/src/main/res/values-de-rDE/arrays.xml | 6 + app/src/main/res/values-de-rDE/strings.xml | 3 +- app/src/main/res/values-es/strings.xml | 2 - app/src/main/res/values-zh-rCN/strings.xml | 1 - app/src/main/res/values/arrays.xml | 6 + app/src/main/res/values/dimens.xml | 2 +- app/src/main/res/values/strings.xml | 3 +- 17 files changed, 328 insertions(+), 370 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 825c1167..064abf9c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' } diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/Mastodon.java b/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/Mastodon.java index 5d28562d..80526a1d 100644 --- a/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/Mastodon.java +++ b/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/Mastodon.java @@ -467,8 +467,10 @@ public class Mastodon implements Connection { @Override public Statuses searchStatuses(String search, long minId, long maxId) throws MastodonException { List 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 { @@ -482,8 +484,10 @@ public class Mastodon implements Connection { @Override public Statuses getPublicTimeline(long minId, long maxId) throws MastodonException { List 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); } diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonUser.java b/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonUser.java index d8b30fa8..588448c5 100644 --- a/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonUser.java +++ b/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonUser.java @@ -171,12 +171,6 @@ public class MastodonUser implements User { } - @Override - public boolean followRequested() { - return false; - } - - @Override public int getFollowing() { return following; diff --git a/app/src/main/java/org/nuclearfog/twidda/config/GlobalSettings.java b/app/src/main/java/org/nuclearfog/twidda/config/GlobalSettings.java index e6262ccd..ae5fc0f5 100644 --- a/app/src/main/java/org/nuclearfog/twidda/config/GlobalSettings.java +++ b/app/src/main/java/org/nuclearfog/twidda/config/GlobalSettings.java @@ -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 */ @@ -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"; @@ -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"; @@ -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; @@ -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; @@ -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; @@ -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; @@ -362,28 +374,6 @@ public class GlobalSettings { 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 * @@ -417,7 +407,7 @@ public class GlobalSettings { popup_color, highlight_color, card_color, icon_color, repost_color, favorite_color, - request_color, follow_color + follow_color }; } @@ -716,23 +706,24 @@ public class GlobalSettings { } /** - * 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(); } @@ -1009,7 +1000,6 @@ public class GlobalSettings { 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); @@ -1023,11 +1013,11 @@ public class GlobalSettings { 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, ""); diff --git a/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java b/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java index 26bc94a1..08ee8ed7 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java @@ -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 */ @@ -1357,11 +1352,6 @@ public class AppDatabase { } 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 { diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseUser.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseUser.java index 160473e8..53025b3e 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseUser.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseUser.java @@ -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 = ""; @@ -62,7 +62,6 @@ public class DatabaseUser implements User, UserTable, UserRegisterTable { 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) @@ -169,12 +168,6 @@ public class DatabaseUser implements User, UserTable, UserRegisterTable { } - @Override - public boolean followRequested() { - return followReqSent; - } - - @Override public int getFollowing() { return following; diff --git a/app/src/main/java/org/nuclearfog/twidda/model/User.java b/app/src/main/java/org/nuclearfog/twidda/model/User.java index 28c20b6f..19318758 100644 --- a/app/src/main/java/org/nuclearfog/twidda/model/User.java +++ b/app/src/main/java/org/nuclearfog/twidda/model/User.java @@ -79,11 +79,6 @@ public interface User extends Serializable, Comparable { */ boolean isProtected(); - /** - * @return true if current user has requested a follow - */ - boolean followRequested(); - /** * @return number of following */ diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/activities/ProfileActivity.java b/app/src/main/java/org/nuclearfog/twidda/ui/activities/ProfileActivity.java index 669237dc..a3299024 100644 --- a/app/src/main/java/org/nuclearfog/twidda/ui/activities/ProfileActivity.java +++ b/app/src/main/java/org/nuclearfog/twidda/ui/activities/ProfileActivity.java @@ -302,11 +302,6 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene 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); diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/activities/SettingsActivity.java b/app/src/main/java/org/nuclearfog/twidda/ui/activities/SettingsActivity.java index e7730352..dfc30a87 100644 --- a/app/src/main/java/org/nuclearfog/twidda/ui/activities/SettingsActivity.java +++ b/app/src/main/java/org/nuclearfog/twidda/ui/activities/SettingsActivity.java @@ -79,7 +79,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen /** * total count of all colors defined */ - private static final int COLOR_COUNT = 10; + private static final int COLOR_COUNT = 9; // app colors private static final int COLOR_BACKGROUND = 0; private static final int COLOR_TEXT = 1; @@ -89,8 +89,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen private static final int COLOR_ICON = 5; private static final int COLOR_REPOST = 6; private static final int COLOR_FAVORITE = 7; - private static final int COLOR_FOLLOW_REQUEST = 8; - private static final int COLOR_FOLLOWING = 9; + private static final int COLOR_FOLLOWING = 8; private GlobalSettings settings; private DatabaseAction databaseAction; @@ -124,41 +123,40 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen protected void onCreate(@Nullable Bundle b) { super.onCreate(b); setContentView(R.layout.page_settings); - Button delButton = findViewById(R.id.delete_db); - Button logout = findViewById(R.id.logout); - Toolbar toolbar = findViewById(R.id.toolbar_setting); - View user_card = findViewById(R.id.settings_data_card); - View push_label = findViewById(R.id.settings_enable_push_descr); - SwitchButton toggleImg = findViewById(R.id.toggleImg); - SwitchButton toolbarOverlap = findViewById(R.id.settings_toolbar_ov); - SwitchButton enableLike = findViewById(R.id.enable_like); - SwitchButton enableLocalTl = findViewById(R.id.settings_local_timeline); - SwitchButton hideSensitive = findViewById(R.id.enable_status_hide_sensitive); - SwitchButton enableStatusIcons = findViewById(R.id.enable_status_indicators); - SwitchButton enableFloatingButton = findViewById(R.id.settings_enable_floating_button); - SeekBar listSizeSelector = findViewById(R.id.settings_list_seek); - Spinner fontSelector = findViewById(R.id.spinner_font); - Spinner scaleSelector = findViewById(R.id.spinner_scale); - enablePush = findViewById(R.id.settings_enable_push); - enable_proxy = findViewById(R.id.settings_enable_proxy); - enable_auth = findViewById(R.id.settings_enable_auth); - enable_auth_label = findViewById(R.id.settings_enable_auth_descr); - colorButtons[COLOR_BACKGROUND] = findViewById(R.id.color_background); - colorButtons[COLOR_TEXT] = findViewById(R.id.color_text); - colorButtons[COLOR_WINDOW] = findViewById(R.id.color_window); - colorButtons[COLOR_HIGHLIGHT] = findViewById(R.id.highlight_color); - colorButtons[COLOR_CARD] = findViewById(R.id.color_card); - colorButtons[COLOR_ICON] = findViewById(R.id.color_icon); - colorButtons[COLOR_REPOST] = findViewById(R.id.color_rt); - colorButtons[COLOR_FAVORITE] = findViewById(R.id.color_fav); - colorButtons[COLOR_FOLLOW_REQUEST] = findViewById(R.id.color_f_req); - colorButtons[COLOR_FOLLOWING] = findViewById(R.id.color_follow); - proxy_address = findViewById(R.id.edit_proxy_address); - proxy_port = findViewById(R.id.edit_proxy_port); - proxy_user = findViewById(R.id.edit_proxyuser); - proxy_pass = findViewById(R.id.edit_proxypass); - list_size = findViewById(R.id.settings_list_size); - root = findViewById(R.id.settings_layout); + Button delButton = findViewById(R.id.page_settings_button_delete_data); + Button logout = findViewById(R.id.page_settings_button_logout); + Toolbar toolbar = findViewById(R.id.page_settings_toolbar); + View user_card = findViewById(R.id.page_settings_card_data); + View push_label = findViewById(R.id.page_settings_enable_push_label); + SwitchButton toggleImg = findViewById(R.id.page_settings_enable_images); + SwitchButton toolbarOverlap = findViewById(R.id.page_settings_toolbar_collapse); + SwitchButton enableLike = findViewById(R.id.page_settings_enable_like); + SwitchButton hideSensitive = findViewById(R.id.page_Settings_sensitive_enable); + SwitchButton enableStatusIcons = findViewById(R.id.page_Settings_enable_status_indicators); + SwitchButton enableFloatingButton = findViewById(R.id.page_settings_enable_floating_button); + SeekBar listSizeSelector = findViewById(R.id.page_settings_list_seek); + Spinner fontSelector = findViewById(R.id.page_settings_font_selector); + Spinner scaleSelector = findViewById(R.id.page_settings_textscale_selector); + Spinner publicTimelineSelector = findViewById(R.id.page_settings_public_timeline_selector); + enablePush = findViewById(R.id.page_settings_enable_push); + enable_proxy = findViewById(R.id.page_settings_enable_proxy); + enable_auth = findViewById(R.id.page_settings_enable_proxyauth); + enable_auth_label = findViewById(R.id.page_settings_enable_proxyauth_label); + colorButtons[COLOR_BACKGROUND] = findViewById(R.id.page_settings_color_background); + colorButtons[COLOR_TEXT] = findViewById(R.id.page_settings_color_text); + colorButtons[COLOR_WINDOW] = findViewById(R.id.page_settings_color_window); + colorButtons[COLOR_HIGHLIGHT] = findViewById(R.id.page_settings_highlight_color); + colorButtons[COLOR_CARD] = findViewById(R.id.page_settings_color_card); + colorButtons[COLOR_ICON] = findViewById(R.id.page_settings_color_icon); + colorButtons[COLOR_REPOST] = findViewById(R.id.page_settings_color_repost); + colorButtons[COLOR_FAVORITE] = findViewById(R.id.page_settings_color_favorite); + colorButtons[COLOR_FOLLOWING] = findViewById(R.id.page_settings_color_follow); + proxy_address = findViewById(R.id.page_settings_input_proxyaddress); + proxy_port = findViewById(R.id.page_settings_input_proxyport); + proxy_user = findViewById(R.id.page_settings_input_proxyuser); + proxy_pass = findViewById(R.id.page_settings_input_proxypass); + list_size = findViewById(R.id.page_settings_list_seek_value); + root = findViewById(R.id.page_settings_root); settings = GlobalSettings.get(this); Configuration configuration = settings.getLogin().getConfiguration(); @@ -175,10 +173,13 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen AppStyles.setTheme(root); AppStyles.setOverflowIcon(toolbar, settings.getIconColor()); + DropdownAdapter publicTimelineAdapter = new DropdownAdapter(this); fontAdapter.setFonts(GlobalSettings.FONT_TYPES); fontAdapter.setItems(GlobalSettings.FONT_NAMES); scaleAdapter.setItems(R.array.scales); + publicTimelineAdapter.setItems(R.array.public_timelines); + publicTimelineSelector.setAdapter(publicTimelineAdapter); fontSelector.setAdapter(fontAdapter); scaleSelector.setAdapter(scaleAdapter); fontSelector.setSelection(settings.getFontIndex(), false); @@ -186,8 +187,8 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen fontSelector.setSelected(false); scaleSelector.setSelected(false); - if (configuration.isPublicTimelinesupported()) { - enableLocalTl.setVisibility(View.VISIBLE); + if (!configuration.isPublicTimelinesupported()) { + publicTimelineSelector.setVisibility(View.GONE); } if (!configuration.isWebpushSupported()) { push_label.setVisibility(View.GONE); @@ -214,10 +215,16 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen } else { colorButtons[COLOR_FAVORITE].setText(R.string.settings_color_fav); } + if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_COMBINED)) { + publicTimelineSelector.setSelection(0); + } else if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_LOCAL)) { + publicTimelineSelector.setSelection(1); + } else if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_REMOTE)) { + publicTimelineSelector.setSelection(2); + } toggleImg.setCheckedImmediately(settings.imagesEnabled()); toolbarOverlap.setCheckedImmediately(settings.toolbarOverlapEnabled()); enableLike.setCheckedImmediately(settings.likeEnabled()); - enableLocalTl.setCheckedImmediately(settings.useLocalTimeline()); hideSensitive.setCheckedImmediately(settings.hideSensitiveEnabled()); enableStatusIcons.setCheckedImmediately(settings.statusIndicatorsEnabled()); enableFloatingButton.setCheckedImmediately(settings.floatingButtonEnabled()); @@ -239,7 +246,6 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen toggleImg.setOnCheckedChangeListener(this); enablePush.setOnCheckedChangeListener(this); enableLike.setOnCheckedChangeListener(this); - enableLocalTl.setOnCheckedChangeListener(this); enableStatusIcons.setOnCheckedChangeListener(this); hideSensitive.setOnCheckedChangeListener(this); enableFloatingButton.setOnCheckedChangeListener(this); @@ -249,6 +255,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen toolbarOverlap.setOnCheckedChangeListener(this); fontSelector.setOnItemSelectedListener(this); scaleSelector.setOnItemSelectedListener(this); + publicTimelineSelector.setOnItemSelectedListener(this); listSizeSelector.setOnSeekBarChangeListener(this); } @@ -331,75 +338,69 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen @Override public void onClick(View v) { // delete database - if (v.getId() == R.id.delete_db) { + if (v.getId() == R.id.page_settings_button_delete_data) { confirmDialog.show(ConfirmDialog.DELETE_APP_DATA); } // logout - else if (v.getId() == R.id.logout) { + else if (v.getId() == R.id.page_settings_button_logout) { confirmDialog.show(ConfirmDialog.APP_LOG_OUT); } // set background color - else if (v.getId() == R.id.color_background) { + else if (v.getId() == R.id.page_settings_color_background) { mode = COLOR_BACKGROUND; color = settings.getBackgroundColor(); showColorPicker(color, false); } // set font color - else if (v.getId() == R.id.color_text) { + else if (v.getId() == R.id.page_settings_color_text) { mode = COLOR_TEXT; color = settings.getTextColor(); showColorPicker(color, false); } // set popup color - else if (v.getId() == R.id.color_window) { + else if (v.getId() == R.id.page_settings_color_window) { mode = COLOR_WINDOW; color = settings.getPopupColor(); showColorPicker(color, false); } // set highlight color - else if (v.getId() == R.id.highlight_color) { + else if (v.getId() == R.id.page_settings_highlight_color) { mode = COLOR_HIGHLIGHT; color = settings.getHighlightColor(); showColorPicker(color, false); } // set card color - else if (v.getId() == R.id.color_card) { + else if (v.getId() == R.id.page_settings_color_card) { mode = COLOR_CARD; color = settings.getCardColor(); showColorPicker(color, true); } // set icon color - else if (v.getId() == R.id.color_icon) { + else if (v.getId() == R.id.page_settings_color_icon) { mode = COLOR_ICON; color = settings.getIconColor(); showColorPicker(color, false); } // set repost icon color - else if (v.getId() == R.id.color_rt) { + else if (v.getId() == R.id.page_settings_color_repost) { mode = COLOR_REPOST; color = settings.getRepostIconColor(); showColorPicker(color, false); } // set favorite icon color - else if (v.getId() == R.id.color_fav) { + else if (v.getId() == R.id.page_settings_color_favorite) { mode = COLOR_FAVORITE; color = settings.getFavoriteIconColor(); showColorPicker(color, false); } // set follow icon color - else if (v.getId() == R.id.color_f_req) { - mode = COLOR_FOLLOW_REQUEST; - color = settings.getFollowPendingColor(); - showColorPicker(color, false); - } - // set follow icon color - else if (v.getId() == R.id.color_follow) { + else if (v.getId() == R.id.page_settings_color_follow) { mode = COLOR_FOLLOWING; color = settings.getFollowIconColor(); showColorPicker(color, false); } // show push configuration dialog - else if (v.getId() == R.id.settings_enable_push_descr) { + else if (v.getId() == R.id.page_settings_enable_push_label) { if (enablePush.isChecked()) { pushDialog.show(); } @@ -462,11 +463,6 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen AppStyles.setColorButton(colorButtons[COLOR_FAVORITE], color); break; - case COLOR_FOLLOW_REQUEST: - settings.setFollowPendingColor(color); - AppStyles.setColorButton(colorButtons[COLOR_FOLLOW_REQUEST], color); - break; - case COLOR_FOLLOWING: settings.setFollowIconColor(color); AppStyles.setColorButton(colorButtons[COLOR_FOLLOWING], color); @@ -479,15 +475,15 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen @Override public void onCheckedChanged(CompoundButton c, boolean checked) { // toggle image loading - if (c.getId() == R.id.toggleImg) { + if (c.getId() == R.id.page_settings_enable_images) { settings.setImageLoad(checked); } // enable toolbar overlap - else if (c.getId() == R.id.settings_toolbar_ov) { + else if (c.getId() == R.id.page_settings_toolbar_collapse) { settings.setToolbarOverlap(checked); } // enable like - else if (c.getId() == R.id.enable_like) { + else if (c.getId() == R.id.page_settings_enable_like) { settings.enableLike(checked); if (checked) { colorButtons[COLOR_FAVORITE].setText(R.string.settings_color_like); @@ -496,19 +492,15 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen } } // enable status indicators - else if (c.getId() == R.id.enable_status_indicators) { + else if (c.getId() == R.id.page_Settings_enable_status_indicators) { settings.enableStatusIndicators(checked); } // enable floating button - else if (c.getId() == R.id.settings_enable_floating_button) { + else if (c.getId() == R.id.page_settings_enable_floating_button) { settings.enableFloatingButton(checked); } - // enable/disable local timeline (Mastodon) - else if (c.getId() == R.id.settings_local_timeline) { - settings.setLocalTimeline(checked); - } // enable/disable push notification - else if (c.getId() == R.id.settings_enable_push) { + else if (c.getId() == R.id.page_settings_enable_push) { if (checked) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && checkSelfPermission(POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{POST_NOTIFICATIONS}, REQUEST_PERMISSION_NOTIFICATION); @@ -522,7 +514,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen settings.setPushEnabled(checked); } // enable proxy settings - else if (c.getId() == R.id.settings_enable_proxy) { + else if (c.getId() == R.id.page_settings_enable_proxy) { if (checked) { proxy_address.setVisibility(View.VISIBLE); proxy_port.setVisibility(View.VISIBLE); @@ -537,7 +529,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen } } // enable proxy authentication - else if (c.getId() == R.id.settings_enable_auth) { + else if (c.getId() == R.id.page_settings_enable_proxyauth) { if (checked) { proxy_user.setVisibility(View.VISIBLE); proxy_pass.setVisibility(View.VISIBLE); @@ -547,7 +539,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen } } // hide sensitive content - else if (c.getId() == R.id.enable_status_hide_sensitive) { + else if (c.getId() == R.id.page_Settings_sensitive_enable) { settings.hideSensitive(checked); } } @@ -556,15 +548,23 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { // Font type spinner - if (parent.getId() == R.id.spinner_font) { + if (parent.getId() == R.id.page_settings_font_selector) { settings.setFontIndex(position); AppStyles.setFontStyle(root); } // Font scale spinner - else if (parent.getId() == R.id.spinner_scale) { + else if (parent.getId() == R.id.page_settings_textscale_selector) { settings.setScaleIndex(position); AppStyles.updateFontScale(this); setResult(RETURN_FONT_SCALE_CHANGED); + } else if (parent.getId() == R.id.page_settings_public_timeline_selector) { + if (position == 0) { + settings.setPublicTimeline(GlobalSettings.TIMELINE_COMBINED); + } else if (position == 1) { + settings.setPublicTimeline(GlobalSettings.TIMELINE_LOCAL); + } else if (position == 2) { + settings.setPublicTimeline(GlobalSettings.TIMELINE_REMOTE); + } } } diff --git a/app/src/main/res/layout/page_settings.xml b/app/src/main/res/layout/page_settings.xml index 7033f623..23b1be1a 100644 --- a/app/src/main/res/layout/page_settings.xml +++ b/app/src/main/res/layout/page_settings.xml @@ -2,7 +2,7 @@ @@ -40,141 +40,131 @@ android:padding="@dimen/settings_cardview_padding"> + app:layout_constraintTop_toBottomOf="@id/page_settings_title_color" + app:constraint_referenced_ids="page_settings_color_background,page_settings_color_text" />