added option to disable floating button, fixed navigation drawer layout and behavior

This commit is contained in:
nuclearfog 2023-07-23 19:01:35 +02:00
parent 428ee14683
commit ebab8a2c68
No known key found for this signature in database
GPG Key ID: 03488A185C476379
10 changed files with 88 additions and 18 deletions

View File

@ -93,6 +93,7 @@ public class GlobalSettings {
private static final String FILTER_RESULTS = "filter_results"; private static final String FILTER_RESULTS = "filter_results";
private static final String MASTODON_LOCAL_TIMELINE = "mastodon_local_timeline"; private static final String MASTODON_LOCAL_TIMELINE = "mastodon_local_timeline";
private static final String HIDE_SENSITIVE = "hide_sensitive"; 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"; private static final String PUSH_ENABLED = "push_enabled";
private static final String LOGIN_ENABLED = "login"; private static final String LOGIN_ENABLED = "login";
@ -162,6 +163,7 @@ public class GlobalSettings {
private boolean twitterAlt; private boolean twitterAlt;
private boolean localOnly; private boolean localOnly;
private boolean hideSensitive; private boolean hideSensitive;
private boolean floatingEnabled;
private int background_color; private int background_color;
private int font_color; private int font_color;
private int highlight_color; private int highlight_color;
@ -501,14 +503,14 @@ public class GlobalSettings {
} }
/** /**
* @return true if tweet indicators enabled * @return true if status indicators enabled
*/ */
public boolean statusIndicatorsEnabled() { public boolean statusIndicatorsEnabled() {
return tweetIndicators; return tweetIndicators;
} }
/** /**
* enable/disable tweet indicators * enable/disable status indicators
* *
* @param enable true to enable tweet indicators * @param enable true to enable tweet indicators
*/ */
@ -520,6 +522,26 @@ public class GlobalSettings {
edit.apply(); edit.apply();
} }
/**
* @return true if floating button (status posting) is enabled
*/
public boolean floatingButtonEnabled() {
return floatingEnabled;
}
/**
* enable/disable floating button (status posting)
*
* @param enable true to enable floating button
*/
public void enableFloatingButton(boolean enable) {
floatingEnabled = enable;
Editor edit = settings.edit();
edit.putBoolean(FLOATING_BUTTON, enable);
edit.apply();
}
/** /**
* @return true to hide sensitivee/spoiler content by default * @return true to hide sensitivee/spoiler content by default
*/ */
@ -1054,6 +1076,7 @@ public class GlobalSettings {
twitterAlt = settings.getBoolean(ENABLE_TWITTER_ALT, false); twitterAlt = settings.getBoolean(ENABLE_TWITTER_ALT, false);
localOnly = settings.getBoolean(MASTODON_LOCAL_TIMELINE, false); localOnly = settings.getBoolean(MASTODON_LOCAL_TIMELINE, false);
hideSensitive = settings.getBoolean(HIDE_SENSITIVE, true); hideSensitive = settings.getBoolean(HIDE_SENSITIVE, true);
floatingEnabled = settings.getBoolean(FLOATING_BUTTON, true);
pushInstance = settings.getString(PUSH_INSTANCE, ConstantsKt.INSTANCE_DEFAULT); pushInstance = settings.getString(PUSH_INSTANCE, ConstantsKt.INSTANCE_DEFAULT);
proxyHost = settings.getString(PROXY_ADDR, ""); proxyHost = settings.getString(PROXY_ADDR, "");
proxyPort = settings.getString(PROXY_PORT, ""); proxyPort = settings.getString(PROXY_PORT, "");

View File

@ -84,6 +84,7 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
private ImageView profileImage; private ImageView profileImage;
private TextView username, screenname; private TextView username, screenname;
private TextView followingCount, followerCount; private TextView followingCount, followerCount;
private View floatingButton;
@Nullable @Nullable
private User currentUser; private User currentUser;
@ -99,10 +100,10 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.page_main); setContentView(R.layout.page_main);
Toolbar toolbar = findViewById(R.id.home_toolbar);
NavigationView navigationView = findViewById(R.id.home_navigator); NavigationView navigationView = findViewById(R.id.home_navigator);
ViewGroup header = (ViewGroup) navigationView.getHeaderView(0); ViewGroup header = (ViewGroup) navigationView.getHeaderView(0);
Toolbar toolbar = findViewById(R.id.home_toolbar); floatingButton = findViewById(R.id.home_post);
View floatingButton = findViewById(R.id.home_post);
drawerLayout = findViewById(R.id.main_layout); drawerLayout = findViewById(R.id.main_layout);
viewPager = findViewById(R.id.home_pager); viewPager = findViewById(R.id.home_pager);
tabSelector = findViewById(R.id.home_tab); tabSelector = findViewById(R.id.home_tab);
@ -118,6 +119,9 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
picasso = PicassoBuilder.get(this); picasso = PicassoBuilder.get(this);
tabSelector.addViewPager(viewPager); tabSelector.addViewPager(viewPager);
viewPager.setOffscreenPageLimit(4); viewPager.setOffscreenPageLimit(4);
if (!settings.floatingButtonEnabled()) {
floatingButton.setVisibility(View.INVISIBLE);
}
toolbar.setTitle(""); toolbar.setTitle("");
toolbar.setNavigationIcon(R.drawable.menu); toolbar.setNavigationIcon(R.drawable.menu);
@ -226,8 +230,14 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
default: default:
case SettingsActivity.RETURN_SETTINGS_CHANGED: case SettingsActivity.RETURN_SETTINGS_CHANGED:
case AccountActivity.RETURN_SETTINGS_CHANGED: case AccountActivity.RETURN_SETTINGS_CHANGED:
if (adapter != null) if (settings.floatingButtonEnabled()) {
floatingButton.setVisibility(View.VISIBLE);
} else {
floatingButton.setVisibility(View.INVISIBLE);
}
if (adapter != null) {
adapter.notifySettingsChanged(); adapter.notifySettingsChanged();
}
setStyle(); setStyle();
setCurrentUser(currentUser); setCurrentUser(currentUser);
break; break;
@ -268,37 +278,42 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
boolean selected = false;
// open filter page // open filter page
if (item.getItemId() == R.id.menu_navigator_filter) { if (item.getItemId() == R.id.menu_navigator_filter) {
Intent intent = new Intent(this, FilterActivity.class); Intent intent = new Intent(this, FilterActivity.class);
startActivity(intent); startActivity(intent);
return true; selected = true;
} }
// open status editor // open status editor
else if (item.getItemId() == R.id.menu_navigator_status) { else if (item.getItemId() == R.id.menu_navigator_status) {
Intent intent = new Intent(this, StatusEditor.class); Intent intent = new Intent(this, StatusEditor.class);
startActivity(intent); startActivity(intent);
return true; selected = true;
} }
// open app settings // open app settings
else if (item.getItemId() == R.id.menu_navigator_settings) { else if (item.getItemId() == R.id.menu_navigator_settings) {
Intent intent = new Intent(this, SettingsActivity.class); Intent intent = new Intent(this, SettingsActivity.class);
activityResultLauncher.launch(intent); activityResultLauncher.launch(intent);
return true; selected = true;
} }
// open account manager // open account manager
else if (item.getItemId() == R.id.menu_navigator_account) { else if (item.getItemId() == R.id.menu_navigator_account) {
Intent intent = new Intent(this, AccountActivity.class); Intent intent = new Intent(this, AccountActivity.class);
activityResultLauncher.launch(intent); activityResultLauncher.launch(intent);
return true; selected = true;
} }
// open user lists // open user lists
else if (item.getItemId() == R.id.menu_navigator_lists) { else if (item.getItemId() == R.id.menu_navigator_lists) {
Intent intent = new Intent(this, UserlistsActivity.class); Intent intent = new Intent(this, UserlistsActivity.class);
intent.putExtra(UserlistsActivity.KEY_ID, settings.getLogin().getId()); intent.putExtra(UserlistsActivity.KEY_ID, settings.getLogin().getId());
startActivity(intent); startActivity(intent);
selected = true;
} }
return false; if (selected) {
drawerLayout.close();
}
return selected;
} }

