Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Changes after updating to Android Component v.19.
Browse files Browse the repository at this point in the history
  • Loading branch information
daoshengmu committed Oct 24, 2019
1 parent 6a9f0a4 commit 23e47d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.os.Looper
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.future.future
import mozilla.components.concept.storage.PageObservation
import mozilla.components.concept.storage.PageVisit
import mozilla.components.concept.storage.VisitInfo
import mozilla.components.concept.storage.VisitType
import org.mozilla.vrbrowser.VRBrowserApplication
Expand Down Expand Up @@ -49,8 +50,8 @@ class HistoryStore constructor(val context: Context) {
VisitType.REDIRECT_PERMANENT))
}

fun recordVisit(aURL: String, visitType: VisitType) = GlobalScope.future {
storage.recordVisit(aURL, visitType)
fun recordVisit(aURL: String, pageVisit: PageVisit) = GlobalScope.future {
storage.recordVisit(aURL, pageVisit)
notifyListeners()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

import java.util.Locale;

import kotlin.coroutines.Continuation;
import mozilla.components.browser.search.provider.localization.SearchLocalization;
import mozilla.components.browser.search.provider.localization.SearchLocalizationProvider;

public class GeolocationLocalizationProvider extends SearchLocalizationProvider {
public class GeolocationLocalizationProvider implements SearchLocalizationProvider {

private String mCountry;
private String mLanguage;
Expand All @@ -20,20 +22,21 @@ public class GeolocationLocalizationProvider extends SearchLocalizationProvider
mRegion = data.getCountryCode();
}

public SearchLocalization determineRegion(Continuation<? super SearchLocalization> continuation) {
return new SearchLocalization(mLanguage, mCountry, mRegion);
}

@NotNull
@Override
public String getCountry() {
return mCountry;
}

@NotNull
@Override
public String getLanguage() {
return mLanguage;
}

@Nullable
@Override
public String getRegion() {
return mRegion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@

import mozilla.components.concept.storage.BookmarkNode;
import mozilla.components.concept.storage.PageObservation;
import mozilla.components.concept.storage.PageVisit;
import mozilla.components.concept.storage.RedirectSource;
import mozilla.components.concept.storage.VisitInfo;
import mozilla.components.concept.storage.VisitType;

Expand Down Expand Up @@ -1408,21 +1410,21 @@ public GeckoResult<Boolean> onVisited(@NonNull GeckoSession geckoSession, @NonNu

boolean isReload = lastVisitedURL != null && lastVisitedURL.equals(url);

VisitType visitType;
PageVisit pageVisit;
if (isReload) {
visitType = VisitType.RELOAD;
pageVisit = new PageVisit(VisitType.RELOAD, RedirectSource.NOT_A_SOURCE);
} else {
if ((flags & VISIT_REDIRECT_SOURCE_PERMANENT) != 0) {
visitType = VisitType.REDIRECT_PERMANENT;
pageVisit = new PageVisit(VisitType.REDIRECT_PERMANENT, RedirectSource.PERMANENT);
} else if ((flags & VISIT_REDIRECT_SOURCE) != 0) {
visitType = VisitType.REDIRECT_TEMPORARY;
pageVisit = new PageVisit(VisitType.REDIRECT_TEMPORARY, RedirectSource.TEMPORARY);
} else {
visitType = VisitType.LINK;
pageVisit = new PageVisit(VisitType.LINK, RedirectSource.NOT_A_SOURCE);
}
}

SessionStore.get().getHistoryStore().deleteVisitsFor(url).thenAcceptAsync(result -> {
SessionStore.get().getHistoryStore().recordVisit(url, visitType);
SessionStore.get().getHistoryStore().recordVisit(url, pageVisit);
});
return GeckoResult.fromValue(true);
}
Expand Down

0 comments on commit 23e47d2

Please sign in to comment.