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

Commit

Permalink
Show Settings instead of toggling after a fxa login (#2469)
Browse files Browse the repository at this point in the history
* Show Settings instead of toggling after a fxa login

* Standardize annotations to use androidx
  • Loading branch information
keianhzo authored and bluemarvin committed Dec 21, 2019
1 parent 9bd7b5e commit 933fcd5
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -26,7 +25,7 @@ public class GeolocationLocalizationProvider implements SearchLocalizationProvid

@Nullable
@Override
public SearchLocalization determineRegion(@NotNull Continuation<? super SearchLocalization> continuation) {
public SearchLocalization determineRegion(@NonNull Continuation<? super SearchLocalization> continuation) {
return new SearchLocalization(mLanguage, mCountry, mRegion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -318,7 +317,7 @@ public void onAuthenticationProblems() {
}
};

@NotNull
@NonNull
public static <T> Predicate<T> distinctByUrl(Function<? super T, ?> keyExtractor) {
Set<Object> seen = ConcurrentHashMap.newKeySet();
return t -> seen.add(keyExtractor.apply(t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -893,30 +892,30 @@ 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());
onTabsClose(new ArrayList<>(Collections.singletonList(session)));

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) {

}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1244,7 +1243,7 @@ public void onTabsClose(ArrayList<Session> aTabs) {
}

@Override
public void onTabsReceived(@NotNull List<TabData> aTabs) {
public void onTabsReceived(@NonNull List<TabData> aTabs) {
WindowWidget targetWindow = mFocusedWindow;

boolean fullscreen = targetWindow.getSession().isInFullScreen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down
Loading

0 comments on commit 933fcd5

Please sign in to comment.