This commit is contained in:
NekoInverter 2020-03-30 12:23:34 +08:00
parent e3f0c4cdff
commit 3a6e09a36f
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
7 changed files with 39 additions and 80 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<>();
@ -246,7 +246,7 @@ public class Emoji {
} else {
b = getBounds();
}
if (SharedConfig.useSystemEmoji) {
if (NekoConfig.useSystemEmoji) {
String emoji = fixEmoji(EmojiData.data[info.page][info.emojiIndex]);
textPaint.setTextSize(b.height() * 0.8f);
canvas.drawText(emoji, 0, emoji.length(), b.left, b.bottom - b.height() * 0.225f, textPaint);

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,13 +10,16 @@ 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();
public static boolean useIPv6 = false;
public static boolean showHiddenFeature = false;
public static boolean useSystemEmoji = SharedConfig.useSystemEmoji;
public static boolean ignoreBlocked = false;
public static boolean hideProxySponsorChannel = false;
public static boolean saveCacheToPrivateDirectory = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
@ -88,6 +92,7 @@ public class NekoConfig {
editor.putBoolean("openArchiveOnPull", openArchiveOnPull);
editor.putBoolean("showHiddenFeature", showHiddenFeature);
editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground);
editor.putBoolean("useSystemEmoji", useSystemEmoji);
editor.putFloat("stickerSize", stickerSize);
editor.putInt("typeface", typeface);
editor.putInt("nameOrder", nameOrder);
@ -142,6 +147,7 @@ public class NekoConfig {
showHiddenFeature = preferences.getBoolean("showHiddenFeature", false);
hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false);
avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", false);
useSystemEmoji = preferences.getBoolean("useSystemEmoji", SharedConfig.useSystemEmoji);
configLoaded = true;
}
}
@ -412,4 +418,12 @@ public class NekoConfig {
editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground);
editor.commit();
}
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;
@ -55,6 +54,7 @@ import org.telegram.ui.Components.SeekBarView;
import java.util.ArrayList;
@SuppressLint("RtlHardcoded")
public class NekoSettingsActivity extends BaseFragment {
private RecyclerListView listView;
@ -197,12 +197,9 @@ public class NekoSettingsActivity extends BaseFragment {
((TextCheckCell) view).setChecked(NekoConfig.saveCacheToPrivateDirectory);
}
} else if (position == useSystemEmojiRow) {
SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji;
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
editor.putBoolean("useSystemEmoji", SharedConfig.useSystemEmoji);
editor.commit();
NekoConfig.toggleUseSystemEmoji();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji);
((TextCheckCell) view).setChecked(NekoConfig.useSystemEmoji);
}
} else if (position == typefaceRow) {
NekoConfig.toggleTypeface();
@ -718,7 +715,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();
@ -805,7 +802,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));
@ -902,9 +899,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;
}
@ -1015,7 +1012,7 @@ public class NekoSettingsActivity extends BaseFragment {
} else if (position == saveCacheToPrivateDirectoryRow) {
textCell.setTextAndCheck(LocaleController.getString("SaveCacheToPrivateDirectory", R.string.SaveCacheToPrivateDirectory), NekoConfig.saveCacheToPrivateDirectory, 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) {
@ -1113,9 +1110,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