added superapp editor, added titles in dockbar and some changes
-Added new SuperApp editor -Added titles in dockbar and option for it in settings -Refactored DockBarAdapter
This commit is contained in:
+320
@@ -0,0 +1,320 @@
|
||||
package com.vtosters.lite.ui.bottomnavigation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.view.menu.MenuItemImpl;
|
||||
import androidx.appcompat.view.menu.MenuView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import com.vk.core.ui.themes.Themable;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import me.grishka.appkit.utils.V;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class BottomNavigationItemView extends FrameLayout implements MenuView.ItemView {
|
||||
private final TextView mSmallLabel;
|
||||
private final TextView mLargeLabel;
|
||||
private final View mCounterContainer;
|
||||
private final TextView mCounter;
|
||||
private final View mDot;
|
||||
private int mItemPos;
|
||||
private MenuItemImpl mItemData;
|
||||
private ColorStateList mColorStateList;
|
||||
private final int mMargin;
|
||||
private final int mDiff;
|
||||
private final float mSmallScale;
|
||||
private final float mLargeScale;
|
||||
private boolean mShiftingModeEnabled;
|
||||
private boolean mIconsModeEnabled;
|
||||
private boolean mStaticModeEnabled;
|
||||
private ImageView mIcon;
|
||||
private ImageView mActionIcon;
|
||||
|
||||
public BottomNavigationItemView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BottomNavigationItemView(@NonNull Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public BottomNavigationItemView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
this.mItemPos = -1;
|
||||
|
||||
var textSize = (float) getResources().getDimensionPixelSize(R.dimen.design_bottom_navigation_text_size);
|
||||
var activeTextSize = (float) getResources().getDimensionPixelSize(R.dimen.design_bottom_navigation_active_text_size);
|
||||
this.mMargin = getResources().getDimensionPixelSize(R.dimen.design_bottom_navigation_margin);
|
||||
this.mDiff = (int) (textSize - activeTextSize);
|
||||
this.mSmallScale = activeTextSize / textSize;
|
||||
this.mLargeScale = textSize / activeTextSize;
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.design_bottom_navigation_item, this, true);
|
||||
this.setBackgroundResource(R.drawable.design_bottom_navigation_item_background);
|
||||
this.mIcon = this.findViewById(R.id.icon);
|
||||
this.mIcon.getLayoutParams().width = V.a(28.0F);
|
||||
this.mIcon.getLayoutParams().height = V.a(28.0F);
|
||||
|
||||
var colorStateList = getResources().getColorStateList(R.color.bottom_navigation_item);
|
||||
this.mSmallLabel = this.findViewById(R.id.smallLabel);
|
||||
mSmallLabel.setTextColor(colorStateList);
|
||||
|
||||
this.mLargeLabel = this.findViewById(R.id.largeLabel);
|
||||
mLargeLabel.setTextColor(colorStateList);
|
||||
|
||||
LayoutInflater.from(this.getContext()).inflate(R.layout.navigation_bottom_counter, this, true);
|
||||
this.mCounterContainer = this.findViewById(R.id.counter_container);
|
||||
this.mCounter = this.findViewById(R.id.counter);
|
||||
this.mDot = this.findViewById(R.id.dot);
|
||||
|
||||
LayoutInflater.from(this.getContext()).inflate(R.layout.navigation_bottom_action, this, true);
|
||||
this.mActionIcon = this.findViewById(R.id.action_icon);
|
||||
VKThemeHelper.a(this.mActionIcon, R.attr.tabbar_active_icon, PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.mActionIcon.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.mActionIcon.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
public MenuItemImpl getItemData() {
|
||||
return this.mItemData;
|
||||
}
|
||||
|
||||
public int getItemPosition() {
|
||||
return this.mItemPos;
|
||||
}
|
||||
|
||||
public void initialize(MenuItemImpl impl, int i) {
|
||||
this.mItemData = impl;
|
||||
this.setCheckable(impl.isCheckable());
|
||||
this.setChecked(impl.isChecked());
|
||||
this.setEnabled(impl.isEnabled());
|
||||
this.setIcon(impl.getIcon());
|
||||
this.setTitle(impl.getTitle());
|
||||
this.setId(impl.getItemId());
|
||||
this.setContentDescription(impl.getTitle());
|
||||
}
|
||||
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
int[] baseState = super.onCreateDrawableState(extraSpace + 1);
|
||||
if (this.mItemData != null && this.mItemData.isCheckable() && this.mItemData.isChecked()) {
|
||||
FrameLayout.mergeDrawableStates(baseState, new int[]{android.R.attr.state_checked});
|
||||
}
|
||||
|
||||
return baseState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (/*this.mShiftingModeEnabled &&*/ this.mCounterContainer.getVisibility() != GONE) {
|
||||
left = this.mCounterContainer.getMeasuredWidth() / 2
|
||||
+ V.a(4.0F)
|
||||
+ Math.min(this.getMeasuredWidth() / 2
|
||||
- this.mCounterContainer.getWidth()
|
||||
- V.a(4.0F), 0);
|
||||
this.mCounterContainer.layout(this.mCounterContainer.getLeft() + left,
|
||||
this.mCounterContainer.getTop(),
|
||||
this.mCounterContainer.getRight() + left,
|
||||
this.mCounterContainer.getBottom());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean prefersCondensedTitle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCheckable(boolean var1) {
|
||||
this.refreshDrawableState();
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.mItemData.setChecked(checked);
|
||||
|
||||
ViewCompat.setPivotX(mLargeLabel, mLargeLabel.getWidth() / 2);
|
||||
ViewCompat.setPivotY(mLargeLabel, mLargeLabel.getBaseline());
|
||||
ViewCompat.setPivotX(mSmallLabel, mSmallLabel.getWidth() / 2);
|
||||
ViewCompat.setPivotY(mSmallLabel, mSmallLabel.getBaseline());
|
||||
|
||||
if (this.mIconsModeEnabled) {
|
||||
var iconParams = (LayoutParams) this.mIcon.getLayoutParams();
|
||||
iconParams.gravity = Gravity.CENTER;
|
||||
iconParams.topMargin = 0;
|
||||
iconParams.bottomMargin = 0;
|
||||
this.mIcon.setLayoutParams(iconParams);
|
||||
|
||||
var counterContainerParams = (LayoutParams) this.mCounterContainer.getLayoutParams();
|
||||
counterContainerParams.gravity = Gravity.CENTER;
|
||||
counterContainerParams.topMargin = this.mMargin + V.a(1.5F);
|
||||
counterContainerParams.bottomMargin = this.mMargin + V.a(1.5F);
|
||||
this.mCounterContainer.setLayoutParams(counterContainerParams);
|
||||
this.mCounterContainer.setTranslationY((float)(-V.a(5.5F)));
|
||||
|
||||
this.mLargeLabel.setVisibility(GONE);
|
||||
this.mSmallLabel.setVisibility(GONE);
|
||||
} else {
|
||||
if (mShiftingModeEnabled) {
|
||||
if (checked) {
|
||||
var iconParams = (LayoutParams)this.mIcon.getLayoutParams();
|
||||
iconParams.gravity = Gravity.TOP|Gravity.CENTER_HORIZONTAL;
|
||||
iconParams.topMargin = this.mMargin;
|
||||
this.mIcon.setLayoutParams(iconParams);
|
||||
|
||||
var counterContainerParams = (LayoutParams)this.mCounterContainer.getLayoutParams();
|
||||
counterContainerParams.gravity = Gravity.TOP|Gravity.CENTER_HORIZONTAL;
|
||||
counterContainerParams.topMargin = this.mMargin + V.a(1.5F);
|
||||
counterContainerParams.bottomMargin = this.mMargin + V.a(1.5F);
|
||||
|
||||
this.mCounterContainer.setLayoutParams(counterContainerParams);
|
||||
this.mCounterContainer.setTranslationY(-V.a(5.5F));
|
||||
|
||||
this.mLargeLabel.setVisibility(VISIBLE);
|
||||
ViewCompat.setScaleX(this.mLargeLabel, 1.0F);
|
||||
ViewCompat.setScaleY(this.mLargeLabel, 1.0F);
|
||||
} else {
|
||||
var iconParams = (LayoutParams)this.mIcon.getLayoutParams();
|
||||
iconParams.gravity = Gravity.CENTER;
|
||||
iconParams.topMargin = this.mMargin;
|
||||
this.mIcon.setLayoutParams(iconParams);
|
||||
|
||||
var counterContainerParams = (LayoutParams)this.mCounterContainer.getLayoutParams();
|
||||
counterContainerParams.gravity = Gravity.CENTER;
|
||||
counterContainerParams.topMargin = this.mMargin + V.a(1.5F);
|
||||
counterContainerParams.bottomMargin = this.mMargin + V.a(1.5F);
|
||||
this.mCounterContainer.setLayoutParams(counterContainerParams);
|
||||
this.mCounterContainer.setTranslationY((float)(-V.a(5.5F)));
|
||||
|
||||
this.mLargeLabel.setVisibility(INVISIBLE);
|
||||
ViewCompat.setScaleX(this.mLargeLabel, 0.5F);
|
||||
ViewCompat.setScaleY(this.mLargeLabel, 0.5F);
|
||||
}
|
||||
mSmallLabel.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
// ViewCompat.setScaleX(mLargeLabel, !mStaticModeEnabled && !checked ? mLargeScale : 1.0f);
|
||||
// ViewCompat.setScaleY(mLargeLabel, !mStaticModeEnabled && !checked ? mLargeScale : 1.0f);
|
||||
ViewCompat.setScaleX(mSmallLabel, !mStaticModeEnabled && checked ? mSmallScale : 1.0f);
|
||||
ViewCompat.setScaleY(mSmallLabel, !mStaticModeEnabled && checked ? mSmallScale : 1.0f);
|
||||
mLargeLabel.setVisibility(/*checked ? VISIBLE :*/ INVISIBLE);
|
||||
mSmallLabel.setVisibility(VISIBLE);//checked ? INVISIBLE : VISIBLE);
|
||||
|
||||
var iconParams = (LayoutParams) this.mIcon.getLayoutParams();
|
||||
iconParams.gravity = Gravity.CENTER;
|
||||
iconParams.topMargin = 0;
|
||||
iconParams.bottomMargin = V.a(6);
|
||||
this.mIcon.setLayoutParams(iconParams);
|
||||
|
||||
var counterContainerParams = (LayoutParams)this.mCounterContainer.getLayoutParams();
|
||||
counterContainerParams.gravity = Gravity.CENTER;
|
||||
counterContainerParams.topMargin = 0;
|
||||
counterContainerParams.bottomMargin = V.a(8);
|
||||
this.mCounterContainer.setLayoutParams(counterContainerParams);
|
||||
this.mCounterContainer.setTranslationY(-V.a(5.5F));
|
||||
}
|
||||
}
|
||||
|
||||
this.refreshDrawableState();
|
||||
}
|
||||
|
||||
public void setCounterText(@Nullable CharSequence text) {
|
||||
this.mCounter.setText(text);
|
||||
if (text == null) {
|
||||
this.mCounterContainer.setVisibility(GONE);
|
||||
} else if (TextUtils.isEmpty(text)) {
|
||||
this.mCounterContainer.setVisibility(VISIBLE);
|
||||
this.mCounter.setVisibility(GONE);
|
||||
this.mDot.setVisibility(VISIBLE);
|
||||
} else {
|
||||
this.mCounterContainer.setVisibility(VISIBLE);
|
||||
this.mCounter.setVisibility(VISIBLE);
|
||||
this.mDot.setVisibility(mItemPos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b) {
|
||||
super.setEnabled(b);
|
||||
this.mSmallLabel.setEnabled(b);
|
||||
this.mLargeLabel.setEnabled(b);
|
||||
this.mIcon.setEnabled(b);
|
||||
}
|
||||
|
||||
public void setIcon(Drawable drawable) {
|
||||
if (drawable != null) {
|
||||
if (drawable.getConstantState() != null)
|
||||
drawable = drawable.getConstantState().newDrawable();
|
||||
|
||||
drawable = DrawableCompat.wrap(drawable).mutate();
|
||||
DrawableCompat.setTintList(drawable, this.mColorStateList);
|
||||
}
|
||||
|
||||
this.mIcon.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setIconTintList(ColorStateList colorStateList) {
|
||||
this.mColorStateList = colorStateList;
|
||||
MenuItemImpl impl = this.mItemData;
|
||||
if (impl != null) {
|
||||
this.setIcon(impl.getIcon());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setIconsMode(boolean enabled) {
|
||||
this.mIconsModeEnabled = enabled;
|
||||
}
|
||||
|
||||
public void setStaticMode(boolean enabled) {
|
||||
this.mStaticModeEnabled = enabled;
|
||||
}
|
||||
|
||||
public void setItemBackground(int resId) {
|
||||
ViewCompat.setBackground(this, resId != 0 ? ContextCompat.getDrawable(this.getContext(), resId) : null);
|
||||
}
|
||||
|
||||
public void setItemPosition(int pos) {
|
||||
this.mItemPos = pos;
|
||||
}
|
||||
|
||||
public void setShiftingMode(boolean var1) {
|
||||
this.mShiftingModeEnabled = var1;
|
||||
}
|
||||
|
||||
public void setShortcut(boolean b, char c) {
|
||||
}
|
||||
|
||||
public void setTextColor(ColorStateList colorStateList) {
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence title) {
|
||||
this.mSmallLabel.setText(title);
|
||||
this.mLargeLabel.setText(title);
|
||||
}
|
||||
|
||||
public boolean showsIcon() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+46
-23
@@ -1,6 +1,5 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static com.vtosters.lite.R.id.groups;
|
||||
import static com.vtosters.lite.R.id.menu_fave;
|
||||
import static com.vtosters.lite.R.id.menu_feedback;
|
||||
import static com.vtosters.lite.R.id.menu_friends;
|
||||
@@ -17,6 +16,7 @@ import static com.vtosters.lite.R.id.tab_feedback;
|
||||
import static com.vtosters.lite.R.id.tab_menu;
|
||||
import static com.vtosters.lite.R.id.tab_messages;
|
||||
import static com.vtosters.lite.R.id.tab_news;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getResources;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -25,6 +25,7 @@ import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.vk.apps.AppsFragment;
|
||||
import com.vk.core.drawable.RecoloredDrawable;
|
||||
@@ -48,12 +49,15 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ru.vtosters.lite.ui.components.DockBarEditorManager;
|
||||
import ru.vtosters.lite.ui.items.DockBarTab;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class DockBarInjector{
|
||||
private static final DockBarManager sManager = DockBarManager.getInstance();
|
||||
public class DockBarInjector {
|
||||
private static final DockBarEditorManager sManager = DockBarEditorManager.getInstance();
|
||||
|
||||
public static Map<Class<? extends FragmentImpl>, Integer> injectMap(){
|
||||
public static Map<Class<? extends FragmentImpl>, Integer> injectMap() {
|
||||
LinkedHashMap<Class<? extends FragmentImpl>, Integer> map = new LinkedHashMap<>();
|
||||
for (DockBarTab tab : sManager.getSelectedTabs()) {
|
||||
map.put(tab.fragmentClass, tab.id);
|
||||
@@ -61,7 +65,8 @@ public class DockBarInjector{
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void inject(BottomNavigationView navigationView){
|
||||
@SuppressLint("RestrictedApi")
|
||||
public static void inject(BottomNavigationView navigationView) {
|
||||
Menu menu = navigationView.getMenu();
|
||||
menu.clear();
|
||||
try {
|
||||
@@ -74,7 +79,7 @@ public class DockBarInjector{
|
||||
Method acquire = synchronisedPoolCls.getDeclaredMethod("acquire");
|
||||
if (synchronizedPool != null) {
|
||||
do {
|
||||
} while(acquire.invoke(synchronizedPool) != null);
|
||||
} while (acquire.invoke(synchronizedPool) != null);
|
||||
}
|
||||
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
|
||||
@@ -86,23 +91,41 @@ public class DockBarInjector{
|
||||
Drawable drawable = getResources().getDrawable(tab.iconID);
|
||||
|
||||
ColorStateList dockcolors = new ColorStateList(
|
||||
new int[][] {
|
||||
new int[] {android.R.attr.state_checked},
|
||||
new int[] {-android.R.attr.state_checked}
|
||||
new int[][]{
|
||||
new int[]{android.R.attr.state_checked},
|
||||
new int[]{-android.R.attr.state_checked}
|
||||
},
|
||||
new int[] {
|
||||
new int[]{
|
||||
Color.parseColor("#ff528bcc"),
|
||||
Color.parseColor("#ffaaaeb3")
|
||||
}
|
||||
);
|
||||
|
||||
add.setIcon(new RecoloredDrawable(drawable, dockcolors));
|
||||
add.setShowAsAction(1);
|
||||
add.setTitle(getContext().getString(tab.titleID));
|
||||
add.setCheckable(true);
|
||||
}
|
||||
if (Globals.getPreferences().getBoolean("dockbar_tab_titles", true)) {
|
||||
var menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
|
||||
for (int i = 0; i < menuView.getChildCount(); i++) {
|
||||
var item = (com.vtosters.lite.ui.bottomnavigation.BottomNavigationItemView) menuView.getChildAt(i);
|
||||
item.setStaticMode(true);
|
||||
item.setIconsMode(false);
|
||||
item.setShiftingMode(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int injectId(String tag){
|
||||
private static void removeAllChildren(ViewGroup view) {
|
||||
for (int i = 0; i < view.getChildCount(); i++) {
|
||||
if (view instanceof ViewGroup) {
|
||||
removeAllChildren((ViewGroup) view.getChildAt(i));
|
||||
view.removeAllViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int injectId(String tag) {
|
||||
for (DockBarTab tab : sManager.getSelectedTabs()) {
|
||||
if (tag.equals(tab.tag))
|
||||
return tab.id;
|
||||
@@ -110,7 +133,7 @@ public class DockBarInjector{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void injectMenuFragment(Menu menu){
|
||||
public static void injectMenuFragment(Menu menu) {
|
||||
List<MenuItem> menuItems = new ArrayList<>();
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
menuItems.add(menu.getItem(i));
|
||||
@@ -167,12 +190,12 @@ public class DockBarInjector{
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCounter(int tabId, BottomNavigationView navigationView){
|
||||
public static void setCounter(int tabId, BottomNavigationView navigationView) {
|
||||
navigationView.a(tabId, counters(tabId));
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
private static CharSequence counters(int tabId){
|
||||
private static CharSequence counters(int tabId) {
|
||||
if (!Preferences.dockcounter()) return null;
|
||||
|
||||
int val = 0;
|
||||
@@ -197,11 +220,11 @@ public class DockBarInjector{
|
||||
break;
|
||||
case tab_feedback:
|
||||
if (Preferences.milkshake())
|
||||
val = MenuCountersState.k();
|
||||
val = MenuCountersState.k();
|
||||
break;
|
||||
case menu_friends:
|
||||
if (!Preferences.milkshake())
|
||||
val = MenuCountersState.k();
|
||||
val = MenuCountersState.k();
|
||||
break;
|
||||
}
|
||||
//
|
||||
@@ -222,7 +245,7 @@ public class DockBarInjector{
|
||||
return val > 0 ? StringUtils.a(val) : null;
|
||||
}
|
||||
|
||||
public static JSONArray injectMenuJSON(JSONArray arr){
|
||||
public static JSONArray injectMenuJSON(JSONArray arr) {
|
||||
List<String> arrayList = new ArrayList(Arrays.asList(
|
||||
"news",
|
||||
"messages",
|
||||
@@ -255,15 +278,15 @@ public class DockBarInjector{
|
||||
}
|
||||
}
|
||||
|
||||
public static int getItemCount(){
|
||||
public static int getItemCount() {
|
||||
return sManager.getSelectedTabs().size();
|
||||
}
|
||||
|
||||
public static boolean isDockOpenAllowed(FragmentImpl fragment){
|
||||
public static boolean isDockOpenAllowed(FragmentImpl fragment) {
|
||||
return isDockOpenAllowed(fragment.getClass());
|
||||
}
|
||||
|
||||
public static boolean isDockOpenAllowed(Class<?> cls){
|
||||
public static boolean isDockOpenAllowed(Class<?> cls) {
|
||||
for (DockBarTab tab : sManager.getSelectedTabs())
|
||||
if (tab.fragmentClass == cls)
|
||||
return false;
|
||||
@@ -273,7 +296,7 @@ public class DockBarInjector{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Class<?> interceptClick(int id, RightMenu rightMenu){
|
||||
public static Class<?> interceptClick(int id, RightMenu rightMenu) {
|
||||
if (id == tab_menu) {
|
||||
rightMenu.a();
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import static ru.vtosters.lite.f0x1d.VTVerifications.isVerified;
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.utils.Base64Utils.decode;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserId;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserToken;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsblock;
|
||||
@@ -34,6 +33,7 @@ import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class JsonInjectors{
|
||||
private static final OkHttpClient mClient = new OkHttpClient();
|
||||
@@ -104,15 +104,28 @@ public class JsonInjectors{
|
||||
return orig;
|
||||
}
|
||||
|
||||
public static JSONObject superapp(JSONObject json) throws JSONException{
|
||||
public static JSONObject superapp(JSONObject json) throws JSONException {
|
||||
var superApps = Globals.getPreferences().getString("superapp_items", "").split(",");
|
||||
if (superApps.length == 0) return json;
|
||||
|
||||
var oldItems = json.optJSONArray("items");
|
||||
var newItems = new JSONArray();
|
||||
if (oldItems != null) {
|
||||
for (int i = 0; i < oldItems.length(); i++) {
|
||||
var item = oldItems.optJSONObject(i);
|
||||
var type = item.optString("type");
|
||||
if (!getBoolValue("superapp_" + type, false))
|
||||
newItems.put(item);
|
||||
for (String superApp : superApps) {
|
||||
if (type.equals(superApp))
|
||||
newItems.put(item);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < superApps.length; i++) {
|
||||
for (int j = i; j < newItems.length(); j++) {
|
||||
var item = newItems.optJSONObject(j);
|
||||
if (superApps[i].equals(item.optString("type")))
|
||||
newItems.put(j, newItems.getJSONObject(i))
|
||||
.put(i, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
import static ru.vtosters.lite.ui.fragments.dockbar.DockBarManager.getInstance;
|
||||
import static ru.vtosters.lite.ui.components.DockBarEditorManager.getInstance;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
package ru.vtosters.lite.ui.adapters;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.ui.components.IItemMovingListener;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.CategorizedViewHolder> implements IItemMovingListener {
|
||||
|
||||
// Adapter item types
|
||||
public static final int MOVING_ITEM = -0x1;
|
||||
public static final int CATEGORY_TITLE = -0x2;
|
||||
|
||||
// Item states
|
||||
public static final int SELECTED_STATE = -0x1;
|
||||
public static final int DISABLED_STATE = -0x2;
|
||||
|
||||
private List mSelectedItems;
|
||||
private List mDisabledItems;
|
||||
private IViewHolderBinder mBinder;
|
||||
|
||||
private int mMinSelectedItems = -1;
|
||||
private int mMaxSelectedItems = -1;
|
||||
|
||||
public CategorizedAdapter(List selectedItems, List disabledItems, IViewHolderBinder binder) {
|
||||
this.mSelectedItems = selectedItems;
|
||||
this.mDisabledItems = disabledItems;
|
||||
this.mBinder = binder;
|
||||
}
|
||||
|
||||
public void setMinAndMaxCounts(int min, int max) {
|
||||
this.mMinSelectedItems = min;
|
||||
this.mMaxSelectedItems = max;
|
||||
}
|
||||
|
||||
public int getItemViewType(int i) {
|
||||
return i == 0 || mSelectedItems.size() + 1 == i ? CATEGORY_TITLE : MOVING_ITEM;
|
||||
}
|
||||
|
||||
public int getTabType(int i) {
|
||||
return i <= mSelectedItems.size() ? SELECTED_STATE : DISABLED_STATE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CategorizedViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
FrameLayout container = new FrameLayout(getContext());
|
||||
container.addView(newCategoryTitle(), new FrameLayout.LayoutParams(-1, -2));
|
||||
container.addView(newMovingItem(), new FrameLayout.LayoutParams(-1, -2));
|
||||
return new CategorizedViewHolder(container);
|
||||
}
|
||||
|
||||
private View newMovingItem() {
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setTag("container");
|
||||
container.setGravity(Gravity.CENTER_VERTICAL);
|
||||
container.setOrientation(LinearLayout.HORIZONTAL);
|
||||
container.setPadding(
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12)
|
||||
);
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, convertDpToPixel(48)));
|
||||
container.setVisibility(View.INVISIBLE);
|
||||
|
||||
ImageView icon = new ImageView(getContext());
|
||||
icon.setTag("icon");
|
||||
icon.setImageTintList(ColorStateList.valueOf(Themes.getAccentColor()));
|
||||
icon.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
convertDpToPixel(24),
|
||||
convertDpToPixel(24)));
|
||||
container.addView(icon);
|
||||
|
||||
TextView name = new TextView(getContext());
|
||||
name.setTag("name");
|
||||
name.setTextSize(16.0f);
|
||||
name.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
name.setTextColor(Themes.getTextAttr());
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
|
||||
params.weight = 1;
|
||||
params.leftMargin = convertDpToPixel(16);
|
||||
container.addView(name, params);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private View newCategoryTitle() {
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setTag("category_title_container");
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
|
||||
container.setVisibility(View.INVISIBLE);
|
||||
|
||||
TextView title = new TextView(getContext());
|
||||
title.setTag("category_title");
|
||||
title.setTextSize(13.0f);
|
||||
title.setPadding(
|
||||
convertDpToPixel(16),
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(16),
|
||||
convertDpToPixel(13)
|
||||
);
|
||||
title.setAllCaps(true);
|
||||
title.setTextColor(Themes.getTextAttr());
|
||||
container.addView(title, new LinearLayout.LayoutParams(-2, -2));
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CategorizedViewHolder viewHolder, int i) {
|
||||
try {
|
||||
Log.d("TAG", i + "");
|
||||
if (getItemViewType(i) == MOVING_ITEM)
|
||||
mBinder.bind(viewHolder, i);
|
||||
else
|
||||
viewHolder.bindCategory(i == 0);
|
||||
} catch (Exception e) {
|
||||
Log.d("TAG", e + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mSelectedItems.size() + mDisabledItems.size() + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDismiss(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemMove(int fromPosition, int toPosition) {
|
||||
if (toPosition == 0)
|
||||
return false;
|
||||
|
||||
Object curr;
|
||||
if (getTabType(fromPosition) == SELECTED_STATE) {
|
||||
var min = mSelectedItems.size() == mMinSelectedItems;
|
||||
if (getTabType(toPosition) == DISABLED_STATE && min)
|
||||
return false;
|
||||
curr = mSelectedItems.get(fromPosition - 1);
|
||||
if (getItemViewType(toPosition) == CATEGORY_TITLE) {
|
||||
if (min)
|
||||
return false;
|
||||
mSelectedItems.remove(fromPosition - 1);
|
||||
mDisabledItems.add(curr);
|
||||
for (int i = mDisabledItems.size() - 2; i >= 0; i--) {
|
||||
var tmp = mDisabledItems.get(i + 1);
|
||||
mDisabledItems.set(i + 1, mDisabledItems.get(i));
|
||||
mDisabledItems.set(i, tmp);
|
||||
}
|
||||
} else {
|
||||
Collections.swap(mSelectedItems, fromPosition - 1, toPosition - 1);
|
||||
}
|
||||
} else if (getTabType(fromPosition) == DISABLED_STATE) {
|
||||
var max = mSelectedItems.size() == mMaxSelectedItems;
|
||||
if (getTabType(toPosition) == SELECTED_STATE && max)
|
||||
return false;
|
||||
curr = mDisabledItems.get(fromPosition - mSelectedItems.size() - 2);
|
||||
if (getItemViewType(toPosition) == CATEGORY_TITLE) {
|
||||
if (max)
|
||||
return false;
|
||||
mDisabledItems.remove(0);
|
||||
mSelectedItems.add(curr);
|
||||
} else {
|
||||
Collections.swap(mDisabledItems,
|
||||
fromPosition - mSelectedItems.size() - 2,
|
||||
toPosition - mSelectedItems.size() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
notifyItemMoved(fromPosition, toPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class CategorizedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final LinearLayout mMovingItemContainer;
|
||||
private final ImageView mIcon;
|
||||
private final TextView mName;
|
||||
|
||||
private final LinearLayout mCategoryTitleContainer;
|
||||
private final TextView mCategoryTitle;
|
||||
|
||||
public CategorizedViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mMovingItemContainer = itemView.findViewWithTag("container");
|
||||
mCategoryTitleContainer = itemView.findViewWithTag("category_title_container");
|
||||
|
||||
mIcon = mMovingItemContainer.findViewWithTag("icon");
|
||||
mName = mMovingItemContainer.findViewWithTag("name");
|
||||
|
||||
mCategoryTitle = mCategoryTitleContainer.findViewWithTag("category_title");
|
||||
}
|
||||
|
||||
public void bindMovingItem(int iconId, int textId) {
|
||||
if (iconId != -1)
|
||||
mIcon.setImageResource(iconId);
|
||||
else
|
||||
mIcon.setVisibility(View.GONE);
|
||||
mName.setText(textId);
|
||||
mMovingItemContainer.setVisibility(View.VISIBLE);
|
||||
mCategoryTitleContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void bindMovingItem(String text) {
|
||||
mIcon.setVisibility(View.GONE);
|
||||
mName.setText(text);
|
||||
mMovingItemContainer.setVisibility(View.VISIBLE);
|
||||
mCategoryTitleContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void bindCategory(boolean fist) {
|
||||
mCategoryTitle.setText(getString(fist ? "selected_items" : "unselected_items"));
|
||||
mCategoryTitleContainer.setVisibility(View.VISIBLE);
|
||||
mMovingItemContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IViewHolderBinder {
|
||||
void bind(CategorizedViewHolder holder, int pos);
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.ui.components;
|
||||
package ru.vtosters.lite.ui.adapters;
|
||||
|
||||
import static ru.vtosters.lite.utils.Themes.getTextAttr;
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.ui.fragments.tgstickers;
|
||||
package ru.vtosters.lite.ui.adapters;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
+17
-21
@@ -1,8 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
package ru.vtosters.lite.ui.components;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPreferences;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
import static ru.vtosters.lite.utils.Preferences.superapp;
|
||||
@@ -43,30 +42,26 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ru.vtosters.lite.ui.items.DockBarTab;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class DockBarManager {
|
||||
public class DockBarEditorManager {
|
||||
|
||||
public static final int MIN_SELECTED_TABS_LIMIT = 3;
|
||||
public static final int MAX_SELECTED_TABS_LIMIT = 9;
|
||||
|
||||
private static DockBarManager sInstance = new DockBarManager();
|
||||
public static final int MIN_SELECTED_TABS = 3;
|
||||
public static final int MAX_SELECTED_TABS = 9;
|
||||
|
||||
private final List<DockBarTab> mSelectedTabs = new ArrayList<>();
|
||||
private final List<DockBarTab> mDisabledTabs = new ArrayList<>();
|
||||
private final String[] mCategoryTitles = {
|
||||
getString("dockbar_selected_items"),
|
||||
getString("dockbar_unselected_items")
|
||||
};
|
||||
|
||||
private static DockBarEditorManager sInstance;
|
||||
|
||||
public static DockBarManager getInstance() {
|
||||
public static DockBarEditorManager getInstance() {
|
||||
return sInstance == null
|
||||
? (sInstance = new DockBarManager())
|
||||
? (sInstance = new DockBarEditorManager())
|
||||
: sInstance;
|
||||
}
|
||||
|
||||
public DockBarManager() {
|
||||
public DockBarEditorManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -109,12 +104,17 @@ public class DockBarManager {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
Globals.getPreferences().edit().putString("dockbar_tabs", mSelectedTabs.stream().map(tab -> tab.tag)
|
||||
.collect(Collectors.joining(","))).commit();
|
||||
Globals.getPreferences().edit().putString("dockbar_tabs", mSelectedTabs.stream()
|
||||
.map(tab -> tab.tag)
|
||||
.collect(Collectors.joining(",")))
|
||||
.commit();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
Globals.getPreferences().edit().putString("dockbar_tabs", "tab_news,tab_superapps,tab_messages,tab_friends,tab_profile").commit();
|
||||
Globals.getPreferences()
|
||||
.edit()
|
||||
.putString("dockbar_tabs", "tab_news,tab_superapps,tab_messages,tab_friends,tab_profile")
|
||||
.commit();
|
||||
}
|
||||
|
||||
public List<DockBarTab> getSelectedTabs() {
|
||||
@@ -125,10 +125,6 @@ public class DockBarManager {
|
||||
return mDisabledTabs;
|
||||
}
|
||||
|
||||
public String[] getCategoryTitles() {
|
||||
return mCategoryTitles;
|
||||
}
|
||||
|
||||
private DockBarTab getTabByTag(String tag) {
|
||||
switch (tag) {
|
||||
case "tab_news":
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
package ru.vtosters.lite.ui.components;
|
||||
|
||||
public interface IItemTouchHelper{
|
||||
public interface IItemMovingListener {
|
||||
|
||||
void onItemDismiss(int index);
|
||||
|
||||
+7
-6
@@ -1,16 +1,17 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
package ru.vtosters.lite.ui.components;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import ru.vtosters.lite.ui.adapters.CategorizedAdapter;
|
||||
|
||||
public class ItemTouchHelperCallback extends ItemTouchHelper.Callback{
|
||||
public class ItemMovingCallback extends ItemTouchHelper.Callback {
|
||||
|
||||
private final DockBarEditorAdapter mAdapter;
|
||||
private final CategorizedAdapter mAdapter;
|
||||
|
||||
public ItemTouchHelperCallback(DockBarEditorAdapter mAdapter){
|
||||
this.mAdapter = mAdapter;
|
||||
public ItemMovingCallback(CategorizedAdapter adapter){
|
||||
this.mAdapter = adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,7 +26,7 @@ public class ItemTouchHelperCallback extends ItemTouchHelper.Callback{
|
||||
|
||||
@Override
|
||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder){
|
||||
int dragFlags = AdapterHelper.getItemViewType(viewHolder.getAdapterPosition()) != AdapterHelper.CATEGORY_TITLE_TYPE
|
||||
int dragFlags = mAdapter.getItemViewType(viewHolder.getAdapterPosition()) == CategorizedAdapter.MOVING_ITEM
|
||||
? ItemTouchHelper.UP | ItemTouchHelper.DOWN
|
||||
: 0;
|
||||
return makeMovementFlags(dragFlags, 0);
|
||||
@@ -0,0 +1,103 @@
|
||||
package ru.vtosters.lite.ui.components;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getPreferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ru.vtosters.lite.ui.items.SuperAppItem;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class SuperAppEditorManager {
|
||||
|
||||
private final List<SuperAppItem> mSelectedItems = new ArrayList<>();
|
||||
private final List<SuperAppItem> mDisabledItems = new ArrayList<>();
|
||||
|
||||
private static SuperAppEditorManager sInstance;
|
||||
|
||||
public static SuperAppEditorManager getInstance() {
|
||||
return sInstance == null
|
||||
? (sInstance = new SuperAppEditorManager())
|
||||
: sInstance;
|
||||
}
|
||||
|
||||
public SuperAppEditorManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
var tmp = getPreferences().getString("superapp_items", "promo,miniapps,vkpay_slim,greeting,holiday,weather,sport,games,informer,food,event,music,vk_run");
|
||||
var selectedTags = !tmp.isEmpty() ? tmp.split(",") : new String[0];
|
||||
parseSelectedItems(selectedTags);
|
||||
}
|
||||
|
||||
private void parseSelectedItems(String[] selectedTabsTags) {
|
||||
List<String> allTags = new ArrayList<>(Arrays.asList( "promo", "miniapps", "vkpay_slim", "greeting", "holiday",
|
||||
"weather", "sport", "games", "informer", "food", "event", "music", "vk_run" ));
|
||||
for (String tag : selectedTabsTags) {
|
||||
mSelectedItems.add(getItemByTag(tag));
|
||||
allTags.remove(tag);
|
||||
}
|
||||
allTags.forEach(tag -> mDisabledItems.add(getItemByTag(tag)));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (mSelectedItems.size() > 0)
|
||||
getPreferences().edit().putString("superapp_items", mSelectedItems.stream()
|
||||
.map(item -> item.type)
|
||||
.collect(Collectors.joining(",")))
|
||||
.commit();
|
||||
else
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
Globals.getPreferences()
|
||||
.edit()
|
||||
.putString("superapp_items", "promo,miniapps,vkpay_slim,greeting,holiday,weather,sport,games,informer,food,event,music,vk_run")
|
||||
.commit();
|
||||
}
|
||||
|
||||
public List<SuperAppItem> getSelectedTabs() {
|
||||
return mSelectedItems;
|
||||
}
|
||||
|
||||
public List<SuperAppItem> getDisabledTabs() {
|
||||
return mDisabledItems;
|
||||
}
|
||||
|
||||
private SuperAppItem getItemByTag(String tag) {
|
||||
switch (tag) {
|
||||
case "promo":
|
||||
return SuperAppItem.valuesOf("promo", "Mini Apps: промо");
|
||||
case "miniapps":
|
||||
return SuperAppItem.valuesOf("miniapps", "Mini Apps: виджет");
|
||||
case "vkpay_slim":
|
||||
return SuperAppItem.valuesOf("vkpay_slim", "VK Pay");
|
||||
case "greeting":
|
||||
return SuperAppItem.valuesOf("greeting", "Приветствие");
|
||||
case "holiday":
|
||||
return SuperAppItem.valuesOf("holiday", "Дни рождения у друзей");
|
||||
case "weather":
|
||||
return SuperAppItem.valuesOf("weather", "Погода");
|
||||
case "sport":
|
||||
return SuperAppItem.valuesOf("sport", "Спортивные события");
|
||||
case "games":
|
||||
return SuperAppItem.valuesOf("games", "Игры");
|
||||
case "informer":
|
||||
return SuperAppItem.valuesOf("informer", "Информер");
|
||||
case "food":
|
||||
return SuperAppItem.valuesOf("food", "Еда");
|
||||
case "event":
|
||||
return SuperAppItem.valuesOf("event", "Мероприятия");
|
||||
case "music":
|
||||
return SuperAppItem.valuesOf("music", "Музыка");
|
||||
case "vk_run":
|
||||
return SuperAppItem.valuesOf("vk_run", "VK Run");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplication;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.ui.adapters.CategorizedAdapter;
|
||||
import ru.vtosters.lite.ui.components.DockBarEditorManager;
|
||||
import ru.vtosters.lite.ui.components.ItemMovingCallback;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class DockBarEditorFragment extends BaseToolbarFragment {
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
|
||||
setTitle(getIdentifier("dockbar_editor", "string"));
|
||||
|
||||
FrameLayout content = new FrameLayout(getContext());
|
||||
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
content.addView(container, new FrameLayout.LayoutParams(-1, -1));
|
||||
|
||||
LinearLayout buttonsContainer = new LinearLayout(getContext());
|
||||
buttonsContainer.setPadding(
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(10),
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(10)
|
||||
);
|
||||
container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
TextView save = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
|
||||
save.setText(Globals.getString("save"));
|
||||
save.setOnClickListener(v -> {
|
||||
DockBarEditorManager.getInstance().save();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2);
|
||||
saveParams.weight = 1.0f;
|
||||
buttonsContainer.addView(save, saveParams);
|
||||
|
||||
View divider = new View(getContext());
|
||||
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(convertDpToPixel(10), 0));
|
||||
|
||||
TextView reset = new TextView(new ContextThemeWrapper(getContext(), R.style.VKUIButton_Primary));
|
||||
reset.setText(Globals.getString("reset"));
|
||||
reset.setOnClickListener(v -> {
|
||||
DockBarEditorManager.getInstance().reset();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2);
|
||||
resetParams.weight = 1.0f;
|
||||
buttonsContainer.addView(reset, resetParams);
|
||||
|
||||
DockBarEditorManager manager = DockBarEditorManager.getInstance();
|
||||
var adapter = new CategorizedAdapter(manager.getSelectedTabs(), manager.getDisabledTabs(), (holder, pos) -> {
|
||||
var tab = pos <= manager.getSelectedTabs().size()
|
||||
? manager.getSelectedTabs().get(pos - 1)
|
||||
: manager.getDisabledTabs().get(pos - manager.getSelectedTabs().size() - 2);
|
||||
holder.bindMovingItem(tab.iconID, tab.titleID);
|
||||
});
|
||||
adapter.setMinAndMaxCounts(DockBarEditorManager.MIN_SELECTED_TABS, DockBarEditorManager.MAX_SELECTED_TABS);
|
||||
|
||||
var recyclerView = new RecyclerView(getContext());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
var params = new LinearLayout.LayoutParams(-1, -1);
|
||||
params.gravity = Gravity.CENTER;
|
||||
container.addView(recyclerView, params);
|
||||
|
||||
new ItemTouchHelper(new ItemMovingCallback(adapter)).attachToRecyclerView(recyclerView);
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getPreferences;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplicationWithTimer;
|
||||
|
||||
import android.os.Bundle;
|
||||
@@ -9,6 +10,8 @@ import androidx.preference.Preference;
|
||||
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class InterfaceFragment extends MaterialPreferenceToolbarFragment{
|
||||
@Override
|
||||
public void onCreate(Bundle bundle){
|
||||
@@ -17,10 +20,20 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment{
|
||||
prefs();
|
||||
}
|
||||
|
||||
//dockbar_tab_titles
|
||||
|
||||
private void prefs(){
|
||||
findPreference("stories").setOnPreferenceClickListener(new restart());
|
||||
findPreference("swipe").setOnPreferenceClickListener(new restart());
|
||||
findPreference("dockcounter").setOnPreferenceClickListener(new restart());
|
||||
findPreference("dockbar_tab_titles").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
getPreferences().edit().putBoolean("dockbar_tab_titles", (boolean) o).commit();
|
||||
Globals.restartApplication();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean restart(Preference preference){
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
import java.util.Arrays;
|
||||
|
||||
import ru.vtosters.lite.downloaders.VideoDownloader;
|
||||
import ru.vtosters.lite.ui.components.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
|
||||
public class MediaFragment extends MaterialPreferenceToolbarFragment{
|
||||
public static void download(Context ctx){
|
||||
|
||||
+26
-22
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
@@ -13,25 +13,24 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.BaseToolbarFragment;
|
||||
import ru.vtosters.lite.ui.adapters.CategorizedAdapter;
|
||||
import ru.vtosters.lite.ui.components.ItemMovingCallback;
|
||||
import ru.vtosters.lite.ui.components.SuperAppEditorManager;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class DockBarEditorFragment extends BaseToolbarFragment {
|
||||
|
||||
private RecyclerView mRecycler;
|
||||
private DockBarEditorAdapter mAdapter;
|
||||
private ItemTouchHelperCallback mCallback;
|
||||
private ItemTouchHelper mItemTouchHelper;
|
||||
public class SuperAppEditorFragment extends BaseToolbarFragment {
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
|
||||
setTitle(getIdentifier("dockbar_editor", "string"));
|
||||
setTitle(getIdentifier("superapp_editor", "string"));
|
||||
|
||||
FrameLayout content = new FrameLayout(getContext());
|
||||
|
||||
@@ -49,9 +48,9 @@ public class DockBarEditorFragment extends BaseToolbarFragment {
|
||||
container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
TextView save = new TextView(new ContextThemeWrapper(getContext(), com.vtosters.lite.R.style.VKUIButton_Primary));
|
||||
save.setText(Globals.getString("dockbar_save"));
|
||||
save.setText(Globals.getString("save"));
|
||||
save.setOnClickListener(v -> {
|
||||
DockBarManager.getInstance().save();
|
||||
SuperAppEditorManager.getInstance().save();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
@@ -63,9 +62,9 @@ public class DockBarEditorFragment extends BaseToolbarFragment {
|
||||
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(convertDpToPixel(10), 0));
|
||||
|
||||
TextView reset = new TextView(new ContextThemeWrapper(getContext(), com.vtosters.lite.R.style.VKUIButton_Primary));
|
||||
reset.setText(Globals.getString("dockbar_reset"));
|
||||
reset.setText(Globals.getString("reset"));
|
||||
reset.setOnClickListener(v -> {
|
||||
DockBarManager.getInstance().reset();
|
||||
SuperAppEditorManager.getInstance().reset();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
@@ -73,18 +72,23 @@ public class DockBarEditorFragment extends BaseToolbarFragment {
|
||||
resetParams.weight = 1.0f;
|
||||
buttonsContainer.addView(reset, resetParams);
|
||||
|
||||
mRecycler = new RecyclerView(getContext());
|
||||
mRecycler.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mRecycler.setAdapter((mAdapter = new DockBarEditorAdapter()));
|
||||
mRecycler.setHasFixedSize(true);
|
||||
SuperAppEditorManager manager = SuperAppEditorManager.getInstance();
|
||||
var adapter = new CategorizedAdapter(manager.getSelectedTabs(), manager.getDisabledTabs(), (holder, pos) -> {
|
||||
var item = pos <= manager.getSelectedTabs().size()
|
||||
? manager.getSelectedTabs().get(pos - 1)
|
||||
: manager.getDisabledTabs().get(pos - manager.getSelectedTabs().size() - 2);
|
||||
holder.bindMovingItem(item.title);
|
||||
});
|
||||
|
||||
var recyclerView = new RecyclerView(getContext());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
var params = new LinearLayout.LayoutParams(-1, -1);
|
||||
params.gravity = Gravity.CENTER;
|
||||
container.addView(mRecycler, params);
|
||||
container.addView(recyclerView, params);
|
||||
|
||||
mCallback = new ItemTouchHelperCallback(mAdapter);
|
||||
|
||||
mItemTouchHelper = new ItemTouchHelper(mCallback);
|
||||
mItemTouchHelper.attachToRecyclerView(mRecycler);
|
||||
new ItemTouchHelper(new ItemMovingCallback(adapter)).attachToRecyclerView(recyclerView);
|
||||
|
||||
return content;
|
||||
}
|
||||
@@ -7,9 +7,6 @@ import static ru.vtosters.lite.ui.PreferencesUtil.addMaterialSwitchPreference;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addPreference;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceCategory;
|
||||
import static ru.vtosters.lite.ui.PreferencesUtil.addPreferenceDrawable;
|
||||
import static ru.vtosters.lite.ui.vkui.VBListBuilder.VBListItem;
|
||||
import static ru.vtosters.lite.ui.vkui.VBListBuilder.buildListOf;
|
||||
import static ru.vtosters.lite.ui.vkui.VBottomSheetBuilder.VBSContent;
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
import static ru.vtosters.lite.utils.About.getCommitLink;
|
||||
import static ru.vtosters.lite.utils.CacheUtils.humanReadableByteCountBin;
|
||||
@@ -61,14 +58,10 @@ import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
import com.vtosters.lite.general.fragments.SettingsAccountFragment;
|
||||
import com.vtosters.lite.general.fragments.SettingsGeneralFragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.ui.components.DockBarEditorManager;
|
||||
import ru.vtosters.lite.ui.components.SuperAppEditorManager;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
import ru.vtosters.lite.ui.fragments.dockbar.DockBarEditorFragment;
|
||||
import ru.vtosters.lite.ui.fragments.dockbar.DockBarManager;
|
||||
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
|
||||
import ru.vtosters.lite.ui.vkui.VBottomSheetBuilder;
|
||||
import ru.vtosters.lite.utils.CacheUtils;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
import ru.vtosters.lite.utils.SSFS;
|
||||
@@ -99,7 +92,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
|
||||
public static String getDocksumm(){
|
||||
if (disableSettingsSumms()) return null;
|
||||
|
||||
return Globals.getString("vtldocksumm") + ": " + DockBarManager.getInstance().getSelectedTabs().size();
|
||||
return Globals.getString("vtldocksumm") + ": " + DockBarEditorManager.getInstance().getSelectedTabs().size();
|
||||
}
|
||||
|
||||
public static String getTGSsumm(){
|
||||
@@ -125,7 +118,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
|
||||
public static String getSuperappsumm(){
|
||||
if (disableSettingsSumms()) return null;
|
||||
|
||||
return "Скрыто элементов" + ": " + preferences.getInt("superappitems", 0);
|
||||
return "Скрыто элементов" + ": " + SuperAppEditorManager.getInstance().getDisabledTabs().size();
|
||||
}
|
||||
|
||||
public static String getCachesumm(){
|
||||
@@ -315,9 +308,9 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
|
||||
|
||||
addPreference(this, "", Globals.getString("dockbar_editor"), docksumm, !DoNotUseOldIcons() ? "ic_list_24" : "ic_list_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(DockBarEditorFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
Intent intent = new Navigator(DockBarEditorFragment.class).b(context);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -372,7 +365,10 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
|
||||
|
||||
if (milkshake() && superapp()) {
|
||||
addPreference(this, "", "Настроить Superapp", superapp, "ic_explore_outline_28", (preference) -> {
|
||||
callEditorPopup();
|
||||
Context context = getContext();
|
||||
Intent intent = new Navigator(SuperAppEditorFragment.class).b(context);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -442,46 +438,6 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
|
||||
}
|
||||
}
|
||||
|
||||
private void callEditorPopup(){
|
||||
hideitems = 0;
|
||||
|
||||
List<VBListItem> list = Arrays.asList(
|
||||
new VBListItem("promo", "Mini Apps: промо"),
|
||||
new VBListItem("miniapps", "Mini Apps: виджет"),
|
||||
new VBListItem("vkpay_slim", "VK Pay"),
|
||||
new VBListItem("greeting", "Приветствие"),
|
||||
new VBListItem("holiday", "Дни рождения у друзей"),
|
||||
new VBListItem("weather", "Погода"),
|
||||
new VBListItem("sport", "Спортивные события"),
|
||||
new VBListItem("games", "Игры"),
|
||||
new VBListItem("informer", "Информер"),
|
||||
new VBListItem("food", "Еда"),
|
||||
new VBListItem("event", "Мероприятия"),
|
||||
new VBListItem("music", "Музыка"),
|
||||
new VBListItem("vk_run", "VK Run")
|
||||
);
|
||||
|
||||
VBottomSheetBuilder.show(getActivity(), new VBSContent(
|
||||
"Выберите пункты для скрытия",
|
||||
buildListOf(getActivity(), list),
|
||||
|
||||
new VBSContent.VBSButton(
|
||||
"Сохранить",
|
||||
() -> {
|
||||
for (VBListItem item : list) {
|
||||
edit().putBoolean("superapp_" + item.id, item.checked).commit();
|
||||
if (item.checked) {
|
||||
hideitems++;
|
||||
edit().putInt("superappitems", hideitems).commit();
|
||||
} else if (hideitems == 0) {
|
||||
edit().putInt("superappitems", hideitems).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
public class AdapterHelper{
|
||||
|
||||
// Adapter item types
|
||||
public static final int TAB_TYPE = 1;
|
||||
public static final int CATEGORY_TITLE_TYPE = 2;
|
||||
|
||||
// Tab types
|
||||
public static final int SELECTED = 3;
|
||||
public static final int DISABLED = 4;
|
||||
|
||||
private static final DockBarManager sManager = DockBarManager.getInstance();
|
||||
|
||||
public static int getItemViewType(int i){
|
||||
return i == 0 || sManager.getSelectedTabs().size() + 1 == i ? CATEGORY_TITLE_TYPE : TAB_TYPE;
|
||||
}
|
||||
|
||||
public static int getTabType(int i){
|
||||
return i <= sManager.getSelectedTabs().size() ? SELECTED : DISABLED;
|
||||
}
|
||||
|
||||
public static boolean needTransfer(int from, int to){
|
||||
return getItemViewType(from) == TAB_TYPE && getItemViewType(to) == CATEGORY_TITLE_TYPE;
|
||||
}
|
||||
|
||||
public static int getItemCount(){
|
||||
return sManager.getSelectedTabs().size() + sManager.getDisabledTabs().size() + 2;
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class DockBarEditorAdapter extends RecyclerView.Adapter<DockBarEditorAdapter.ItemViewHolder>
|
||||
implements IItemTouchHelper{
|
||||
|
||||
private final DockBarManager mDockBarManager = DockBarManager.getInstance();
|
||||
|
||||
@Override
|
||||
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
|
||||
FrameLayout container = new FrameLayout(getContext());
|
||||
container.addView(newGroupTitle(), new FrameLayout.LayoutParams(-1, -2));
|
||||
container.addView(newTabItem(), new FrameLayout.LayoutParams(-1, -2));
|
||||
return new ItemViewHolder(container);
|
||||
}
|
||||
|
||||
private View newTabItem(){
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setTag("tab_container");
|
||||
container.setGravity(Gravity.CENTER_VERTICAL);
|
||||
container.setOrientation(LinearLayout.HORIZONTAL);
|
||||
container.setPadding(
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12)
|
||||
);
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, convertDpToPixel(48)));
|
||||
container.setVisibility(View.INVISIBLE);
|
||||
|
||||
ImageView icon = new ImageView(getContext());
|
||||
icon.setTag("tab_icon");
|
||||
icon.setImageTintList(ColorStateList.valueOf(Themes.getAccentColor()));
|
||||
icon.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
convertDpToPixel(24),
|
||||
convertDpToPixel(24)));
|
||||
container.addView(icon);
|
||||
|
||||
TextView name = new TextView(getContext());
|
||||
name.setTag("tab_name");
|
||||
name.setTextSize(16.0f);
|
||||
name.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
name.setTextColor(Themes.getTextAttr());
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
|
||||
params.weight = 1;
|
||||
params.leftMargin = convertDpToPixel(16);
|
||||
container.addView(name, params);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private View newGroupTitle(){
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setTag("category_title_container");
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
|
||||
container.setVisibility(View.INVISIBLE);
|
||||
|
||||
TextView title = new TextView(getContext());
|
||||
title.setTag("category_title");
|
||||
title.setTextSize(13.0f);
|
||||
title.setPadding(
|
||||
convertDpToPixel(16),
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(16),
|
||||
convertDpToPixel(13)
|
||||
);
|
||||
title.setAllCaps(true);
|
||||
title.setTextColor(Themes.getTextAttr());
|
||||
container.addView(title, new LinearLayout.LayoutParams(-2, -2));
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ItemViewHolder holder, int position){
|
||||
holder.bind(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount(){
|
||||
return AdapterHelper.getItemCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDismiss(int index){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemMove(int fromPosition, int toPosition){
|
||||
if (toPosition == 0)
|
||||
return false;
|
||||
|
||||
var selectedTabs = mDockBarManager.getSelectedTabs();
|
||||
var disabledTabs = mDockBarManager.getDisabledTabs();
|
||||
|
||||
DockBarTab curr;
|
||||
if (AdapterHelper.getTabType(fromPosition) == AdapterHelper.SELECTED) {
|
||||
curr = selectedTabs.get(fromPosition - 1);
|
||||
var min = selectedTabs.size() == DockBarManager.MIN_SELECTED_TABS_LIMIT;
|
||||
if (AdapterHelper.getItemViewType(toPosition) == AdapterHelper.CATEGORY_TITLE_TYPE) {
|
||||
if (min)
|
||||
return false;
|
||||
selectedTabs.remove(fromPosition - 1);
|
||||
disabledTabs.add(curr);
|
||||
for (int i = disabledTabs.size() - 2; i >= 0; i--) {
|
||||
var tmp = disabledTabs.get(i + 1);
|
||||
disabledTabs.set(i + 1, disabledTabs.get(i));
|
||||
disabledTabs.set(i, tmp);
|
||||
}
|
||||
} else if (AdapterHelper.getTabType(toPosition) == AdapterHelper.DISABLED && min) {
|
||||
return false;
|
||||
} else {
|
||||
Collections.swap(selectedTabs, fromPosition - 1, toPosition - 1);
|
||||
}
|
||||
} else if (AdapterHelper.getTabType(fromPosition) == AdapterHelper.DISABLED) {
|
||||
curr = disabledTabs.get(fromPosition - selectedTabs.size() - 2);
|
||||
var max = selectedTabs.size() == DockBarManager.MAX_SELECTED_TABS_LIMIT;
|
||||
if (AdapterHelper.getItemViewType(toPosition) == AdapterHelper.CATEGORY_TITLE_TYPE) {
|
||||
if (max)
|
||||
return false;
|
||||
disabledTabs.remove(0);
|
||||
selectedTabs.add(curr);
|
||||
} else if (AdapterHelper.getTabType(toPosition) == AdapterHelper.SELECTED && max) {
|
||||
return false;
|
||||
} else {
|
||||
Collections.swap(disabledTabs, fromPosition - selectedTabs.size() - 2, toPosition - selectedTabs.size() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
notifyItemMoved(fromPosition, toPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected class ItemViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
private final LinearLayout mTabContainer;
|
||||
private final ImageView mTabIcon;
|
||||
private final TextView mTabName;
|
||||
|
||||
private final LinearLayout mCategoryTitleContainer;
|
||||
private final TextView mCategoryTitle;
|
||||
|
||||
public ItemViewHolder(View itemView){
|
||||
super(itemView);
|
||||
|
||||
mTabContainer = itemView.findViewWithTag("tab_container");
|
||||
mCategoryTitleContainer = itemView.findViewWithTag("category_title_container");
|
||||
|
||||
mTabIcon = mTabContainer.findViewWithTag("tab_icon");
|
||||
mTabName = mTabContainer.findViewWithTag("tab_name");
|
||||
|
||||
mCategoryTitle = mCategoryTitleContainer.findViewWithTag("category_title");
|
||||
}
|
||||
|
||||
public void bind(int pos){
|
||||
if (AdapterHelper.getItemViewType(pos) == AdapterHelper.TAB_TYPE) {
|
||||
DockBarTab tab = AdapterHelper.getTabType(pos) == AdapterHelper.SELECTED
|
||||
? mDockBarManager.getSelectedTabs().get(pos - 1)
|
||||
: mDockBarManager.getDisabledTabs().get(pos - mDockBarManager.getSelectedTabs().size() - 2);
|
||||
mTabIcon.setImageResource(tab.iconID);
|
||||
mTabName.setText(tab.titleID);
|
||||
mTabContainer.setVisibility(View.VISIBLE);
|
||||
mCategoryTitleContainer.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mCategoryTitle.setText(mDockBarManager.getCategoryTitles()[pos == 0 ? 0 : 1]);
|
||||
mCategoryTitleContainer.setVisibility(View.VISIBLE);
|
||||
mTabContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -30,7 +29,6 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
@@ -43,6 +41,7 @@ import java.io.File;
|
||||
|
||||
import ru.vtosters.lite.tgs.TGPref;
|
||||
import ru.vtosters.lite.ui.PreferencesUtil;
|
||||
import ru.vtosters.lite.ui.adapters.StickerPackAdapter;
|
||||
import ru.vtosters.lite.ui.fragments.BaseToolbarFragment;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
package ru.vtosters.lite.ui.items;
|
||||
|
||||
import com.vk.core.fragments.FragmentImpl;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package ru.vtosters.lite.ui.items;
|
||||
|
||||
public class SuperAppItem {
|
||||
|
||||
public String type;
|
||||
public String title;
|
||||
|
||||
public SuperAppItem(String type, String title) {
|
||||
this.type = type;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public static SuperAppItem valuesOf(String type, String title) {
|
||||
return new SuperAppItem(type, title);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package ru.vtosters.lite.ui.vkui;
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Themes.getTextAttr;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VBListBuilder{
|
||||
public static ViewGroup buildListOf(Context ctx, List<VBListItem> items){
|
||||
LinearLayout mainView = new LinearLayout(ctx);
|
||||
mainView.setOrientation(LinearLayout.VERTICAL);
|
||||
mainView.setPadding(convertDpToPixel(8f), 0, convertDpToPixel(8f), 0);
|
||||
|
||||
for (VBListItem item : items) {
|
||||
AppCompatCheckBox mcb = new AppCompatCheckBox(ctx, null);
|
||||
mcb.setPadding(0, convertDpToPixel(8f), 0, convertDpToPixel(8f));
|
||||
|
||||
mcb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f);
|
||||
mcb.setTextColor(getTextAttr());
|
||||
|
||||
mcb.setChecked(item.checked);
|
||||
mcb.setText(item.title);
|
||||
|
||||
mcb.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
item.checked = isChecked;
|
||||
});
|
||||
|
||||
mainView.addView(mcb);
|
||||
}
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
public static class VBListItem{
|
||||
public String id;
|
||||
public String title;
|
||||
public boolean checked;
|
||||
|
||||
public VBListItem(String id, String title){
|
||||
this(id, title, getBoolValue("superapp_" + id, false));
|
||||
}
|
||||
|
||||
public VBListItem(String id, String title, boolean checked){
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.checked = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,10 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:duplicateParentState="true"
|
||||
android:paddingBottom="10.0dip">
|
||||
android:paddingBottom="5.0dip">
|
||||
|
||||
<TextView
|
||||
android:id="@id/smallLabel"
|
||||
|
||||
@@ -5418,6 +5418,7 @@
|
||||
<string name="dnw">Неписалка</string>
|
||||
<string name="docknumbers">Счётчики в докбаре</string>
|
||||
<string name="docknumberssum">Отключение не работает в интерфейсе для планшетов</string>
|
||||
<string name="dockbar_tab_titles">Показ заголовков вкладок в докбаре</string>
|
||||
<string name="fcmtokenfixed">Уведомления были восстановлены!</string>
|
||||
<string name="fcmtokenget">FCM токен получен</string>
|
||||
<string name="fcmtokenrem">FCM токен удален</string>
|
||||
@@ -5629,10 +5630,9 @@
|
||||
<string name="other_fix_dynamic_colors">Исправление покрасок для Android 12+</string>
|
||||
|
||||
<string name="dockbar_editor">Редактор докбара</string>
|
||||
<string name="dockbar_save">Сохранить</string>
|
||||
<string name="dockbar_reset">Сбросить</string>
|
||||
<string name="dockbar_selected_items">Выбранные элементы</string>
|
||||
<string name="dockbar_unselected_items">Невыбранные элементы</string>
|
||||
<string name="superapp_editor">SuperApp Редактор</string>
|
||||
<string name="selected_items">Выбранные элементы</string>
|
||||
<string name="unselected_items">Отключенные элементы</string>
|
||||
|
||||
<string name="add_another_account">Добавить новый аккаунт</string>
|
||||
|
||||
|
||||
@@ -5570,6 +5570,7 @@ Warning! It can cause long downloads of user lists if there are a lot of users i
|
||||
<string name="dnw">Do not write</string>
|
||||
<string name="docknumbers">Counters in dockbar</string>
|
||||
<string name="docknumberssum">"Disabling doesn't work in the tablet interface"</string>
|
||||
<string name="dockbar_tab_titles">Show dockbar item titles</string>
|
||||
<string name="fcmtokenfixed">Notifications have been restored!</string>
|
||||
<string name="fcmtokenget">FCM token received</string>
|
||||
<string name="fcmtokenrem">FCM token deleted</string>
|
||||
@@ -5782,10 +5783,9 @@ May look like a fake leaving the online"</string>
|
||||
<string name="other_fix_dynamic_colors">Fix colors on Android 12+</string>
|
||||
|
||||
<string name="dockbar_editor">Dockbar editor</string>
|
||||
<string name="dockbar_save">Save</string>
|
||||
<string name="dockbar_reset">Reset</string>
|
||||
<string name="dockbar_selected_items">Selected items</string>
|
||||
<string name="dockbar_unselected_items">Disabled items</string>
|
||||
<string name="superapp_editor">SuperApp editor</string>
|
||||
<string name="selected_items">Selected items</string>
|
||||
<string name="unselected_items">Disabled items</string>
|
||||
|
||||
<string name="add_another_account">Add new account</string>
|
||||
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
android:key="dockcounter"
|
||||
android:summary="@string/docknumberssum"
|
||||
android:title="@string/docknumbers" />
|
||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="dockbar_tab_titles"
|
||||
android:title="@string/dockbar_tab_titles" />
|
||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="disableSettingsSumms"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
# invoke-static {v0}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->injectMenuJSON(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
# invoke-static {v0}, Lru/vtosters/lite/hooks/DockBarInjector;->injectMenuJSON(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
# move-result-object v0
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
|
||||
invoke-virtual {v3, v5, v1}, Landroid/view/MenuInflater;->inflate(ILandroid/view/Menu;)V
|
||||
|
||||
# invoke-static {v1}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->injectMenuFragment(Landroid/view/Menu;)V
|
||||
# invoke-static {v1}, Lru/vtosters/lite/hooks/DockBarInjector;->injectMenuFragment(Landroid/view/Menu;)V
|
||||
|
||||
.line 5
|
||||
invoke-direct {p0, v1}, Lcom/vk/menu/MenuFragment;->a(Landroidx/appcompat/view/menu/MenuBuilder;)Ljava/util/List;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
.method public static final a(Ljava/lang/String;)I
|
||||
.locals 3
|
||||
|
||||
invoke-static {p0}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->injectId(Ljava/lang/String;)I
|
||||
invoke-static {p0}, Lru/vtosters/lite/hooks/DockBarInjector;->injectId(Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->injectMap()Ljava/util/Map;
|
||||
invoke-static {}, Lru/vtosters/lite/hooks/DockBarInjector;->injectMap()Ljava/util/Map;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
@@ -1719,7 +1719,7 @@
|
||||
:cond_0
|
||||
iget-object v5, p0, Lcom/vk/navigation/NavigationDelegateBottom;->U:Lcom/vk/navigation/right/RightMenu;
|
||||
|
||||
invoke-static {p1, v5}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->interceptClick(ILcom/vk/navigation/right/RightMenu;)Ljava/lang/Class;
|
||||
invoke-static {p1, v5}, Lru/vtosters/lite/hooks/DockBarInjector;->interceptClick(ILcom/vk/navigation/right/RightMenu;)Ljava/lang/Class;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
@@ -2083,7 +2083,7 @@
|
||||
|
||||
iput-object v3, p0, Lcom/vk/navigation/NavigationDelegateBottom;->H:Lcom/vtosters/lite/ui/bottomnavigation/BottomNavigationView;
|
||||
|
||||
invoke-static {v3}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->inject(Lcom/vtosters/lite/ui/bottomnavigation/BottomNavigationView;)V
|
||||
invoke-static {v3}, Lru/vtosters/lite/hooks/DockBarInjector;->inject(Lcom/vtosters/lite/ui/bottomnavigation/BottomNavigationView;)V
|
||||
|
||||
.line 11
|
||||
invoke-virtual {p0}, Lcom/vk/navigation/NavigationDelegate;->c()Landroid/app/Activity;
|
||||
@@ -2827,7 +2827,7 @@
|
||||
.method private final f(Lcom/vk/core/fragments/FragmentImpl;)Z
|
||||
.locals 1
|
||||
|
||||
invoke-static {p1}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->isDockOpenAllowed(Lcom/vk/core/fragments/FragmentImpl;)Z
|
||||
invoke-static {p1}, Lru/vtosters/lite/hooks/DockBarInjector;->isDockOpenAllowed(Lcom/vk/core/fragments/FragmentImpl;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -3925,7 +3925,7 @@
|
||||
.method public a(Lcom/vk/core/fragments/FragmentImpl;)Z
|
||||
.locals 1
|
||||
|
||||
invoke-static {p1}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->isDockOpenAllowed(Lcom/vk/core/fragments/FragmentImpl;)Z
|
||||
invoke-static {p1}, Lru/vtosters/lite/hooks/DockBarInjector;->isDockOpenAllowed(Lcom/vk/core/fragments/FragmentImpl;)Z
|
||||
|
||||
move-result p1
|
||||
|
||||
@@ -5428,7 +5428,7 @@
|
||||
|
||||
if-eqz v2, :cond_0
|
||||
|
||||
invoke-static {v1, v2}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->setCounter(ILcom/vtosters/lite/ui/bottomnavigation/BottomNavigationView;)V
|
||||
invoke-static {v1, v2}, Lru/vtosters/lite/hooks/DockBarInjector;->setCounter(ILcom/vtosters/lite/ui/bottomnavigation/BottomNavigationView;)V
|
||||
|
||||
goto :goto_0
|
||||
|
||||
|
||||
-1327
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -59,7 +59,7 @@
|
||||
.line 1
|
||||
new-instance v0, Landroidx/core/util/Pools$SynchronizedPool;
|
||||
|
||||
invoke-static {}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->getItemCount()I
|
||||
invoke-static {}, Lru/vtosters/lite/hooks/DockBarInjector;->getItemCount()I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
|
||||
iput-object p1, p0, Lcom/vtosters/lite/ui/bottomnavigation/BottomNavigationMenuView;->e:Landroid/view/View$OnClickListener;
|
||||
|
||||
invoke-static {}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->getItemCount()I
|
||||
invoke-static {}, Lru/vtosters/lite/hooks/DockBarInjector;->getItemCount()I
|
||||
|
||||
move-result p1
|
||||
|
||||
|
||||
+1
-1
@@ -686,7 +686,7 @@
|
||||
.method public getMaxItemCount()I
|
||||
.locals 1
|
||||
|
||||
invoke-static {}, Lru/vtosters/lite/ui/fragments/dockbar/DockBarInjector;->getItemCount()I
|
||||
invoke-static {}, Lru/vtosters/lite/hooks/DockBarInjector;->getItemCount()I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user