1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

Open dialogs filter by tapping on the pencil button

This commit is contained in:
NekoInverter 2020-02-21 11:11:15 +08:00
parent 0fd8f86bfe
commit df2904ac31
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
5 changed files with 78 additions and 14 deletions

View File

@ -1158,10 +1158,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
actionBar.setOnTouchListener((v, event) -> {
int x = (int) event.getX();
int y = (int) event.getY();
if (event.getAction() == MotionEvent.ACTION_DOWN) {
FilterPopup.getInstance(currentAccount).createMenu(this, x, y, folderId);
if (event.getAction() == MotionEvent.ACTION_DOWN && NekoConfig.openFilterByActionBar) {
FilterPopup.getInstance(currentAccount).createMenu(this, x, y, folderId, false);
}
return true;
return NekoConfig.openFilterByActionBar;
});
actionBar.setTitleActionRunnable(() -> {
hideFloatingButton(false);
@ -1620,9 +1620,21 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
floatingButtonContainer.setVisibility(onlySelect || folderId != 0 ? View.GONE : View.VISIBLE);
contentView.addView(floatingButtonContainer, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 4 : 0, 0, LocaleController.isRTL ? 0 : 4, 0));
floatingButtonContainer.setOnClickListener(v -> {
Bundle args = new Bundle();
args.putBoolean("destroyAfterSelect", true);
presentFragment(new ContactsActivity(args));
if (!NekoConfig.openFilterByFab) {
Bundle args = new Bundle();
args.putBoolean("destroyAfterSelect", true);
presentFragment(new ContactsActivity(args));
} else {
FilterPopup.getInstance(currentAccount).createMenu(this, floatingButtonContainer.getRight(), floatingButtonContainer.getTop() + actionBar.getHeight(), folderId, true);
}
});
floatingButtonContainer.setOnLongClickListener(v -> {
if (NekoConfig.openFilterByFab) {
Bundle args = new Bundle();
args.putBoolean("destroyAfterSelect", true);
presentFragment(new ContactsActivity(args));
}
return NekoConfig.openFilterByFab;
});
floatingButton = new ImageView(context);

View File

@ -219,7 +219,7 @@ public class FilterPopup extends BaseController {
return count;
}
public void createMenu(DialogsActivity dialogsActivity, int x, int y, int folderId) {
public void createMenu(DialogsActivity dialogsActivity, int x, int y, int folderId, boolean fab) {
ArrayList<CharSequence> items = new ArrayList<>();
final ArrayList<Integer> options = new ArrayList<>();
ArrayList<Integer> unreadCounts = new ArrayList<>();
@ -404,9 +404,8 @@ public class FilterPopup extends BaseController {
}
int totalHeight = dialogsActivity.getFragmentView().getHeight();
int height = popupLayout.getMeasuredHeight();
int popupY = height < totalHeight ? y : AndroidUtilities.statusBarHeight;
int popupY = height < totalHeight ? y - (fab ? height : 0) : AndroidUtilities.statusBarHeight;
scrimPopupWindow.showAtLocation(dialogsActivity.getFragmentView(), Gravity.LEFT | Gravity.TOP, popupX, popupY);
}
public static class DialogType {

View File

@ -46,6 +46,9 @@ public class NekoConfig {
public static int translationProvider = 1;
public static boolean openFilterByActionBar = true;
public static boolean openFilterByFab = false;
private static boolean configLoaded;
static {
@ -85,6 +88,8 @@ public class NekoConfig {
editor.putBoolean("unlimitedPinnedDialogs", unlimitedPinnedDialogs);
editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction);
editor.putBoolean("openArchiveOnPull", openArchiveOnPull);
editor.putBoolean("openFilterByActionBar", openFilterByActionBar);
editor.putBoolean("openFilterByFab", openFilterByFab);
editor.putInt("translationProvider", translationProvider);
editor.putInt("eventType", eventType);
editor.putInt("actionBarDecoration", actionBarDecoration);
@ -133,6 +138,8 @@ public class NekoConfig {
translationProvider = preferences.getInt("translationProvider", 1);
disablePhotoSideAction = preferences.getBoolean("disablePhotoSideAction", true);
openArchiveOnPull = preferences.getBoolean("openArchiveOnPull", false);
openFilterByActionBar = preferences.getBoolean("openFilterByActionBar", true);
openFilterByFab = preferences.getBoolean("openFilterByFab", false);
configLoaded = true;
}
}
@ -383,4 +390,20 @@ public class NekoConfig {
editor.putBoolean("openArchiveOnPull", openArchiveOnPull);
editor.commit();
}
public static void toggleOpenFilterByFab() {
openFilterByFab = !openFilterByFab;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("openFilterByFab", openFilterByFab);
editor.commit();
}
public static void toggleOpenFilterByActionBar() {
openFilterByActionBar = !openFilterByActionBar;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("openFilterByActionBar", openFilterByActionBar);
editor.commit();
}
}

View File

@ -70,6 +70,10 @@ public class NekoSettingsActivity extends BaseFragment {
private int ipv6Row;
private int connection2Row;
private int dialogsFilterRow;
private int openFilterByActionBarRow;
private int openFilterByFabRow;
private int dialogsFilter2Row;
private int chatRow;
private int inappCameraRow;
@ -506,6 +510,16 @@ public class NekoSettingsActivity extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.openArchiveOnPull);
}
} else if (position == openFilterByActionBarRow) {
NekoConfig.toggleOpenFilterByActionBar();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.openFilterByActionBar);
}
} else if (position == openFilterByFabRow) {
NekoConfig.toggleOpenFilterByFab();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.openFilterByFab);
}
}
});
@ -527,6 +541,10 @@ public class NekoSettingsActivity extends BaseFragment {
connectionRow = rowCount++;
ipv6Row = rowCount++;
connection2Row = rowCount++;
dialogsFilterRow = rowCount++;
openFilterByActionBarRow = rowCount++;
openFilterByFabRow = rowCount++;
dialogsFilter2Row = rowCount++;
chatRow = rowCount++;
inappCameraRow = rowCount++;
useSystemEmojiRow = rowCount++;
@ -1030,6 +1048,10 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedPinnedDialogs", R.string.UnlimitedPinnedDialogs), LocaleController.getString("UnlimitedPinnedDialogsAbout", R.string.UnlimitedPinnedDialogsAbout), NekoConfig.unlimitedPinnedDialogs, true, true);
} else if (position == openArchiveOnPullRow) {
textCell.setTextAndCheck(LocaleController.getString("OpenArchiveOnPull", R.string.OpenArchiveOnPull), NekoConfig.openArchiveOnPull, true);
} else if (position == openFilterByActionBarRow) {
textCell.setTextAndCheck(LocaleController.getString("TapOnActionBar", R.string.TapOnActionBar), NekoConfig.openFilterByActionBar, true);
} else if (position == openFilterByFabRow) {
textCell.setTextAndCheck(LocaleController.getString("TapOnFab", R.string.TapOnFab), NekoConfig.openFilterByFab, false);
}
break;
}
@ -1043,6 +1065,8 @@ public class NekoSettingsActivity extends BaseFragment {
headerCell.setText(LocaleController.getString("Chat", R.string.Chat));
} else if (position == experimentRow) {
headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment));
} else if (position == dialogsFilterRow) {
headerCell.setText(LocaleController.getString("OpenDialogsFilterBy", R.string.OpenDialogsFilterBy));
}
break;
}
@ -1067,7 +1091,8 @@ public class NekoSettingsActivity extends BaseFragment {
(position == disableFilteringRow && sensitiveCanChange) || position == stickerSizeRow ||
position == unlimitedFavedStickersRow || position == messageMenuRow || position == deleteAccountRow ||
position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow;
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
position == openFilterByActionBarRow || position == openFilterByFabRow;
}
@Override
@ -1108,7 +1133,7 @@ public class NekoSettingsActivity extends BaseFragment {
@Override
public int getItemViewType(int position) {
if (position == connection2Row || position == chat2Row || position == experiment2Row) {
if (position == connection2Row || position == chat2Row || position == experiment2Row || position == dialogsFilter2Row) {
return 1;
} else if (position == nameOrderRow || position == mapPreviewRow || position == stickerSizeRow || position == messageMenuRow ||
position == deleteAccountRow || position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow) {
@ -1119,9 +1144,11 @@ public class NekoSettingsActivity extends BaseFragment {
position == forceTabletRow || position == newYearRow ||
position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow ||
position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow) {
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
position == openFilterByActionBarRow || position == openFilterByFabRow) {
return 3;
} else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) {
} else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow ||
position == dialogsFilterRow) {
return 4;
} else if (position == needRestartRow) {
return 7;

View File

@ -39,7 +39,7 @@
<string name="NekogramRunning">Nekogram is running</string>
<string name="EventType">Sidebar icon set*</string>
<string name="ChristmasHat">Show christmas hat everyday*</string>
<string name="ActionBarDecoration">Action bar decoration*</string>
<string name="ActionBarDecoration">Title bar decoration*</string>
<string name="DependsOnDate">Depends on date</string>
<string name="Christmas">Christmas</string>
<string name="Valentine">Valentine\'s day</string>
@ -87,4 +87,7 @@
<string name="UnlimitedPinnedDialogs">Unlimited pinned dialogs</string>
<string name="UnlimitedPinnedDialogsAbout">Pin unlimited dialogs by turn their sync off.</string>
<string name="OpenArchiveOnPull">Open Archive on pulldown</string>
<string name="OpenDialogsFilterBy">Open dialogs filter by</string>
<string name="TapOnActionBar">Tap on the title bar</string>
<string name="TapOnFab">Tap on the pencil button</string>
</resources>