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

Commit 933fcd5

Browse files
keianhzobluemarvin
authored andcommitted
Show Settings instead of toggling after a fxa login (#2469)
* Show Settings instead of toggling after a fxa login * Standardize annotations to use androidx
1 parent 9bd7b5e commit 933fcd5

File tree

13 files changed

+60
-57
lines changed

13 files changed

+60
-57
lines changed

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionSettings.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import android.content.Context;
44

5-
import org.jetbrains.annotations.NotNull;
5+
import androidx.annotation.NonNull;
6+
67
import org.mozilla.geckoview.GeckoSessionSettings;
78
import org.mozilla.vrbrowser.browser.SettingsStore;
89

@@ -16,7 +17,7 @@ class SessionSettings {
1617
private boolean isServoEnabled;
1718
private String userAgentOverride;
1819

19-
/* package */ SessionSettings(@NotNull Builder builder) {
20+
/* package */ SessionSettings(@NonNull Builder builder) {
2021
this.isPrivateBrowsingEnabled = builder.isPrivateBrowsingEnabled;
2122
this.isTrackingProtectionEnabled = builder.isTrackingProtectionEnabled;
2223
this.isSuspendMediaWhenInactiveEnabled = builder.isSuspendMediaWhenInactiveEnabled;

app/src/common/shared/org/mozilla/vrbrowser/search/GeolocationLocalizationProvider.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package org.mozilla.vrbrowser.search;
22

33
import androidx.annotation.NonNull;
4+
import androidx.annotation.Nullable;
45

5-
import org.jetbrains.annotations.NotNull;
6-
import org.jetbrains.annotations.Nullable;
76
import org.mozilla.vrbrowser.geolocation.GeolocationData;
87

98
import java.util.Locale;
@@ -26,7 +25,7 @@ public class GeolocationLocalizationProvider implements SearchLocalizationProvid
2625

2726
@Nullable
2827
@Override
29-
public SearchLocalization determineRegion(@NotNull Continuation<? super SearchLocalization> continuation) {
28+
public SearchLocalization determineRegion(@NonNull Continuation<? super SearchLocalization> continuation) {
3029
return new SearchLocalization(mLanguage, mCountry, mRegion);
3130
}
3231
}

app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
import android.widget.FrameLayout;
1515

1616
import androidx.annotation.NonNull;
17+
import androidx.annotation.Nullable;
1718
import androidx.databinding.DataBindingUtil;
1819
import androidx.recyclerview.widget.LinearLayoutManager;
1920
import androidx.recyclerview.widget.RecyclerView;
2021

21-
import org.jetbrains.annotations.NotNull;
22-
import org.jetbrains.annotations.Nullable;
2322
import org.mozilla.geckoview.GeckoSessionSettings;
2423
import org.mozilla.vrbrowser.R;
2524
import org.mozilla.vrbrowser.VRBrowserActivity;
@@ -54,8 +53,6 @@
5453
import mozilla.components.service.fxa.sync.SyncReason;
5554
import mozilla.components.service.fxa.sync.SyncStatusObserver;
5655

57-
import static org.mozilla.vrbrowser.browser.BookmarksStoreKt.DESKTOP_ROOT;
58-
5956
public class BookmarksView extends FrameLayout implements BookmarksStore.BookmarkListener {
6057

6158
private static final String LOGTAG = SystemUtils.createLogtag(BookmarksView.class);
@@ -304,12 +301,12 @@ private void updateSyncBindings(boolean isSyncing) {
304301
private AccountObserver mAccountListener = new AccountObserver() {
305302

306303
@Override
307-
public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) {
304+
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
308305
mBinding.setIsSignedIn(true);
309306
}
310307

311308
@Override
312-
public void onProfileUpdated(@NotNull Profile profile) {
309+
public void onProfileUpdated(@NonNull Profile profile) {
313310
}
314311

315312
@Override

app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomInlineAutocompleteEditText.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import android.content.Context;
44
import android.util.AttributeSet;
55

6-
import org.jetbrains.annotations.NotNull;
7-
import org.jetbrains.annotations.Nullable;
6+
import androidx.annotation.NonNull;
7+
import androidx.annotation.Nullable;
88

99
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText;
1010

@@ -14,15 +14,15 @@ interface OnSelectionChangedCallback {
1414
void onSelectionChanged(int selectionStart, int selectionEnd);
1515
}
1616

17-
public CustomInlineAutocompleteEditText(@NotNull Context ctx, @Nullable AttributeSet attrs, int defStyleAttr) {
17+
public CustomInlineAutocompleteEditText(@NonNull Context ctx, @Nullable AttributeSet attrs, int defStyleAttr) {
1818
super(ctx, attrs, defStyleAttr);
1919
}
2020

21-
public CustomInlineAutocompleteEditText(@NotNull Context ctx, @Nullable AttributeSet attrs) {
21+
public CustomInlineAutocompleteEditText(@NonNull Context ctx, @Nullable AttributeSet attrs) {
2222
super(ctx, attrs);
2323
}
2424

25-
public CustomInlineAutocompleteEditText(@NotNull Context ctx) {
25+
public CustomInlineAutocompleteEditText(@NonNull Context ctx) {
2626
super(ctx);
2727
}
2828

app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
import android.widget.FrameLayout;
1515

1616
import androidx.annotation.NonNull;
17+
import androidx.annotation.Nullable;
1718
import androidx.databinding.DataBindingUtil;
1819
import androidx.recyclerview.widget.LinearLayoutManager;
1920
import androidx.recyclerview.widget.RecyclerView;
2021

21-
import org.jetbrains.annotations.NotNull;
22-
import org.jetbrains.annotations.Nullable;
2322
import org.mozilla.geckoview.GeckoSessionSettings;
2423
import org.mozilla.vrbrowser.R;
2524
import org.mozilla.vrbrowser.VRBrowserActivity;
@@ -299,12 +298,12 @@ private void updateSyncBindings(boolean isSyncing) {
299298
private AccountObserver mAccountListener = new AccountObserver() {
300299

301300
@Override
302-
public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) {
301+
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
303302
mBinding.setIsSignedIn(true);
304303
}
305304

306305
@Override
307-
public void onProfileUpdated(@NotNull Profile profile) {
306+
public void onProfileUpdated(@NonNull Profile profile) {
308307
}
309308

310309
@Override
@@ -318,7 +317,7 @@ public void onAuthenticationProblems() {
318317
}
319318
};
320319

321-
@NotNull
320+
@NonNull
322321
public static <T> Predicate<T> distinctByUrl(Function<? super T, ?> keyExtractor) {
323322
Set<Object> seen = ConcurrentHashMap.newKeySet();
324323
return t -> seen.add(keyExtractor.apply(t));

app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import android.widget.LinearLayout;
1212
import android.widget.TextView;
1313

14-
import org.jetbrains.annotations.NotNull;
14+
import androidx.annotation.NonNull;
15+
import androidx.annotation.StringRes;
16+
1517
import org.mozilla.vrbrowser.R;
1618
import org.mozilla.vrbrowser.audio.AudioEngine;
1719

18-
import androidx.annotation.StringRes;
19-
2020
public class SingleEditSetting extends LinearLayout {
2121

2222
private AudioEngine mAudio;
@@ -162,7 +162,7 @@ public boolean isEditing() {
162162
return mEdit1.getVisibility() == View.VISIBLE;
163163
}
164164

165-
public boolean contains(@NotNull View view) {
165+
public boolean contains(@NonNull View view) {
166166
return findViewById(view.getId()) == view;
167167
}
168168

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.mozilla.vrbrowser.browser.SessionChangeListener;
2626
import org.mozilla.vrbrowser.browser.engine.Session;
2727
import org.mozilla.vrbrowser.browser.engine.SessionStore;
28-
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
2928
import org.mozilla.vrbrowser.ui.views.UIButton;
3029
import org.mozilla.vrbrowser.ui.widgets.settings.SettingsWidget;
3130

@@ -388,7 +387,7 @@ public void toggleSettingsDialog() {
388387
toggleSettingsDialog(SettingsWidget.SettingDialog.MAIN);
389388
}
390389

391-
public void toggleSettingsDialog(SettingsWidget.SettingDialog settingDialog) {
390+
public void toggleSettingsDialog(@NonNull SettingsWidget.SettingDialog settingDialog) {
392391
UIWidget widget = getChild(mSettingsDialogHandle);
393392
if (widget == null) {
394393
widget = createChild(SettingsWidget.class, false);
@@ -405,6 +404,20 @@ public void toggleSettingsDialog(SettingsWidget.SettingDialog settingDialog) {
405404
}
406405
}
407406

407+
public void showSettingsDialog(@NonNull SettingsWidget.SettingDialog settingDialog) {
408+
UIWidget widget = getChild(mSettingsDialogHandle);
409+
if (widget == null) {
410+
widget = createChild(SettingsWidget.class, false);
411+
mSettingsDialogHandle = widget.getHandle();
412+
}
413+
414+
if (mAttachedWindow != null) {
415+
widget.getPlacement().parentHandle = mAttachedWindow.getHandle();
416+
}
417+
418+
((SettingsWidget)widget).show(REQUEST_FOCUS, settingDialog);
419+
}
420+
408421
public void setTrayVisible(boolean aVisible) {
409422
if (mTrayVisible != aVisible) {
410423
mTrayVisible = aVisible;

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import androidx.annotation.StringRes;
2828
import androidx.annotation.UiThread;
2929

30-
import org.jetbrains.annotations.NotNull;
3130
import org.mozilla.geckoview.GeckoResult;
3231
import org.mozilla.geckoview.GeckoSession;
3332
import org.mozilla.geckoview.PanZoomController;
@@ -1336,7 +1335,7 @@ private int getWindowWidth(float aWorldWidth) {
13361335
return (int) Math.floor(SettingsStore.WINDOW_WIDTH_DEFAULT * aWorldWidth / WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width));
13371336
}
13381337

1339-
private void showLibraryItemContextMenu(@NotNull View view, LibraryMenuWidget.LibraryContextMenuItem item, boolean isLastVisibleItem) {
1338+
private void showLibraryItemContextMenu(@NonNull View view, LibraryMenuWidget.LibraryContextMenuItem item, boolean isLastVisibleItem) {
13401339
view.requestFocusFromTouch();
13411340

13421341
hideContextMenus();
@@ -1408,7 +1407,7 @@ public void onRemoveFromBookmarks(LibraryMenuWidget.LibraryContextMenuItem item)
14081407

14091408
private BookmarksCallback mBookmarksListener = new BookmarksCallback() {
14101409
@Override
1411-
public void onShowContextMenu(@NonNull View view, @NotNull Bookmark item, boolean isLastVisibleItem) {
1410+
public void onShowContextMenu(@NonNull View view, @NonNull Bookmark item, boolean isLastVisibleItem) {
14121411
showLibraryItemContextMenu(
14131412
view,
14141413
new LibraryMenuWidget.LibraryContextMenuItem(
@@ -1420,7 +1419,7 @@ public void onShowContextMenu(@NonNull View view, @NotNull Bookmark item, boolea
14201419

14211420
@Override
14221421
public void onFxASynSettings(@NonNull View view) {
1423-
mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA);
1422+
mWidgetManager.getTray().showSettingsDialog(SettingsWidget.SettingDialog.FXA);
14241423
}
14251424

14261425
@Override
@@ -1459,7 +1458,7 @@ public void onShowContextMenu(@NonNull View view, @NonNull VisitInfo item, boole
14591458

14601459
@Override
14611460
public void onFxASynSettings(@NonNull View view) {
1462-
mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA);
1461+
mWidgetManager.getTray().showSettingsDialog(SettingsWidget.SettingDialog.FXA);
14631462
}
14641463

14651464
@Override

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.google.gson.GsonBuilder;
1111
import com.google.gson.reflect.TypeToken;
1212

13-
import org.jetbrains.annotations.NotNull;
1413
import org.mozilla.geckoview.GeckoSession;
1514
import org.mozilla.vrbrowser.R;
1615
import org.mozilla.vrbrowser.VRBrowserApplication;
@@ -893,30 +892,30 @@ public void onLoggedOut() {
893892
}
894893

895894
@Override
896-
public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) {
895+
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
897896
if (authType != AuthType.Existing.INSTANCE) {
898897
Session session = mFocusedWindow.getSession();
899898
addTab(mFocusedWindow, mAccounts.getConnectionSuccessURL());
900899
onTabsClose(new ArrayList<>(Collections.singletonList(session)));
901900

902901
switch (mAccounts.getLoginOrigin()) {
903902
case BOOKMARKS:
904-
getFocusedWindow().switchBookmarks();
903+
getFocusedWindow().showBookmarks();
905904
break;
906905

907906
case HISTORY:
908-
getFocusedWindow().switchHistory();
907+
getFocusedWindow().showHistory();
909908
break;
910909

911910
case SETTINGS:
912-
mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA);
911+
mWidgetManager.getTray().showSettingsDialog(SettingsWidget.SettingDialog.FXA);
913912
break;
914913
}
915914
}
916915
}
917916

918917
@Override
919-
public void onProfileUpdated(@NotNull Profile profile) {
918+
public void onProfileUpdated(@NonNull Profile profile) {
920919

921920
}
922921

@@ -1156,7 +1155,7 @@ public void addTab(WindowWidget targetWindow) {
11561155
addTab(targetWindow, null);
11571156
}
11581157

1159-
public void addTab(@NotNull WindowWidget targetWindow, @Nullable String aUri) {
1158+
public void addTab(@NonNull WindowWidget targetWindow, @Nullable String aUri) {
11601159
Session session = SessionStore.get().createSuspendedSession(aUri, targetWindow.getSession().isPrivateMode());
11611160
setFirstPaint(targetWindow, session);
11621161
targetWindow.getSession().setActive(false);
@@ -1244,7 +1243,7 @@ public void onTabsClose(ArrayList<Session> aTabs) {
12441243
}
12451244

12461245
@Override
1247-
public void onTabsReceived(@NotNull List<TabData> aTabs) {
1246+
public void onTabsReceived(@NonNull List<TabData> aTabs) {
12481247
WindowWidget targetWindow = mFocusedWindow;
12491248

12501249
boolean fullscreen = targetWindow.getSession().isInFullScreen();

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SendTabDialogWidget.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import androidx.annotation.Nullable;
1414
import androidx.databinding.DataBindingUtil;
1515

16-
import org.jetbrains.annotations.NotNull;
1716
import org.mozilla.vrbrowser.R;
1817
import org.mozilla.vrbrowser.VRBrowserApplication;
1918
import org.mozilla.vrbrowser.browser.Accounts;
@@ -147,7 +146,7 @@ private void showWhatsNewDialog() {
147146
// DeviceConstellationObserver
148147

149148
@Override
150-
public void onDevicesUpdate(@NotNull ConstellationState constellationState) {
149+
public void onDevicesUpdate(@NonNull ConstellationState constellationState) {
151150
post(() -> {
152151
mSendTabsDialogBinding.setIsSyncing(false);
153152

@@ -182,14 +181,14 @@ public void onLoggedOut() {
182181
}
183182

184183
@Override
185-
public void onAuthenticated(@NotNull OAuthAccount oAuthAccount, @NotNull AuthType authType) {
184+
public void onAuthenticated(@NonNull OAuthAccount oAuthAccount, @NonNull AuthType authType) {
186185
if (mAccounts.getLoginOrigin() == Accounts.LoginOrigin.SEND_TABS) {
187186
show(REQUEST_FOCUS);
188187
}
189188
}
190189

191190
@Override
192-
public void onProfileUpdated(@NotNull Profile profile) {
191+
public void onProfileUpdated(@NonNull Profile profile) {
193192

194193
}
195194

0 commit comments

Comments
 (0)