From f1e2c6f99cbcc660097143e961f5af17e9359f6d Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Mon, 12 Aug 2019 15:57:30 -0700 Subject: [PATCH] Add missing curly brackets to if statements --- .../mozilla/vrbrowser/VRBrowserActivity.java | 6 ++- .../browser/engine/SessionStack.java | 42 ++++++++++--------- .../vrbrowser/input/CustomKeyboard.java | 6 +-- .../suggestions/SuggestionsProvider.java | 12 ++++-- .../vrbrowser/telemetry/TelemetryWrapper.java | 15 ++++--- .../ui/adapters/LanguagesAdapter.java | 6 ++- .../ui/views/CustomKeyboardView.java | 21 +++++----- .../vrbrowser/ui/views/HoneycombButton.java | 6 ++- .../vrbrowser/ui/views/NavigationURLBar.java | 20 +++++---- .../mozilla/vrbrowser/ui/views/UIButton.java | 25 +++++++---- .../vrbrowser/ui/views/UITextButton.java | 9 ++-- .../vrbrowser/ui/views/VolumeControl.java | 3 +- .../vrbrowser/ui/widgets/MenuWidget.java | 3 +- .../ui/widgets/NavigationBarWidget.java | 13 +++--- .../ui/widgets/SuggestionsWidget.java | 22 ++++++---- .../vrbrowser/ui/widgets/TopBarWidget.java | 3 +- .../vrbrowser/ui/widgets/TrayWidget.java | 11 +++-- .../vrbrowser/ui/widgets/UIWidget.java | 3 +- .../vrbrowser/ui/widgets/WindowWidget.java | 25 +++++++---- .../mozilla/vrbrowser/ui/widgets/Windows.java | 35 +++++++++------- .../ui/widgets/dialogs/AppDialogWidget.java | 18 +++++--- .../ui/widgets/dialogs/ContextMenuWidget.java | 15 ++++--- .../ui/widgets/dialogs/VoiceSearchWidget.java | 16 ++++--- .../ui/widgets/prompts/AuthPromptWidget.java | 9 ++-- .../widgets/prompts/ChoicePromptWidget.java | 3 +- .../settings/DisplayLanguageOptionsView.java | 6 ++- .../widgets/settings/DisplayOptionsView.java | 3 +- .../ui/widgets/settings/SettingsFooter.java | 3 +- .../ui/widgets/settings/SettingsHeader.java | 8 ++-- .../ui/widgets/settings/SettingsView.java | 3 +- .../ui/widgets/settings/SettingsWidget.java | 5 ++- .../mozilla/vrbrowser/utils/LocaleUtils.java | 19 +++++---- .../mozilla/vrbrowser/utils/ViewUtils.java | 9 ++-- app/src/main/cpp/BrowserWorld.cpp | 9 ++-- 34 files changed, 248 insertions(+), 164 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 807854d39..a1bac5588 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -307,8 +307,9 @@ protected void onStart() { protected void onStop() { super.onStop(); - if (SettingsStore.getInstance(this).getCylinderDensity() > 0.0f) + if (SettingsStore.getInstance(this).getCylinderDensity() > 0.0f) { TelemetryWrapper.queueCurvedModeActiveEvent(); + } TelemetryWrapper.stop(); @@ -1286,8 +1287,9 @@ public void setCPULevel(int aCPULevel) { @Override public void openNewWindow(String uri) { WindowWidget newWindow = mWindows.addWindow(); - if (newWindow != null) + if (newWindow != null) { newWindow.getSessionStack().newSessionWithUrl(uri); + } } @Override diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStack.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStack.java index dcce4cb4f..986f33981 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStack.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStack.java @@ -446,8 +446,9 @@ public void newSessionWithUrl(String url) { private void stackSession(int sessionId) { int currentSessionId = getCurrentSessionId(); - if (currentSessionId != NO_SESSION) + if (currentSessionId != NO_SESSION) { pushSession(currentSessionId); + } setCurrentSession(sessionId); mCurrentSession = null; @@ -524,8 +525,9 @@ public void setCurrentSession(int aId) { } dumpAllState(mCurrentSession); - if (mCurrentSession != null) + if (mCurrentSession != null) { mCurrentSession.setActive(true); + } } public void setRegion(String aRegion) { @@ -750,9 +752,9 @@ public int getCurrentSessionId() { } public boolean isPrivateMode() { - if (mCurrentSession != null) + if (mCurrentSession != null) { return mCurrentSession.getSettings().getUsePrivateMode(); - + } return false; } @@ -1169,72 +1171,72 @@ public void onContentBlocked(@NonNull final GeckoSession session, @NonNull final @Nullable @Override public GeckoResult onAlertPrompt(@NonNull GeckoSession geckoSession, @NonNull AlertPrompt alertPrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onAlertPrompt(geckoSession, alertPrompt); - + } return GeckoResult.fromValue(alertPrompt.dismiss()); } @Nullable @Override public GeckoResult onButtonPrompt(@NonNull GeckoSession geckoSession, @NonNull ButtonPrompt buttonPrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onButtonPrompt(geckoSession, buttonPrompt); - + } return GeckoResult.fromValue(buttonPrompt.dismiss()); } @Nullable @Override public GeckoResult onTextPrompt(@NonNull GeckoSession geckoSession, @NonNull TextPrompt textPrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onTextPrompt(geckoSession, textPrompt); - + } return GeckoResult.fromValue(textPrompt.dismiss()); } @Nullable @Override public GeckoResult onAuthPrompt(@NonNull GeckoSession geckoSession, @NonNull AuthPrompt authPrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onAuthPrompt(geckoSession, authPrompt); - + } return GeckoResult.fromValue(authPrompt.dismiss()); } @Nullable @Override public GeckoResult onChoicePrompt(@NonNull GeckoSession geckoSession, @NonNull ChoicePrompt choicePrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onChoicePrompt(geckoSession, choicePrompt); - + } return GeckoResult.fromValue(choicePrompt.dismiss()); } @Nullable @Override public GeckoResult onColorPrompt(@NonNull GeckoSession geckoSession, @NonNull ColorPrompt colorPrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onColorPrompt(geckoSession, colorPrompt); - + } return GeckoResult.fromValue(colorPrompt.dismiss()); } @Nullable @Override public GeckoResult onDateTimePrompt(@NonNull GeckoSession geckoSession, @NonNull DateTimePrompt dateTimePrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onDateTimePrompt(geckoSession, dateTimePrompt); - + } return GeckoResult.fromValue(dateTimePrompt.dismiss()); } @Nullable @Override public GeckoResult onFilePrompt(@NonNull GeckoSession geckoSession, @NonNull FilePrompt filePrompt) { - if (mPromptDelegate != null) + if (mPromptDelegate != null) { return mPromptDelegate.onFilePrompt(geckoSession, filePrompt); - + } return GeckoResult.fromValue(filePrompt.dismiss()); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java b/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java index 7ca1e9ed6..29f9f3e82 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/input/CustomKeyboard.java @@ -72,8 +72,7 @@ public CustomKeyboard (Context context, int layoutTemplateResId, CharSequence ch final Key key = new Key(mRows[rowIndex]); - if (column >= maxColumns - || x + mDefaultWidth + horizontalPadding > mDisplayWidth) { + if (column >= maxColumns || x + mDefaultWidth + horizontalPadding > mDisplayWidth) { mRows[rowIndex].rowEdgeFlags = EDGE_BOTTOM; @@ -103,8 +102,9 @@ public CustomKeyboard (Context context, int layoutTemplateResId, CharSequence ch } for (Row row : mRows) { - if (rows != null) + if (rows != null) { rows.add(row); + } } setParentField(this, "mTotalHeight", y + mDefaultHeight); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/search/suggestions/SuggestionsProvider.java b/app/src/common/shared/org/mozilla/vrbrowser/search/suggestions/SuggestionsProvider.java index a732c7e5c..5b2bcbac6 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/search/suggestions/SuggestionsProvider.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/search/suggestions/SuggestionsProvider.java @@ -27,8 +27,9 @@ public int compare(Object obj1, Object obj2) { } else if (suggestion1.type == suggestion2.type) { if (mFilterText != null) { - if (suggestion1.title != null && suggestion2.title != null) + if (suggestion1.title != null && suggestion2.title != null) { return suggestion1.title.toLowerCase().indexOf(mFilterText) - suggestion2.title.toLowerCase().indexOf(mFilterText); + } return suggestion1.url.toLowerCase().indexOf(mFilterText) - suggestion2.url.indexOf(mFilterText); } else { @@ -85,8 +86,9 @@ public CompletableFuture> getBookmarkSuggestions(@NonNull L null, Type.BOOKMARK ))); - if (mComparator != null) + if (mComparator != null) { items.sort(mComparator); + } future.complete(items); }); @@ -105,8 +107,9 @@ public CompletableFuture> getHistorySuggestions(@NonNull fi null, Type.HISTORY ))); - if (mComparator != null) + if (mComparator != null) { items.sort(mComparator); + } future.complete(items); }); @@ -145,8 +148,9 @@ public CompletableFuture> getSearchEngineSuggestions(@NonNu Type.SUGGESTION )); }); - if (mComparator != null) + if (mComparator != null) { items.sort(mComparator); + } future.complete(items); }); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java b/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java index 66d07665b..e92101271 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java @@ -286,8 +286,9 @@ public static void uploadPageLoadToHistogram(String uri) { return; } - if (uri == null) + if (uri == null) { return; + } try { URI uriLink = URI.create(uri); @@ -546,8 +547,9 @@ private static void queueActiveWindowPctEvent() { for (long time : activePlacementTime) totalTime += time; - if (totalTime == 0) + if (totalTime == 0) { return; + } float[] pcts = new float[MAX_WINDOWS]; for (int index = 0; index< MAX_WINDOWS; index++) @@ -596,10 +598,12 @@ private static void queueOpenWindowsAvgEvent() { Log.d(LOGTAG, "\tPrivate: " + privateWM); for (int index = 0; index< MAX_WINDOWS; index++) { - if (openWindows[index] != 0) + if (openWindows[index] != 0) { openWindows[index] = 1; - if (openPrivateWindows[index] != 0) + } + if (openPrivateWindows[index] != 0) { openPrivateWindows[index] = 1; + } } } @@ -622,8 +626,9 @@ private static void queueOpenWindowsPctEvent() { for (long time : openPrivateWindowsTime) totalTime += time; - if (totalTime == 0) + if (totalTime == 0) { return; + } float[] pcts = new float[MAX_WINDOWS]; for (int index = 0; index< MAX_WINDOWS; index++) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/LanguagesAdapter.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/LanguagesAdapter.java index 863020fd8..8e5a3ee27 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/LanguagesAdapter.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/adapters/LanguagesAdapter.java @@ -153,13 +153,15 @@ public void onBindViewHolder(@NonNull LanguageViewHolder holder, int position) { } else if (holder.binding.add.getVisibility() == View.VISIBLE && ViewUtils.isInsideView(holder.binding.add, (int)event.getRawX(), (int)event.getRawY())) { - if (!language.isDefault() && !language.isPreferred()) + if (!language.isDefault() && !language.isPreferred()) { mLanguageItemCallback.onAdd(holder.binding.add, language); + } } else if (holder.binding.delete.getVisibility() == View.VISIBLE && ViewUtils.isInsideView(holder.binding.delete, (int)event.getRawX(), (int)event.getRawY())) { - if (!language.isDefault() && language.isPreferred()) + if (!language.isDefault() && language.isPreferred()) { mLanguageItemCallback.onRemove(holder.binding.delete, language); + } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomKeyboardView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomKeyboardView.java index e5ca2abe3..1f1d8456e 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomKeyboardView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomKeyboardView.java @@ -747,25 +747,22 @@ private void onBufferDraw() { boolean stateHovered = false; boolean statePressed = false; for (int state : drawableState) { - if (state == android.R.attr.state_hovered) + if (state == android.R.attr.state_hovered) { stateHovered = true; - else if (state == android.R.attr.state_pressed) + } else if (state == android.R.attr.state_pressed) { statePressed = true; + } } Drawable keyBackground = mKeyBackground; int columns = ((CustomKeyboard)mKeyboard).getMaxColums(); if (mFeaturedKeyBackground != null && mFeaturedKeyCodes.contains(key.codes[0])) { keyBackground = mFeaturedKeyBackground; - } else if ((i == columns && i == keyCount - 1) && mKeySingleBackground != null) { keyBackground = mKeySingleBackground; - } else if ((i == 0 || i == columns) && mKeyCapStartBackground != null) { keyBackground = mKeyCapStartBackground; - } else if ((i == keyCount - 1 || i == columns - 1)&& mKeyCapEndBackground != null) { keyBackground = mKeyCapEndBackground; - } keyBackground.setState(drawableState); @@ -938,8 +935,9 @@ private void detectAndSendKey(int index, int x, int y, long eventTime) { } code = key.codes[mTapCount]; - if (mKeyboardActionListener != null) + if (mKeyboardActionListener != null) { mKeyboardActionListener.onMultiTap(key); + } } if (mKeyboardActionListener != null) { mKeyboardActionListener.onKey(code, codes, hasPopup); @@ -1218,8 +1216,9 @@ public boolean onHoverEvent(MotionEvent event) { if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) { int touchX = (int) event.getX() - getPaddingLeft(); int touchY = (int) event.getY() - getPaddingTop(); - if (touchY >= -mVerticalCorrection) + if (touchY >= -mVerticalCorrection) { touchY += mVerticalCorrection; + } keyIndex = getKeyIndices(touchX, touchY, null); } @@ -1245,8 +1244,9 @@ public void setFeaturedKeyBackground(int resId, int[] keyCodes) { private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) { int touchX = (int) me.getX() - getPaddingLeft(); int touchY = (int) me.getY() - getPaddingTop(); - if (touchY >= -mVerticalCorrection) + if (touchY >= -mVerticalCorrection) { touchY += mVerticalCorrection; + } final int action = me.getAction(); final long eventTime = me.getEventTime(); int keyIndex = getKeyIndices(touchX, touchY, null); @@ -1290,8 +1290,9 @@ private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) { mDownTime = me.getEventTime(); mLastMoveTime = mDownTime; checkMultiTap(eventTime, keyIndex); - if (mKeyboardActionListener != null) + if (mKeyboardActionListener != null) { mKeyboardActionListener.onPress(keyIndex != NOT_A_KEY ? mKeys[keyIndex].codes[0] : 0); + } if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) { mRepeatKeyIndex = mCurrentKey; Message msg = mHandler.obtainMessage(MSG_REPEAT); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HoneycombButton.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HoneycombButton.java index d8bde0ed8..344ad2f68 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HoneycombButton.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HoneycombButton.java @@ -82,8 +82,9 @@ private void initialize(Context aContext) { setClickable(true); mIcon = findViewById(R.id.settings_button_icon); - if (mIcon != null) + if (mIcon != null) { mIcon.setImageDrawable(mButtonIcon); + } mText = findViewById(R.id.settings_button_text); if (mText != null) { @@ -94,8 +95,9 @@ private void initialize(Context aContext) { } mSecondaryText = findViewById(R.id.settings_secondary_text); - if (mSecondaryText != null) + if (mSecondaryText != null) { mSecondaryText.setText(mSecondaryButtonText); + } setOnHoverListener((view, motionEvent) -> false); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index 1a644ae72..e9339de24 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -291,14 +291,15 @@ public void setURL(String aURL) { } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - if (aURL.startsWith("jar:")) + if (aURL.startsWith("jar:")) { return; - else if (aURL.startsWith("resource:") || mSessionStack.isHomeUri(aURL)) + } else if (aURL.startsWith("resource:") || mSessionStack.isHomeUri(aURL)) { aURL = ""; - else if (aURL.startsWith("data:") && mSessionStack.isPrivateMode()) + } else if (aURL.startsWith("data:") && mSessionStack.isPrivateMode()) { aURL = ""; - else + } else { index = aURL.indexOf("://"); + } // Update the URL bar only if the URL is different than the current one and // the URL bar is not focused to avoid override user input @@ -413,8 +414,7 @@ private void syncViews() { mLoadingView.setVisibility(mIsLoading ? View.VISIBLE : View.GONE); mInsecureIcon.setVisibility(!mIsLoading && mIsInsecure ? View.VISIBLE : View.GONE); leftPadding = mURLLeftContainer.getMeasuredWidth(); - } - else { + } else { mURLLeftContainer.setVisibility(View.GONE); mLoadingView.setVisibility(View.GONE); mInsecureIcon.setVisibility(View.GONE); @@ -469,10 +469,11 @@ public void handleURLEdit(String text) { } public void setPrivateMode(boolean isEnabled) { - if (isEnabled) + if (isEnabled) { mURL.setBackground(getContext().getDrawable(R.drawable.url_background_private)); - else + } else { mURL.setBackground(getContext().getDrawable(R.drawable.url_background)); + } } @Override @@ -487,8 +488,9 @@ public void setClickable(boolean clickable) { } view.requestFocusFromTouch(); - if (mDelegate != null) + if (mDelegate != null) { mDelegate.OnVoiceSearchClicked(); + } TelemetryWrapper.voiceInputEvent(); }; diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java index 88ba1f7f3..0c416b005 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UIButton.java @@ -76,21 +76,24 @@ public UIButton(Context context, AttributeSet attrs, int defStyleAttr) { @TargetApi(Build.VERSION_CODES.O) public String getTooltip() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return mTooltipText; - else + } else { return getTooltipText() == null ? null : getTooltipText().toString(); + } } @TargetApi(Build.VERSION_CODES.O) public void setTooltip(String text) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { mTooltipText = text; - else + } else { setTooltipText(text); + } - if (mTooltipView != null && mTooltipView.isVisible()) + if (mTooltipView != null && mTooltipView.isVisible()) { mTooltipView.setText(text); + } } @Override @@ -156,8 +159,9 @@ public boolean isPrivate() { private void setPrivate() { mState = State.PRIVATE; - if (mPrivateModeBackground != null) + if (mPrivateModeBackground != null) { setBackground(mPrivateModeBackground); + } if (mPrivateModeTintColorListRes != 0) { setTintColorList(mPrivateModeTintColorListRes); @@ -166,8 +170,9 @@ private void setPrivate() { private void setNormal() { mState = State.NORMAL; - if (mBackground != null) + if (mBackground != null) { setBackground(mBackground); + } if(mTintColorListRes != 0) { setTintColorList(mTintColorListRes); @@ -176,8 +181,9 @@ private void setNormal() { private void setActive() { mState = State.ACTIVE; - if (mActiveModeBackground != null) + if (mActiveModeBackground != null) { setBackground(mActiveModeBackground); + } if (mActiveModeTintColorListRes != 0) { setTintColorList(mActiveModeTintColorListRes); @@ -187,8 +193,9 @@ private void setActive() { private Runnable mShowTooltipRunnable = new Runnable() { @Override public void run() { - if (mTooltipView != null && mTooltipView.isVisible()) + if (mTooltipView != null && mTooltipView.isVisible()) { return; + } mTooltipView = new TooltipWidget(getContext()); mTooltipView.setText(getTooltip()); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UITextButton.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UITextButton.java index 8e36fdc81..49ea5b4a1 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UITextButton.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/UITextButton.java @@ -131,8 +131,9 @@ public boolean isPrivate() { private void setPrivate() { mState = State.PRIVATE; - if (mPrivateModeBackground != null) + if (mPrivateModeBackground != null) { setBackground(mPrivateModeBackground); + } if (mPrivateModeTintColorListRes != 0) { setTintColorList(mPrivateModeTintColorListRes); @@ -141,8 +142,9 @@ private void setPrivate() { private void setNormal() { mState = State.NORMAL; - if (mBackground != null) + if (mBackground != null) { setBackground(mBackground); + } if(mTintColorListRes != 0) { setTintColorList(mTintColorListRes); @@ -151,8 +153,9 @@ private void setNormal() { private void setActive() { mState = State.ACTIVE; - if (mActiveModeBackground != null) + if (mActiveModeBackground != null) { setBackground(mActiveModeBackground); + } if (mActiveModeTintColorListRes != 0) { setTintColorList(mActiveModeTintColorListRes); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/VolumeControl.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/VolumeControl.java index 82e383750..55e9901ea 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/VolumeControl.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/VolumeControl.java @@ -66,8 +66,7 @@ public void setMuted(boolean aMuted) { mMuted = aMuted; if (mMuted && !mTouching) { mSeekBar.setProgress(0); - } - else if (!mMuted) { + } else if (!mMuted) { updateProgress(); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MenuWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MenuWidget.java index 4e723c948..89c7ef19d 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MenuWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MenuWidget.java @@ -149,8 +149,9 @@ public View getView(int position, View convertView, ViewGroup parent) { @Override public boolean onHover(View view, MotionEvent event) { int position = (int)view.getTag(R.string.position_tag); - if (!isEnabled(position)) + if (!isEnabled(position)) { return false; + } TextView label = view.findViewById(R.id.listItemText); ImageView image = view.findViewById(R.id.listItemImage); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index c1401916b..db0f9e284 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -149,8 +149,9 @@ private void initialize(@NonNull Context aContext) { mBackButton.setOnClickListener(v -> { v.requestFocusFromTouch(); - if (mSessionStack.canGoBack()) + if (mSessionStack.canGoBack()) { mSessionStack.goBack(); + } if (mAudio != null) { mAudio.playSound(AudioEngine.Sound.BACK); @@ -384,8 +385,9 @@ public void detachFromWindow() { mSessionStack.removeContentListener(this); mSessionStack = null; } - if (mAttachedWindow != null) + if (mAttachedWindow != null) { mAttachedWindow.removeBookmarksListener(this); + } mAttachedWindow = null; } @@ -576,8 +578,9 @@ private void exitResizeMode(ResizeAction aResizeAction) { mWidgetManager.setTrayVisible(!mIsInFullScreenMode); closeFloatingMenus(); - if (aResizeAction == ResizeAction.KEEP_SIZE) + if (aResizeAction == ResizeAction.KEEP_SIZE) { TelemetryWrapper.windowsResizeEvent(); + } } private void enterVRVideo(@VideoProjectionMenuWidget.VideoProjectionFlags int aProjection) { @@ -740,8 +743,8 @@ public void onCanGoForward(GeckoSession aSession, boolean canGoForward) { final GeckoResult result = new GeckoResult<>(); Uri uri = Uri.parse(aRequest.uri); - if ("file".equalsIgnoreCase(uri.getScheme()) - && !mWidgetManager.isPermissionGranted(android.Manifest.permission.READ_EXTERNAL_STORAGE)) { + if ("file".equalsIgnoreCase(uri.getScheme()) && + !mWidgetManager.isPermissionGranted(android.Manifest.permission.READ_EXTERNAL_STORAGE)) { mWidgetManager.requestPermission( aRequest.uri, android.Manifest.permission.READ_EXTERNAL_STORAGE, diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/SuggestionsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/SuggestionsWidget.java index b57f53172..f6f414fc9 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/SuggestionsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/SuggestionsWidget.java @@ -202,7 +202,7 @@ public View getView(int position, View convertView, ViewGroup parent) { View listItem = convertView; ItemViewHolder itemViewHolder; - if(listItem == null) { + if (listItem == null) { listItem = LayoutInflater.from(getContext()).inflate(R.layout.list_popup_window_item, parent, false); itemViewHolder = new ItemViewHolder(); @@ -253,22 +253,24 @@ public View getView(int position, View convertView, ViewGroup parent) { } // Type related - if (selectedItem.type == SuggestionItem.Type.SUGGESTION) + if (selectedItem.type == SuggestionItem.Type.SUGGESTION) { itemViewHolder.favicon.setImageResource(R.drawable.ic_icon_search); - else if (selectedItem.type == SuggestionItem.Type.COMPLETION) + } else if (selectedItem.type == SuggestionItem.Type.COMPLETION) { itemViewHolder.favicon.setImageResource(R.drawable.ic_icon_globe); - else if (selectedItem.type == SuggestionItem.Type.HISTORY) + } else if(selectedItem.type ==SuggestionItem.Type.HISTORY) { itemViewHolder.favicon.setImageResource(R.drawable.ic_icon_history); - else if (selectedItem.type == SuggestionItem.Type.BOOKMARK) + } else if (selectedItem.type == SuggestionItem.Type.BOOKMARK) { itemViewHolder.favicon.setImageResource(R.drawable.ic_icon_bookmark); + } itemViewHolder.delete.setVisibility(GONE); itemViewHolder.favicon.setVisibility(VISIBLE); - if (position == 0) + if (position == 0) { itemViewHolder.divider.setVisibility(VISIBLE); - else + } else { itemViewHolder.divider.setVisibility(GONE); + } return listItem; } @@ -307,8 +309,9 @@ else if (selectedItem.type == SuggestionItem.Type.BOOKMARK) private OnTouchListener mTouchListener = (view, event) -> { int position = (int)view.getTag(R.string.position_tag); - if (!isEnabled(position)) + if (!isEnabled(position)) { return false; + } int ev = event.getActionMasked(); switch (ev) { @@ -327,8 +330,9 @@ else if (selectedItem.type == SuggestionItem.Type.BOOKMARK) private OnHoverListener mHoverListener = (view, motionEvent) -> { int position = (int)view.getTag(R.string.position_tag); - if (!isEnabled(position)) + if (!isEnabled(position)) { return false; + } View favicon = view.findViewById(R.id.favicon); TextView title = view.findViewById(R.id.title); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java index 3b3275f7d..6202262ce 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java @@ -159,8 +159,7 @@ public void setVisible(boolean aIsVisible) { if (aIsVisible) { mWidgetManager.addWidget(this); - } - else { + } else { mWidgetManager.removeWidget(this); } } 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 069889b5a..c1626ee01 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 @@ -89,8 +89,9 @@ private void initialize(Context aContext) { } toggleSettingsDialog(); - if (isDialogOpened(mSettingsDialogHandle)) + if (isDialogOpened(mSettingsDialogHandle)) { view.requestFocusFromTouch(); + } }); mBookmarksButton = findViewById(R.id.bookmarksButton); @@ -263,8 +264,9 @@ public void detachFromWindow() { mSessionStack.removeSessionChangeListener(this); mSessionStack = null; } - if (mAttachedWindow != null) + if (mAttachedWindow != null) { mAttachedWindow.removeBookmarksListener(this); + } } @Override @@ -283,10 +285,11 @@ public void attachToWindow(@NonNull WindowWidget aWindow) { handleSessionState(); } - if (mAttachedWindow.isBookmarksVisible()) + if (mAttachedWindow.isBookmarksVisible()) { onBookmarksShown(aWindow); - else + } else { onBookmarksHidden(aWindow); + } } // SessionStack.SessionChangeListener diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java index fae38dfb0..cd1acb14d 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java @@ -310,8 +310,9 @@ public void hide(@HideFlags int aHideFlags) { @Override public boolean isVisible() { for (UIWidget child : mChildren.values()) { - if (child.isVisible()) + if (child.isVisible()) { return true; + } } return mWidgetPlacement.visible; 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 1200c32f2..713ecb2c0 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 @@ -191,8 +191,9 @@ public void close() { } public void loadHomeIfNotRestored() { - if (!mIsRestored) + if (!mIsRestored) { loadHome(); + } } public void loadHome() { @@ -336,13 +337,15 @@ public void disableVRVideoMode() { } public void setWindowPlacement(@NonNull Windows.WindowPlacement aPlacement) { - if (mActive) + if (mActive) { TelemetryWrapper.activePlacementEvent(mWindowPlacement.getValue(), false); + } mWindowPlacement = aPlacement; - if (mActive) + if (mActive) { TelemetryWrapper.activePlacementEvent(mWindowPlacement.getValue(), true); + } } public @NonNull Windows.WindowPlacement getWindowPlacement() { @@ -451,8 +454,9 @@ public void setSurface(Surface aSurface, final int aWidth, final int aHeight, Ru } private void callSurfaceChanged() { - if (mDisplay != null) + if (mDisplay != null) { mDisplay.surfaceChanged(mSurface, mBorderWidth, mBorderWidth, mWidth - mBorderWidth * 2, mHeight - mBorderWidth * 2); + } } @Override @@ -611,10 +615,11 @@ public void onCurrentSessionChange(GeckoSession aSession, int aId) { aSession.getTextInput().setView(this); boolean isPrivateMode = aSession.getSettings().getUsePrivateMode(); - if (isPrivateMode) + if (isPrivateMode) { setPrivateBrowsingEnabled(true); - else + } else { setPrivateBrowsingEnabled(false); + } } // View @@ -965,17 +970,19 @@ public void onVideoAvailabilityChanged(boolean aVideosAvailable) { @Override public void onLocationChange(@NonNull GeckoSession session, @Nullable String url) { - if (isBookmarksVisible()) + if (isBookmarksVisible()) { switchBookmarks(); + } } @Nullable @Override public GeckoResult onLoadRequest(@NonNull GeckoSession session, @NonNull LoadRequest request) { - if (request.isRedirect) + if (request.isRedirect) { SessionStore.get().getHistoryStore().addHistory(request.uri, VisitType.EMBED); - else if (request.triggerUri != null) + } else if (request.triggerUri != null) { SessionStore.get().getHistoryStore().addHistory(request.uri, VisitType.LINK); + } return GeckoResult.ALLOW; } 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 328810c2d..f50f37c13 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 @@ -133,10 +133,11 @@ private WindowsState restoreState() { } finally { boolean deleted = file.delete(); - if (deleted) + if (deleted) { Log.d(getClass().getCanonicalName(), "Persistent windows state successfully restored"); - else + } else { Log.d(getClass().getCanonicalName(), "Persistent window state couldn't be deleted"); + } } return restored; @@ -258,8 +259,9 @@ public void closeWindow(@NonNull WindowWidget aWindow) { } else if (empty) { // Ensure that there is at least one window. WindowWidget window = addWindow(); - if (window != null) + if (window != null) { window.loadHome(); + } } updateViews(); @@ -307,8 +309,9 @@ public void focusWindow(@NonNull WindowWidget aWindow) { if (aWindow != mFocusedWindow) { WindowWidget prev = mFocusedWindow; mFocusedWindow = aWindow; - if (prev != null) + if (prev != null) { prev.setActiveWindow(false); + } mFocusedWindow.setActiveWindow(true); if (mDelegate != null) { mDelegate.onFocusedWindowChanged(mFocusedWindow, prev); @@ -367,8 +370,9 @@ public void enterPrivateMode() { if (mPrivateWindows.size() == 0) { WindowWidget window = addWindow(); - if (window != null) + if (window != null) { window.loadHome(); + } } else { focusWindow(getFrontWindow()); @@ -501,10 +505,11 @@ private void removeWindow(@NonNull WindowWidget aWindow) { updateMaxWindowScales(); updateCurvedMode(); - if (aWindow.getSessionStack().isPrivateMode()) - TelemetryWrapper.openWindowsEvent(mPrivateWindows.size()+1, mPrivateWindows.size(), true); - else - TelemetryWrapper.openWindowsEvent(mRegularWindows.size()+1, mRegularWindows.size(), false); + if (aWindow.getSessionStack().isPrivateMode()) { + TelemetryWrapper.openWindowsEvent(mPrivateWindows.size() + 1, mPrivateWindows.size(), true); + } else { + TelemetryWrapper.openWindowsEvent(mRegularWindows.size() + 1, mRegularWindows.size(), false); + } } private void setWindowVisible(@NonNull WindowWidget aWindow, boolean aVisible) { @@ -629,10 +634,11 @@ private WindowWidget createWindow() { window.getTopBar().setDelegate(this); window.getSessionStack().addContentListener(this); - if (mPrivateMode) - TelemetryWrapper.openWindowsEvent(mPrivateWindows.size()-1, mPrivateWindows.size(), true); - else - TelemetryWrapper.openWindowsEvent(mRegularWindows.size()-1, mRegularWindows.size(), false); + if (mPrivateMode) { + TelemetryWrapper.openWindowsEvent(mPrivateWindows.size() - 1, mPrivateWindows.size(), true); + } else { + TelemetryWrapper.openWindowsEvent(mRegularWindows.size() - 1, mRegularWindows.size(), false); + } return window; } @@ -656,8 +662,9 @@ public void onPrivateBrowsingClicked() { @Override public void onAddWindowClicked() { WindowWidget window = addWindow(); - if (window != null) + if (window != null) { window.loadHome(); + } } // TopBarWidget Delegate diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/AppDialogWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/AppDialogWidget.java index 55d8deee1..2364bc758 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/AppDialogWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/AppDialogWidget.java @@ -56,14 +56,16 @@ private void initialize(Context aContext) { mBinding = DataBindingUtil.inflate(inflater, R.layout.app_dialog, this, true); mBinding.leftButton.setOnClickListener(v -> { - if (mAppDialogDelegate != null) + if (mAppDialogDelegate != null) { mAppDialogDelegate.onButtonClicked(LEFT); + } AppDialogWidget.this.onDismiss(); }); mBinding.rightButton.setOnClickListener(v -> { - if (mAppDialogDelegate != null) + if (mAppDialogDelegate != null) { mAppDialogDelegate.onButtonClicked(RIGHT); + } AppDialogWidget.this.onDismiss(); }); @@ -143,17 +145,21 @@ public void setMessage(String message) { } public void setButtons(@StringRes int[] buttons) { - if (buttons.length > 0) + if (buttons.length > 0) { mBinding.leftButton.setText(buttons[LEFT]); - if (buttons.length > 1) + } + if (buttons.length > 1) { mBinding.rightButton.setText(buttons[RIGHT]); + } } public void setButtons(@NonNull String[] buttons) { - if (buttons.length > 0) + if (buttons.length > 0) { mBinding.leftButton.setText(buttons[LEFT]); - if (buttons.length > 1) + } + if (buttons.length > 1) { mBinding.rightButton.setText(buttons[RIGHT]); + } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/ContextMenuWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/ContextMenuWidget.java index 9c66d1511..71ce7ce45 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/ContextMenuWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/ContextMenuWidget.java @@ -145,28 +145,31 @@ private PointF anchorForCurrentMousePosition() { float halfWidth = WidgetPlacement.convertPixelsToDp(getContext(), getWidth()); float halfHeight = WidgetPlacement.convertPixelsToDp(getContext(), getHeight()); if (mMousePos.x > (browserWindowWidth - halfWidth)) { - if (mMousePos.y < halfHeight) + if (mMousePos.y < halfHeight) { // Top Right return new PointF(1.0f, 1.0f); - else + } else { // Middle/Bottom Right return new PointF(1.0f, 0.0f); + } } else if (mMousePos.x < (browserWindowWidth + halfWidth)) { - if (mMousePos.y < halfHeight) + if (mMousePos.y < halfHeight) { // Top Left return new PointF(0.0f, 1.0f); - else + } else { // Middle/Bottom Left new PointF(0.0f, 0.0f); + } } else { - if (mMousePos.y < halfHeight) + if (mMousePos.y < halfHeight) { // Top Middle return new PointF(1.0f, 1.0f); - else if (mMousePos.y > (browserWindowHeight - halfHeight)) + } else if (mMousePos.y > (browserWindowHeight - halfHeight)) { // Bottom Middle return new PointF(0.0f, 0.0f); + } } return new PointF(0.0f, 0.0f); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/VoiceSearchWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/VoiceSearchWidget.java index a62d501e1..7806098db 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/VoiceSearchWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/VoiceSearchWidget.java @@ -187,8 +187,9 @@ public void onSpeechStatusChanged(final MozillaSpeechService.SpeechState aState, Log.d(LOGTAG, "===> STT_RESULT"); String transcription = ((STTResult)aPayload).mTranscription; float confidence = ((STTResult)aPayload).mConfidence; - if (mDelegate != null) + if (mDelegate != null) { mDelegate.OnVoiceSearchResult(transcription, confidence); + } hide(REMOVE_WIDGET); break; case START_LISTEN: @@ -204,15 +205,17 @@ public void onSpeechStatusChanged(final MozillaSpeechService.SpeechState aState, // Handle when a cancelation was fully executed Log.d(LOGTAG, "===> CANCELED"); setResultState(); - if (mDelegate != null) + if (mDelegate != null) { mDelegate.OnVoiceSearchCanceled(); + } break; case ERROR: Log.d(LOGTAG, "===> ERROR: " + aPayload.toString()); setResultState(); // Handle when any error occurred - if (mDelegate != null) + if (mDelegate != null) { mDelegate.OnVoiceSearchError(); + } break; default: break; @@ -222,16 +225,17 @@ public void onSpeechStatusChanged(final MozillaSpeechService.SpeechState aState, }; public void startVoiceSearch() { - if (ActivityCompat.checkSelfPermission(getContext().getApplicationContext(), Manifest.permission.RECORD_AUDIO) - != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.checkSelfPermission(getContext().getApplicationContext(), Manifest.permission.RECORD_AUDIO) != + PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions((Activity)getContext(), new String[]{Manifest.permission.RECORD_AUDIO}, VOICESEARCH_AUDIO_REQUEST_CODE); } else { String locale = LocaleUtils.getVoiceSearchLocale(getContext()); mMozillaSpeechService.setLanguage(LocaleUtils.mapToMozillaSpeechLocales(locale)); boolean storeData = SettingsStore.getInstance(getContext()).isSpeechDataCollectionEnabled(); - if (SessionStore.get().getActiveStore().isPrivateMode()) + if (SessionStore.get().getActiveStore().isPrivateMode()) { storeData = false; + } mMozillaSpeechService.storeSamples(storeData); mMozillaSpeechService.storeTranscriptions(storeData); mMozillaSpeechService.start(getContext().getApplicationContext()); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/AuthPromptWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/AuthPromptWidget.java index 704978840..dd8c882f0 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/AuthPromptWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/AuthPromptWidget.java @@ -66,10 +66,11 @@ protected void initialize(Context aContext) { } if (mPromptDelegate != null && mPromptDelegate instanceof AuthPromptDelegate) { - if (mUsernameText.getVisibility() == VISIBLE) - ((AuthPromptDelegate)mPromptDelegate).confirm(mUsernameText.getText().toString(), mPasswordText.getText().toString()); - else - ((AuthPromptDelegate)mPromptDelegate).confirm(mPasswordText.getText().toString()); + if (mUsernameText.getVisibility() == VISIBLE) { + ((AuthPromptDelegate) mPromptDelegate).confirm(mUsernameText.getText().toString(), mPasswordText.getText().toString()); + } else { + ((AuthPromptDelegate) mPromptDelegate).confirm(mPasswordText.getText().toString()); + } } hide(REMOVE_WIDGET); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/ChoicePromptWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/ChoicePromptWidget.java index e09061226..6a391c332 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/ChoicePromptWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/ChoicePromptWidget.java @@ -299,8 +299,9 @@ public View getView(int position, View convertView, ViewGroup parent) { private OnHoverListener mHoverListener = (view, motionEvent) -> { int position = (int)view.getTag(R.string.position_tag); - if (!isEnabled(position)) + if (!isEnabled(position)) { return false; + } TextView label = view.findViewById(R.id.optionLabel); RadioButton check = view.findViewById(R.id.radioOption); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayLanguageOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayLanguageOptionsView.java index 637d9eed2..ce7c7f89b 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayLanguageOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayLanguageOptionsView.java @@ -71,8 +71,9 @@ protected boolean reset() { String currentLocale = LocaleUtils.getCurrentLocale(); String locale = mBinding.languageRadio.getValueForId(mBinding.languageRadio.getCheckedRadioButtonId()).toString(); - if (!locale.equalsIgnoreCase(currentLocale)) + if (!locale.equalsIgnoreCase(currentLocale)) { setLanguage(checkedId, true); + } }; private OnClickListener mResetListener = (view) -> { @@ -88,8 +89,9 @@ private void setLanguage(int checkedId, boolean doApply) { String language = mBinding.languageRadio.getValueForId(checkedId).toString(); LocaleUtils.setDisplayLocale(getContext(), language); - if (mDelegate != null) + if (mDelegate != null) { mDelegate.showRestartDialog(); + } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java index fd2087a5d..32f8805db 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java @@ -278,8 +278,9 @@ public boolean isEditing() { setAutoplay(SettingsStore.AUTOPLAY_ENABLED, true); setCurvedDisplay(false, true); - if (restart) + if (restart) { showRestartDialog(); + } }; private void setCurvedDisplay(boolean value, boolean doApply) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsFooter.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsFooter.java index 60fb8c51c..275439351 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsFooter.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsFooter.java @@ -57,8 +57,9 @@ private void initialize(@NonNull Context aContext, @NonNull TypedArray attribute if (attributes != null) { String description = attributes.getString(R.styleable.SettingsFooter_description); - if (description != null) + if (description != null) { mBinding.setDescription(description); + } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsHeader.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsHeader.java index 9a7966ff9..b32a81774 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsHeader.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsHeader.java @@ -59,13 +59,15 @@ private void initialize(@NonNull Context aContext, @NonNull TypedArray attribute String description = attributes.getString(R.styleable.SettingsHeader_description); int helpVisibility = attributes.getInt(R.styleable.SettingsHeader_helpVisibility, VISIBLE); - if (title != null) + if (title != null) { mBinding.setTitle(title); + } - if (description != null) + if (description != null) { mBinding.setDescription(description); - else + } else { mBinding.displayLanguageDescription.setVisibility(View.GONE); + } mBinding.setHelpVisibility(helpVisibility); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java index 60fa34c22..3cb4edb3c 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/SettingsView.java @@ -63,8 +63,9 @@ protected boolean isVisible() { } public void onShown() { - if (mScrollbar != null) + if (mScrollbar != null) { mScrollbar.fullScroll(ScrollView.FOCUS_UP); + } setFocusableInTouchMode(true); requestFocusFromTouch(); 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 c3c76fbf8..a6c050f92 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 @@ -373,10 +373,11 @@ public void onWorldClick() { public void onDismiss() { if (mCurrentView != null) { if (!mCurrentView.isEditing()) { - if (isLanguagesSubView(mCurrentView)) + if (isLanguagesSubView(mCurrentView)) { showLanguageOptionsDialog(); - else + } else { showView(null); + } } } else { super.onDismiss(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/utils/LocaleUtils.java b/app/src/common/shared/org/mozilla/vrbrowser/utils/LocaleUtils.java index 6621eb90f..8ed0ae45f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/utils/LocaleUtils.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/utils/LocaleUtils.java @@ -49,8 +49,9 @@ public static String getCurrentLocale() { } private static HashMap getAllLanguages() { - if (mLanguagesCache != null) + if (mLanguagesCache != null) { return mLanguagesCache; + } String currentLocale = getCurrentLocale(); Locale[] locales = Locale.getAvailableLocales(); @@ -59,8 +60,9 @@ private static HashMap getAllLanguages() { String languageId = temp.toLanguageTag(); String displayName = temp.getDisplayName().substring(0, 1).toUpperCase() + temp.getDisplayName().substring(1); Language locale = new Language(languageId, displayName + " [" + languageId + "]"); - if (languageId.equals(currentLocale)) + if (languageId.equals(currentLocale)) { locale.setDefault(true); + } mLanguagesCache.put(languageId, locale); } @@ -97,8 +99,9 @@ public static List getPreferredLanguages(@NonNull Context aContext) { preferredLanguages.add(lang); } - if (!savedLanguages.stream().anyMatch(str -> str.trim().equals(getCurrentLocale()))) + if (!savedLanguages.stream().anyMatch(str -> str.trim().equals(getCurrentLocale()))) { preferredLanguages.add(getCurrentLocaleLanguage()); + } return preferredLanguages; } @@ -204,19 +207,21 @@ public static Locale getLocale(@NonNull Resources res) { } public static String mapOldLocaleToNew(@NonNull String locale) { - if (locale.equalsIgnoreCase("cmn-Hant-TW")) + if (locale.equalsIgnoreCase("cmn-Hant-TW")) { locale = "zh-Hant-TW"; - else if (locale.equalsIgnoreCase("cmn-Hans-CN")) + } else if (locale.equalsIgnoreCase("cmn-Hans-CN")) { locale = "zh-Hans-CN"; + } return locale; } public static String mapToMozillaSpeechLocales(@NonNull String locale) { - if (locale.equalsIgnoreCase("zh-Hant-TW")) + if (locale.equalsIgnoreCase("zh-Hant-TW")) { locale = "cmn-Hant-TW"; - else if (locale.equalsIgnoreCase("zh-Hans-CN")) + } else if (locale.equalsIgnoreCase("zh-Hans-CN")) { locale = "cmn-Hans-CN"; + } return locale; } 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 595641f57..7627b19db 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/utils/ViewUtils.java @@ -67,8 +67,9 @@ public static TooltipPosition fromId(int id) { } public static UIWidget getParentWidget(@NonNull View view) { - if (view == null) + if (view == null) { return null; + } ViewParent v = view.getParent(); if (v instanceof UIWidget) { @@ -91,11 +92,13 @@ public static Spanned getSpannedText(String text) { } public static boolean isChildrenOf(@NonNull View parent, @NonNull View view) { - if (parent == null || view == null) + if (parent == null || view == null) { return false; + } - if (!(parent instanceof ViewGroup)) + if (!(parent instanceof ViewGroup)) { return false; + } return parent.findViewById(view.getId()) != null; } diff --git a/app/src/main/cpp/BrowserWorld.cpp b/app/src/main/cpp/BrowserWorld.cpp index dd66551b0..30e791d84 100644 --- a/app/src/main/cpp/BrowserWorld.cpp +++ b/app/src/main/cpp/BrowserWorld.cpp @@ -443,8 +443,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) { hitWidget->GetWorldSize(width, height); VRBrowser::HandleResize(hitWidget->GetHandle(), width, height); } - } - else if (hitWidget) { + } else if (hitWidget) { float theX = 0.0f, theY = 0.0f; hitWidget->ConvertToWidgetCoordinates(hitPoint, theX, theY); const uint32_t handle = hitWidget->GetHandle(); @@ -751,8 +750,7 @@ BrowserWorld::Draw() { m.CheckExitImmersive(); if (m.splashAnimation) { DrawSplashAnimation(); - } - else if (m.externalVR->IsPresenting()) { + } else if (m.externalVR->IsPresenting()) { m.CheckBackButton(); DrawImmersive(); } else { @@ -814,8 +812,9 @@ BrowserWorld::UpdatePointerColor() { int32_t color = VRBrowser::GetPointerColor(); VRB_LOG("Setting pointer color to: %d:", color); - if (m.controllers) + if (m.controllers) { m.controllers->SetPointerColor(vrb::Color(color)); + } } void