diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 35ea0e74b..1e4db3d03 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -35,6 +35,8 @@ jobs: run: go install github.com/golang/protobuf/protoc-gen-go@latest - name: Build + env: + GIT_LFS_SKIP_SMUDGE: 1 run: LIB_NAME=liblantern.so make lantern # Install gotestfmt on the VM running the action. diff --git a/README.md b/README.md index 1a3b44622..488c373ed 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ All these dependencies must be in your PATH. Some of this is Android specific, s #### macOS -* `make darwin` +* `make macos` * `make ffigen` * `flutter run -d macos` diff --git a/android/app/build.gradle b/android/app/build.gradle index 8b606e0f4..3b235d4eb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -78,13 +78,6 @@ android { } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true - manifestPlaceholders = [ - TapsellMediationAppKey : "ad680da7-f319-42cb-bdde-3b6c43486eaa", - TapsellMediationAdmobAdapterSignature : "ca-app-pub-2685698271254859~9283700921", - TapsellMediationApplovinAdapterSignature: "YOUR_APPLOVIN_SIGNATURE", - TapsellMediationAppMarket : "GooglePlay", - ] - } kotlin { jvmToolchain(17) diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 1182b8ea1..84bca66ab 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -220,10 +220,3 @@ -keep class org.whispersystems.** { *; } ##---------------End: proguard configuration for Signal ---------- # - -##---------------Begin: proguard configuration for Tapsell ---------- --dontwarn ir.tapsell.mediation.flutter.utils.UtilsKt --keep class ir.tapsell.mediation.flutter.utils.UtilsKt --keep class ir.tapsell.mediation.flutter.TapsellFlutterPlugin -##---------------End: proguard configuration for Tapsell ---------- -# diff --git a/android/build.gradle b/android/build.gradle index 510737ce5..c7f60b45e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,7 +3,6 @@ buildscript { ext.signal_version = '2.8.1' ext.protoc_version = '4.26.1' ext.desugarJdk = '2.0.4' - ext.tapsellVersion = '1.0.1-beta07' repositories { google() diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..94113f200 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/assets/images/tray_dark_connected.png b/assets/images/tray_dark_connected.png new file mode 100644 index 000000000..4d2ab0a76 Binary files /dev/null and b/assets/images/tray_dark_connected.png differ diff --git a/assets/images/tray_dark_disconnected.png b/assets/images/tray_dark_disconnected.png new file mode 100644 index 000000000..b564c7231 Binary files /dev/null and b/assets/images/tray_dark_disconnected.png differ diff --git a/assets/images/tray_light_connected.png b/assets/images/tray_light_connected.png new file mode 100644 index 000000000..b35079890 Binary files /dev/null and b/assets/images/tray_light_connected.png differ diff --git a/assets/images/tray_light_disconnected.png b/assets/images/tray_light_disconnected.png new file mode 100644 index 000000000..663b4983c Binary files /dev/null and b/assets/images/tray_light_disconnected.png differ diff --git a/desktop/app/app.go b/desktop/app/app.go index 845d8c9e8..424ec036b 100644 --- a/desktop/app/app.go +++ b/desktop/app/app.go @@ -19,9 +19,9 @@ import ( "github.com/getlantern/errors" "github.com/getlantern/eventual" "github.com/getlantern/flashlight/v7" - "github.com/getlantern/flashlight/v7/bandit" flashlightClient "github.com/getlantern/flashlight/v7/client" "github.com/getlantern/flashlight/v7/config" + "github.com/getlantern/flashlight/v7/dialer" "github.com/getlantern/flashlight/v7/email" "github.com/getlantern/flashlight/v7/geolookup" "github.com/getlantern/flashlight/v7/logging" @@ -424,7 +424,7 @@ func (app *App) onConfigUpdate(cfg *config.Global, src config.Source) { email.SetDefaultRecipient(cfg.ReportIssueEmail) } -func (app *App) onProxiesUpdate(proxies []bandit.Dialer, src config.Source) { +func (app *App) onProxiesUpdate(proxies []dialer.ProxyDialer, src config.Source) { log.Debugf("[Startup Desktop] Got proxies update from %v", src) app.fetchedProxiesConfig.Store(true) app.hasSucceedingProxy.Store(true) diff --git a/desktop/diagnostics/diagnostics.go b/desktop/diagnostics/diagnostics.go index 0619c4899..146f5baaa 100644 --- a/desktop/diagnostics/diagnostics.go +++ b/desktop/diagnostics/diagnostics.go @@ -8,7 +8,7 @@ import ( "github.com/getlantern/diagnostics" "github.com/getlantern/errors" - "github.com/getlantern/flashlight/v7/bandit" + "github.com/getlantern/flashlight/v7/dialer" ) const ( @@ -33,7 +33,7 @@ type Report struct { } // Run the diagnostics. -func Run(proxies []bandit.Dialer) Report { +func Run(proxies []dialer.ProxyDialer) Report { s := newSuite() s.initAndAdd(func() (*diagnostic, error) { defaultGateway, err := gateway.DiscoverGateway() diff --git a/go.mod b/go.mod index 4402cd287..5c191d772 100644 --- a/go.mod +++ b/go.mod @@ -38,8 +38,8 @@ require ( github.com/getlantern/eventual v1.0.0 github.com/getlantern/eventual/v2 v2.0.2 github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c - github.com/getlantern/flashlight/v7 v7.6.124 - github.com/getlantern/fronted v0.0.0-20241028162429-6616677cce5d + github.com/getlantern/flashlight/v7 v7.6.133 + github.com/getlantern/fronted v0.0.0-20241106204211-209e8131cbd8 github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65 github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770 github.com/getlantern/i18n v0.0.0-20181205222232-2afc4f49bb1c diff --git a/go.sum b/go.sum index be3b9cd8a..37a40c26f 100644 --- a/go.sum +++ b/go.sum @@ -293,12 +293,12 @@ github.com/getlantern/fdcount v0.0.0-20210503151800-5decd65b3731/go.mod h1:XZwE+ github.com/getlantern/filepersist v0.0.0-20160317154340-c5f0cd24e799/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8= github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c h1:mcz27xtAkb1OuOLBct/uFfL1p3XxAIcFct82GbT+UZM= github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8= -github.com/getlantern/flashlight/v7 v7.6.124 h1:7UXgoSNyR6lxy0WIVP1Ddilop0lP0I2ZeYjjEGL6IzY= -github.com/getlantern/flashlight/v7 v7.6.124/go.mod h1:XpFdE7V0Na3Os1ZGVVGopmiTvuOlAfjNEyLQ4CaRmyU= +github.com/getlantern/flashlight/v7 v7.6.133 h1:2BLB+EAfq36XgbGUDtOmiqV1glUcpoOZwem+gyDxacM= +github.com/getlantern/flashlight/v7 v7.6.133/go.mod h1:PNDmAgH5Y3+Gi7Fnl05f1MW1joM+djK5ukKIaEjJMZA= github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede h1:yrU6Px3ZkvCsDLPryPGi6FN+2iqFPq+JeCb7EFoDBhw= github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede/go.mod h1:nhnoiS6DE6zfe+BaCMU4YI01UpsuiXnDqM5S8jxHuuI= -github.com/getlantern/fronted v0.0.0-20241028162429-6616677cce5d h1:UyXg0m0jaZV3JBKpn8MImV1RU6uknVkVyLZ+7mOu/dI= -github.com/getlantern/fronted v0.0.0-20241028162429-6616677cce5d/go.mod h1:WByj7b55hNRpeuIaES521Poebt0ABOdzG/9g+bS4BiQ= +github.com/getlantern/fronted v0.0.0-20241106204211-209e8131cbd8 h1:6J3WfWrjfaBsyzeaUpYiAwSeI5Fkl5+TXYEmUSh1el0= +github.com/getlantern/fronted v0.0.0-20241106204211-209e8131cbd8/go.mod h1:WByj7b55hNRpeuIaES521Poebt0ABOdzG/9g+bS4BiQ= github.com/getlantern/geo v0.0.0-20240108161311-50692a1b69a9 h1:mSg57/+t59Q08AqArlhW+3N1AVPn5ox0dTOYonRps6w= github.com/getlantern/geo v0.0.0-20240108161311-50692a1b69a9/go.mod h1:RjQ0krF8NTCc5xo2Q1995/vZBnYg33h8svn15do7dLg= github.com/getlantern/geolookup v0.0.0-20230327091034-aebe73c6eef4 h1:Ju9l1RretVWJTNo2vpl/xAW8Dcuiyg5kJC6LRBpCigw= diff --git a/internalsdk/android.go b/internalsdk/android.go index f717d580e..8d405a03c 100644 --- a/internalsdk/android.go +++ b/internalsdk/android.go @@ -17,19 +17,20 @@ import ( "github.com/getlantern/errors" "github.com/getlantern/eventual/v2" "github.com/getlantern/flashlight/v7" - "github.com/getlantern/flashlight/v7/bandit" "github.com/getlantern/flashlight/v7/bandwidth" "github.com/getlantern/flashlight/v7/client" "github.com/getlantern/flashlight/v7/config" + "github.com/getlantern/flashlight/v7/dialer" "github.com/getlantern/flashlight/v7/geolookup" "github.com/getlantern/flashlight/v7/logging" "github.com/getlantern/flashlight/v7/ops" "github.com/getlantern/golog" - "github.com/getlantern/lantern-client/internalsdk/analytics" - "github.com/getlantern/lantern-client/internalsdk/common" "github.com/getlantern/mtime" "github.com/getsentry/sentry-go" + "github.com/getlantern/lantern-client/internalsdk/analytics" + "github.com/getlantern/lantern-client/internalsdk/common" + // import gomobile just to make sure it stays in go.mod _ "golang.org/x/mobile/bind/java" ) @@ -102,7 +103,6 @@ type Session interface { SetChatEnabled(bool) SplitTunnelingEnabled() (bool, error) SetShowGoogleAds(bool) - SetShowTapSellAds(bool) SetHasConfigFetched(bool) SetHasProxyFetched(bool) SetUserIdAndToken(int64, string) error @@ -139,7 +139,6 @@ type PanickingSession interface { SetIP(string) SplitTunnelingEnabled() bool SetShowGoogleAds(bool) - SetShowTapSellAds(bool) // workaround for lack of any sequence types in gomobile bind... ;_; // used to implement GetInternalHeaders() map[string]string // Should return a JSON encoded map[string]string {"key":"val","key2":"val", ...} @@ -301,10 +300,6 @@ func (s *panickingSessionImpl) SetShowGoogleAds(enabled bool) { s.wrapped.SetShowGoogleAds(enabled) } -func (s *panickingSessionImpl) SetShowTapSellAds(enabled bool) { - s.wrapped.SetShowTapSellAds(enabled) -} - func (s *panickingSessionImpl) SetUserIdAndToken(userID int64, token string) { err := s.wrapped.SetUserIdAndToken(userID, token) panicIfNecessary(err) @@ -568,7 +563,7 @@ func run(configDir, locale string, settings Settings, wrappedSession Session) { flashlight.WithOnConfig(func(g *config.Global, s config.Source) { session.SetHasConfigFetched(true) }), - flashlight.WithOnProxies(func(d []bandit.Dialer, s config.Source) { + flashlight.WithOnProxies(func(d []dialer.ProxyDialer, s config.Source) { session.SetHasProxyFetched(true) }), flashlight.WithOnDialError(func(err error, hasSucceeding bool) { @@ -613,15 +608,9 @@ func run(configDir, locale string, settings Settings, wrappedSession Session) { showAdsEnabled := runner.FeatureEnabled(config.FeatureInterstitialAds, common.ApplicationVersion) log.Debugf("Feature: Show ads enabled? %v", showAdsEnabled) session.SetShowGoogleAds(showAdsEnabled) - - showTapSellAdsEnabled := runner.FeatureEnabled(config.FeatureTapsellAds, common.ApplicationVersion) - log.Debugf("Feature: Show tapsell ads enabled? %v", showTapSellAdsEnabled) - session.SetShowTapSellAds(showTapSellAdsEnabled) - } else { // Explicitly disable ads for Pro users. session.SetShowGoogleAds(false) - session.SetShowTapSellAds(false) } } diff --git a/internalsdk/android_test.go b/internalsdk/android_test.go index 7cdf1be53..523d49bf0 100644 --- a/internalsdk/android_test.go +++ b/internalsdk/android_test.go @@ -75,7 +75,6 @@ func (c testSession) SetAuthEnabled(enabled bool) {} func (c testSession) SetMatomoEnabled(bool) {} func (c testSession) IsPlayVersion() (bool, error) { return false, nil } func (c testSession) SetShowGoogleAds(enabled bool) {} -func (c testSession) SetShowTapSellAds(enabled bool) {} func (c testSession) SetHasConfigFetched(enabled bool) {} func (c testSession) SetHasProxyFetched(enabled bool) {} func (c testSession) SetOnSuccess(enabled bool) {} diff --git a/internalsdk/auth/auth.go b/internalsdk/auth/auth.go index 69b7c6ae9..d05ff93b8 100644 --- a/internalsdk/auth/auth.go +++ b/internalsdk/auth/auth.go @@ -10,6 +10,7 @@ import ( "github.com/getlantern/flashlight/v7/proxied" "github.com/getlantern/golog" + "github.com/getlantern/lantern-client/internalsdk/common" "github.com/getlantern/lantern-client/internalsdk/pro" "github.com/getlantern/lantern-client/internalsdk/protos" @@ -61,7 +62,7 @@ func NewClient(baseURL string, userConfig func() common.UserConfig) AuthClient { log.Debug("using proxied.Fronted") //this is ios version httpClient = &http.Client{ - Transport: proxied.Fronted(30 * time.Second), + Transport: proxied.Fronted("auth_fronted_roundtrip", 30*time.Second), } } else { log.Debug("using proxied.ChainedNonPersistent") diff --git a/internalsdk/ios/ios.go b/internalsdk/ios/ios.go index d72c6fd55..3faab417a 100644 --- a/internalsdk/ios/ios.go +++ b/internalsdk/ios/ios.go @@ -12,11 +12,12 @@ import ( "github.com/getlantern/dnsgrab" "github.com/getlantern/dnsgrab/persistentcache" "github.com/getlantern/errors" - "github.com/getlantern/flashlight/v7/bandit" "github.com/getlantern/flashlight/v7/bandwidth" "github.com/getlantern/flashlight/v7/chained" + "github.com/getlantern/flashlight/v7/dialer" "github.com/getlantern/flashlight/v7/stats" "github.com/getlantern/ipproxy" + "github.com/getlantern/lantern-client/internalsdk/common" ) @@ -115,7 +116,7 @@ type BandwidthTracker interface { type cw struct { ipStack io.WriteCloser client *iosClient - dialer *bandit.BanditDialer + dialer dialer.Dialer ipp ipproxy.Proxy quotaTextPath string lastSavedQuota time.Time @@ -136,7 +137,7 @@ func (c *cw) Reconfigure() { panic(log.Errorf("Unable to load dialers on reconfigure: %v", err)) } - c.dialer, err = bandit.New(bandit.Options{ + c.dialer = dialer.New(&dialer.Options{ Dialers: dialers, }) if err != nil { @@ -215,9 +216,8 @@ func (c *iosClient) start() (ClientWriter, error) { return nil, errors.New("No dialers found") } tracker := stats.NewTracker() - dialer, err := bandit.New(bandit.Options{ - Dialers: dialers, - StatsTracker: tracker, + dialer := dialer.New(&dialer.Options{ + Dialers: dialers, }) if err != nil { return nil, err @@ -313,7 +313,7 @@ func (c *iosClient) loadUserConfig() error { return nil } -func (c *iosClient) loadDialers() ([]bandit.Dialer, error) { +func (c *iosClient) loadDialers() ([]dialer.ProxyDialer, error) { cf := &configurer{configFolderPath: c.configDir} chained.PersistSessionStates(c.configDir) diff --git a/internalsdk/ios/tcp.go b/internalsdk/ios/tcp.go index 44cfd9f5f..8ecb77602 100644 --- a/internalsdk/ios/tcp.go +++ b/internalsdk/ios/tcp.go @@ -11,7 +11,7 @@ import ( "time" "github.com/getlantern/dnsgrab" - "github.com/getlantern/flashlight/v7/bandit" + "github.com/getlantern/flashlight/v7/dialer" "github.com/getlantern/idletiming" "github.com/getlantern/netx" ) @@ -38,7 +38,7 @@ type proxiedTCPHandler struct { mx sync.RWMutex } -func newProxiedTCPHandler(c *iosClient, dialer *bandit.BanditDialer, grabber dnsgrab.Server) *proxiedTCPHandler { +func newProxiedTCPHandler(c *iosClient, dialer dialer.Dialer, grabber dnsgrab.Server) *proxiedTCPHandler { result := &proxiedTCPHandler{ dialOut: dialer.DialContext, client: c, @@ -66,7 +66,7 @@ func (h *proxiedTCPHandler) handleDial() { runtime.LockOSThread() for req := range h.dialRequests { - upstream, err := h.dialOut(req.ctx, bandit.NetworkConnect, req.addr) + upstream, err := h.dialOut(req.ctx, dialer.NetworkConnect, req.addr) if err == nil { req.upstream <- upstream } else { diff --git a/internalsdk/mocks/Session.go b/internalsdk/mocks/Session.go index ac43967e5..c7b031605 100644 --- a/internalsdk/mocks/Session.go +++ b/internalsdk/mocks/Session.go @@ -602,11 +602,6 @@ func (_m *Session) SetShowGoogleAds(_a0 bool) { _m.Called(_a0) } -// SetShowTapSellAds provides a mock function with given fields: _a0 -func (_m *Session) SetShowTapSellAds(_a0 bool) { - _m.Called(_a0) -} - // SetStaging provides a mock function with given fields: _a0 func (_m *Session) SetStaging(_a0 bool) error { ret := _m.Called(_a0) diff --git a/internalsdk/session_model.go b/internalsdk/session_model.go index 86a30003c..45ef05591 100644 --- a/internalsdk/session_model.go +++ b/internalsdk/session_model.go @@ -82,7 +82,6 @@ const ( pathAcceptedTermsVersion = "accepted_terms_version" pathAdsEnabled = "adsEnabled" pathShowAds = "showAds" - pathTapSellAdsEnabled = "tapsellAdsEnabled" pathStoreVersion = "storeVersion" pathTestPlayVersion = "testPlayVersion" pathServerInfo = "/server_info" @@ -776,9 +775,6 @@ func (m *SessionModel) checkAvailableFeatures() { // Check for ads feature googleAdsEnabled := m.featureEnabled(config.FeatureInterstitialAds) m.SetShowGoogleAds(googleAdsEnabled) - - tapSellAdsEnabled := m.featureEnabled(config.FeatureTapsellAds) - m.SetShowTapSellAds(tapSellAdsEnabled) } // check if feature is enabled or not @@ -1273,14 +1269,6 @@ func (m *SessionModel) SetShowGoogleAds(adsEnable bool) { checkAdsEnabled(m) } -func (m *SessionModel) SetShowTapSellAds(adsEnable bool) { - log.Debugf("SetShowTapSellAds %v", adsEnable) - panicIfNecessary(pathdb.Mutate(m.db, func(tx pathdb.TX) error { - return pathdb.Put(tx, pathTapSellAdsEnabled, adsEnable, "") - })) - checkAdsEnabled(m) -} - func (m *SessionModel) SerializedInternalHeaders() (string, error) { // Return static for now // Todo implement this method @@ -1564,22 +1552,12 @@ func checkAdsEnabled(session *SessionModel) error { if err != nil { return err } - tapSellAdsEnable, err := pathdb.Get[bool](session.db, pathTapSellAdsEnabled) - if err != nil { - return err - } if googleAdsEnable { log.Debug("Google Ads is enabled") return pathdb.Mutate(session.db, func(tx pathdb.TX) error { return pathdb.Put[string](tx, pathShowAds, "google", "") }) } - if tapSellAdsEnable { - log.Debug("TapSell Ads is enabled") - return pathdb.Mutate(session.db, func(tx pathdb.TX) error { - return pathdb.Put[string](tx, pathShowAds, "tapsell", "") - }) - } return nil } diff --git a/lib/app.dart b/lib/app.dart index 60e017790..e8e1e1bbe 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -130,6 +130,7 @@ class _LanternAppState extends State ), colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.black), ), + themeMode: ThemeMode.system, title: 'app_name'.i18n, localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, diff --git a/lib/common/ui/image_paths.dart b/lib/common/ui/image_paths.dart index 7504aa14c..dea9b5a12 100644 --- a/lib/common/ui/image_paths.dart +++ b/lib/common/ui/image_paths.dart @@ -139,7 +139,6 @@ class ImagePaths { static const warning = 'assets/images/warning.svg'; static const emptyCheck = 'assets/images/empty_check.svg'; - // illustrations static const welcome_illustration = 'assets/images/welcome_illustration.svg'; static const introducing_illustration_bubble = @@ -155,19 +154,24 @@ class ImagePaths { static const empty_search = 'assets/images/empty_search.svg'; static const lantern_logotype = 'assets/images/lantern_logotype.svg'; static const lantern_pro_logotype = 'assets/images/lantern_pro_logotype.svg'; - static const addAccountIllustration = 'assets/images/add_account_illustration.svg'; + static const addAccountIllustration = + 'assets/images/add_account_illustration.svg'; static const cloudOff = 'assets/images/cloud_off.svg'; static const restore = 'assets/images/restore.svg'; static const lanternConnected = 'assets/images/lantern_connected.png'; static const lanternDisconnected = 'assets/images/lantern_disconnected.png'; - static const lanternDiss = 'assets/images/lantern_dis.png'; + static const lanternLightConnected = 'assets/images/tray_light_connected.png'; + static const lanternLightDisconnected = + 'assets/images/tray_light_disconnected.png'; + static const lanternDarkDisconnected = + 'assets/images/tray_dark_disconnected.png'; + static const lanternDarkConnected = 'assets/images/tray_dark_connected.png'; static const lanternConnectedIco = 'assets/images/lantern_connected.ico'; - static const lanternDisconnectedIco = 'assets/images/lantern_disconnected.ico'; + static const lanternDisconnectedIco = + 'assets/images/lantern_disconnected.ico'; static const proxySetting = 'assets/images/proxy_setting.svg'; static const copy = 'assets/images/copy.svg'; - - static String countdownPath(int index) => 'assets/images/countdown_stopwatch/timer_$index.svg'; } diff --git a/lib/core/helpers/ad_helper.dart b/lib/core/helpers/ad_helper.dart index 3de61515d..b493d7aff 100644 --- a/lib/core/helpers/ad_helper.dart +++ b/lib/core/helpers/ad_helper.dart @@ -2,9 +2,8 @@ import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:lantern/core/utils/common.dart'; import 'package:lantern/features/replica/common.dart'; import 'package:logger/logger.dart'; -import 'package:tapsell_mediation/tapsell.dart'; -enum _AdsProvider { tapsell, google } +enum _AdsProvider { google } var logger = Logger( printer: PrettyPrinter( @@ -112,99 +111,8 @@ class GoogleAdsProvider implements AdsProvider { } } -class TapSellAdsProvider implements AdsProvider { - String appId = ''; - int _failedLoadAttempts = 0; - bool isAdLoading = false; - bool isAdsShown = false; - final int _maxFailAttempts = 5; - - @override - Future loadInterstitialAd(VoidCallback adLoadedCallback) async { - // Since we are showing ads to non-EU user - Tapsell.setUserConsent(true); - - if (isAdLoading || isAdsShown || appId.isNotEmpty) { - logger.i( - "[Ads Manager] Tapsell ad is already loading $isAdLoading or shown $isAdsShown"); - return; - } - if (_failedLoadAttempts < _maxFailAttempts) { - try { - isAdLoading = true; - appId = (await Tapsell.requestInterstitialAd( - AppSecret.videoInterstitialZoneId)) ?? - ''; - logger.i("[Ads Manager] Tapsell ad loaded $appId"); - isAdLoading = false; - if (appId.isNotEmpty) { - adLoadedCallback(); - } else { - _failedLoadAttempts++; - Future.delayed( - const Duration(milliseconds: 500), - () { - loadInterstitialAd(adLoadedCallback); - }, - ); - } - } catch (e) { - logger.e("[Ads Manager] requesting tapsell ad failed $e", error: e); - _failedLoadAttempts++; - isAdLoading = false; - Future.delayed( - const Duration(milliseconds: 500), - () { - loadInterstitialAd(adLoadedCallback); - }, - ); - } - } - } - - @override - Future showInterstitialAd() async { - if (appId.isEmpty || isAdsShown) { - logger.i( - "[Ads Manager] Tapsell ad is not ready or already shown $isAdsShown"); - return; - } - await Tapsell.showInterstitialAd( - appId, - onAdClicked: () { - logger.i("[Ads Manager] Tapsell ad clicked"); - isAdsShown = true; - }, - onAdFailed: (message) { - logger.e("[Ads Manager] Tapsell ad failed to show $message"); - }, - onAdClosed: (completionState) { - logger.i("[Ads Manager] Tapsell ad closed $completionState"); - isAdsShown = true; - }, - onAdImpression: () { - logger.i("[Ads Manager] Tapsell ad impression"); - isAdsShown = true; - }, - ); - } - - @override - Future dispose() { - appId = ''; - isAdsShown = true; - return Future.value(); - } - - @override - bool isAdReady() { - return appId.isNotEmpty; - } -} - class AdHelper { final googleAdsService = GoogleAdsProvider(); - final tapSellAdsService = TapSellAdsProvider(); static final AdHelper _instance = AdHelper._internal(); AdHelper._internal(); @@ -212,28 +120,23 @@ class AdHelper { factory AdHelper() => _instance; Future isAdsReadyToShow() async { - return googleAdsService.isAdReady() || tapSellAdsService.isAdReady(); + return googleAdsService.isAdReady(); } Future loadAds({required String provider}) async { - if(provider.isEmpty){ + if (provider.isEmpty) { logger.i("[Ads Manager] Provider is empty do not show ads"); return; } if (provider == _AdsProvider.google.name) { logger.i("[Ads Manager] Loading Google Ads"); await googleAdsService.loadInterstitialAd(showAds); - } else if (provider == _AdsProvider.tapsell.name) { - logger.i("[Ads Manager] Loading Tapsell Ads"); - await tapSellAdsService.loadInterstitialAd(showAds); } } Future showAds() async { if (googleAdsService.isAdReady()) { await googleAdsService.showInterstitialAd(); - } else if (tapSellAdsService.isAdReady()) { - await tapSellAdsService.showInterstitialAd(); } } } diff --git a/lib/core/utils/common_desktop.dart b/lib/core/utils/common_desktop.dart index 7a6cfca9f..80c30fa8c 100644 --- a/lib/core/utils/common_desktop.dart +++ b/lib/core/utils/common_desktop.dart @@ -1,7 +1,3 @@ -import 'dart:io'; - -import 'package:lantern/common/ui/image_paths.dart'; - export 'dart:convert'; export 'dart:ffi'; // For FFI export 'package:ffi/src/utf8.dart'; @@ -14,15 +10,3 @@ export 'package:lantern/core/service/websocket_subscriber.dart'; export 'package:lantern/core/service/lantern_ffi_service.dart'; export 'package:web_socket_channel/io.dart'; export 'package:web_socket_channel/web_socket_channel.dart'; - - -String getSystemTrayIconPath(bool connected) { - if (connected) { - return Platform.isWindows - ? ImagePaths.lanternConnectedIco - : ImagePaths.lanternConnected; - } - return Platform.isWindows - ? ImagePaths.lanternDisconnectedIco - : ImagePaths.lanternDisconnected; -} diff --git a/lib/features/tray/tray_container.dart b/lib/features/tray/tray_container.dart index 7c2918c5c..57cefa9b0 100644 --- a/lib/features/tray/tray_container.dart +++ b/lib/features/tray/tray_container.dart @@ -45,10 +45,27 @@ class _TrayContainerState extends State with TrayListener { vpnNotifier.vpnStatus.addListener(_updateTrayMenu); } + String _getSystemTrayIconPath(bool connected) { + if (Platform.isWindows) { + return connected + ? ImagePaths.lanternConnectedIco + : ImagePaths.lanternDisconnectedIco; + } else if (Platform.isMacOS) { + return connected + ? ImagePaths.lanternDarkConnected + : ImagePaths.lanternDarkDisconnected; + } + + return connected + ? ImagePaths.lanternConnected + : ImagePaths.lanternDisconnected; + } + Future _updateTrayMenu() async { final vpnNotifier = context.read(); final isConnected = vpnNotifier.isConnected(); - await trayManager.setIcon(getSystemTrayIconPath(isConnected)); + await trayManager.setIcon(_getSystemTrayIconPath(isConnected), + isTemplate: Platform.isMacOS); Menu menu = Menu( items: [ MenuItem( diff --git a/macos/Podfile.lock b/macos/Podfile.lock index d18691a57..f9567becc 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -157,4 +157,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: b026caf428aef5db8f45e6734a110a98281273f6 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/pubspec.lock b/pubspec.lock index ba79f1742..523436717 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1761,22 +1761,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0+1" - tapsell_mediation: - dependency: "direct main" - description: - name: tapsell_mediation - sha256: cd393853faff889b881d0b077dfea3c03a70e93b7fbb7ee8b2e61eab5135cec3 - url: "https://pub.dev" - source: hosted - version: "1.0.1-beta06" - tapsell_mediation_legacy: - dependency: "direct main" - description: - name: tapsell_mediation_legacy - sha256: "0e9a37eeb28875e3b4667742e1993647245e9c3c95ca17f09010afbdb0ed1b89" - url: "https://pub.dev" - source: hosted - version: "1.0.1-beta06" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cb169590c..1091e6240 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -125,8 +125,6 @@ dependencies: # Ads google_mobile_ads: ^5.1.0 - tapsell_mediation: ^1.0.1-beta06 - tapsell_mediation_legacy: ^1.0.1-beta06 retry: ^3.1.2 # Generate bindings to native libraries