diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java index a41270f60..7aae77b9b 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java @@ -2,7 +2,8 @@ import android.content.Context; -import org.jetbrains.annotations.NotNull; +import androidx.annotation.NonNull; + import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.vrbrowser.browser.SettingsStore; @@ -16,7 +17,7 @@ class SessionSettings { private boolean isServoEnabled; private String userAgentOverride; - /* package */ SessionSettings(@NotNull Builder builder) { + /* package */ SessionSettings(@NonNull Builder builder) { this.isPrivateBrowsingEnabled = builder.isPrivateBrowsingEnabled; this.isTrackingProtectionEnabled = builder.isTrackingProtectionEnabled; this.isSuspendMediaWhenInactiveEnabled = builder.isSuspendMediaWhenInactiveEnabled; diff --git a/app/src/common/shared/org/mozilla/vrbrowser/search/GeolocationLocalizationProvider.java b/app/src/common/shared/org/mozilla/vrbrowser/search/GeolocationLocalizationProvider.java index 500020da3..75d6cac1e 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/search/GeolocationLocalizationProvider.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/search/GeolocationLocalizationProvider.java @@ -1,9 +1,8 @@ package org.mozilla.vrbrowser.search; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.mozilla.vrbrowser.geolocation.GeolocationData; import java.util.Locale; @@ -26,7 +25,7 @@ public class GeolocationLocalizationProvider implements SearchLocalizationProvid @Nullable @Override - public SearchLocalization determineRegion(@NotNull Continuation continuation) { + public SearchLocalization determineRegion(@NonNull Continuation continuation) { return new SearchLocalization(mLanguage, mCountry, mRegion); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java index 4512d1d56..4b00f6a4a 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java @@ -14,12 +14,11 @@ import android.widget.FrameLayout; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.VRBrowserActivity; @@ -54,8 +53,6 @@ import mozilla.components.service.fxa.sync.SyncReason; import mozilla.components.service.fxa.sync.SyncStatusObserver; -import static org.mozilla.vrbrowser.browser.BookmarksStoreKt.DESKTOP_ROOT; - public class BookmarksView extends FrameLayout implements BookmarksStore.BookmarkListener { private static final String LOGTAG = SystemUtils.createLogtag(BookmarksView.class); @@ -304,12 +301,12 @@ private void updateSyncBindings(boolean isSyncing) { private AccountObserver mAccountListener = new AccountObserver() { @Override - public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) { + public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) { mBinding.setIsSignedIn(true); } @Override - public void onProfileUpdated(@NotNull Profile profile) { + public void onProfileUpdated(@NonNull Profile profile) { } @Override diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomInlineAutocompleteEditText.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomInlineAutocompleteEditText.java index d28ea4882..97bf45d34 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomInlineAutocompleteEditText.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomInlineAutocompleteEditText.java @@ -3,8 +3,8 @@ import android.content.Context; import android.util.AttributeSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import mozilla.components.ui.autocomplete.InlineAutocompleteEditText; @@ -14,15 +14,15 @@ interface OnSelectionChangedCallback { void onSelectionChanged(int selectionStart, int selectionEnd); } - public CustomInlineAutocompleteEditText(@NotNull Context ctx, @Nullable AttributeSet attrs, int defStyleAttr) { + public CustomInlineAutocompleteEditText(@NonNull Context ctx, @Nullable AttributeSet attrs, int defStyleAttr) { super(ctx, attrs, defStyleAttr); } - public CustomInlineAutocompleteEditText(@NotNull Context ctx, @Nullable AttributeSet attrs) { + public CustomInlineAutocompleteEditText(@NonNull Context ctx, @Nullable AttributeSet attrs) { super(ctx, attrs); } - public CustomInlineAutocompleteEditText(@NotNull Context ctx) { + public CustomInlineAutocompleteEditText(@NonNull Context ctx) { super(ctx); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java index 1cdd1edae..7113cc5a3 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java @@ -14,12 +14,11 @@ import android.widget.FrameLayout; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.VRBrowserActivity; @@ -299,12 +298,12 @@ private void updateSyncBindings(boolean isSyncing) { private AccountObserver mAccountListener = new AccountObserver() { @Override - public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) { + public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) { mBinding.setIsSignedIn(true); } @Override - public void onProfileUpdated(@NotNull Profile profile) { + public void onProfileUpdated(@NonNull Profile profile) { } @Override @@ -318,7 +317,7 @@ public void onAuthenticationProblems() { } }; - @NotNull + @NonNull public static Predicate distinctByUrl(Function keyExtractor) { Set seen = ConcurrentHashMap.newKeySet(); return t -> seen.add(keyExtractor.apply(t)); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java index a76a50768..d9334d3ab 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java @@ -11,12 +11,12 @@ import android.widget.LinearLayout; import android.widget.TextView; -import org.jetbrains.annotations.NotNull; +import androidx.annotation.NonNull; +import androidx.annotation.StringRes; + import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.audio.AudioEngine; -import androidx.annotation.StringRes; - public class SingleEditSetting extends LinearLayout { private AudioEngine mAudio; @@ -162,7 +162,7 @@ public boolean isEditing() { return mEdit1.getVisibility() == View.VISIBLE; } - public boolean contains(@NotNull View view) { + public boolean contains(@NonNull View view) { return findViewById(view.getId()) == view; } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java index 899dccb16..afea26143 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java @@ -25,7 +25,6 @@ import org.mozilla.vrbrowser.browser.SessionChangeListener; import org.mozilla.vrbrowser.browser.engine.Session; import org.mozilla.vrbrowser.browser.engine.SessionStore; -import org.mozilla.vrbrowser.telemetry.TelemetryWrapper; import org.mozilla.vrbrowser.ui.views.UIButton; import org.mozilla.vrbrowser.ui.widgets.settings.SettingsWidget; @@ -388,7 +387,7 @@ public void toggleSettingsDialog() { toggleSettingsDialog(SettingsWidget.SettingDialog.MAIN); } - public void toggleSettingsDialog(SettingsWidget.SettingDialog settingDialog) { + public void toggleSettingsDialog(@NonNull SettingsWidget.SettingDialog settingDialog) { UIWidget widget = getChild(mSettingsDialogHandle); if (widget == null) { widget = createChild(SettingsWidget.class, false); @@ -405,6 +404,20 @@ public void toggleSettingsDialog(SettingsWidget.SettingDialog settingDialog) { } } + public void showSettingsDialog(@NonNull SettingsWidget.SettingDialog settingDialog) { + UIWidget widget = getChild(mSettingsDialogHandle); + if (widget == null) { + widget = createChild(SettingsWidget.class, false); + mSettingsDialogHandle = widget.getHandle(); + } + + if (mAttachedWindow != null) { + widget.getPlacement().parentHandle = mAttachedWindow.getHandle(); + } + + ((SettingsWidget)widget).show(REQUEST_FOCUS, settingDialog); + } + public void setTrayVisible(boolean aVisible) { if (mTrayVisible != aVisible) { mTrayVisible = aVisible; diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index 52f1c77de..2e6381c8b 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -27,7 +27,6 @@ import androidx.annotation.StringRes; import androidx.annotation.UiThread; -import org.jetbrains.annotations.NotNull; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.PanZoomController; @@ -1336,7 +1335,7 @@ private int getWindowWidth(float aWorldWidth) { return (int) Math.floor(SettingsStore.WINDOW_WIDTH_DEFAULT * aWorldWidth / WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width)); } - private void showLibraryItemContextMenu(@NotNull View view, LibraryMenuWidget.LibraryContextMenuItem item, boolean isLastVisibleItem) { + private void showLibraryItemContextMenu(@NonNull View view, LibraryMenuWidget.LibraryContextMenuItem item, boolean isLastVisibleItem) { view.requestFocusFromTouch(); hideContextMenus(); @@ -1408,7 +1407,7 @@ public void onRemoveFromBookmarks(LibraryMenuWidget.LibraryContextMenuItem item) private BookmarksCallback mBookmarksListener = new BookmarksCallback() { @Override - public void onShowContextMenu(@NonNull View view, @NotNull Bookmark item, boolean isLastVisibleItem) { + public void onShowContextMenu(@NonNull View view, @NonNull Bookmark item, boolean isLastVisibleItem) { showLibraryItemContextMenu( view, new LibraryMenuWidget.LibraryContextMenuItem( @@ -1420,7 +1419,7 @@ public void onShowContextMenu(@NonNull View view, @NotNull Bookmark item, boolea @Override public void onFxASynSettings(@NonNull View view) { - mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA); + mWidgetManager.getTray().showSettingsDialog(SettingsWidget.SettingDialog.FXA); } @Override @@ -1459,7 +1458,7 @@ public void onShowContextMenu(@NonNull View view, @NonNull VisitInfo item, boole @Override public void onFxASynSettings(@NonNull View view) { - mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA); + mWidgetManager.getTray().showSettingsDialog(SettingsWidget.SettingDialog.FXA); } @Override diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java index 8767e5da4..7b25020f8 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java @@ -10,7 +10,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import org.jetbrains.annotations.NotNull; import org.mozilla.geckoview.GeckoSession; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.VRBrowserApplication; @@ -893,7 +892,7 @@ public void onLoggedOut() { } @Override - public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) { + public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) { if (authType != AuthType.Existing.INSTANCE) { Session session = mFocusedWindow.getSession(); addTab(mFocusedWindow, mAccounts.getConnectionSuccessURL()); @@ -901,22 +900,22 @@ public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthTyp switch (mAccounts.getLoginOrigin()) { case BOOKMARKS: - getFocusedWindow().switchBookmarks(); + getFocusedWindow().showBookmarks(); break; case HISTORY: - getFocusedWindow().switchHistory(); + getFocusedWindow().showHistory(); break; case SETTINGS: - mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA); + mWidgetManager.getTray().showSettingsDialog(SettingsWidget.SettingDialog.FXA); break; } } } @Override - public void onProfileUpdated(@NotNull Profile profile) { + public void onProfileUpdated(@NonNull Profile profile) { } @@ -1156,7 +1155,7 @@ public void addTab(WindowWidget targetWindow) { addTab(targetWindow, null); } - public void addTab(@NotNull WindowWidget targetWindow, @Nullable String aUri) { + public void addTab(@NonNull WindowWidget targetWindow, @Nullable String aUri) { Session session = SessionStore.get().createSuspendedSession(aUri, targetWindow.getSession().isPrivateMode()); setFirstPaint(targetWindow, session); targetWindow.getSession().setActive(false); @@ -1244,7 +1243,7 @@ public void onTabsClose(ArrayList aTabs) { } @Override - public void onTabsReceived(@NotNull List aTabs) { + public void onTabsReceived(@NonNull List aTabs) { WindowWidget targetWindow = mFocusedWindow; boolean fullscreen = targetWindow.getSession().isInFullScreen(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SendTabDialogWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SendTabDialogWidget.java index 4e2fecf09..f183c9de3 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SendTabDialogWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SendTabDialogWidget.java @@ -13,7 +13,6 @@ import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; -import org.jetbrains.annotations.NotNull; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.VRBrowserApplication; import org.mozilla.vrbrowser.browser.Accounts; @@ -147,7 +146,7 @@ private void showWhatsNewDialog() { // DeviceConstellationObserver @Override - public void onDevicesUpdate(@NotNull ConstellationState constellationState) { + public void onDevicesUpdate(@NonNull ConstellationState constellationState) { post(() -> { mSendTabsDialogBinding.setIsSyncing(false); @@ -182,14 +181,14 @@ public void onLoggedOut() { } @Override - public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) { + public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) { if (mAccounts.getLoginOrigin() == Accounts.LoginOrigin.SEND_TABS) { show(REQUEST_FOCUS); } } @Override - public void onProfileUpdated(@NotNull Profile profile) { + public void onProfileUpdated(@NonNull Profile profile) { } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java index d21376987..02a284f7f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java @@ -10,10 +10,10 @@ import android.view.LayoutInflater; import android.view.View; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.VRBrowserApplication; import org.mozilla.vrbrowser.browser.Accounts; @@ -222,12 +222,12 @@ private void signOut(View view) { private AccountObserver mAccountListener = new AccountObserver() { @Override - public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) { + public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) { mBinding.signButton.setButtonText(R.string.settings_fxa_account_sign_out); } @Override - public void onProfileUpdated(@NotNull Profile profile) { + public void onProfileUpdated(@NonNull Profile profile) { mBinding.accountEmail.setText(profile.getEmail()); mBinding.setLastSync(mAccounts.lastSync()); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java index 93f4afbf8..b21e1bad5 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsWidget.java @@ -24,7 +24,6 @@ import androidx.annotation.NonNull; import androidx.databinding.DataBindingUtil; -import org.jetbrains.annotations.NotNull; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.vrbrowser.BuildConfig; import org.mozilla.vrbrowser.R; @@ -330,12 +329,12 @@ private void updateCurrentAccountState() { private AccountObserver mAccountObserver = new AccountObserver() { @Override - public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) { + public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) { } @Override - public void onProfileUpdated(@NotNull Profile profile) { + public void onProfileUpdated(@NonNull Profile profile) { updateProfile(profile); } @@ -430,7 +429,9 @@ private void showFXAOptionsDialog() { } public void show(@ShowFlags int aShowFlags, @NonNull SettingDialog settingDialog) { - show(aShowFlags); + if (!isVisible()) { + show(aShowFlags); + } switch (settingDialog) { case LANGUAGE: diff --git a/app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java b/app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java index 3e46a6e9a..a6e367e99 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java @@ -2,7 +2,6 @@ import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; @@ -16,7 +15,6 @@ import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.text.style.URLSpan; -import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -25,10 +23,8 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.coordinatorlayout.widget.ViewGroupUtils; import androidx.core.text.HtmlCompat; -import org.jetbrains.annotations.NotNull; import org.mozilla.vrbrowser.ui.widgets.UIWidget; public class ViewUtils { @@ -123,7 +119,7 @@ public static boolean isEqualOrChildrenOf(@NonNull ViewGroup aParent, @NonNull V return isChildrenOf(aParent, aView); } - public static boolean isInsideView(@NotNull View view, int rx, int ry) { + public static boolean isInsideView(@NonNull View view, int rx, int ry) { int[] location = new int[2]; view.getLocationOnScreen(location); int x = location[0];