Split hide/settings nav actions

pull/203/head
M66B 3 years ago
parent 49239a8d5b
commit 9931a551bc

@ -33,16 +33,22 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -107,6 +113,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private NestedScrollView drawerContainer; private NestedScrollView drawerContainer;
private ImageButton ibExpanderNav; private ImageButton ibExpanderNav;
private ImageButton ibPin; private ImageButton ibPin;
private ImageButton ibHide;
private ImageButton ibSettings; private ImageButton ibSettings;
private ImageButton ibFetchMore; private ImageButton ibFetchMore;
private ImageButton ibSync; private ImageButton ibSync;
@ -278,6 +285,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
drawerContainer = findViewById(R.id.drawer_container); drawerContainer = findViewById(R.id.drawer_container);
ibExpanderNav = drawerContainer.findViewById(R.id.ibExpanderNav); ibExpanderNav = drawerContainer.findViewById(R.id.ibExpanderNav);
ibPin = drawerContainer.findViewById(R.id.ibPin); ibPin = drawerContainer.findViewById(R.id.ibPin);
ibHide = drawerContainer.findViewById(R.id.ibHide);
ibSettings = drawerContainer.findViewById(R.id.ibSettings); ibSettings = drawerContainer.findViewById(R.id.ibSettings);
ibFetchMore = drawerContainer.findViewById(R.id.ibFetchMore); ibFetchMore = drawerContainer.findViewById(R.id.ibFetchMore);
ibSync = drawerContainer.findViewById(R.id.ibSync); ibSync = drawerContainer.findViewById(R.id.ibSync);
@ -326,19 +334,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}); });
ibPin.setImageLevel(nav_pinned ? 1 : 0); ibPin.setImageLevel(nav_pinned ? 1 : 0);
// Navigation settings ibHide.setOnClickListener(new View.OnClickListener() {
ibSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(ActivityView.this, owner, ibSettings);
popupMenu.inflate(R.menu.popup_nav);
popupMenu.insertIcons(ActivityView.this);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public void onClick(View view) {
int itemId = item.getItemId();
if (itemId == R.id.menu_hide) {
View dview = LayoutInflater.from(ActivityView.this).inflate(R.layout.dialog_nav_options, null); View dview = LayoutInflater.from(ActivityView.this).inflate(R.layout.dialog_nav_options, null);
new AlertDialog.Builder(ActivityView.this) new AlertDialog.Builder(ActivityView.this)
.setView(dview) .setView(dview)
@ -350,16 +348,31 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}) })
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();
return true; }
} else if (itemId != R.id.menu_settings) { });
// Navigation settings
ibSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(ActivityView.this, owner, ibSettings);
for (int i = 0; i < FragmentOptions.PAGE_TITLES.length; i++)
popupMenu.getMenu()
.add(Menu.NONE, i, i, FragmentOptions.PAGE_TITLES[i])
.setIcon(FragmentOptions.PAGE_ICONS[i]);
popupMenu.insertIcons(ActivityView.this);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
String tab = FragmentOptions.TAB_LABELS.get(item.getOrder()); String tab = FragmentOptions.TAB_LABELS.get(item.getOrder());
startActivity(new Intent(ActivityView.this, ActivitySetup.class) startActivity(new Intent(ActivityView.this, ActivitySetup.class)
.setAction(tab) .setAction(tab)
.putExtra("tab", tab)); .putExtra("tab", tab));
return true; return true;
} }
return false;
}
}); });
popupMenu.show(); popupMenu.show();

