mirror of https://github.com/NekoX-Dev/NekoX.git
Fix merge 8.9.3
Move GooglePushListenerServiceProvider into gservices/ Remove Premium Gifting Optimize ApplicationLoader init TODO: 1. fix ChatMenu 2. fix MapsProvider and LocationProvider
This commit is contained in:
parent
db06bb66f4
commit
7d1f137c21
|
@ -3,15 +3,15 @@ import cn.hutool.core.util.RuntimeUtil
|
|||
apply plugin: "com.android.application"
|
||||
apply plugin: "kotlin-android"
|
||||
|
||||
def verName = "8.8.5-rc02"
|
||||
def verCode = 663
|
||||
def verName = "8.9.3-preview01"
|
||||
def verCode = 664
|
||||
|
||||
if (System.getenv("DEBUG_BUILD") == "true") {
|
||||
verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1").trim()
|
||||
}
|
||||
|
||||
def officialVer = "8.8.5"
|
||||
def officialCode = 2721
|
||||
def officialVer = "8.9.3"
|
||||
def officialCode = 2757
|
||||
|
||||
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
|
||||
|
||||
|
@ -386,6 +386,11 @@ dependencies {
|
|||
compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
|
||||
compileOnly "com.google.android.play:core:$playCoreVersion"
|
||||
|
||||
// TODO: Remove in nogcm vesion
|
||||
implementation 'com.google.android.gms:play-services-maps:18.1.0'
|
||||
implementation 'com.google.android.gms:play-services-location:20.0.0'
|
||||
|
||||
|
||||
debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion"
|
||||
debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
|
||||
debugImplementation "com.google.android.play:core:$playCoreVersion"
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
public class GooglePushListenerServiceProvider implements PushListenerController.IPushListenerServiceProvider {
|
||||
|
||||
private Boolean hasServices;
|
||||
|
||||
public GooglePushListenerServiceProvider() {}
|
||||
|
||||
@Override
|
||||
public String getLogTitle() {
|
||||
return "Google Play Services";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPushType() {
|
||||
return PushListenerController.PUSH_TYPE_FIREBASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPushToken() {
|
||||
String currentPushString = SharedConfig.pushString;
|
||||
if (!TextUtils.isEmpty(currentPushString)) {
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION && BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("FCM regId = " + currentPushString);
|
||||
}
|
||||
} else {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("FCM Registration not found.");
|
||||
}
|
||||
}
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
try {
|
||||
SharedConfig.pushStringGetTimeStart = SystemClock.elapsedRealtime();
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
SharedConfig.pushStringGetTimeEnd = SystemClock.elapsedRealtime();
|
||||
if (!task.isSuccessful()) {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("Failed to get regid");
|
||||
}
|
||||
SharedConfig.pushStringStatus = "__FIREBASE_FAILED__";
|
||||
PushListenerController.sendRegistrationToServer(getPushType(), null);
|
||||
return;
|
||||
}
|
||||
String token = task.getResult();
|
||||
if (!TextUtils.isEmpty(token)) {
|
||||
PushListenerController.sendRegistrationToServer(getPushType(), token);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasServices() {
|
||||
if (hasServices == null) {
|
||||
try {
|
||||
int resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(ApplicationLoader.applicationContext);
|
||||
hasServices = resultCode == ConnectionResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
hasServices = false;
|
||||
}
|
||||
}
|
||||
return hasServices;
|
||||
}
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
package tw.nekomimi.nekogram;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.IntentSender;
|
||||
import android.text.TextUtils;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailabilityLight;
|
||||
import com.google.android.play.core.appupdate.AppUpdateManager;
|
||||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
|
||||
import com.google.android.play.core.install.InstallStateUpdatedListener;
|
||||
import com.google.android.play.core.install.model.AppUpdateType;
|
||||
import com.google.android.play.core.install.model.InstallStatus;
|
||||
import com.google.android.play.core.install.model.UpdateAvailability;
|
||||
import com.google.android.play.core.missingsplits.MissingSplitsManagerFactory;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.GcmPushListenerService;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
|
||||
import kotlin.Unit;
|
||||
import tw.nekomimi.nekogram.utils.UIUtil;
|
||||
|
||||
@Keep
|
||||
public class GcmImpl implements ExternalGcm.Interface {
|
||||
|
||||
private static Boolean hasPlayServices;
|
||||
|
||||
@Override
|
||||
public boolean checkPlayServices() {
|
||||
if (hasPlayServices != null) return hasPlayServices;
|
||||
try {
|
||||
int resultCode = GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(ApplicationLoader.applicationContext);
|
||||
hasPlayServices = resultCode == ConnectionResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
hasPlayServices = false;
|
||||
FileLog.e(e);
|
||||
}
|
||||
return hasPlayServices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkSplit(Context ctx) {
|
||||
//noinspection deprecation
|
||||
return MissingSplitsManagerFactory.create(ctx).disableAppIfMissingRequiredSplits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPlayServices() {
|
||||
Utilities.stageQueue.postRunnable(() -> {
|
||||
if (hasPlayServices = checkPlayServices()) {
|
||||
final String currentPushString = SharedConfig.pushString;
|
||||
if (!TextUtils.isEmpty(currentPushString)) {
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION && BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("GCM regId = " + currentPushString);
|
||||
}
|
||||
} else {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("GCM Registration not found.");
|
||||
}
|
||||
}
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
try {
|
||||
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(instanceIdResult -> {
|
||||
String token = instanceIdResult.getToken();
|
||||
if (!TextUtils.isEmpty(token)) {
|
||||
GcmPushListenerService.sendRegistrationToServer(token);
|
||||
}
|
||||
}).addOnFailureListener(e -> {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("Failed to get regid");
|
||||
}
|
||||
SharedConfig.pushStringStatus = "__FIREBASE_FAILED__";
|
||||
GcmPushListenerService.sendRegistrationToServer(null);
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("No valid Google Play Services APK found.");
|
||||
}
|
||||
SharedConfig.pushStringStatus = "__NO_GOOGLE_PLAY_SERVICES__";
|
||||
ConnectionsManager.setRegId(null, SharedConfig.pushStringStatus);
|
||||
}
|
||||
}, 2300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRegistrationToServer() {
|
||||
if (!checkPlayServices()) return;
|
||||
GcmPushListenerService.sendRegistrationToServer(SharedConfig.pushString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUpdate(Activity ctx) {
|
||||
/* if (!checkPlayServices()) return;
|
||||
AppUpdateManager manager = AppUpdateManagerFactory.create(ctx);
|
||||
InstallStateUpdatedListener listener = (installState) -> {
|
||||
if (installState.installStatus() == InstallStatus.DOWNLOADED) {
|
||||
BottomBuilder builder = new BottomBuilder(ctx);
|
||||
builder.addTitle(LocaleController.getString("UpdateDownloaded", R.string.UpdateDownloaded));
|
||||
builder.addItem(LocaleController.getString("UpdateUpdate", R.string.UpdateUpdate), R.drawable.baseline_system_update_24, false, (it) -> {
|
||||
manager.completeUpdate();
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
builder.addItem(LocaleController.getString("UpdateLater", R.string.UpdateLater), R.drawable.baseline_watch_later_24, false, null);
|
||||
try {
|
||||
builder.show();
|
||||
} catch (WindowManager.BadTokenException e) {
|
||||
manager.completeUpdate();
|
||||
}
|
||||
}
|
||||
};
|
||||
manager.registerListener(listener);
|
||||
manager.getAppUpdateInfo().addOnSuccessListener((appUpdateInfo) -> {
|
||||
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.availableVersionCode() <= BuildConfig.VERSION_CODE) {
|
||||
FileLog.d("update available");
|
||||
try {
|
||||
manager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType.FLEXIBLE, ctx, 114514);
|
||||
} catch (IntentSender.SendIntentException ignored) {
|
||||
}
|
||||
} else {
|
||||
FileLog.d("no updates");
|
||||
}
|
||||
});*/
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -483,6 +483,10 @@ public class AndroidUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isMapsInstalled(BaseFragment baseFragment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class LinkSpec {
|
||||
String url;
|
||||
int start;
|
||||
|
|
|
@ -48,7 +48,6 @@ import java.lang.reflect.Method;
|
|||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import tw.nekomimi.nekogram.ExternalGcm;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
import tw.nekomimi.nekogram.parts.SignturesKt;
|
||||
import tw.nekomimi.nekogram.utils.FileUtil;
|
||||
|
@ -95,102 +94,11 @@ public class ApplicationLoader extends Application {
|
|||
applicationContext = getApplicationContext();
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
if (SDK_INT >= Build.VERSION_CODES.P) {
|
||||
Reflection.unseal(base);
|
||||
}
|
||||
Thread.currentThread().setUncaughtExceptionHandler((thread, error) -> {
|
||||
Log.e("nekox", "from " + thread.toString(), error);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @author weishu
|
||||
* @date 2018/6/7.
|
||||
*/
|
||||
public static class Reflection {
|
||||
private static final String TAG = "Reflection";
|
||||
|
||||
private static Object sVmRuntime;
|
||||
private static Method setHiddenApiExemptions;
|
||||
|
||||
static {
|
||||
if (SDK_INT >= Build.VERSION_CODES.P) {
|
||||
try {
|
||||
Method forName = Class.class.getDeclaredMethod("forName", String.class);
|
||||
Method getDeclaredMethod = Class.class.getDeclaredMethod("getDeclaredMethod", String.class, Class[].class);
|
||||
|
||||
Class<?> vmRuntimeClass = (Class<?>) forName.invoke(null, "dalvik.system.VMRuntime");
|
||||
Method getRuntime = (Method) getDeclaredMethod.invoke(vmRuntimeClass, "getRuntime", null);
|
||||
setHiddenApiExemptions = (Method) getDeclaredMethod.invoke(vmRuntimeClass, "setHiddenApiExemptions", new Class[]{String[].class});
|
||||
sVmRuntime = getRuntime.invoke(null);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("reflect bootstrap failed:", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static int UNKNOWN = -9999;
|
||||
|
||||
private static final int ERROR_SET_APPLICATION_FAILED = -20;
|
||||
|
||||
private static final int ERROR_EXEMPT_FAILED = -21;
|
||||
|
||||
private static int unsealed = UNKNOWN;
|
||||
|
||||
public static int unseal(Context context) {
|
||||
if (SDK_INT < 28) {
|
||||
// Below Android P, ignore
|
||||
return 0;
|
||||
}
|
||||
|
||||
// try exempt API first.
|
||||
if (exemptAll()) {
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_EXEMPT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* make the method exempted from hidden API check.
|
||||
*
|
||||
* @param method the method signature prefix.
|
||||
* @return true if success.
|
||||
*/
|
||||
public static boolean exempt(String method) {
|
||||
return exempt(new String[]{method});
|
||||
}
|
||||
|
||||
/**
|
||||
* make specific methods exempted from hidden API check.
|
||||
*
|
||||
* @param methods the method signature prefix, such as "Ldalvik/system", "Landroid" or even "L"
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean exempt(String... methods) {
|
||||
if (sVmRuntime == null || setHiddenApiExemptions == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
setHiddenApiExemptions.invoke(sVmRuntime, new Object[]{methods});
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make all hidden API exempted.
|
||||
*
|
||||
* @return true if success.
|
||||
*/
|
||||
public static boolean exemptAll() {
|
||||
return exempt(new String[]{"L"});
|
||||
}
|
||||
}
|
||||
|
||||
public static ILocationServiceProvider getLocationServiceProvider() {
|
||||
if (locationServiceProvider == null) {
|
||||
locationServiceProvider = applicationLoaderInstance.onCreateLocationServiceProvider();
|
||||
|
@ -222,26 +130,13 @@ public class ApplicationLoader extends Application {
|
|||
}
|
||||
|
||||
protected PushListenerController.IPushListenerServiceProvider onCreatePushProvider() {
|
||||
return PushListenerController.GooglePushListenerServiceProvider.INSTANCE;
|
||||
return PushListenerController.getProvider();
|
||||
}
|
||||
|
||||
public static String getApplicationId() {
|
||||
return BuildConfig.APPLICATION_ID;
|
||||
}
|
||||
|
||||
// protected String onGetApplicationId() {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public static boolean isHuaweiStoreBuild() {
|
||||
return applicationLoaderInstance.isHuaweiBuild();
|
||||
}
|
||||
|
||||
protected boolean isHuaweiBuild() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SdCardPath")
|
||||
public static File getDataDirFixed() {
|
||||
try {
|
||||
|
@ -260,23 +155,15 @@ public class ApplicationLoader extends Application {
|
|||
}
|
||||
|
||||
public static File getFilesDirFixed() {
|
||||
|
||||
File filesDir = new File(getDataDirFixed(), "files");
|
||||
|
||||
FileUtil.initDir(filesDir);
|
||||
|
||||
return filesDir;
|
||||
|
||||
}
|
||||
|
||||
public static File getCacheDirFixed() {
|
||||
|
||||
File filesDir = new File(getDataDirFixed(), "cache");
|
||||
|
||||
FileUtil.initDir(filesDir);
|
||||
|
||||
return filesDir;
|
||||
|
||||
}
|
||||
|
||||
public static void postInitApplication() {
|
||||
|
@ -286,11 +173,10 @@ public class ApplicationLoader extends Application {
|
|||
applicationInited = true;
|
||||
|
||||
SharedConfig.loadConfig();
|
||||
LocaleController.getInstance();
|
||||
SharedPrefsHelper.init(applicationContext);
|
||||
UserConfig.getInstance(0).loadConfig();
|
||||
|
||||
LinkedList<Runnable> postRun = new LinkedList<>();
|
||||
|
||||
try {
|
||||
connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
BroadcastReceiver networkStateReceiver = new BroadcastReceiver() {
|
||||
|
@ -339,26 +225,27 @@ public class ApplicationLoader extends Application {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LinkedList<Runnable> postRun = new LinkedList<>();
|
||||
for (int a : SharedConfig.activeAccounts) {
|
||||
final int finalA = a;
|
||||
Runnable initRunnable = () -> loadAccount(finalA);
|
||||
if (finalA == UserConfig.selectedAccount) initRunnable.run();
|
||||
if (finalA == UserConfig.selectedAccount) {
|
||||
initRunnable.run();
|
||||
ChatThemeController.init();
|
||||
}
|
||||
else postRun.add(initRunnable);
|
||||
}
|
||||
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("app initied");
|
||||
}
|
||||
for (Runnable runnable : postRun) {
|
||||
Utilities.stageQueue.postRunnable(runnable);
|
||||
}
|
||||
Utilities.stageQueue.postRunnable(ExternalGcm::initPlayServices);
|
||||
// init fcm
|
||||
initPushServices();
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("app initied");
|
||||
}
|
||||
}
|
||||
|
||||
private static final HashSet<Integer> loadedAccounts = new HashSet<>();
|
||||
|
||||
public static void loadAccount(int account) {
|
||||
if (!loadedAccounts.add(account)) return;
|
||||
UserConfig inst = UserConfig.getInstance(account);
|
||||
inst.loadConfig();
|
||||
if (!inst.isClientActivated()) {
|
||||
|
@ -368,7 +255,7 @@ public class ApplicationLoader extends Application {
|
|||
}
|
||||
|
||||
MessagesController.getInstance(account);
|
||||
if (account == 0) {
|
||||
if ("".equals(SharedConfig.pushStringStatus)) {
|
||||
SharedConfig.pushStringStatus = "__FIREBASE_GENERATING_SINCE_" + ConnectionsManager.getInstance(account).getCurrentTime() + "__";
|
||||
} else {
|
||||
ConnectionsManager.getInstance(account);
|
||||
|
@ -382,8 +269,6 @@ public class ApplicationLoader extends Application {
|
|||
ContactsController.getInstance(account).checkAppAccount();
|
||||
DownloadController.getInstance(account);
|
||||
});
|
||||
|
||||
ChatThemeController.init();
|
||||
}
|
||||
|
||||
public ApplicationLoader() {
|
||||
|
@ -398,10 +283,6 @@ public class ApplicationLoader extends Application {
|
|||
} catch (Throwable ignore) {
|
||||
}
|
||||
|
||||
if (BuildVars.isPlay && ExternalGcm.checkSplit(this)) {
|
||||
return; // Skip app initialization.
|
||||
}
|
||||
|
||||
super.onCreate();
|
||||
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
|
@ -412,16 +293,7 @@ public class ApplicationLoader extends Application {
|
|||
applicationContext = getApplicationContext();
|
||||
}
|
||||
|
||||
// Since static init is thread-safe, no lock is needed there.
|
||||
Utilities.stageQueue.postRunnable(() -> {
|
||||
SignturesKt.checkMT(this);
|
||||
});
|
||||
|
||||
try {
|
||||
Class.forName("org.robolectric.android.internal.AndroidTestEnvironment");
|
||||
return;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
Utilities.stageQueue.postRunnable(() -> SignturesKt.checkMT(this));
|
||||
|
||||
NativeLoader.initNativeLibs(ApplicationLoader.applicationContext);
|
||||
ConnectionsManager.native_setJava(false);
|
||||
|
@ -444,16 +316,16 @@ public class ApplicationLoader extends Application {
|
|||
org.osmdroid.config.Configuration.getInstance().setUserAgentValue("Telegram-FOSS ( NekoX ) " + BuildConfig.VERSION_NAME);
|
||||
org.osmdroid.config.Configuration.getInstance().setOsmdroidBasePath(new File(ApplicationLoader.applicationContext.getCacheDir(), "osmdroid"));
|
||||
|
||||
startPushService();
|
||||
LauncherIconController.tryFixLauncherIconIfNeeded();
|
||||
LauncherIconController.tryFixLauncherIconIfNeeded();
|
||||
}
|
||||
|
||||
// Local Push Service, TFoss implementation
|
||||
public static void startPushService() {
|
||||
Utilities.stageQueue.postRunnable(ApplicationLoader::startPushServiceInternal);
|
||||
}
|
||||
|
||||
private static void startPushServiceInternal() {
|
||||
if (ExternalGcm.checkPlayServices()) {
|
||||
if (PushListenerController.getProvider().hasServices()) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences preferences = MessagesController.getNotificationsSettings(UserConfig.selectedAccount);
|
||||
|
@ -503,6 +375,21 @@ LauncherIconController.tryFixLauncherIconIfNeeded();
|
|||
});
|
||||
}
|
||||
|
||||
private static void initPushServices() {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (getPushProvider().hasServices()) {
|
||||
getPushProvider().onRequestPushToken();
|
||||
} else {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("No valid " + getPushProvider().getLogTitle() + " APK found.");
|
||||
}
|
||||
SharedConfig.pushStringStatus = "__NO_GOOGLE_PLAY_SERVICES__";
|
||||
PushListenerController.sendRegistrationToServer(getPushProvider().getPushType(), null);
|
||||
startPushService();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.util.Consumer;
|
||||
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.PremiumPreviewFragment;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Currency;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class BillingController {
|
||||
|
||||
private static BillingController instance;
|
||||
|
||||
public static BillingController getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new BillingController(ApplicationLoader.applicationContext);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private BillingController(Context ctx) {
|
||||
|
||||
}
|
||||
|
||||
public String formatCurrency(long amount, String currency) {
|
||||
return formatCurrency(amount, currency, getCurrencyExp(currency));
|
||||
}
|
||||
|
||||
public String formatCurrency(long amount, String currency, int exp) {
|
||||
if (currency.isEmpty()) {
|
||||
return String.valueOf(amount);
|
||||
}
|
||||
Currency cur = Currency.getInstance(currency);
|
||||
if (cur != null) {
|
||||
NumberFormat numberFormat = NumberFormat.getCurrencyInstance();
|
||||
numberFormat.setCurrency(cur);
|
||||
|
||||
return numberFormat.format(amount / Math.pow(10, exp));
|
||||
}
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public int getCurrencyExp(String currency) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -54,4 +54,8 @@ public class BuildVars {
|
|||
LOGS_ENABLED = DEBUG_VERSION = sharedPreferences.getBoolean("logsEnabled", DEBUG_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean useInvoiceBilling() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public class GoogleLocationProvider implements ILocationServiceProvider {
|
|||
|
||||
@Override
|
||||
public boolean checkServices() {
|
||||
return PushListenerController.GooglePushListenerServiceProvider.INSTANCE.hasServices();
|
||||
return PushListenerController.getProvider().hasServices();
|
||||
}
|
||||
|
||||
public final static class GoogleLocationRequest implements ILocationRequest {
|
||||
|
|
|
@ -24,8 +24,6 @@ import android.util.LongSparseArray;
|
|||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import androidx.collection.LongSparseArray;
|
||||
|
||||
import org.telegram.SQLite.SQLiteCursor;
|
||||
import org.telegram.SQLite.SQLitePreparedStatement;
|
||||
import org.telegram.tgnet.NativeByteBuffer;
|
||||
|
@ -48,6 +46,7 @@ public class LocationController extends BaseController implements NotificationCe
|
|||
private GpsLocationListener gpsLocationListener = new GpsLocationListener();
|
||||
private GpsLocationListener networkLocationListener = new GpsLocationListener();
|
||||
private GpsLocationListener passiveLocationListener = new GpsLocationListener();
|
||||
private FusedLocationListener fusedLocationListener = new FusedLocationListener();
|
||||
private Location lastKnownLocation;
|
||||
private long lastLocationSendTime;
|
||||
private boolean locationSentSinceLastMapUpdate = true;
|
||||
|
|
|
@ -80,7 +80,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import tw.nekomimi.nekogram.ExternalGcm;
|
||||
import tw.nekomimi.nekogram.ui.InternalFilters;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
|
|
|
@ -7,10 +7,6 @@ import android.util.Base64;
|
|||
import androidx.annotation.IntDef;
|
||||
import androidx.collection.LongSparseArray;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailabilityLight;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
|
@ -1288,72 +1284,44 @@ public class PushListenerController {
|
|||
int getPushType();
|
||||
}
|
||||
|
||||
public final static class GooglePushListenerServiceProvider implements IPushListenerServiceProvider {
|
||||
public final static GooglePushListenerServiceProvider INSTANCE = new GooglePushListenerServiceProvider();
|
||||
private static IPushListenerServiceProvider instance = null;
|
||||
|
||||
private Boolean hasServices;
|
||||
|
||||
private GooglePushListenerServiceProvider() {}
|
||||
private static class DummyPushProvider implements IPushListenerServiceProvider {
|
||||
@Override
|
||||
public boolean hasServices() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogTitle() {
|
||||
return "Google Play Services";
|
||||
return "Dummy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPushToken() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPushType() {
|
||||
return PUSH_TYPE_FIREBASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPushToken() {
|
||||
String currentPushString = SharedConfig.pushString;
|
||||
if (!TextUtils.isEmpty(currentPushString)) {
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION && BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("FCM regId = " + currentPushString);
|
||||
}
|
||||
} else {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("FCM Registration not found.");
|
||||
}
|
||||
}
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
try {
|
||||
SharedConfig.pushStringGetTimeStart = SystemClock.elapsedRealtime();
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
SharedConfig.pushStringGetTimeEnd = SystemClock.elapsedRealtime();
|
||||
if (!task.isSuccessful()) {
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("Failed to get regid");
|
||||
}
|
||||
SharedConfig.pushStringStatus = "__FIREBASE_FAILED__";
|
||||
PushListenerController.sendRegistrationToServer(getPushType(), null);
|
||||
return;
|
||||
}
|
||||
String token = task.getResult();
|
||||
if (!TextUtils.isEmpty(token)) {
|
||||
PushListenerController.sendRegistrationToServer(getPushType(), token);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasServices() {
|
||||
if (hasServices == null) {
|
||||
try {
|
||||
int resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(ApplicationLoader.applicationContext);
|
||||
hasServices = resultCode == ConnectionResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
hasServices = false;
|
||||
}
|
||||
}
|
||||
return hasServices;
|
||||
}
|
||||
}
|
||||
|
||||
public static IPushListenerServiceProvider getProvider() {
|
||||
if (instance != null)
|
||||
return instance;
|
||||
if (BuildConfig.BUILD_TYPE.equals("debug") || BuildConfig.BUILD_TYPE.equals("release")) {
|
||||
try {
|
||||
instance = (IPushListenerServiceProvider) Class.forName("org.telegram.messenger.GooglePushListenerServiceProvider").newInstance();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
instance = new DummyPushProvider();
|
||||
}
|
||||
} else {
|
||||
instance = new DummyPushProvider();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -240,7 +240,6 @@ import org.telegram.ui.Components.PinnedLineView;
|
|||
import org.telegram.ui.Components.PipRoundVideoView;
|
||||
import org.telegram.ui.Components.PollVotesAlert;
|
||||
import org.telegram.ui.Components.PopupSwipeBackLayout;
|
||||
import org.telegram.ui.Components.Premium.GiftPremiumBottomSheet;
|
||||
import org.telegram.ui.Components.Premium.PremiumFeatureBottomSheet;
|
||||
import org.telegram.ui.Components.Premium.PremiumPreviewBottomSheet;
|
||||
import org.telegram.ui.Components.RLottieDrawable;
|
||||
|
@ -26855,9 +26854,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
((ChatActionCell) view).setDelegate(new ChatActionCell.ChatActionCellDelegate() {
|
||||
@Override
|
||||
public void didOpenPremiumGift(ChatActionCell cell, TLRPC.TL_premiumGiftOption giftOption, boolean animateConfetti) {
|
||||
showDialog(new PremiumPreviewBottomSheet(ChatActivity.this, currentAccount, getCurrentUser(), new GiftPremiumBottomSheet.GiftTier(giftOption))
|
||||
.setAnimateConfetti(animateConfetti)
|
||||
.setOutboundGift(cell.getMessageObject().isOut()));
|
||||
Toast.makeText(ChatActivity.this.getContext(), LocaleController.getString("nekoxPremiumGiftRemoved", R.string.nekoxPremiumGiftRemoved), Toast.LENGTH_SHORT).show();
|
||||
// showDialog(new PremiumPreviewBottomSheet(ChatActivity.this, currentAccount, getCurrentUser(), new GiftPremiumBottomSheet.GiftTier(giftOption))
|
||||
// .setAnimateConfetti(animateConfetti)
|
||||
// .setOutboundGift(cell.getMessageObject().isOut()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -421,6 +421,8 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
private Drawable sendButtonDrawable;
|
||||
private Drawable inactinveSendButtonDrawable;
|
||||
private Drawable sendButtonInverseDrawable;
|
||||
private ActionBarPopupWindow sendPopupWindow;
|
||||
private ActionBarPopupWindow.ActionBarPopupWindowLayout sendPopupLayout;
|
||||
private ImageView cancelBotButton;
|
||||
private ChatActivityEnterViewAnimatedIconView emojiButton;
|
||||
private ImageView expandStickersButton;
|
||||
|
@ -3123,13 +3125,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
audioVideoButtonContainer.setSoundEffectsEnabled(false);
|
||||
sendButtonContainer.addView(audioVideoButtonContainer, LayoutHelper.createFrame(48, 48));
|
||||
if (NekoConfig.useChatAttachMediaMenu.Bool()) {
|
||||
audioVideoButtonContainer.setFocusable(true);
|
||||
audioVideoButtonContainer.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||
audioVideoButtonContainer.setOnClickListener(v -> {
|
||||
if (recordCircle.isSendButtonVisible()) {
|
||||
if (!hasRecordVideo || calledRecordRunnable) {
|
||||
startedDraggingX = -1;
|
||||
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
||||
if (hasRecordVideo && audioVideoButtonContainer.getTag() != null) {
|
||||
delegate.needStartRecordVideo(1, true, 0);
|
||||
} else {
|
||||
if (recordingAudioVideo && isInScheduleMode()) {
|
||||
|
@ -3148,6 +3148,8 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
});
|
||||
} else {
|
||||
audioVideoButtonContainer.setOnTouchListener((view, motionEvent) -> {
|
||||
audioVideoButtonContainer.setFocusable(true);
|
||||
audioVideoButtonContainer.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (recordCircle.isSendButtonVisible()) {
|
||||
if (!hasRecordVideo || calledRecordRunnable) {
|
||||
|
@ -3172,7 +3174,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
}
|
||||
if (parentFragment != null) {
|
||||
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
||||
TLRPC.UserFull userFull = parentFragment.getCurrentUserInfo();
|
||||
TLRPC.UserFull userFull = parentFragment.getCurrentUserInfo();
|
||||
if (chat != null && !ChatObject.canSendMedia(chat) || userFull != null && userFull.voice_messages_forbidden) {
|
||||
delegate.needShowMediaBanHint();
|
||||
return true;
|
||||
|
@ -3322,7 +3324,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
audioVideoSendButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.SRC_IN));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21 && NekoConfig.useChatAttachMediaMenu.Bool()) {
|
||||
audioVideoSendButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
||||
audioVideoSendButton.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
||||
}
|
||||
|
||||
audioVideoButtonContainer.addView(audioVideoSendButton, LayoutHelper.createFrame(48, 48));
|
||||
|
@ -3817,10 +3819,10 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
}
|
||||
}
|
||||
|
||||
videoSendButton.setTag(null);
|
||||
audioVideoSendButton.setTag(null);
|
||||
recordAudioVideoRunnable.run();
|
||||
delegate.onSwitchRecordMode(videoSendButton.getTag() == null);
|
||||
setRecordVideoButtonVisible(videoSendButton.getTag() == null, true);
|
||||
delegate.onSwitchRecordMode(audioVideoSendButton.getTag() == null);
|
||||
setRecordVideoButtonVisible(audioVideoSendButton.getTag() == null, true);
|
||||
if (!NekoConfig.disableVibration.Bool()) {
|
||||
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
|
||||
}
|
||||
|
@ -3849,10 +3851,10 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
}
|
||||
}
|
||||
|
||||
videoSendButton.setTag(1);
|
||||
audioVideoSendButton.setTag(1);
|
||||
recordAudioVideoRunnable.run();
|
||||
delegate.onSwitchRecordMode(videoSendButton.getTag() == null);
|
||||
setRecordVideoButtonVisible(videoSendButton.getTag() == null, true);
|
||||
delegate.onSwitchRecordMode(audioVideoSendButton.getTag() == null);
|
||||
setRecordVideoButtonVisible(audioVideoSendButton.getTag() == null, true);
|
||||
if (!NekoConfig.disableVibration.Bool()) {
|
||||
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
|
||||
}
|
||||
|
@ -4036,9 +4038,6 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
|
||||
}
|
||||
|
||||
private ActionBarPopupWindow sendPopupWindow;
|
||||
private ActionBarPopupWindow.ActionBarPopupWindowLayout sendPopupLayout;
|
||||
|
||||
private boolean onSendLongClick(View view) {
|
||||
if (isInScheduleMode()) {
|
||||
return false;
|
||||
|
@ -4369,14 +4368,8 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
if (audioVideoSendButton == null) {
|
||||
return;
|
||||
}
|
||||
if (NekoConfig.useChatAttachMediaMenu.Bool()) visible = animated = false;
|
||||
|
||||
videoSendButton.setTag(visible ? 1 : null);
|
||||
|
||||
if (audioVideoButtonAnimation != null) {
|
||||
audioVideoButtonAnimation.cancel();
|
||||
audioVideoButtonAnimation = null;
|
||||
}
|
||||
// if (NekoConfig.useChatAttachMediaMenu.Bool()) visible = animated = false;
|
||||
audioVideoSendButton.setTag(visible ? 1 : null);
|
||||
|
||||
isInVideoMode = visible;
|
||||
|
||||
|
@ -6429,8 +6422,6 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
}
|
||||
recordCircle.voiceEnterTransitionInProgress = false;
|
||||
|
||||
boolean isVid = isInVideoMode() && !NekoConfig.useChatAttachMediaMenu.Bool();
|
||||
|
||||
if (recordingAudioVideo) {
|
||||
if (recordInterfaceState == 1) {
|
||||
return;
|
||||
|
|
|
@ -133,6 +133,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
|
||||
private boolean scrolling;
|
||||
|
||||
private View loadingMapView;
|
||||
private FrameLayout mapViewClip;
|
||||
private LocationActivityAdapter adapter;
|
||||
private RecyclerListView listView;
|
||||
|
@ -192,11 +193,16 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
private int clipSize;
|
||||
private int nonClipSize;
|
||||
|
||||
// Google Maps
|
||||
private final static int map_list_menu_map = 2;
|
||||
private final static int map_list_menu_satellite = 3;
|
||||
private final static int map_list_menu_hybrid = 4;
|
||||
|
||||
// OSM
|
||||
private final static int map_list_menu_osm = 2;
|
||||
private final static int map_list_menu_wiki = 3;
|
||||
private final static int map_list_menu_cartodark = 4;
|
||||
|
||||
private MyLocationNewOverlay myLocationOverlay;
|
||||
|
||||
public final static int LOCATION_TYPE_SEND = 0;
|
||||
public final static int LOCATION_TYPE_SEND_WITH_LIVE = 1;
|
||||
|
@ -253,7 +259,8 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
super(context);
|
||||
}
|
||||
|
||||
public void addInfoView(IMapsProvider.IMarker marker, VenueLocation location) {
|
||||
public void addInfoView(IMapsProvider.IMarker marker) {
|
||||
VenueLocation location = (VenueLocation) marker.getTag();
|
||||
if (lastPressedVenue == location) {
|
||||
return;
|
||||
}
|
||||
|
@ -370,7 +377,6 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void updatePositions() {
|
||||
if (map == null) {
|
||||
return;
|
||||
|
@ -379,7 +385,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
for (HashMap.Entry<IMapsProvider.IMarker, View> entry : views.entrySet()) {
|
||||
IMapsProvider.IMarker marker = entry.getKey();
|
||||
View view = entry.getValue();
|
||||
Point point = projection.toPixels(marker.getPosition(), null);
|
||||
Point point = projection.toScreenLocation(marker.getPosition());
|
||||
view.setTranslationX(point.x - view.getMeasuredWidth() / 2);
|
||||
view.setTranslationY(point.y - view.getMeasuredHeight() + AndroidUtilities.dp(22));
|
||||
}
|
||||
|
@ -529,6 +535,9 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
};
|
||||
mapViewClip.setWillNotDraw(false);
|
||||
|
||||
loadingMapView = new View(context);
|
||||
loadingMapView.setBackgroundDrawable(new MapPlaceholderDrawable());
|
||||
|
||||
searchAreaButton = new SearchButton(context);
|
||||
searchAreaButton.setTranslationX(-AndroidUtilities.dp(80));
|
||||
searchAreaButton.setVisibility(INVISIBLE);
|
||||
|
@ -572,9 +581,15 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
mapTypeButton.setSubMenuOpenSide(2);
|
||||
mapTypeButton.setAdditionalXOffset(AndroidUtilities.dp(10));
|
||||
mapTypeButton.setAdditionalYOffset(-AndroidUtilities.dp(10));
|
||||
mapTypeButton.addSubItem(map_list_menu_osm, R.drawable.msg_map, "Standard OSM", resourcesProvider);
|
||||
mapTypeButton.addSubItem(map_list_menu_wiki, R.drawable.msg_map, "Wikimedia", resourcesProvider);
|
||||
mapTypeButton.addSubItem(map_list_menu_cartodark, R.drawable.msg_map, "Carto Dark", resourcesProvider);
|
||||
if (false) {
|
||||
mapTypeButton.addSubItem(map_list_menu_map, R.drawable.msg_map, LocaleController.getString("Map", R.string.Map), resourcesProvider);
|
||||
mapTypeButton.addSubItem(map_list_menu_satellite, R.drawable.msg_satellite, LocaleController.getString("Satellite", R.string.Satellite), resourcesProvider);
|
||||
mapTypeButton.addSubItem(map_list_menu_hybrid, R.drawable.msg_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), resourcesProvider);
|
||||
} else {
|
||||
mapTypeButton.addSubItem(map_list_menu_osm, R.drawable.msg_map, "Standard OSM", resourcesProvider);
|
||||
mapTypeButton.addSubItem(map_list_menu_wiki, R.drawable.msg_map, "Wikimedia", resourcesProvider);
|
||||
mapTypeButton.addSubItem(map_list_menu_cartodark, R.drawable.msg_map, "Carto Dark", resourcesProvider);
|
||||
}
|
||||
mapTypeButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
|
||||
drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), getThemedColor(Theme.key_location_actionBackground), getThemedColor(Theme.key_location_actionPressedBackground));
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
|
@ -693,7 +708,6 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
userLocationMoved = false;
|
||||
showSearchPlacesButton(false);
|
||||
map.animateCamera(ApplicationLoader.getMapsProvider().newCameraUpdateLatLng(new IMapsProvider.LatLng(myLocation.getLatitude(), myLocation.getLongitude())));
|
||||
// final IMapController controller = mapView.getController();
|
||||
if (searchedForCustomLocations) {
|
||||
if (myLocation != null) {
|
||||
adapter.searchPlacesWithQuery(null, myLocation, true, true);
|
||||
|
@ -1004,10 +1018,6 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
if(mapView.getOverlays().contains(myLocationOverlay)) {
|
||||
mapView.getOverlays().remove(myLocationOverlay);
|
||||
}
|
||||
myLocationOverlay.disableMyLocation();
|
||||
}
|
||||
onResumeCalled = false;
|
||||
}
|
||||
|
@ -1029,10 +1039,14 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
try {
|
||||
if (mapView != null) {
|
||||
mapView.onPause();
|
||||
if(mapView.getOverlays().contains(myLocationOverlay)) {
|
||||
mapView.getOverlays().remove(myLocationOverlay);
|
||||
}
|
||||
myLocationOverlay.disableMyLocation();
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
try {
|
||||
if (mapView != null) {
|
||||
mapView.onDestroy();
|
||||
mapView = null;
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
|
||||
|
@ -1247,7 +1261,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
return;
|
||||
}
|
||||
for (int a = 0, N = placeMarkers.size(); a < N; a++) {
|
||||
placeMarkers.get(a).marker.remove(mapView);
|
||||
placeMarkers.get(a).marker.remove();
|
||||
}
|
||||
placeMarkers.clear();
|
||||
for (int a = 0, N = places.size(); a < N; a++) {
|
||||
|
@ -1262,20 +1276,8 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
venueLocation.num = a;
|
||||
venueLocation.marker = map.addMarker(options);
|
||||
venueLocation.venue = venue;
|
||||
venueLocation.marker.setTag(venueLocation);
|
||||
placeMarkers.add(venueLocation);
|
||||
marker.setOnMarkerClickListener(new Marker.OnMarkerClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClick(Marker marker, MapView mapView) {
|
||||
markerImageView.setVisibility(View.INVISIBLE);
|
||||
if (!userLocationMoved) {
|
||||
locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.SRC_IN));
|
||||
locationButton.setTag(Theme.key_location_actionIcon);
|
||||
userLocationMoved = true;
|
||||
}
|
||||
overlayView.addInfoView(marker, venueLocation);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -1303,15 +1305,6 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
return;
|
||||
}
|
||||
|
||||
//Paris, Tour Eiffel
|
||||
GeoPoint initLocation = new GeoPoint(48.85825, 2.29448);
|
||||
final IMapController controller = mapView.getController();
|
||||
mapView.setMaxZoomLevel(20.0);
|
||||
mapView.setMultiTouchControls(true);
|
||||
mapView.setBuiltInZoomControls(false);
|
||||
controller.setCenter(initLocation);
|
||||
controller.setZoom(7.);
|
||||
|
||||
userLocation = new Location("network");
|
||||
userLocation.setLatitude(48.85825);
|
||||
userLocation.setLongitude(2.29448);
|
||||
|
@ -1344,17 +1337,14 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
map.setOnMyLocationChangeListener(location -> {
|
||||
if (parentAlert == null || parentAlert.baseFragment == null) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
myLocationOverlay.runOnFirstFix(() -> AndroidUtilities.runOnUIThread(() -> {
|
||||
positionMarker(myLocationOverlay.getLastFix());
|
||||
getLocationController().setMapLocation(myLocationOverlay.getLastFix(), isFirstLocation);
|
||||
positionMarker(location);
|
||||
getLocationController().setMapLocation(location, isFirstLocation);
|
||||
isFirstLocation = false;
|
||||
});
|
||||
map.setOnMarkerClickListener(marker -> {
|
||||
|
@ -1374,14 +1364,14 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
if (overlayView != null) {
|
||||
overlayView.updatePositions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onZoom(ZoomEvent event) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (loadingMapView.getTag() == null) {
|
||||
loadingMapView.animate().alpha(0.0f).setDuration(180).start();
|
||||
}
|
||||
}, 200);
|
||||
positionMarker(myLocation = getLastLocation());
|
||||
attributionOverlay.bringToFront();
|
||||
|
||||
if (checkGpsEnabled && getParentActivity() != null) {
|
||||
checkGpsEnabled = false;
|
||||
if (!getParentActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) {
|
||||
|
@ -1498,7 +1488,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
mapTypeButton.setTranslationY(translationY);
|
||||
searchAreaButton.setTranslation(translationY);
|
||||
locationButton.setTranslationY(-clipSize);
|
||||
markerImageView.setTranslationY(markerTop = (mapHeight) / 2 - AndroidUtilities.dp(48) + trY);
|
||||
markerImageView.setTranslationY(markerTop = (mapHeight - clipSize) / 2 - AndroidUtilities.dp(48) + trY);
|
||||
if (prevClipSize != clipSize) {
|
||||
IMapsProvider.LatLng location;
|
||||
if (lastPressedMarker != null) {
|
||||
|
@ -1664,8 +1654,6 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
mapView.getOverlays().add(myLocationOverlay);
|
||||
myLocationOverlay.enableMyLocation();
|
||||
}
|
||||
onResumeCalled = true;
|
||||
}
|
||||
|
@ -1676,6 +1664,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
if (mapView.getView().getParent() == null) {
|
||||
mapViewClip.addView(mapView.getView(), 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, overScrollHeight + AndroidUtilities.dp(10), Gravity.TOP | Gravity.LEFT));
|
||||
mapViewClip.addView(overlayView, 1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, overScrollHeight + AndroidUtilities.dp(10), Gravity.TOP | Gravity.LEFT));
|
||||
mapViewClip.addView(loadingMapView, 2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
}
|
||||
searchItem.setVisibility(VISIBLE);
|
||||
|
||||
|
|
|
@ -1,558 +0,0 @@
|
|||
package org.telegram.ui.Components.Premium;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextPaint;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.ProductDetails;
|
||||
import com.android.billingclient.api.QueryProductDetailsParams;
|
||||
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BillingController;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBarLayout;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.BottomSheetWithRecyclerListView;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.PremiumPreviewFragment;
|
||||
import org.telegram.ui.ProfileActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class GiftPremiumBottomSheet extends BottomSheetWithRecyclerListView {
|
||||
private PremiumGradient.GradientTools gradientTools;
|
||||
private PremiumGradient.GradientTools outlineGradient;
|
||||
private PremiumButtonView premiumButtonView;
|
||||
private PremiumGiftTierCell dummyCell;
|
||||
|
||||
private List<GiftTier> giftTiers = new ArrayList<>();
|
||||
private int selectedTierIndex = 0;
|
||||
|
||||
private int totalGradientHeight;
|
||||
|
||||
private int rowsCount;
|
||||
private int headerRow;
|
||||
private int tiersStartRow;
|
||||
private int tiersEndRow;
|
||||
private int footerRow;
|
||||
private int buttonRow;
|
||||
|
||||
private TLRPC.User user;
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public GiftPremiumBottomSheet(BaseFragment fragment, TLRPC.User user) {
|
||||
super(fragment, false, true);
|
||||
this.user = user;
|
||||
|
||||
gradientTools = new PremiumGradient.GradientTools(Theme.key_premiumGradient1, Theme.key_premiumGradient2, null, null);
|
||||
gradientTools.exactly = true;
|
||||
gradientTools.x1 = 0;
|
||||
gradientTools.y1 = 0f;
|
||||
gradientTools.x2 = 0;
|
||||
gradientTools.y2 = 1f;
|
||||
gradientTools.cx = 0;
|
||||
gradientTools.cy = 0;
|
||||
|
||||
outlineGradient = new PremiumGradient.GradientTools(Theme.key_premiumGradient1, Theme.key_premiumGradient2, Theme.key_premiumGradient3, Theme.key_premiumGradient4);
|
||||
outlineGradient.paint.setStyle(Paint.Style.STROKE);
|
||||
outlineGradient.paint.setStrokeWidth(AndroidUtilities.dp(1.5f));
|
||||
|
||||
dummyCell = new PremiumGiftTierCell(getContext());
|
||||
|
||||
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(user.id);
|
||||
if (userFull != null) {
|
||||
List<QueryProductDetailsParams.Product> products = new ArrayList<>();
|
||||
long pricePerMonthMax = 0;
|
||||
for (TLRPC.TL_premiumGiftOption option : userFull.premium_gifts) {
|
||||
GiftTier giftTier = new GiftTier(option);
|
||||
giftTiers.add(giftTier);
|
||||
if (BuildVars.useInvoiceBilling()) {
|
||||
if (giftTier.getPricePerMonth() > pricePerMonthMax) {
|
||||
pricePerMonthMax = giftTier.getPricePerMonth();
|
||||
}
|
||||
} else if (giftTier.giftOption.store_product != null && BillingController.getInstance().isReady()) {
|
||||
products.add(QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.setProductId(giftTier.giftOption.store_product)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
if (BuildVars.useInvoiceBilling()) {
|
||||
for (GiftTier tier : giftTiers) {
|
||||
tier.setPricePerMonthRegular(pricePerMonthMax);
|
||||
}
|
||||
} else if (!products.isEmpty()) {
|
||||
long startMs = System.currentTimeMillis();
|
||||
BillingController.getInstance().queryProductDetails(products, (billingResult, list) -> {
|
||||
long pricePerMonthMaxStore = 0;
|
||||
|
||||
for (ProductDetails details : list) {
|
||||
for (GiftTier giftTier : giftTiers) {
|
||||
if (giftTier.giftOption.store_product != null && giftTier.giftOption.store_product.equals(details.getProductId())) {
|
||||
giftTier.setGooglePlayProductDetails(details);
|
||||
|
||||
if (giftTier.getPricePerMonth() > pricePerMonthMaxStore) {
|
||||
pricePerMonthMaxStore = giftTier.getPricePerMonth();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (GiftTier giftTier : giftTiers) {
|
||||
giftTier.setPricePerMonthRegular(pricePerMonthMaxStore);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(()-> {
|
||||
recyclerListView.getAdapter().notifyDataSetChanged();
|
||||
updateButtonText(System.currentTimeMillis() - startMs > 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!giftTiers.isEmpty()) {
|
||||
selectedTierIndex = 0;
|
||||
updateButtonText(false);
|
||||
}
|
||||
|
||||
headerRow = rowsCount++;
|
||||
tiersStartRow = rowsCount;
|
||||
rowsCount += giftTiers.size();
|
||||
tiersEndRow = rowsCount;
|
||||
footerRow = rowsCount++;
|
||||
buttonRow = rowsCount++;
|
||||
|
||||
recyclerListView.setOnItemClickListener((view, position) -> {
|
||||
if (view instanceof PremiumGiftTierCell) {
|
||||
PremiumGiftTierCell giftTierCell = (PremiumGiftTierCell) view;
|
||||
selectedTierIndex = giftTiers.indexOf(giftTierCell.tier);
|
||||
updateButtonText(true);
|
||||
giftTierCell.setChecked(true, true);
|
||||
|
||||
for (int i = 0; i < recyclerListView.getChildCount(); i++) {
|
||||
View ch = recyclerListView.getChildAt(i);
|
||||
if (ch instanceof PremiumGiftTierCell) {
|
||||
PremiumGiftTierCell otherCell = (PremiumGiftTierCell) ch;
|
||||
if (otherCell.tier != giftTierCell.tier) {
|
||||
otherCell.setChecked(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < recyclerListView.getHiddenChildCount(); i++) {
|
||||
View ch = recyclerListView.getHiddenChildAt(i);
|
||||
if (ch instanceof PremiumGiftTierCell) {
|
||||
PremiumGiftTierCell otherCell = (PremiumGiftTierCell) ch;
|
||||
if (otherCell.tier != giftTierCell.tier) {
|
||||
otherCell.setChecked(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < recyclerListView.getCachedChildCount(); i++) {
|
||||
View ch = recyclerListView.getCachedChildAt(i);
|
||||
if (ch instanceof PremiumGiftTierCell) {
|
||||
PremiumGiftTierCell otherCell = (PremiumGiftTierCell) ch;
|
||||
if (otherCell.tier != giftTierCell.tier) {
|
||||
otherCell.setChecked(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < recyclerListView.getAttachedScrapChildCount(); i++) {
|
||||
View ch = recyclerListView.getAttachedScrapChildAt(i);
|
||||
if (ch instanceof PremiumGiftTierCell) {
|
||||
PremiumGiftTierCell otherCell = (PremiumGiftTierCell) ch;
|
||||
if (otherCell.tier != giftTierCell.tier) {
|
||||
otherCell.setChecked(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
recyclerListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
Path path = new Path();
|
||||
recyclerListView.setSelectorTransformer(canvas -> {
|
||||
path.rewind();
|
||||
Rect selectorRect = recyclerListView.getSelectorRect();
|
||||
AndroidUtilities.rectTmp.set(selectorRect.left + AndroidUtilities.dp(20), selectorRect.top + AndroidUtilities.dp(3), selectorRect.right - AndroidUtilities.dp(20), selectorRect.bottom - AndroidUtilities.dp(3));
|
||||
path.addRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(12), AndroidUtilities.dp(12), Path.Direction.CW);
|
||||
canvas.clipPath(path);
|
||||
});
|
||||
}
|
||||
|
||||
private void updateButtonText(boolean animated) {
|
||||
if (!BuildVars.useInvoiceBilling() && (!BillingController.getInstance().isReady() || giftTiers.get(selectedTierIndex).googlePlayProductDetails == null)) {
|
||||
premiumButtonView.setButton(LocaleController.getString(R.string.Loading), v -> {}, true);
|
||||
premiumButtonView.setFlickerDisabled(true);
|
||||
return;
|
||||
}
|
||||
premiumButtonView.setButton(LocaleController.formatString(R.string.GiftSubscriptionFor, giftTiers.get(selectedTierIndex).getFormattedPrice()), v -> onGiftPremium(), animated);
|
||||
premiumButtonView.setFlickerDisabled(false);
|
||||
}
|
||||
|
||||
private void onGiftSuccess(boolean fromGooglePlay) {
|
||||
TLRPC.UserFull full = MessagesController.getInstance(currentAccount).getUserFull(user.id);
|
||||
if (full != null) {
|
||||
user.premium = true;
|
||||
MessagesController.getInstance(currentAccount).putUser(user, true);
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, user.id, full);
|
||||
}
|
||||
|
||||
if (getBaseFragment() != null) {
|
||||
List<BaseFragment> fragments = new ArrayList<>(((LaunchActivity) getBaseFragment().getParentActivity()).getActionBarLayout().fragmentsStack);
|
||||
|
||||
ActionBarLayout layout = getBaseFragment().getParentLayout();
|
||||
ChatActivity lastChatActivity = null;
|
||||
for (BaseFragment fragment : fragments) {
|
||||
if (fragment instanceof ChatActivity) {
|
||||
lastChatActivity = (ChatActivity) fragment;
|
||||
if (lastChatActivity.getDialogId() != user.id) {
|
||||
fragment.removeSelfFromStack();
|
||||
}
|
||||
} else if (fragment instanceof ProfileActivity) {
|
||||
if (fromGooglePlay && layout.getLastFragment() == fragment) {
|
||||
fragment.finishFragment();
|
||||
} else {
|
||||
fragment.removeSelfFromStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastChatActivity == null || lastChatActivity.getDialogId() != user.id) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("user_id", user.id);
|
||||
layout.presentFragment(new ChatActivity(args), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onGiftPremium() {
|
||||
GiftTier tier = giftTiers.get(selectedTierIndex);
|
||||
if (BuildVars.useInvoiceBilling()) {
|
||||
if (getBaseFragment().getParentActivity() instanceof LaunchActivity) {
|
||||
Uri uri = Uri.parse(tier.giftOption.bot_url);
|
||||
if (uri.getHost().equals("t.me")) {
|
||||
if (!uri.getPath().startsWith("/$") && !uri.getPath().startsWith("/invoice/")) {
|
||||
((LaunchActivity) getBaseFragment().getParentActivity()).setNavigateToPremiumBot(true);
|
||||
} else {
|
||||
((LaunchActivity) getBaseFragment().getParentActivity()).setNavigateToPremiumGiftCallback(()-> onGiftSuccess(false));
|
||||
}
|
||||
}
|
||||
Browser.openUrl(getBaseFragment().getParentActivity(), tier.giftOption.bot_url);
|
||||
}
|
||||
} else {
|
||||
if (BillingController.getInstance().isReady() && tier.googlePlayProductDetails != null) {
|
||||
TLRPC.TL_inputStorePaymentGiftPremium giftPremium = new TLRPC.TL_inputStorePaymentGiftPremium();
|
||||
giftPremium.user_id = MessagesController.getInstance(currentAccount).getInputUser(user);
|
||||
ProductDetails.OneTimePurchaseOfferDetails offerDetails = tier.googlePlayProductDetails.getOneTimePurchaseOfferDetails();
|
||||
giftPremium.currency = offerDetails.getPriceCurrencyCode();
|
||||
giftPremium.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(giftPremium.currency)));
|
||||
|
||||
BillingController.getInstance().addResultListener(tier.giftOption.store_product, billingResult -> {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
AndroidUtilities.runOnUIThread(()-> onGiftSuccess(true));
|
||||
}
|
||||
});
|
||||
|
||||
TLRPC.TL_payments_canPurchasePremium req = new TLRPC.TL_payments_canPurchasePremium();
|
||||
req.purpose = giftPremium;
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(()->{
|
||||
if (response instanceof TLRPC.TL_boolTrue) {
|
||||
BillingController.getInstance().launchBillingFlow(getBaseFragment().getParentActivity(), AccountInstance.getInstance(currentAccount), giftPremium, Collections.singletonList(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(tier.googlePlayProductDetails)
|
||||
.build()));
|
||||
} else if (error != null) {
|
||||
AlertsCreator.processError(currentAccount, error, getBaseFragment(), req);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(FrameLayout containerView) {
|
||||
super.onViewCreated(containerView);
|
||||
|
||||
premiumButtonView = new PremiumButtonView(getContext(), true);
|
||||
|
||||
FrameLayout buttonContainer = new FrameLayout(getContext());
|
||||
buttonContainer.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.CENTER_VERTICAL, 16, 0, 16, 0));
|
||||
buttonContainer.setBackgroundColor(getThemedColor(Theme.key_dialogBackground));
|
||||
containerView.addView(buttonContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 68, Gravity.BOTTOM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onPreMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
measureGradient(View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(heightMeasureSpec));
|
||||
}
|
||||
|
||||
private void measureGradient(int w, int h) {
|
||||
int yOffset = 0;
|
||||
for (int i = 0; i < giftTiers.size(); i++) {
|
||||
dummyCell.bind(giftTiers.get(i));
|
||||
dummyCell.measure(View.MeasureSpec.makeMeasureSpec(w, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(h, View.MeasureSpec.AT_MOST));
|
||||
giftTiers.get(i).yOffset = yOffset;
|
||||
yOffset += dummyCell.getMeasuredHeight();
|
||||
}
|
||||
|
||||
totalGradientHeight = yOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getTitle() {
|
||||
return LocaleController.getString(R.string.GiftTelegramPremiumTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecyclerListView.SelectionAdapter createAdapter() {
|
||||
return new RecyclerListView.SelectionAdapter() {
|
||||
private final static int VIEW_TYPE_HEADER = 0,
|
||||
VIEW_TYPE_TIER = 1,
|
||||
VIEW_TYPE_FOOTER = 2,
|
||||
VIEW_TYPE_BUTTON = 3;
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
return holder.getItemViewType() == VIEW_TYPE_TIER;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType) {
|
||||
default:
|
||||
case VIEW_TYPE_HEADER:
|
||||
view = new PremiumGiftHeaderCell(getContext());
|
||||
break;
|
||||
case VIEW_TYPE_TIER:
|
||||
AtomicReference<Float> progressRef = new AtomicReference<>(0f);
|
||||
PremiumGiftTierCell premiumGiftTierCell = new PremiumGiftTierCell(getContext()) {
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (discountView.getVisibility() == VISIBLE) {
|
||||
AndroidUtilities.rectTmp.set(discountView.getLeft(), discountView.getTop(), discountView.getRight(), discountView.getBottom());
|
||||
gradientTools.gradientMatrix(0, 0, getMeasuredWidth(), totalGradientHeight, 0, -tier.yOffset);
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(6), AndroidUtilities.dp(6), gradientTools.paint);
|
||||
}
|
||||
|
||||
float progress = progressRef.get();
|
||||
int alpha = outlineGradient.paint.getAlpha();
|
||||
outlineGradient.paint.setAlpha((int) (progress * alpha));
|
||||
AndroidUtilities.rectTmp.set(AndroidUtilities.dp(20), AndroidUtilities.dp(3), getWidth() - AndroidUtilities.dp(20), getHeight() - AndroidUtilities.dp(3));
|
||||
outlineGradient.gradientMatrix(0, 0, getMeasuredWidth(), getMeasuredHeight(), 0, 0);
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(12), AndroidUtilities.dp(12), outlineGradient.paint);
|
||||
outlineGradient.paint.setAlpha(alpha);
|
||||
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
};
|
||||
premiumGiftTierCell.setCirclePaintProvider(obj -> {
|
||||
gradientTools.gradientMatrix(0, 0, premiumGiftTierCell.getMeasuredWidth(), totalGradientHeight, 0, -premiumGiftTierCell.tier.yOffset);
|
||||
return gradientTools.paint;
|
||||
});
|
||||
premiumGiftTierCell.setProgressDelegate(progress -> {
|
||||
progressRef.set(progress);
|
||||
premiumGiftTierCell.invalidate();
|
||||
});
|
||||
view = premiumGiftTierCell;
|
||||
break;
|
||||
case VIEW_TYPE_FOOTER:
|
||||
TextInfoPrivacyCell privacyCell = new TextInfoPrivacyCell(getContext());
|
||||
privacyCell.setTopPadding(28);
|
||||
privacyCell.getTextView().setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
String str = LocaleController.getString(R.string.GiftPremiumListFeaturesAndTerms);
|
||||
int startIndex = str.indexOf('*'), lastIndex = str.lastIndexOf('*');
|
||||
if (startIndex != -1 && lastIndex != -1) {
|
||||
str = str.substring(0, startIndex) + str.substring(startIndex + 1, lastIndex) + str.substring(lastIndex + 1);
|
||||
SpannableString span = new SpannableString(str);
|
||||
span.setSpan(new LinkSpan(), startIndex, lastIndex - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
privacyCell.setText(span);
|
||||
} else {
|
||||
privacyCell.setText(str);
|
||||
}
|
||||
privacyCell.setPadding(AndroidUtilities.dp(21), 0, AndroidUtilities.dp(21), 0);
|
||||
view = privacyCell;
|
||||
break;
|
||||
case VIEW_TYPE_BUTTON:
|
||||
view = new View(getContext()) {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(68), MeasureSpec.EXACTLY));
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
return new RecyclerListView.Holder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (position == headerRow) {
|
||||
((PremiumGiftHeaderCell) holder.itemView).bind(user);
|
||||
} else if (position >= tiersStartRow && position < tiersEndRow) {
|
||||
PremiumGiftTierCell giftTierCell = (PremiumGiftTierCell) holder.itemView;
|
||||
giftTierCell.bind(giftTiers.get(position - tiersStartRow));
|
||||
giftTierCell.setChecked(position - tiersStartRow == selectedTierIndex, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == headerRow) {
|
||||
return VIEW_TYPE_HEADER;
|
||||
} else if (position >= tiersStartRow && position < tiersEndRow) {
|
||||
return VIEW_TYPE_TIER;
|
||||
} else if (position == footerRow) {
|
||||
return VIEW_TYPE_FOOTER;
|
||||
} else if (position == buttonRow) {
|
||||
return VIEW_TYPE_BUTTON;
|
||||
}
|
||||
return VIEW_TYPE_HEADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return rowsCount;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private final class LinkSpan extends ClickableSpan {
|
||||
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
getBaseFragment().presentFragment(new PremiumPreviewFragment("profile"));
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint p) {
|
||||
super.updateDrawState(p);
|
||||
p.setUnderlineText(false);
|
||||
}
|
||||
}
|
||||
|
||||
public final static class GiftTier {
|
||||
public final TLRPC.TL_premiumGiftOption giftOption;
|
||||
private int discount;
|
||||
private long pricePerMonth;
|
||||
|
||||
private long pricePerMonthRegular;
|
||||
private ProductDetails googlePlayProductDetails;
|
||||
|
||||
public int yOffset;
|
||||
|
||||
public GiftTier(TLRPC.TL_premiumGiftOption giftOption) {
|
||||
this.giftOption = giftOption;
|
||||
}
|
||||
|
||||
public ProductDetails getGooglePlayProductDetails() {
|
||||
return googlePlayProductDetails;
|
||||
}
|
||||
|
||||
public void setGooglePlayProductDetails(ProductDetails googlePlayProductDetails) {
|
||||
this.googlePlayProductDetails = googlePlayProductDetails;
|
||||
}
|
||||
|
||||
public void setPricePerMonthRegular(long pricePerMonthRegular) {
|
||||
this.pricePerMonthRegular = pricePerMonthRegular;
|
||||
}
|
||||
|
||||
public int getMonths() {
|
||||
return giftOption.months;
|
||||
}
|
||||
|
||||
public int getDiscount() {
|
||||
if (discount == 0) {
|
||||
if (getPricePerMonth() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pricePerMonthRegular != 0) {
|
||||
discount = (int) ((1.0 - getPricePerMonth() / (double) pricePerMonthRegular) * 100);
|
||||
|
||||
if (discount == 0) {
|
||||
discount = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return discount;
|
||||
}
|
||||
|
||||
public long getPricePerMonth() {
|
||||
if (pricePerMonth == 0) {
|
||||
long price = getPrice();
|
||||
if (price != 0) {
|
||||
pricePerMonth = price / giftOption.months;
|
||||
}
|
||||
}
|
||||
return pricePerMonth;
|
||||
}
|
||||
|
||||
public String getFormattedPricePerMonth() {
|
||||
if (BuildVars.useInvoiceBilling() || giftOption.store_product == null) {
|
||||
return BillingController.getInstance().formatCurrency(getPricePerMonth(), getCurrency());
|
||||
}
|
||||
|
||||
return googlePlayProductDetails == null ? "" : BillingController.getInstance().formatCurrency(getPricePerMonth(), getCurrency(), 6);
|
||||
}
|
||||
|
||||
public String getFormattedPrice() {
|
||||
if (BuildVars.useInvoiceBilling() || giftOption.store_product == null) {
|
||||
return BillingController.getInstance().formatCurrency(getPrice(), getCurrency());
|
||||
}
|
||||
|
||||
return googlePlayProductDetails == null ? "" : BillingController.getInstance().formatCurrency(getPrice(), getCurrency(), 6);
|
||||
}
|
||||
|
||||
public long getPrice() {
|
||||
if (BuildVars.useInvoiceBilling() || giftOption.store_product == null) {
|
||||
return giftOption.amount;
|
||||
}
|
||||
return googlePlayProductDetails == null ? 0 : googlePlayProductDetails.getOneTimePurchaseOfferDetails().getPriceAmountMicros();
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
if (BuildVars.useInvoiceBilling() || giftOption.store_product == null) {
|
||||
return giftOption.currency;
|
||||
}
|
||||
return googlePlayProductDetails == null ? "" : googlePlayProductDetails.getOneTimePurchaseOfferDetails().getPriceCurrencyCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
package org.telegram.ui.Components.Premium;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.os.SystemClock;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BillingController;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.GenericProvider;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.CheckBox2;
|
||||
import org.telegram.ui.Components.CheckBoxBase;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
public class PremiumGiftTierCell extends ViewGroup {
|
||||
private CheckBox2 checkBox;
|
||||
private TextView titleView;
|
||||
private TextView priceTotalView;
|
||||
private TextView pricePerMonthView;
|
||||
|
||||
private int leftPaddingToTextDp = 24;
|
||||
|
||||
protected GiftPremiumBottomSheet.GiftTier tier;
|
||||
protected TextView discountView;
|
||||
|
||||
private String colorKey1 = Theme.key_windowBackgroundWhite;
|
||||
private String colorKey2 = Theme.key_windowBackgroundGray;
|
||||
private int gradientWidth;
|
||||
private LinearGradient gradient;
|
||||
private Paint paint = new Paint();
|
||||
private PremiumGiftTierCell globalGradientView;
|
||||
private int color0;
|
||||
private int color1;
|
||||
private Matrix matrix = new Matrix();
|
||||
private long lastUpdateTime;
|
||||
private int totalTranslation;
|
||||
private float parentXOffset;
|
||||
private int parentWidth, parentHeight;
|
||||
|
||||
private boolean isDrawingGradient;
|
||||
|
||||
public PremiumGiftTierCell(@NonNull Context context) {
|
||||
super(context);
|
||||
|
||||
checkBox = new CheckBox2(context, 24);
|
||||
checkBox.setDrawBackgroundAsArc(10);
|
||||
checkBox.setColor(Theme.key_radioBackground, Theme.key_radioBackground, Theme.key_checkboxCheck);
|
||||
addView(checkBox);
|
||||
|
||||
titleView = new TextView(context);
|
||||
titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
titleView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
addView(titleView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 0, 8, 0, 0));
|
||||
|
||||
discountView = new TextView(context);
|
||||
discountView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
discountView.setTextColor(Color.WHITE);
|
||||
discountView.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
|
||||
discountView.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
|
||||
addView(discountView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, 0, 0, 0, 8));
|
||||
|
||||
pricePerMonthView = new TextView(context);
|
||||
pricePerMonthView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
pricePerMonthView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
||||
addView(pricePerMonthView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, 0, 0, 0, 8));
|
||||
|
||||
priceTotalView = new TextView(context);
|
||||
priceTotalView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
priceTotalView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
||||
addView(priceTotalView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END));
|
||||
|
||||
setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12));
|
||||
setClipToPadding(false);
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
public void setParentXOffset(float parentXOffset) {
|
||||
this.parentXOffset = parentXOffset;
|
||||
}
|
||||
|
||||
public void setGlobalGradientView(PremiumGiftTierCell globalGradientView) {
|
||||
this.globalGradientView = globalGradientView;
|
||||
}
|
||||
|
||||
public void setProgressDelegate(CheckBoxBase.ProgressDelegate delegate) {
|
||||
checkBox.setProgressDelegate(delegate);
|
||||
}
|
||||
|
||||
public void setCirclePaintProvider(GenericProvider<Void, Paint> circlePaintProvider) {
|
||||
checkBox.setCirclePaintProvider(circlePaintProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
AndroidUtilities.rectTmp2.set(AndroidUtilities.dp(8) + getPaddingLeft(), (int)((getMeasuredHeight() - checkBox.getMeasuredHeight()) / 2f), 0, 0);
|
||||
checkRtlAndLayout(checkBox);
|
||||
|
||||
AndroidUtilities.rectTmp2.set(getMeasuredWidth() - priceTotalView.getMeasuredWidth() - AndroidUtilities.dp(16) - getPaddingRight(), (int) ((getMeasuredHeight() - priceTotalView.getMeasuredHeight()) / 2f), 0, 0);
|
||||
checkRtlAndLayout(priceTotalView);
|
||||
|
||||
AndroidUtilities.rectTmp2.set(AndroidUtilities.dp(8 + leftPaddingToTextDp) + checkBox.getMeasuredWidth() + getPaddingLeft(), getPaddingTop(), 0, 0);
|
||||
checkRtlAndLayout(titleView);
|
||||
|
||||
if (discountView.getVisibility() == VISIBLE) {
|
||||
AndroidUtilities.rectTmp2.set(AndroidUtilities.dp(8 + leftPaddingToTextDp) + checkBox.getMeasuredWidth() + getPaddingLeft(), getMeasuredHeight() - discountView.getMeasuredHeight() - getPaddingBottom(), 0, 0);
|
||||
checkRtlAndLayout(discountView);
|
||||
}
|
||||
|
||||
AndroidUtilities.rectTmp2.set(AndroidUtilities.dp(8 + leftPaddingToTextDp + (discountView.getVisibility() == VISIBLE ? 6 : 0)) + checkBox.getMeasuredWidth() + discountView.getMeasuredWidth() + getPaddingLeft(), getMeasuredHeight() - pricePerMonthView.getMeasuredHeight() - getPaddingBottom(), 0, 0);
|
||||
checkRtlAndLayout(pricePerMonthView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (isDrawingGradient) {
|
||||
Paint paint = this.paint;
|
||||
if (globalGradientView != null) {
|
||||
paint = globalGradientView.paint;
|
||||
}
|
||||
|
||||
drawChild(canvas, checkBox, getDrawingTime());
|
||||
|
||||
updateColors();
|
||||
updateGradient();
|
||||
|
||||
AndroidUtilities.rectTmp.set(priceTotalView.getLeft(), priceTotalView.getTop() + AndroidUtilities.dp(4), priceTotalView.getRight(), priceTotalView.getBottom() - AndroidUtilities.dp(4));
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(8), AndroidUtilities.dp(8), paint);
|
||||
|
||||
AndroidUtilities.rectTmp.set(pricePerMonthView.getLeft(), AndroidUtilities.dp(42), pricePerMonthView.getRight(), AndroidUtilities.dp(54));
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(8), AndroidUtilities.dp(8), paint);
|
||||
|
||||
AndroidUtilities.rectTmp.set(titleView.getLeft(), titleView.getTop() + AndroidUtilities.dp(4), titleView.getRight(), titleView.getBottom() - AndroidUtilities.dp(4));
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(8), AndroidUtilities.dp(8), paint);
|
||||
|
||||
invalidate();
|
||||
} else {
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRtlAndLayout(View v) {
|
||||
Rect rect = AndroidUtilities.rectTmp2;
|
||||
rect.right = rect.left + v.getMeasuredWidth();
|
||||
rect.bottom = rect.top + v.getMeasuredHeight();
|
||||
if (LocaleController.isRTL) {
|
||||
int right = rect.right;
|
||||
rect.right = rect.left;
|
||||
rect.left = right;
|
||||
}
|
||||
v.layout(AndroidUtilities.rectTmp2.left, AndroidUtilities.rectTmp2.top, AndroidUtilities.rectTmp2.right, AndroidUtilities.rectTmp2.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec), height = AndroidUtilities.dp(68);
|
||||
int checkboxSpec = MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(28), MeasureSpec.EXACTLY);
|
||||
checkBox.measure(checkboxSpec, checkboxSpec);
|
||||
|
||||
priceTotalView.measure(MeasureSpec.makeMeasureSpec(width - checkBox.getMeasuredWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
titleView.measure(MeasureSpec.makeMeasureSpec(width - checkBox.getMeasuredWidth() - priceTotalView.getMeasuredWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
if (discountView.getVisibility() == VISIBLE) {
|
||||
discountView.measure(MeasureSpec.makeMeasureSpec(width - checkBox.getMeasuredWidth() - priceTotalView.getMeasuredWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
} else {
|
||||
discountView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY));
|
||||
}
|
||||
pricePerMonthView.measure(MeasureSpec.makeMeasureSpec(width - checkBox.getMeasuredWidth() - priceTotalView.getMeasuredWidth() - discountView.getMeasuredWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked, boolean animate) {
|
||||
checkBox.setChecked(checked, animate);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void bind(GiftPremiumBottomSheet.GiftTier tier) {
|
||||
this.tier = tier;
|
||||
|
||||
titleView.setText(LocaleController.formatPluralString("Months", tier.getMonths()));
|
||||
|
||||
isDrawingGradient = !BuildVars.useInvoiceBilling() && (!BillingController.getInstance().isReady() || tier.getGooglePlayProductDetails() == null);
|
||||
if (!isDrawingGradient) {
|
||||
if (tier.getDiscount() <= 0) {
|
||||
discountView.setVisibility(GONE);
|
||||
} else {
|
||||
discountView.setText(LocaleController.formatString(R.string.GiftPremiumOptionDiscount, tier.getDiscount()));
|
||||
discountView.setVisibility(VISIBLE);
|
||||
}
|
||||
pricePerMonthView.setText(LocaleController.formatString(R.string.PricePerMonth, tier.getFormattedPricePerMonth()));
|
||||
priceTotalView.setText(tier.getFormattedPrice());
|
||||
} else {
|
||||
discountView.setText(LocaleController.formatString(R.string.GiftPremiumOptionDiscount, 10));
|
||||
discountView.setVisibility(VISIBLE);
|
||||
pricePerMonthView.setText(LocaleController.formatString(R.string.PricePerMonth, 100));
|
||||
priceTotalView.setText("USD00,00");
|
||||
}
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void updateGradient() {
|
||||
if (globalGradientView != null) {
|
||||
globalGradientView.updateGradient();
|
||||
return;
|
||||
}
|
||||
long newUpdateTime = SystemClock.elapsedRealtime();
|
||||
long dt = Math.abs(lastUpdateTime - newUpdateTime);
|
||||
if (dt > 17) {
|
||||
dt = 16;
|
||||
}
|
||||
if (dt < 4) {
|
||||
dt = 0;
|
||||
}
|
||||
int width = parentWidth;
|
||||
if (width == 0) {
|
||||
width = getMeasuredWidth();
|
||||
}
|
||||
lastUpdateTime = newUpdateTime;
|
||||
totalTranslation += dt * width / 400.0f;
|
||||
if (totalTranslation >= width * 4) {
|
||||
totalTranslation = -gradientWidth * 2;
|
||||
}
|
||||
matrix.setTranslate(totalTranslation + parentXOffset, 0);
|
||||
if (gradient != null) {
|
||||
gradient.setLocalMatrix(matrix);
|
||||
}
|
||||
}
|
||||
|
||||
public void setParentSize(int parentWidth, int parentHeight, float parentXOffset) {
|
||||
this.parentWidth = parentWidth;
|
||||
this.parentHeight = parentHeight;
|
||||
this.parentXOffset = parentXOffset;
|
||||
}
|
||||
|
||||
public void updateColors() {
|
||||
if (globalGradientView != null) {
|
||||
globalGradientView.updateColors();
|
||||
return;
|
||||
}
|
||||
int color0 = Theme.getColor(colorKey1);
|
||||
int color1 = Theme.getColor(colorKey2);
|
||||
if (this.color1 != color1 || this.color0 != color0) {
|
||||
this.color0 = color0;
|
||||
this.color1 = color1;
|
||||
gradient = new LinearGradient(0, 0, gradientWidth = AndroidUtilities.dp(200), 0, new int[]{color1, color0, color0, color1}, new float[]{0.0f, 0.4f, 0.6f, 1f}, Shader.TileMode.CLAMP);
|
||||
paint.setShader(gradient);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView {
|
|||
ArrayList<PremiumPreviewFragment.PremiumFeatureData> premiumFeatures = new ArrayList<>();
|
||||
int currentAccount;
|
||||
TLRPC.User user;
|
||||
GiftPremiumBottomSheet.GiftTier giftTier;
|
||||
// GiftPremiumBottomSheet.GiftTier giftTier;
|
||||
boolean isOutboundGift;
|
||||
|
||||
PremiumFeatureCell dummyCell;
|
||||
|
@ -87,21 +87,21 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView {
|
|||
boolean animateConfetti;
|
||||
FrameLayout buttonContainer;
|
||||
|
||||
public PremiumPreviewBottomSheet(BaseFragment fragment, int currentAccount, TLRPC.User user) {
|
||||
this(fragment, currentAccount, user, null);
|
||||
}
|
||||
// public PremiumPreviewBottomSheet(BaseFragment fragment, int currentAccount, TLRPC.User user) {
|
||||
// this(fragment, currentAccount, user, null);
|
||||
// }
|
||||
|
||||
public PremiumPreviewBottomSheet(BaseFragment fragment, int currentAccount, TLRPC.User user, GiftPremiumBottomSheet.GiftTier gift) {
|
||||
public PremiumPreviewBottomSheet(BaseFragment fragment, int currentAccount, TLRPC.User user) {
|
||||
super(fragment, false, false);
|
||||
this.fragment = fragment;
|
||||
topPadding = 0.26f;
|
||||
this.user = user;
|
||||
this.currentAccount = currentAccount;
|
||||
this.giftTier = gift;
|
||||
// this.giftTier = gift;
|
||||
dummyCell = new PremiumFeatureCell(getContext());
|
||||
PremiumPreviewFragment.fillPremiumFeaturesList(premiumFeatures, currentAccount);
|
||||
|
||||
if (giftTier != null || UserConfig.getInstance(currentAccount).isPremium()) {
|
||||
if (UserConfig.getInstance(currentAccount).isPremium()) {
|
||||
buttonContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -119,9 +119,9 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView {
|
|||
rowCount += premiumFeatures.size();
|
||||
featuresEndRow = rowCount;
|
||||
sectionRow = rowCount++;
|
||||
if (!UserConfig.getInstance(currentAccount).isPremium() && gift == null) {
|
||||
buttonRow = rowCount++;
|
||||
}
|
||||
// if (!UserConfig.getInstance(currentAccount).isPremium() && gift == null) {
|
||||
// buttonRow = rowCount++;
|
||||
// }
|
||||
recyclerListView.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), 0);
|
||||
recyclerListView.setOnItemClickListener((view, position) -> {
|
||||
if (view instanceof PremiumFeatureCell) {
|
||||
|
@ -266,18 +266,18 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView {
|
|||
subtitleView.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
|
||||
linearLayout.addView(subtitleView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 16, 9, 16, 20));
|
||||
|
||||
if (giftTier != null) {
|
||||
if (isOutboundGift) {
|
||||
titleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserGiftedPremiumOutboundDialogTitle, user != null ? user.first_name : "", giftTier.getMonths()), null));
|
||||
subtitleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserGiftedPremiumOutboundDialogSubtitle, user != null ? user.first_name : ""), null));
|
||||
} else {
|
||||
titleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserGiftedPremiumDialogTitle, user != null ? user.first_name : "", giftTier.getMonths()), null));
|
||||
subtitleView.setText(AndroidUtilities.replaceTags(LocaleController.getString(R.string.TelegramPremiumUserGiftedPremiumDialogSubtitle)));
|
||||
}
|
||||
} else {
|
||||
// if (giftTier != null) {
|
||||
// if (isOutboundGift) {
|
||||
// titleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserGiftedPremiumOutboundDialogTitle, user != null ? user.first_name : "", giftTier.getMonths()), null));
|
||||
// subtitleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserGiftedPremiumOutboundDialogSubtitle, user != null ? user.first_name : ""), null));
|
||||
// } else {
|
||||
// titleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserGiftedPremiumDialogTitle, user != null ? user.first_name : "", giftTier.getMonths()), null));
|
||||
// subtitleView.setText(AndroidUtilities.replaceTags(LocaleController.getString(R.string.TelegramPremiumUserGiftedPremiumDialogSubtitle)));
|
||||
// }
|
||||
// } else {
|
||||
titleView.setText(AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TelegramPremiumUserDialogTitle, ContactsController.formatName(user.first_name, user.last_name)), null));
|
||||
subtitleView.setText(AndroidUtilities.replaceTags(LocaleController.getString(R.string.TelegramPremiumUserDialogSubtitle)));
|
||||
}
|
||||
// }
|
||||
|
||||
starParticlesView = new StarParticlesView(context);
|
||||
FrameLayout frameLayout = new FrameLayout(context) {
|
||||
|
|
|
@ -1067,7 +1067,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
for (int i = 0, size = gridView.getChildCount(); i < size; i++) {
|
||||
final View child = gridView.getChildAt(i);
|
||||
if (child instanceof StickerEmojiCell) {
|
||||
Bitmap bitmap = ((StickerEmojiCell) child).getImageView().getImageReceiver().getBitmap();
|
||||
Bitmap bitmap = ((StickerEmojiCell) child).getImageView().getBitmap();
|
||||
if (bitmap == null) continue;
|
||||
ProxyUtil.showQrDialog(getContext(), stickersUrl, imageSize -> Bitmap.createScaledBitmap(bitmap,imageSize,imageSize, true));
|
||||
return;
|
||||
|
|
|
@ -614,7 +614,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||
if (commentTextView != null) {
|
||||
commentTextView.onDestroy();
|
||||
}
|
||||
commentTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, null, EditTextEmoji.STYLE_DIALOG);
|
||||
commentTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, null, EditTextEmoji.STYLE_DIALOG, false);
|
||||
InputFilter[] inputFilters = new InputFilter[1];
|
||||
inputFilters[0] = new InputFilter.LengthFilter(MessagesController.getInstance(UserConfig.selectedAccount).maxCaptionLength);
|
||||
commentTextView.setFilters(inputFilters);
|
||||
|
|
|
@ -181,7 +181,6 @@ import kotlin.Unit;
|
|||
import kotlin.text.StringsKt;
|
||||
import tw.nekomimi.nekogram.InternalUpdater;
|
||||
import tw.nekomimi.nekogram.ui.BottomBuilder;
|
||||
import tw.nekomimi.nekogram.ExternalGcm;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
import tw.nekomimi.nekogram.settings.NekoSettingsActivity;
|
||||
|
@ -2310,7 +2309,7 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar
|
|||
req.hash = phoneHash;
|
||||
req.settings = new TLRPC.TL_codeSettings();
|
||||
req.settings.allow_flashcall = false;
|
||||
req.settings.allow_app_hash = PushListenerController.GooglePushListenerServiceProvider.INSTANCE.hasServices();
|
||||
req.settings.allow_app_hash = PushListenerController.getProvider().hasServices();
|
||||
|
||||
Bundle params = new Bundle();
|
||||
params.putString("phone", phone);
|
||||
|
|
|
@ -220,12 +220,17 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
private final static int open_in = 1;
|
||||
private final static int share_live_location = 5;
|
||||
|
||||
// Official: Google Maps
|
||||
private final static int map_list_menu_map = 2;
|
||||
private final static int map_list_menu_satellite = 3;
|
||||
private final static int map_list_menu_hybrid = 4;
|
||||
|
||||
// OSM
|
||||
private final static int map_list_menu_osm = 2;
|
||||
private final static int map_list_menu_wiki = 3;
|
||||
private final static int map_list_menu_cartodark = 4;
|
||||
|
||||
private MyLocationNewOverlay myLocationOverlay;
|
||||
|
||||
public final static int LOCATION_TYPE_SEND = 0;
|
||||
public final static int LOCATION_TYPE_SEND_WITH_LIVE = 1;
|
||||
public final static int LOCATION_TYPE_GROUP = 4;
|
||||
|
@ -288,7 +293,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
super(context);
|
||||
}
|
||||
|
||||
public void addInfoView(IMapsProvider.IMarker marker, VenueLocation location) {
|
||||
public void addInfoView(IMapsProvider.IMarker marker) {
|
||||
VenueLocation location = (VenueLocation) marker.getTag();
|
||||
if (location == null || lastPressedVenue == location) {
|
||||
return;
|
||||
}
|
||||
|
@ -728,9 +734,15 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
mapTypeButton.setSubMenuOpenSide(2);
|
||||
mapTypeButton.setAdditionalXOffset(AndroidUtilities.dp(10));
|
||||
mapTypeButton.setAdditionalYOffset(-AndroidUtilities.dp(10));
|
||||
mapTypeButton.addSubItem(map_list_menu_osm, R.drawable.msg_map, "Standard OSM");
|
||||
mapTypeButton.addSubItem(map_list_menu_wiki, R.drawable.msg_map, "Wikimedia");
|
||||
mapTypeButton.addSubItem(map_list_menu_cartodark, R.drawable.msg_map, "Carto Dark");
|
||||
if (false) {
|
||||
mapTypeButton.addSubItem(map_list_menu_map, R.drawable.msg_map, LocaleController.getString("Map", R.string.Map));
|
||||
mapTypeButton.addSubItem(map_list_menu_satellite, R.drawable.msg_satellite, LocaleController.getString("Satellite", R.string.Satellite));
|
||||
mapTypeButton.addSubItem(map_list_menu_hybrid, R.drawable.msg_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid));
|
||||
} else {
|
||||
mapTypeButton.addSubItem(map_list_menu_osm, R.drawable.msg_map, "Standard OSM");
|
||||
mapTypeButton.addSubItem(map_list_menu_wiki, R.drawable.msg_map, "Wikimedia");
|
||||
mapTypeButton.addSubItem(map_list_menu_cartodark, R.drawable.msg_map, "Carto Dark");
|
||||
}
|
||||
mapTypeButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
|
||||
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
|
@ -768,7 +780,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
map.setMapType(IMapsProvider.MAP_TYPE_HYBRID);
|
||||
}
|
||||
});
|
||||
mapViewClip.addView(getAttributionOverlay(context), LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 0 : 4, 0, LocaleController.isRTL ? 4 : 0, 20));
|
||||
|
||||
locationButton = new ImageView(context);
|
||||
drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
|
@ -878,7 +890,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
if (info != null && info.proximityMeters > 0) {
|
||||
proximityButton.setImageResource(R.drawable.msg_location_alert);
|
||||
if (proximityCircle != null) {
|
||||
mapView.getOverlayManager().remove(proximityCircle);
|
||||
proximityCircle.remove();
|
||||
proximityCircle = null;
|
||||
}
|
||||
canUndo = true;
|
||||
|
@ -1421,9 +1433,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
private void openProximityAlert() {
|
||||
if (proximityCircle == null) {
|
||||
createCircle(500);
|
||||
proximityCircleRadius = 500;
|
||||
} else {
|
||||
previousRadius = proximityCircleRadius;
|
||||
previousRadius = proximityCircle.getRadius();
|
||||
}
|
||||
|
||||
TLRPC.User user;
|
||||
|
@ -1434,8 +1445,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
proximitySheet = new ProximitySheet(getParentActivity(), user, (move, radius) -> {
|
||||
if (proximityCircle != null) {
|
||||
proximityCircleRadius = radius;
|
||||
proximityCircle.setPoints(Polygon.pointsAsCircle(proximityCircleCenter, radius));
|
||||
proximityCircle.setRadius(radius);
|
||||
if (move) {
|
||||
moveToBounds(radius, true, true);
|
||||
}
|
||||
|
@ -1479,10 +1489,9 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
if (!proximitySheet.getRadiusSet()) {
|
||||
if (previousRadius > 0) {
|
||||
proximityCircleRadius = previousRadius;
|
||||
proximityCircle.setPoints(Polygon.pointsAsCircle(proximityCircleCenter, previousRadius));
|
||||
proximityCircle.setRadius(previousRadius);
|
||||
} else if (proximityCircle != null) {
|
||||
mapView.getOverlayManager().remove(proximityCircle);
|
||||
proximityCircle.remove();
|
||||
proximityCircle = null;
|
||||
}
|
||||
}
|
||||
|
@ -1544,7 +1553,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
|
||||
private Bitmap[] bitmapCache = new Bitmap[7];
|
||||
|
||||
private Bitmap createPlaceBitmap(int num) {
|
||||
if (bitmapCache[num % 7] != null) {
|
||||
return bitmapCache[num % 7];
|
||||
|
@ -1570,7 +1578,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
return;
|
||||
}
|
||||
for (int a = 0, N = placeMarkers.size(); a < N; a++) {
|
||||
placeMarkers.get(a).marker.remove(mapView);
|
||||
placeMarkers.get(a).marker.remove();
|
||||
}
|
||||
placeMarkers.clear();
|
||||
for (int a = 0, N = places.size(); a < N; a++) {
|
||||
|
@ -1585,20 +1593,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
venueLocation.num = a;
|
||||
venueLocation.marker = map.addMarker(options);
|
||||
venueLocation.venue = venue;
|
||||
venueLocation.marker.setTag(venueLocation);
|
||||
placeMarkers.add(venueLocation);
|
||||
marker.setOnMarkerClickListener(new Marker.OnMarkerClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClick(Marker marker, MapView mapView) {
|
||||
markerImageView.setVisibility(View.INVISIBLE);
|
||||
if (!userLocationMoved) {
|
||||
locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
|
||||
locationButton.setTag(Theme.key_location_actionIcon);
|
||||
userLocationMoved = true;
|
||||
}
|
||||
overlayView.addInfoView(marker, venueLocation);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
@ -1647,6 +1643,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
liveLocation.hasRotation = false;
|
||||
}
|
||||
}
|
||||
|
||||
markers.add(liveLocation);
|
||||
markersMap.put(liveLocation.id, liveLocation);
|
||||
LocationController.SharingLocationInfo myInfo = getLocationController().getSharingLocationInfo(dialogId);
|
||||
|
@ -1692,6 +1689,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
dirOptions.anchor(0.5f, 0.5f);
|
||||
liveLocation.directionMarker = map.addMarker(dirOptions);
|
||||
}
|
||||
|
||||
markers.add(liveLocation);
|
||||
markersMap.put(liveLocation.id, liveLocation);
|
||||
}
|
||||
|
@ -1707,15 +1705,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
return;
|
||||
}
|
||||
|
||||
//Paris, Tour Eiffel
|
||||
GeoPoint initLocation = new GeoPoint(48.85825, 2.29448);
|
||||
final IMapController controller = mapView.getController();
|
||||
mapView.setMaxZoomLevel(20.0);
|
||||
mapView.setMultiTouchControls(true);
|
||||
mapView.setBuiltInZoomControls(false);
|
||||
controller.setCenter(initLocation);
|
||||
controller.setZoom(7.);
|
||||
|
||||
if (chatLocation != null) {
|
||||
LiveLocation liveLocation = addUserMarker(chatLocation);
|
||||
map.moveCamera(ApplicationLoader.getMapsProvider().newCameraUpdateLatLngZoom(liveLocation.marker.getPosition(), map.getMaxZoomLevel() - 4));
|
||||
|
@ -1779,12 +1768,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onZoom(ZoomEvent event) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
map.setOnMyLocationChangeListener(location -> {
|
||||
|
@ -1802,19 +1785,16 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
locationButton.setTag(Theme.key_location_actionIcon);
|
||||
userLocationMoved = true;
|
||||
}
|
||||
overlayView.addInfoView(marker);
|
||||
return true;
|
||||
});
|
||||
map.setOnCameraMoveListener(() -> {
|
||||
if (overlayView != null) {
|
||||
overlayView.updatePositions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onZoom(ZoomEvent event) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
positionMarker(myLocation = getLastLocation());
|
||||
attributionOverlay.bringToFront();
|
||||
|
||||
if (checkGpsEnabled && getParentActivity() != null) {
|
||||
checkGpsEnabled = false;
|
||||
checkGpsEnabled();
|
||||
|
@ -1868,11 +1848,11 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
circleOptions.center(new IMapsProvider.LatLng(myLocation.getLatitude(), myLocation.getLongitude()));
|
||||
circleOptions.radius(meters);
|
||||
if (isActiveThemeDark()) {
|
||||
proximityCircle.getOutlinePaint().setColor(0x9666A3D7);
|
||||
proximityCircle.getFillPaint().setColor(0x1c66A3D7);
|
||||
circleOptions.strokeColor(0x9666A3D7);
|
||||
circleOptions.fillColor(0x1c66A3D7);
|
||||
} else {
|
||||
proximityCircle.getOutlinePaint().setColor(0x964286F5);
|
||||
proximityCircle.getOutlinePaint().setColor(0x1c4286F5);
|
||||
circleOptions.strokeColor(0x964286F5);
|
||||
circleOptions.fillColor(0x1c4286F5);
|
||||
}
|
||||
circleOptions.strokePattern(PATTERN_POLYGON_ALPHA);
|
||||
circleOptions.strokeWidth(2);
|
||||
|
@ -2244,11 +2224,10 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
}
|
||||
if (geoPoints.size() > 0) {
|
||||
builder = BoundingBox.fromGeoPoints(geoPoints);
|
||||
}
|
||||
if (firstFocus) {
|
||||
listView.smoothScrollBy(0, AndroidUtilities.dp(66 * 1.5f));
|
||||
if (builder != null) {
|
||||
if (firstFocus) {
|
||||
listView.smoothScrollBy(0, AndroidUtilities.dp(66 * 1.5f));
|
||||
}
|
||||
firstFocus = false;
|
||||
adapter.setLiveLocations(markers);
|
||||
if (messageObject.isLiveLocation()) {
|
||||
|
@ -2450,7 +2429,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
if (DialogObject.isUserDialog(messageObject.getDialogId())) {
|
||||
proximityButton.setImageResource(R.drawable.msg_location_alert);
|
||||
if (proximityCircle != null) {
|
||||
mapView.getOverlayManager().remove(proximityCircle);
|
||||
proximityCircle.remove();
|
||||
proximityCircle = null;
|
||||
}
|
||||
}
|
||||
|
@ -2517,10 +2496,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
if (mapView.getOverlays().contains(myLocationOverlay)) {
|
||||
mapView.getOverlays().remove(myLocationOverlay);
|
||||
}
|
||||
myLocationOverlay.disableMyLocation();
|
||||
}
|
||||
if (undoView[0] != null) {
|
||||
undoView[0].hide(true, 0);
|
||||
|
@ -2612,11 +2587,9 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
if (mapView != null && mapsInitialized) {
|
||||
try {
|
||||
mapView.onResume();
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
mapView.getOverlays().add(myLocationOverlay);
|
||||
myLocationOverlay.enableMyLocation();
|
||||
}
|
||||
onResumeCalled = true;
|
||||
if (map != null) {
|
||||
|
@ -2696,8 +2669,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
IMapsProvider.IMapStyleOptions style = ApplicationLoader.getMapsProvider().loadRawResourceStyle(ApplicationLoader.applicationContext, R.raw.mapstyle_night);
|
||||
map.setMapStyle(style);
|
||||
if (proximityCircle != null) {
|
||||
proximityCircle.getOutlinePaint().setColor(0xffffffff);
|
||||
proximityCircle.getFillPaint().setColor(0x20ffffff);
|
||||
proximityCircle.setStrokeColor(0xffffffff);
|
||||
proximityCircle.setFillColor(0x20ffffff);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2705,8 +2678,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
currentMapStyleDark = false;
|
||||
map.setMapStyle(null);
|
||||
if (proximityCircle != null) {
|
||||
proximityCircle.getOutlinePaint().setColor(0xff000000);
|
||||
proximityCircle.getFillPaint().setColor(0x20000000);
|
||||
proximityCircle.setStrokeColor(0xff000000);
|
||||
proximityCircle.setFillColor(0x20000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2556,7 +2556,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
req.settings = new TLRPC.TL_codeSettings();
|
||||
req.settings.allow_flashcall = simcardAvailable && allowCall && allowCancelCall && allowReadCallLog;
|
||||
req.settings.allow_missed_call = simcardAvailable && allowCall;
|
||||
req.settings.allow_app_hash = PushListenerController.GooglePushListenerServiceProvider.INSTANCE.hasServices();
|
||||
req.settings.allow_app_hash = PushListenerController.getProvider().hasServices();
|
||||
ArrayList<TLRPC.TL_auth_loggedOut> tokens = MessagesController.getSavedLogOutTokens();
|
||||
if (tokens != null) {
|
||||
for (int i = 0; i < tokens.size(); i++) {
|
||||
|
|
|
@ -6285,7 +6285,7 @@ public class PassportActivity extends BaseFragment implements NotificationCenter
|
|||
req.phone_number = phone;
|
||||
req.settings = new TLRPC.TL_codeSettings();
|
||||
req.settings.allow_flashcall = simcardAvailable && allowCall;
|
||||
req.settings.allow_app_hash = PushListenerController.GooglePushListenerServiceProvider.INSTANCE.hasServices();
|
||||
req.settings.allow_app_hash = PushListenerController.getProvider().hasServices();
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
if (req.settings.allow_flashcall) {
|
||||
try {
|
||||
|
|
|
@ -94,6 +94,7 @@ import org.telegram.PhoneFormat.PhoneFormat;
|
|||
import org.telegram.messenger.AccountInstance;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.ChatThemeController;
|
||||
|
@ -167,7 +168,6 @@ import org.telegram.ui.Components.HintView;
|
|||
import org.telegram.ui.Components.IdenticonDrawable;
|
||||
import org.telegram.ui.Components.ImageUpdater;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Premium.GiftPremiumBottomSheet;
|
||||
import org.telegram.ui.Components.Premium.PremiumGradient;
|
||||
import org.telegram.ui.Components.Premium.PremiumPreviewBottomSheet;
|
||||
import org.telegram.ui.Components.Premium.ProfilePremiumCell;
|
||||
|
@ -411,7 +411,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
private final static int delete_avatar = 35;
|
||||
private final static int add_photo = 36;
|
||||
private final static int qr_button = 37;
|
||||
private final static int gift_premium = 38;
|
||||
// private final static int gift_premium = 38;
|
||||
|
||||
private Rect rect = new Rect();
|
||||
|
||||
|
@ -1913,9 +1913,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
presentFragment(fragment);
|
||||
} else if (id == view_discussion) {
|
||||
openDiscussion();
|
||||
} else if (id == gift_premium) {
|
||||
} /*else if (id == gift_premium) {
|
||||
showDialog(new GiftPremiumBottomSheet(ProfileActivity.this, getMessagesController().getUser(userId)));
|
||||
} else if (id == start_secret_chat) {
|
||||
} */ else if (id == start_secret_chat) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), resourcesProvider);
|
||||
builder.setTitle(LocaleController.getString("AreYouSureSecretChatTitle", R.string.AreYouSureSecretChatTitle));
|
||||
builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat));
|
||||
|
@ -7051,9 +7051,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
otherItem.addSubItem(delete_contact, R.drawable.baseline_delete_24, LocaleController.getString("DeleteContact", R.string.DeleteContact));
|
||||
}
|
||||
if (!UserObject.isDeleted(user) && !isBot && currentEncryptedChat == null && !userBlocked && userId != 333000 && userId != 777000 && userId != 42777) {
|
||||
if (!user.premium && !BuildVars.IS_BILLING_UNAVAILABLE && !user.self && userInfo != null && !getMessagesController().premiumLocked && !userInfo.premium_gifts.isEmpty()) {
|
||||
otherItem.addSubItem(gift_premium, R.drawable.msg_gift_premium, LocaleController.getString(R.string.GiftPremium));
|
||||
}
|
||||
// if (!user.premium && !BuildVars.IS_BILLING_UNAVAILABLE && !user.self && userInfo != null && !getMessagesController().premiumLocked && !userInfo.premium_gifts.isEmpty()) {
|
||||
// otherItem.addSubItem(gift_premium, R.drawable.msg_gift_premium, LocaleController.getString(R.string.GiftPremium));
|
||||
// }
|
||||
otherItem.addSubItem(start_secret_chat, R.drawable.baseline_lock_24, LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
||||
}
|
||||
if (StrUtil.isNotBlank(user.username)) {
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package tw.nekomimi.nekogram;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
public class ExternalGcm {
|
||||
|
||||
interface Interface {
|
||||
boolean checkSplit(Context ctx);
|
||||
|
||||
boolean checkPlayServices();
|
||||
|
||||
void initPlayServices();
|
||||
|
||||
void sendRegistrationToServer();
|
||||
|
||||
void checkUpdate(Activity ctx);
|
||||
}
|
||||
|
||||
static class NoImpl implements Interface {
|
||||
|
||||
@Override
|
||||
public boolean checkSplit(Context ctx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayServices() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPlayServices() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRegistrationToServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUpdate(Activity ctx) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Interface impl;
|
||||
|
||||
static {
|
||||
try {
|
||||
impl = (Interface) Class.forName("tw.nekomimi.nekogram.GcmImpl").newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
impl = new NoImpl();
|
||||
} catch (Exception e) {
|
||||
impl = new NoImpl();
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkSplit(Context ctx) {
|
||||
return impl.checkSplit(ctx);
|
||||
}
|
||||
|
||||
public static void initPlayServices() {
|
||||
impl.initPlayServices();
|
||||
}
|
||||
|
||||
public static boolean checkPlayServices() {
|
||||
return impl.checkPlayServices();
|
||||
}
|
||||
|
||||
public static void sendRegistrationToServer() {
|
||||
impl.sendRegistrationToServer();
|
||||
}
|
||||
|
||||
|
||||
public static void checkUpdate(Activity ctx) {
|
||||
impl.checkUpdate(ctx);
|
||||
}
|
||||
|
||||
}
|
|
@ -58,7 +58,6 @@ import java.util.Map;
|
|||
import java.util.function.Function;
|
||||
|
||||
import kotlin.text.StringsKt;
|
||||
import tw.nekomimi.nekogram.ExternalGcm;
|
||||
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||
import tw.nekomimi.nekogram.utils.FileUtil;
|
||||
import tw.nekomimi.nekogram.utils.GsonUtil;
|
||||
|
|
|
@ -276,4 +276,5 @@
|
|||
<string name="StickerSettings">Sticker</string>
|
||||
<string name="ConfirmSettings">Confirmation</string>
|
||||
<string name="InteractionSettings">Interaction</string>
|
||||
<string name="nekoxPremiumGiftRemoved">Premium Gift is removed in NekoX.</string>
|
||||
</resources>
|
Loading…
Reference in New Issue