This commit is contained in:
世界 2020-03-31 13:26:10 +08:00
parent 1894c438ad
commit 5548a600a6
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
9 changed files with 244 additions and 35 deletions

View File

@ -42,8 +42,13 @@ jobs:
env GO111MODULE=off gomobile bind -v -ldflags='-s -w' github.com/2dust/AndroidLibV2rayLite
cd ../jni
retry=0
until [ $retry -ge 114514 ]; do
sudo apt-get install -y ninja-build && break
retry=$[$retry+1]
sleep 5
done
sudo apt-get install -y ninja-build
export NDK=$ANDROID_HOME/ndk-bundle
export NINJA_PATH=/usr/bin/ninja
export PATH=`echo $ANDROID_HOME/cmake/*/bin`:$PATH

View File

@ -1,3 +1,5 @@
import java.security.MessageDigest
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
@ -198,6 +200,15 @@ android {
defaultConfig.versionCode = 3
def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]
def tgVoipDexClassesPath = "org/telegram/messenger/voip"
def dxUtilPath = "${sdkDirectory.path}/build-tools/${buildToolsVersion}/dx"
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
dxUtilPath += ".bat"
}
flavorDimensions "minApi"
productFlavors {
@ -257,6 +268,92 @@ android {
}
}
applicationVariants.all { variant ->
def assembleTgVoipDexTaskName = "assemble${variant.name.capitalize()}TgVoipDex"
task "${assembleTgVoipDexTaskName}" {
doLast {
def sourceDir = (File) android.sourceSets.main.java.srcDirs[0]
def classesDir = "${buildDir}/intermediates/javac/${variant.name}/classes"
def javaDir = "${buildDir}/intermediates/java_tgvoip/${variant.name}/java"
def tgVoipDir = new File(classesDir, tgVoipDexClassesPath)
def javaVoipDirFile = new File(javaDir, tgVoipDexClassesPath)
def tgVoipDexJavaFile = new File(javaVoipDirFile, "TgVoipDex.java")
if (!javaVoipDirFile.exists()) {
javaVoipDirFile.mkdirs()
}
def assetsDirFile = new File(buildDir, "intermediates/merged_assets/${variant.name}/out")
if (!assetsDirFile.exists()) {
assetsDirFile.mkdirs()
}
def tgVoipDexFile = new File(assetsDirFile, tgVoipDexFileName)
def classes = tgVoipDir.list(new FilenameFilter() {
@Override
boolean accept(File dir, String name) {
// handle inner and anonymous classes
return tgVoipDexClasses.any { name == "${it}.class" || name.startsWith("${it}\$") && name.endsWith(".class") }
}
}).collect { "${tgVoipDexClassesPath}/${it}" }
// 1. create libtgvoip.dex
exec {
workingDir classesDir
commandLine([dxUtilPath, "--dex", "--output=${tgVoipDexFile}"] + classes)
}
// 2. remove classes from the main dex
project.delete classes.collect { "${classesDir}/${it}" }
// 3. insert checksum of libtgvoip.dex into TgVoipDex.java
def digest = MessageDigest.getInstance("SHA1")
def fileInputStream = tgVoipDexFile.newInputStream()
def buffer = new byte[4096]
def len
while ((len = fileInputStream.read(buffer)) > 0) {
digest.update(buffer, 0, len)
}
def dexChecksum = new String(Base64.getEncoder().encode(digest.digest())).trim()
tgVoipDexJavaFile.write(new String(new File(sourceDir, "${tgVoipDexClassesPath}/TgVoipDex.java").readBytes()).replace("\$CHECKSUM\$", dexChecksum))
exec {
commandLine([findJavac(), "-d", classesDir, tgVoipDexJavaFile.absolutePath])
}
}
}
tasks.findByName("compile${variant.name.capitalize()}JavaWithJavac").finalizedBy(assembleTgVoipDexTaskName)
tasks.findByName("${assembleTgVoipDexTaskName}").mustRunAfter tasks.findByName("merge${variant.name.capitalize()}Assets")
}
}
private static File findJavaHome() {
String javaPath = System.getProperty("java.home")
if (javaPath != null) {
File javaBase = new File(javaPath)
if (javaBase.exists()) {
if (javaBase.getName().equalsIgnoreCase("jre") && new File(javaBase.getParentFile(), "bin/java").exists()) {
return javaBase.getParentFile()
} else {
return javaBase
}
} else {
return null
}
} else {
return null
}
}
private static File findJavac() {
File javaHome = findJavaHome()
if (javaHome != null) {
return new File(javaHome, "bin/javac")
} else {
return null
}
}
apply plugin: 'com.google.gms.google-services'