View File

@ -150,6 +150,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
SwitchButton enableLocalTl = findViewById(R.id.settings_local_timeline); SwitchButton enableLocalTl = findViewById(R.id.settings_local_timeline);
SwitchButton hideSensitive = findViewById(R.id.enable_status_hide_sensitive); SwitchButton hideSensitive = findViewById(R.id.enable_status_hide_sensitive);
SwitchButton enableStatusIcons = findViewById(R.id.enable_status_indicators); 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); SeekBar listSizeSelector = findViewById(R.id.settings_list_seek);
Spinner fontSelector = findViewById(R.id.spinner_font); Spinner fontSelector = findViewById(R.id.spinner_font);
Spinner scaleSelector = findViewById(R.id.spinner_scale); Spinner scaleSelector = findViewById(R.id.spinner_scale);
@ -242,6 +243,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
enableLocalTl.setCheckedImmediately(settings.useLocalTimeline()); enableLocalTl.setCheckedImmediately(settings.useLocalTimeline());
hideSensitive.setCheckedImmediately(settings.hideSensitiveEnabled()); hideSensitive.setCheckedImmediately(settings.hideSensitiveEnabled());
enableStatusIcons.setCheckedImmediately(settings.statusIndicatorsEnabled()); enableStatusIcons.setCheckedImmediately(settings.statusIndicatorsEnabled());
enableFloatingButton.setCheckedImmediately(settings.floatingButtonEnabled());
enablePush.setCheckedImmediately(settings.pushEnabled()); enablePush.setCheckedImmediately(settings.pushEnabled());
enable_proxy.setCheckedImmediately(settings.isProxyEnabled()); enable_proxy.setCheckedImmediately(settings.isProxyEnabled());
enable_auth.setCheckedImmediately(settings.isProxyAuthSet()); enable_auth.setCheckedImmediately(settings.isProxyAuthSet());
@ -264,6 +266,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
enableLocalTl.setOnCheckedChangeListener(this); enableLocalTl.setOnCheckedChangeListener(this);
enableStatusIcons.setOnCheckedChangeListener(this); enableStatusIcons.setOnCheckedChangeListener(this);
hideSensitive.setOnCheckedChangeListener(this); hideSensitive.setOnCheckedChangeListener(this);
enableFloatingButton.setOnCheckedChangeListener(this);
enable_proxy.setOnCheckedChangeListener(this); enable_proxy.setOnCheckedChangeListener(this);
enable_auth.setOnCheckedChangeListener(this); enable_auth.setOnCheckedChangeListener(this);
push_label.setOnClickListener(this); push_label.setOnClickListener(this);
@ -539,6 +542,10 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
else if (c.getId() == R.id.enable_status_indicators) { else if (c.getId() == R.id.enable_status_indicators) {
settings.enableStatusIndicators(checked); settings.enableStatusIndicators(checked);
} }
// enable floating button
else if (c.getId() == R.id.settings_enable_floating_button) {
settings.enableFloatingButton(checked);
}
// enable/disable local timeline (Mastodon) // enable/disable local timeline (Mastodon)
else if (c.getId() == R.id.settings_local_timeline) { else if (c.getId() == R.id.settings_local_timeline) {
settings.setLocalTimeline(checked); settings.setLocalTimeline(checked);

View File

@ -1,10 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp" android:width="24dp"
android:height="20dp" android:height="24dp"
android:viewportWidth="20" android:viewportWidth="17"
android:viewportHeight="20"> android:viewportHeight="17">
<path <path
android:pathData="M18.606,8.264L1.57,8.264c-0.735,0 -0.799,0.726 -0.799,1.624 0,0.898 0.064,1.624 0.799,1.624L18.606,11.511c0.735,0 0.799,-0.726 0.799,-1.624 0,-0.898 -0.064,-1.624 -0.799,-1.624zM18.606,14.758L1.57,14.758c-0.735,0 -0.799,0.726 -0.799,1.624 0,0.898 0.064,1.624 0.799,1.624L18.606,18.006c0.735,0 0.799,-0.726 0.799,-1.624 0,-0.898 -0.064,-1.624 -0.799,-1.624zM1.57,5.017L18.606,5.017c0.735,0 0.799,-0.726 0.799,-1.624 0,-0.898 -0.064,-1.624 -0.799,-1.624L1.57,1.769c-0.735,0 -0.799,0.726 -0.799,1.624 0,0.898 0.064,1.624 0.799,1.624z" android:pathData="M14.933,7.071L2.133,7.071c-0.552,0 -0.6,0.447 -0.6,1 0,0.553 0.048,1 0.6,1L14.933,9.071c0.552,0 0.6,-0.447 0.6,-1 0,-0.553 -0.048,-1 -0.6,-1zM14.933,11.071L2.133,11.071c-0.552,0 -0.6,0.447 -0.6,1 0,0.553 0.048,1 0.6,1L14.933,13.071c0.552,0 0.6,-0.447 0.6,-1 0,-0.553 -0.048,-1 -0.6,-1zM2.133,5.071L14.933,5.071c0.552,0 0.6,-0.447 0.6,-1 0,-0.553 -0.048,-1 -0.6,-1L2.133,3.071c-0.552,0 -0.6,0.447 -0.6,1 0,0.553 0.048,1 0.6,1z"
android:strokeWidth="1.47002"
android:fillColor="#ffffff"/> android:fillColor="#ffffff"/>
</vector> </vector>

View File

@ -6,6 +6,7 @@
android:id="@+id/navogation_header_root" android:id="@+id/navogation_header_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/mainpage_toolbar_height"
android:padding="@dimen/navigation_header_layout_padding" android:padding="@dimen/navigation_header_layout_padding"
tools:ignore="UseCompatTextViewDrawableXml"> tools:ignore="UseCompatTextViewDrawableXml">

View File

@ -59,7 +59,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="false" android:fitsSystemWindows="false"
android:layout_gravity="start" android:layout_gravity="start"
android:layout_marginTop="@dimen/mainpage_toolbar_height" android:maxWidth="@dimen/mainpage_navigation_max_width"
app:headerLayout="@layout/navigation_header" app:headerLayout="@layout/navigation_header"
app:menu="@menu/main_navigation"/> app:menu="@menu/main_navigation"/>

View File

@ -226,13 +226,35 @@
app:layout_constraintBottom_toBottomOf="@id/settings_toolbar_ov" app:layout_constraintBottom_toBottomOf="@id/settings_toolbar_ov"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
<com.kyleduo.switchbutton.SwitchButton
android:id="@+id/settings_enable_floating_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_column_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_toolbar_ov" />
<TextView
android:id="@+id/settings_enable_floating_button_descr"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:lines="1"
android:text="@string/settings_enable_floating_button"
android:textSize="@dimen/settings_textsize_small"
android:layout_marginStart="@dimen/settings_switch_margin"
android:layout_marginEnd="@dimen/settings_switch_margin"
app:layout_constraintStart_toEndOf="@id/settings_enable_floating_button"
app:layout_constraintTop_toTopOf="@id/settings_enable_floating_button"
app:layout_constraintBottom_toBottomOf="@id/settings_enable_floating_button"
app:layout_constraintEnd_toEndOf="parent" />
<com.kyleduo.switchbutton.SwitchButton <com.kyleduo.switchbutton.SwitchButton
android:id="@+id/enable_like" android:id="@+id/enable_like"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_column_margin" android:layout_marginTop="@dimen/settings_column_margin"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_toolbar_ov" app:layout_constraintTop_toBottomOf="@id/settings_enable_floating_button"
app:layout_constraintEnd_toStartOf="@id/enable_like_descr" /> app:layout_constraintEnd_toStartOf="@id/enable_like_descr" />
<TextView <TextView

View File

@ -199,6 +199,7 @@
<string name="info_location_pending">Ortung läuft, bitte warten.</string> <string name="info_location_pending">Ortung läuft, bitte warten.</string>
<string name="error_search">Suchbegriff ist entweder zu lang oder enthält nicht erlaubte Zeichen!</string> <string name="error_search">Suchbegriff ist entweder zu lang oder enthält nicht erlaubte Zeichen!</string>
<string name="button_share">Link teilen</string> <string name="button_share">Link teilen</string>
<string name="settings_enable_floating_button">Floating-Button aktivieren</string>
<string name="settings_look">Aussehen</string> <string name="settings_look">Aussehen</string>
<string name="dialog_link_image_preview">Linkvorschau Bild</string> <string name="dialog_link_image_preview">Linkvorschau Bild</string>
<string name="account_page">Accounts</string> <string name="account_page">Accounts</string>

View File

@ -201,6 +201,7 @@
<!--dimens of page_main.xml--> <!--dimens of page_main.xml-->
<dimen name="mainpage_toolbar_height">@dimen/toolbar_height</dimen> <dimen name="mainpage_toolbar_height">@dimen/toolbar_height</dimen>
<dimen name="mainpage_floating_button_margin">20dp</dimen> <dimen name="mainpage_floating_button_margin">20dp</dimen>
<dimen name="mainpage_navigation_max_width">220sp</dimen>
<!--dimens of page_list.xml--> <!--dimens of page_list.xml-->
<dimen name="listpage_toolbar_height">@dimen/toolbar_height</dimen> <dimen name="listpage_toolbar_height">@dimen/toolbar_height</dimen>

View File

@ -289,6 +289,7 @@
<string name="editprofile_add_banner">add banner</string> <string name="editprofile_add_banner">add banner</string>
<string name="settings_app_information">App source code:</string> <string name="settings_app_information">App source code:</string>
<string name="settings_enable_toolbar_overlap">Collapsed profile layout</string> <string name="settings_enable_toolbar_overlap">Collapsed profile layout</string>
<string name="settings_enable_floating_button">enable floating button</string>
<string name="settings_look">Look</string> <string name="settings_look">Look</string>
<string name="settings_description_enable_twitter_alt">use Nitter to open Twitter links</string> <string name="settings_description_enable_twitter_alt">use Nitter to open Twitter links</string>
<string name="settings_description_local_timeline">show local timelines only</string> <string name="settings_description_local_timeline">show local timelines only</string>