@ -172,7 +172,7 @@ public class FragmentContacts extends FragmentBase {
final TextView tvMessage = dview.findViewById(R.id.tvMessage); final TextView tvMessage = dview.findViewById(R.id.tvMessage);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
tvMessage.setText(getText(R.string.title_delete_contacts)); tvMessage.setText(getString(R.string.title_delete_contacts));
cbNotAgain.setVisibility(View.GONE); cbNotAgain.setVisibility(View.GONE);
return new AlertDialog.Builder(getContext()) return new AlertDialog.Builder(getContext())

@ -81,7 +81,7 @@ public class FragmentOptions extends FragmentBase {
R.layout.fragment_options_misc R.layout.fragment_options_misc
}; };
private static final int[] PAGE_TITLES = { static final int[] PAGE_TITLES = {
R.string.title_advanced_section_main, R.string.title_advanced_section_main,
R.string.title_advanced_section_synchronize, R.string.title_advanced_section_synchronize,
R.string.title_advanced_section_send, R.string.title_advanced_section_send,
@ -94,7 +94,7 @@ public class FragmentOptions extends FragmentBase {
R.string.title_advanced_section_misc R.string.title_advanced_section_misc
}; };
private static final int[] PAGE_ICONS = { static final int[] PAGE_ICONS = {
R.drawable.twotone_home_24, R.drawable.twotone_home_24,
R.drawable.twotone_sync_24, R.drawable.twotone_sync_24,
R.drawable.twotone_send_24, R.drawable.twotone_send_24,

@ -31,6 +31,18 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/pin" /> app:srcCompat="@drawable/pin" />
<ImageButton
android:id="@+id/ibHide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_hide"
android:padding="6dp"
android:tooltipText="@string/title_hide"
app:layout_constraintStart_toEndOf="@id/ibPin"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_visibility_off_24" />
<ImageButton <ImageButton
android:id="@+id/ibSettings" android:id="@+id/ibSettings"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -39,7 +51,7 @@
android:contentDescription="@string/title_setup" android:contentDescription="@string/title_setup"
android:padding="6dp" android:padding="6dp"
android:tooltipText="@string/title_setup" android:tooltipText="@string/title_setup"
app:layout_constraintStart_toEndOf="@id/ibPin" app:layout_constraintStart_toEndOf="@id/ibHide"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_settings_24" /> app:srcCompat="@drawable/twotone_settings_24" />
@ -67,6 +79,12 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_sync_24" /> app:srcCompat="@drawable/twotone_sync_24" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpOptions"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="ibPin,ibHide,ibSettings,ibFetchMore,ibSync" />
<View <View
android:id="@+id/vSeparatorOptions" android:id="@+id/vSeparatorOptions"
android:layout_width="0dp" android:layout_width="0dp"
@ -76,12 +94,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibExpanderNav" /> app:layout_constraintTop_toBottomOf="@id/ibExpanderNav" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpOptions"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="ibPin,ibSettings,ibFetchMore,ibSync" />
<ImageButton <ImageButton
android:id="@+id/ibExpanderAccount" android:id="@+id/ibExpanderAccount"
android:layout_width="0dp" android:layout_width="0dp"

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_hide"
android:icon="@drawable/twotone_visibility_off_24"
android:title="@string/title_hide" />
<item
android:id="@+id/menu_settings"
android:icon="@drawable/twotone_settings_24"
android:title="@string/menu_setup">
<menu>
<item
android:id="@+id/menu_settings_main"
android:icon="@drawable/twotone_home_24"
android:orderInCategory="0"
android:title="@string/title_advanced_section_main" />
<item
android:id="@+id/menu_settings_sync"
android:icon="@drawable/twotone_sync_24"
android:orderInCategory="1"
android:title="@string/title_advanced_section_synchronize" />
<item
android:id="@+id/menu_settings_send"
android:icon="@drawable/twotone_send_24"
android:orderInCategory="2"
android:title="@string/title_advanced_section_send" />
<item
android:id="@+id/menu_settings_connection"
android:icon="@drawable/twotone_cloud_24"
android:orderInCategory="3"
android:title="@string/title_advanced_section_connection" />
<item
android:id="@+id/menu_settings_display"
android:icon="@drawable/twotone_monitor_24"
android:orderInCategory="4"
android:title="@string/title_advanced_section_display" />
<item
android:id="@+id/menu_settings_behavior"
android:icon="@drawable/twotone_psychology_24"
android:orderInCategory="5"
android:title="@string/title_advanced_section_behavior" />
<item
android:id="@+id/menu_settings_privacy"
android:icon="@drawable/twotone_account_circle_24"
android:orderInCategory="6"
android:title="@string/title_advanced_section_privacy" />
<item
android:id="@+id/menu_settings_encryption"
android:icon="@drawable/twotone_lock_24"
android:orderInCategory="7"
android:title="@string/title_advanced_section_encryption" />
<item
android:id="@+id/menu_settings_notification"
android:icon="@drawable/twotone_notifications_24"
android:orderInCategory="8"
android:title="@string/title_advanced_section_notifications" />
<item
android:id="@+id/menu_settings_misc"
android:icon="@drawable/twotone_more_24"
android:orderInCategory="9"
android:title="@string/title_advanced_section_misc" />
</menu>
</item>
</menu>
Loading…
Cancel
Save