View File

@ -117,10 +117,18 @@ endif
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
TGVOIP_NATIVE_VERSION := 1.1
TGVOIP_ADDITIONAL_CFLAGS := -DTGVOIP_NO_VIDEO
include $(MY_LOCAL_PATH)/libtgvoip/Android.mk
LOCAL_PATH := $(MY_LOCAL_PATH) # restore local path after include
include $(CLEAR_VARS)
TGVOIP_NATIVE_VERSION := 2.1
TGVOIP_ADDITIONAL_CFLAGS := -DTGVOIP_NO_VIDEO
include $(MY_LOCAL_PATH)/libtgvoip2/Android.mk
LOCAL_PATH := $(MY_LOCAL_PATH) # restore local path after include
include $(CLEAR_VARS)
LOCAL_CPPFLAGS := -Wall -std=c++14 -DANDROID -frtti -DHAVE_PTHREAD -finline-functions -ffast-math -Os
@ -296,7 +304,7 @@ LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math -D__STDC_CONSTANT_MACROS
LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -Os -funroll-loops -std=c++14 -DPACKAGE_NAME='"drinkless/org/ton"'
LOCAL_LDLIBS := -ljnigraphics -llog -lz -lEGL -lGLESv2 -landroid
LOCAL_STATIC_LIBRARIES := webp sqlite lz4 rlottie tgnet swscale avformat avcodec avresample avutil swresample voip flac
LOCAL_STATIC_LIBRARIES := webp sqlite lz4 rlottie tgnet swscale avformat avcodec avresample avutil flac
LOCAL_SRC_FILES := \
./opus/src/opus.c \

View File

@ -0,0 +1,91 @@
package org.telegram.ui.Components;
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
public class CircularViewPager extends ViewPager {
private Adapter adapter;
public CircularViewPager(@NonNull Context context) {
super(context);
}
public CircularViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
{
addOnPageChangeListener(new OnPageChangeListener() {
private int scrollState;
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == getCurrentItem() && positionOffset == 0f && scrollState == ViewPager.SCROLL_STATE_DRAGGING) {
checkCurrentItem();
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE) {
checkCurrentItem();
}
scrollState = state;
}
private void checkCurrentItem() {
if (adapter != null) {
final int position = getCurrentItem();
final int newPosition = adapter.getExtraCount() + adapter.getRealPosition(position);
if (position != newPosition) {
setCurrentItem(newPosition, false);
}
}
}
});
}
@Override
@Deprecated
public void setAdapter(@Nullable PagerAdapter adapter) {
if (adapter instanceof Adapter) {
setAdapter((Adapter) adapter);
} else {
throw new IllegalArgumentException();
}
}
public void setAdapter(Adapter adapter) {
this.adapter = adapter;
super.setAdapter(adapter);
setCurrentItem(adapter.getExtraCount(), false);
}
public static abstract class Adapter extends PagerAdapter {
public int getRealPosition(int adapterPosition) {
final int count = getCount();
final int extraCount = getExtraCount();
if (adapterPosition < extraCount) {
return count - extraCount * 2 - (extraCount - adapterPosition - 1) - 1;
} else if (adapterPosition >= count - extraCount) {
return adapterPosition - (count - extraCount);
} else {
return adapterPosition - extraCount;
}
}
public abstract int getExtraCount();
}
}

View File

@ -65,6 +65,8 @@ import java.util.regex.Pattern;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import tw.nekomimi.nekogram.utils.ProxyUtil;
public class StickersAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate {
public interface StickersAlertDelegate {
@ -552,6 +554,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
containerView.addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 5, 5, 0));
optionsButton.addSubItem(1, R.drawable.msg_share, LocaleController.getString("StickersShare", R.string.StickersShare));
optionsButton.addSubItem(2, R.drawable.msg_link, LocaleController.getString("CopyLink", R.string.CopyLink));
optionsButton.addSubItem(3, R.drawable.wallet_qr, LocaleController.getString("ShareQRCode", R.string.ShareQRCode));
optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu());
optionsButton.setDelegate(this::onSubItemClick);
optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
@ -658,6 +661,8 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
} catch (Exception e) {
FileLog.e(e);
}
} else if (id == 3) {
ProxyUtil.showQrDialog((Activity) getContext(),stickersUrl);
}
}

