1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-11-16 05:16:15 +01:00
(cherry picked from commit 3a6e09a36f)
This commit is contained in:
NekoInverter 2020-03-30 12:23:34 +08:00 committed by 世界
parent 4961c99cf9
commit 4c487b1836
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
7 changed files with 39 additions and 79 deletions

View File

@ -8,8 +8,6 @@
package org.telegram.messenger;
import org.telegram.ui.ActionBar.Theme;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
@ -36,6 +34,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import tw.nekomimi.nekogram.NekoConfig;
public class Emoji {
private static HashMap<CharSequence, DrawableInfo> rects = new HashMap<>();

View File

@ -114,12 +114,12 @@ public class MessageDetailsActivity extends BaseFragment {
public boolean onFragmentCreate() {
super.onFragmentCreate();
updateRows(false);
updateRows();
return true;
}
@SuppressLint("NewApi")
@SuppressLint({"NewApi", "RtlHardcoded"})
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
@ -223,7 +223,7 @@ public class MessageDetailsActivity extends BaseFragment {
}
}
private void updateRows(boolean notify) {
private void updateRows() {
rowCount = 0;
idRow = rowCount++;
messageRow = TextUtils.isEmpty(messageObject.messageText) ? -1 : rowCount++;
@ -241,7 +241,7 @@ public class MessageDetailsActivity extends BaseFragment {
emptyRow = rowCount++;
exportRow = rowCount++;
endRow = rowCount++;
if (notify && listAdapter != null) {
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
@ -405,6 +405,7 @@ public class MessageDetailsActivity extends BaseFragment {
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
}
//noinspection ConstantConditions
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
return new RecyclerListView.Holder(view);
}

View File

@ -1,5 +1,6 @@
package tw.nekomimi.nekogram;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@ -9,7 +10,9 @@ import android.os.Build;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationsService;
import org.telegram.messenger.SharedConfig;
@SuppressLint("ApplySharedPref")
public class NekoConfig {
private static final Object sync = new Object();
@ -19,6 +22,7 @@ public class NekoConfig {
public static boolean openFilterByActionBar = true;
public static boolean openFilterByFab = false;
public static boolean useSystemEmoji = SharedConfig.useSystemEmoji;
public static boolean ignoreBlocked = false;
public static boolean hideProxySponsorChannel = false;
public static boolean saveCacheToSdcard = false;
@ -93,6 +97,7 @@ public class NekoConfig {
editor.putBoolean("openFilterByFab", openFilterByFab);
// editor.putBoolean("showHiddenFeature", showHiddenFeature);
editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground);
editor.putBoolean("useSystemEmoji", useSystemEmoji);
editor.putFloat("stickerSize", stickerSize);
editor.putInt("typeface", typeface);
editor.putInt("nameOrder", nameOrder);
@ -149,6 +154,7 @@ public class NekoConfig {
//showHiddenFeature = preferences.getBoolean("showHiddenFeature", false);
hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false);
avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", true);
useSystemEmoji = preferences.getBoolean("useSystemEmoji", SharedConfig.useSystemEmoji);
configLoaded = true;
}
}
@ -436,4 +442,13 @@ public class NekoConfig {
editor.apply();
}
public static void toggleUseSystemEmoji() {
useSystemEmoji = !useSystemEmoji;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("useSystemEmoji", useSystemEmoji);
editor.commit();
}
}
}

View File

@ -6,7 +6,6 @@ import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Build;
@ -33,6 +32,7 @@ import org.telegram.ui.Components.SeekBarView;
import java.util.ArrayList;
@SuppressLint("RtlHardcoded")
public class NekoSettingsActivity extends BaseFragment {
private RecyclerListView listView;
@ -221,12 +221,9 @@ public class NekoSettingsActivity extends BaseFragment {
((TextCheckCell) view).setChecked(NekoXConfig.skipOpenLinkConfirm);
}
} else if (position == useSystemEmojiRow) {
SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji;
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
editor.putBoolean("useSystemEmoji", SharedConfig.useSystemEmoji);
editor.apply();
NekoConfig.toggleUseSystemEmoji();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji);
((TextCheckCell) view).setChecked(NekoConfig.useSystemEmoji);
}
} else if (position == typefaceRow) {
NekoConfig.toggleTypeface();
@ -781,7 +778,7 @@ public class NekoSettingsActivity extends BaseFragment {
}
}
textCell.setTag(a);
textCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
textCell.setBackground(Theme.getSelectorDrawable(false));
linearLayoutInviteContainer.addView(textCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
textCell.setOnClickListener(v2 -> {
Integer tag = (Integer) v2.getTag();
@ -1061,7 +1058,7 @@ public class NekoSettingsActivity extends BaseFragment {
optionsButton.setLongClickEnabled(false);
optionsButton.setSubMenuOpenSide(2);
optionsButton.setIcon(R.drawable.ic_ab_other);
optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1));
optionsButton.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector), 1));
optionsButton.addSubItem(1, R.drawable.msg_reset, LocaleController.getString("Reset", R.string.Reset));
optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu());
optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
@ -1158,9 +1155,9 @@ public class NekoSettingsActivity extends BaseFragment {
switch (holder.getItemViewType()) {
case 1: {
if (position == experiment2Row) {
holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
holder.itemView.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
} else {
holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
holder.itemView.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
}
break;
}
@ -1281,7 +1278,7 @@ public class NekoSettingsActivity extends BaseFragment {
} else if (position == disableChatActionRow) {
textCell.setTextAndCheck(LocaleController.getString("DisableChatAction", R.string.DisableChatAction), NekoXConfig.disableChatAction, true);
} else if (position == useSystemEmojiRow) {
textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true);
textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), NekoConfig.useSystemEmoji, true);
} else if (position == typefaceRow) {
textCell.setTextAndCheck(LocaleController.getString("TypefaceUseDefault", R.string.TypefaceUseDefault), NekoConfig.typeface == 1, true);
} else if (position == ignoreBlockedRow) {
@ -1394,9 +1391,10 @@ public class NekoSettingsActivity extends BaseFragment {
break;
case 7:
view = new TextInfoPrivacyCell(mContext);
view.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
break;
}
//noinspection ConstantConditions
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
return new RecyclerListView.Holder(view);
}

