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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
wip
  • Loading branch information
keianhzo committed Oct 12, 2018
1 parent e6f95df commit e85881e
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,8 @@ public void reject() {
}
}
}

public boolean isPermissionDialogVisible() {
return mPermissionWidget != null && mPermissionWidget.isVisible();
}
}
17 changes: 13 additions & 4 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.mozilla.vrbrowser.ui.RootWidget;
import org.mozilla.vrbrowser.ui.TopBarWidget;
import org.mozilla.vrbrowser.ui.TrayWidget;
import org.mozilla.vrbrowser.ui.UIWidget;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -104,6 +105,7 @@ public void run() {
LinkedList<Runnable> mBackHandlers;
private boolean mIsPresentingImmersive = false;
private Thread mUiThread;
private boolean isDimmed;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -123,6 +125,7 @@ protected void onCreate(Bundle savedInstanceState) {
intentFilter.addAction(CrashReporterService.CRASH_ACTION);
registerReceiver(mCrashReceiver, intentFilter, getString(R.string.app_permission_name), null);

isDimmed = false;
mLastGesture = NoGesture;
super.onCreate(savedInstanceState);

Expand Down Expand Up @@ -794,9 +797,12 @@ public void popBackHandler(Runnable aRunnable) {

@Override
public void fadeOutWorld() {
if (SessionStore.get().isCurrentSessionPrivate() ^
if (!isDimmed && (SessionStore.get().isCurrentSessionPrivate() ^
mNavigationBar.isInFocusMode() ^
mTray.isSettingsDialogOpened()) {
mTray.isSettingsDialogOpened() ^
mPermissionDelegate.isPermissionDialogVisible() ^
(mCrashDialog != null && mCrashDialog.isVisible()))) {
isDimmed = true;
queueRunnable(new Runnable() {
@Override
public void run() {
Expand All @@ -808,9 +814,12 @@ public void run() {

@Override
public void fadeInWorld() {
if ((!SessionStore.get().isCurrentSessionPrivate() &&
if (isDimmed && (!SessionStore.get().isCurrentSessionPrivate() &&
!mNavigationBar.isInFocusMode() &&
!mTray.isSettingsDialogOpened())) {
!mTray.isSettingsDialogOpened() &&
!mPermissionDelegate.isPermissionDialogVisible() &&
!(mCrashDialog != null && mCrashDialog.isVisible()))) {
isDimmed = false;
queueRunnable(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.SessionStore;
import org.mozilla.vrbrowser.SettingsStore;
import org.mozilla.vrbrowser.WidgetManagerDelegate;
import org.mozilla.vrbrowser.WidgetPlacement;
import org.mozilla.vrbrowser.audio.AudioEngine;

public class CrashDialogWidget extends UIWidget {
public class CrashDialogWidget extends UIWidget implements WidgetManagerDelegate.FocusChangeListener {
private static final String LOGTAG = "VRB";

public interface CrashDialogDelegate {
Expand Down Expand Up @@ -50,6 +51,8 @@ public CrashDialogWidget(Context aContext, AttributeSet aAttrs, int aDefStyle) {
private void initialize(Context aContext) {
inflate(aContext, R.layout.crash_dialog, this);

mWidgetManager.addFocusChangeListener(this);

mLearnMoreButton = findViewById(R.id.learnMoreButton);
mDontSendButton = findViewById(R.id.dontSendButton);
mSendDataButton = findViewById(R.id.sendDataButton);
Expand All @@ -69,7 +72,7 @@ public void onClick(View view) {

SessionStore.get().loadUri(getContext().getString(R.string.crash_dialog_learn_more_url));

hide();
onDismiss();
}
});
mDontSendButton.setOnClickListener(new OnClickListener() {
Expand All @@ -79,7 +82,7 @@ public void onClick(View view) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

hide();
onDismiss();
}
});
mSendDataButton.setOnClickListener(new OnClickListener() {
Expand All @@ -89,13 +92,13 @@ public void onClick(View view) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

hide();

if(mCrashDialogDelegate != null) {
mCrashDialogDelegate.onSendData();
}

SettingsStore.getInstance(getContext()).setCrashReportingEnabled(mSendDataCheckBox.isChecked());

hide();
}
});

Expand All @@ -113,6 +116,13 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mAudio = AudioEngine.fromContext(aContext);
}

@Override
public void releaseWidget() {
mWidgetManager.removeFocusChangeListener(this);

super.releaseWidget();
}

@Override
protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.visible = false;
Expand All @@ -127,13 +137,28 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
}

@Override
protected void onBackButton() {
hide();
if (mDelegate != null)
mDelegate.onWidgetClosed(getHandle());
public void show() {
super.show();

mWidgetManager.fadeOutWorld();
}

@Override
public void hide() {
super.hide();

mWidgetManager.fadeInWorld();
}

public void setCrashDialogDelegate(CrashDialogDelegate aDelegate) {
mCrashDialogDelegate = aDelegate;
}

// WidgetManagerDelegate.FocusChangeListener
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (oldFocus == this && isVisible()) {
onDismiss();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.SessionStore;
Expand Down Expand Up @@ -78,7 +77,7 @@ public void onClick(View view) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onBackButton();
onDismiss();
}
});

Expand Down Expand Up @@ -175,11 +174,21 @@ private void showRestartDialog() {
if (widget == null) {
widget = createChild(RestartDialogWidget.class, false);
mRestartDialogHandle = widget.getHandle();
widget.setDelegate(new Delegate() {
@Override
public void onDismiss() {
onRestartDialogDismissed();
}
});
}

widget.show();
}

private void onRestartDialogDismissed() {
show();
}

private SwitchSetting.OnCheckedChangeListener mRemoteDebuggingListener = new SwitchSetting.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean value, boolean doApply) {
Expand All @@ -198,6 +207,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean value, boole
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean value, boolean doApply) {
setEnvOverride(value);
showRestartDialog();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.SessionStore;
import org.mozilla.vrbrowser.Widget;
import org.mozilla.vrbrowser.WidgetManagerDelegate;
import org.mozilla.vrbrowser.WidgetPlacement;
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
Expand Down Expand Up @@ -173,7 +172,7 @@ public void onClick(View view) {
mBackHandler = new Runnable() {
@Override
public void run() {
onBackButton();
onDismiss();
}
};

Expand Down Expand Up @@ -257,7 +256,7 @@ public void dismiss() {
mPopupKeyboardLayer.setVisibility(View.GONE);
}

protected void onBackButton() {
protected void onDismiss() {
dismiss();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.anchorY = 0.5f;
}

@Override
public void show() {
super.show();

mWidgetManager.fadeOutWorld();
}

@Override
public void hide() {
super.hide();

mWidgetManager.fadeInWorld();
}

public void showPrompt(String aUri, PermissionType aType, GeckoSession.PermissionDelegate.Callback aCallback) {
int messageId;
int iconId;
Expand Down Expand Up @@ -180,14 +194,14 @@ private void handlePermissionResult(boolean aGranted) {
}
mPermissionCallback = null;

hide();
onDismiss();
}

// WidgetManagerDelegate.FocusChangeListener
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (oldFocus == this) {
hide();
if (oldFocus == this && isVisible()) {
onDismiss();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onClick(View view) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onBackButton();
onDismiss();
}
});

Expand Down
54 changes: 28 additions & 26 deletions app/src/common/shared/org/mozilla/vrbrowser/ui/SettingsWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
import java.util.Calendar;
import java.util.GregorianCalendar;

public class SettingsWidget extends UIWidget {
public class SettingsWidget extends UIWidget implements WidgetManagerDelegate.FocusChangeListener {

private static final String LOGTAG = "VRB";

private AudioEngine mAudio;
private int mRestartDialogHandle = -1;
private int mDeveloperOptionsDialogHandle = -1;
private TextView mBuildText;

Expand Down Expand Up @@ -77,6 +76,8 @@ public SettingsWidget(Context aContext, AttributeSet aAttrs, int aDefStyle) {
private void initialize(Context aContext) {
inflate(aContext, R.layout.settings, this);

mWidgetManager.addFocusChangeListener(this);

ImageButton cancelButton = findViewById(R.id.settingsCancelButton);

cancelButton.setOnClickListener(new OnClickListener() {
Expand All @@ -86,7 +87,7 @@ public void onClick(View v) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

onBackButton();
onDismiss();
}
});

Expand Down Expand Up @@ -189,6 +190,8 @@ public void onClick(View view) {

@Override
public void releaseWidget() {
mWidgetManager.removeFocusChangeListener(this);

super.releaseWidget();
}

Expand Down Expand Up @@ -297,45 +300,44 @@ private String versionCodeToDate(final int aVersionCode) {
return formatted;
}

private void showRestartDialog() {
UIWidget widget = getChild(mRestartDialogHandle);
if (widget == null) {
widget = createChild(RestartDialogWidget.class, false);
mRestartDialogHandle = widget.getHandle();
}

widget.show();

hide();
}

private void showDeveloperOptionsDialog() {
hide();

UIWidget widget = getChild(mDeveloperOptionsDialogHandle);
if (widget == null) {
widget = createChild(DeveloperOptionsWidget.class, false);
mDeveloperOptionsDialogHandle = widget.getHandle();
widget.setDelegate(new Delegate() {
@Override
public void onDismiss() {
onDeveloperOptionsDialogDismissed();
}
});
}

widget.show();
}

@Override
public void toggle() {
super.toggle();

if (!isVisible())
mWidgetManager.fadeInWorld();
else
mWidgetManager.fadeOutWorld();
private void onDeveloperOptionsDialogDismissed() {
show();
mWidgetManager.fadeInWorld();
}

// WindowManagerDelegate.FocusChangeListener
@Override
protected void onBackButton() {
super.onBackButton();
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
boolean dismiss = false;
UIWidget widget = getChild(mDeveloperOptionsDialogHandle);
if (widget != null && oldFocus == widget && widget.isVisible()) {
dismiss = true;

mWidgetManager.fadeInWorld();
} else if (oldFocus == this && isVisible()) {
dismiss = true;
}

if (dismiss) {
onDismiss();
}
}

}
Loading

0 comments on commit e85881e

Please sign in to comment.