View File

@ -153,6 +153,7 @@ import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.utils.ProxyUtil;
public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -189,7 +190,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private boolean passcodeItemVisible;
private ActionBarMenuItem proxyItem;
private ActionBarMenuItem scanItem;
private boolean proxyItemVisible;
private ActionBarMenuItem searchItem;
private ActionBarMenuItem doneItem;
private ProxyDrawable proxyDrawable;
@ -1553,7 +1553,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (switchItem != null) {
switchItem.setVisibility(View.GONE);
}
if (proxyItem != null && proxyItemVisible) {
if (proxyItem != null) {
proxyItem.setVisibility(View.GONE);
scanItem.setVisibility(View.VISIBLE);
}
@ -1575,7 +1575,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (switchItem != null) {
switchItem.setVisibility(View.VISIBLE);
}
if (proxyItem != null && proxyItemVisible) {
if (proxyItem != null) {
proxyItem.setVisibility(View.VISIBLE);
scanItem.setVisibility(View.GONE);
}
@ -1642,11 +1642,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (folderId != 0) {
actionBar.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats));
} else {
if (BuildVars.DEBUG_VERSION) {
actionBar.setTitle("Telegram Beta");
} else {
actionBar.setTitle(LocaleController.getString("NekoX", R.string.NekoX));
}
actionBar.setTitle(getNekoTitle(LocaleController.getString("NekoX", R.string.NekoX)));
}
if (folderId == 0) {
actionBar.setSupportsHolidayImage(true);
@ -4869,16 +4865,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
String proxyAddress = preferences.getString("proxy_ip", "");
boolean proxyEnabled;
if ((proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty()) {
if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) {
proxyItem.setVisibility(View.VISIBLE);
}
proxyItemVisible = true;
proxyDrawable.setConnected(proxyEnabled, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated);
} else {
proxyItemVisible = false;
proxyItem.setVisibility(View.GONE);
if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) {
proxyItem.setVisibility(View.VISIBLE);
}
proxyDrawable.setConnected(true, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated);
}
private AnimatorSet doneItemAnimator;
@ -4905,7 +4895,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (searchItem != null) {
searchItem.setVisibility(View.VISIBLE);
}
if (proxyItem != null && proxyItemVisible) {
if (proxyItem != null) {
proxyItem.setVisibility(View.VISIBLE);
}
if (passcodeItem != null && passcodeItemVisible) {
@ -4914,9 +4904,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
ArrayList<Animator> arrayList = new ArrayList<>();
arrayList.add(ObjectAnimator.ofFloat(doneItem, View.ALPHA, show ? 1.0f : 0.0f));
if (proxyItemVisible) {
arrayList.add(ObjectAnimator.ofFloat(proxyItem, View.ALPHA, show ? 0.0f : 1.0f));
}
arrayList.add(ObjectAnimator.ofFloat(proxyItem, View.ALPHA, show ? 0.0f : 1.0f));
if (passcodeItemVisible) {
arrayList.add(ObjectAnimator.ofFloat(passcodeItem, View.ALPHA, show ? 0.0f : 1.0f));
}
@ -4930,7 +4918,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (searchItem != null) {
searchItem.setVisibility(View.INVISIBLE);
}
if (proxyItem != null && proxyItemVisible) {
if (proxyItem != null) {
proxyItem.setVisibility(View.INVISIBLE);
}
if (passcodeItem != null && passcodeItemVisible) {
@ -5093,7 +5081,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
private String getNekoTitle(String title) {
return LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title;
if (!NekoXConfig.removeTitleEmoji) {
title = LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title;
}
return title;
//if (FilterPopup.getInstance(currentAccount).getTotalUnreadCount() == 0) {
// return LocaleController.getString("NekogramEmojiDialogs", R.string.NekogramEmojiDialogs) + " " + title;
//}

View File

@ -72,12 +72,6 @@ public class PrivacyUsersActivity extends BaseFragment implements NotificationCe
public static final int TYPE_BLOCKED = 1;
public static final int TYPE_FILTER = 2;
private int currentType;
public static final int TYPE_PRIVACY = 0;
public static final int TYPE_BLOCKED = 1;
public static final int TYPE_FILTER = 2;
private int unblock_all = 1;
public interface PrivacyActivityDelegate {

View File

@ -101,6 +101,7 @@ public class NekoSettingsActivity extends BaseFragment {
private int forceTabletRow;
private int openArchiveOnPullRow;
private int avatarAsDrawerBackgroundRow;
private int removeTitleEmojiRow;
private int eventTypeRow;
private int newYearRow;
private int actionBarDecorationRow;
@ -547,6 +548,12 @@ public class NekoSettingsActivity extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.avatarAsDrawerBackground);
}
} else if (position == removeTitleEmojiRow) {
NekoXConfig.toggleRemoveTitleEmoji();
NotificationCenter.getInstance(UserConfig.selectedAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoXConfig.removeTitleEmoji);
}
}
});
@ -600,6 +607,7 @@ public class NekoSettingsActivity extends BaseFragment {
forceTabletRow = rowCount++;
openArchiveOnPullRow = rowCount++;
avatarAsDrawerBackgroundRow = rowCount++;
removeTitleEmojiRow = rowCount++;
nameOrderRow = rowCount++;
eventTypeRow = NekoXConfig.developerMode ? rowCount++ : -1;
newYearRow = NekoXConfig.developerMode ? rowCount++ : -1;
@ -1181,9 +1189,10 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndCheck(LocaleController.getString("DisableSystemAccount", R.string.DisableSystemAccount), NekoXConfig.disableSystemAccount, true);
} else if (position == avatarAsDrawerBackgroundRow) {
textCell.setTextAndCheck(LocaleController.getString("UseAvatarAsDrawerBackground", R.string.UseAvatarAsDrawerBackground), NekoConfig.avatarAsDrawerBackground, true);
} else if (position == removeTitleEmojiRow) {
textCell.setTextAndCheck(LocaleController.getString("RemoveTitleEmoji", R.string.RemoveTitleEmoji), NekoXConfig.removeTitleEmoji, true);
}
break;
}
case 4: {
@ -1225,7 +1234,8 @@ public class NekoSettingsActivity extends BaseFragment {
position == unlimitedFavedStickersRow || position == messageMenuRow || position == deleteAccountRow ||
position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
position == hideKeyboardOnChatScrollRow || position == sortMenuRow || position == disableSystemAccountRow || position == avatarAsDrawerBackgroundRow;
position == hideKeyboardOnChatScrollRow || position == sortMenuRow || position == disableSystemAccountRow ||
position == avatarAsDrawerBackgroundRow || position == removeTitleEmojiRow;
}
@Override
@ -1267,7 +1277,7 @@ public class NekoSettingsActivity extends BaseFragment {
@Override
public int getItemViewType(int position) {
if (position == connection2Row || position == dialogs2Row|| position == chat2Row || position == experiment2Row || position == privacy2Row) {
if (position == connection2Row || position == dialogs2Row || position == chat2Row || position == experiment2Row || position == privacy2Row) {
return 1;
} else if (position == nameOrderRow || position == mapPreviewRow || position == stickerSizeRow || position == messageMenuRow ||
position == sortMenuRow ||
@ -1280,7 +1290,8 @@ public class NekoSettingsActivity extends BaseFragment {
position == saveCacheToSdcardRow || position == unlimitedFavedStickersRow || position == skipOpenLinkConfiirm ||
position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
position == hideKeyboardOnChatScrollRow || position == disableSystemAccountRow || position == avatarAsDrawerBackgroundRow) {
position == hideKeyboardOnChatScrollRow || position == disableSystemAccountRow || position == avatarAsDrawerBackgroundRow ||
position == removeTitleEmojiRow) {
return 3;
} else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow || position == dialogsRow || position == privacyRow) {
return 4;

View File

@ -3,6 +3,8 @@
<string name="NekoX" translatable="false">Nekogram X</string>
<string name="RemoveTitleEmoji">Remove emoji in title</string>
<string name="NekoXProxy">NekoX Public Proxy</string>
<string name="PublicPrefix">[ Public ]</string>
<string name="NekoXProxyInfo">It may take tens of seconds to load the NekoX Public built-in proxy :)</string>