View File

@ -1,5 +1,6 @@
package tw.nekomimi.nekogram;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Shader;
@ -24,6 +25,7 @@ import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.LayoutHelper;
@SuppressLint("ViewConstructor")
public class StickerSizePreviewMessagesCell extends LinearLayout {
private BackgroundGradientDrawable.Disposable backgroundGradientDisposable;
@ -169,8 +171,6 @@ public class StickerSizePreviewMessagesCell extends LinearLayout {
float scale = 2.0f / AndroidUtilities.density;
canvas.scale(scale, scale);
drawable.setBounds(0, 0, (int) Math.ceil(getMeasuredWidth() / scale), (int) Math.ceil(getMeasuredHeight() / scale));
drawable.draw(canvas);
canvas.restore();
} else {
int viewHeight = getMeasuredHeight();
float scaleX = (float) getMeasuredWidth() / (float) drawable.getIntrinsicWidth();
@ -183,9 +183,9 @@ public class StickerSizePreviewMessagesCell extends LinearLayout {
canvas.save();
canvas.clipRect(0, 0, width, getMeasuredHeight());
drawable.setBounds(x, y, x + width, y + height);
drawable.draw(canvas);
canvas.restore();
}
drawable.draw(canvas);
canvas.restore();
}
if (a == 0 && oldBackgroundDrawable != null && themeAnimationValue >= 1.0f) {
if (oldBackgroundGradientDisposable != null) {
@ -228,6 +228,7 @@ public class StickerSizePreviewMessagesCell extends LinearLayout {
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
return false;

View File

@ -1,55 +0,0 @@
package tw.nekomimi.nekogram;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.text.Layout;
import android.text.StaticLayout;
import android.view.View;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.ui.ActionBar.Theme;
public class UnreadCountBadgeView extends View {
public String countString;
StaticLayout countLayout;
int countWidth;
private RectF rect = new RectF();
public UnreadCountBadgeView(Context context, String countString) {
super(context);
this.countString = countString;
countWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(Theme.dialogs_countTextPaint.measureText(countString)));
countLayout = new StaticLayout(countString, Theme.dialogs_countTextPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = Theme.dialogs_countPaint;
paint.setAlpha(255);
Theme.dialogs_countTextPaint.setAlpha(255);
int countLeft = AndroidUtilities.dp(5.5f);
int countTop = AndroidUtilities.dp(12.5f);
int x = 0;
rect.set(x, countTop, x + countWidth + AndroidUtilities.dp(11), countTop + AndroidUtilities.dp(23));
canvas.drawRoundRect(rect, 11.5f * AndroidUtilities.density, 11.5f * AndroidUtilities.density, paint);
if (countLayout != null) {
canvas.save();
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
countLayout.draw(canvas);
canvas.restore();
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(
countWidth + AndroidUtilities.dp(29),
AndroidUtilities.dp(48)
);
}
}

View File

@ -116,7 +116,7 @@ public class LingoTranslator extends Translator {
}
}
public class LingoRequest {
public static class LingoRequest {
@SerializedName("source")
@Expose
@ -145,7 +145,7 @@ public class LingoTranslator extends Translator {
}
class LingoResponse {
static class LingoResponse {
@SerializedName("target")
@Expose