This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixes #435 Added support for alert/prompt/confirm * Fixed layout reference that caused a TC failure * Improve resizing glitch
- Loading branch information
1 parent
853b724
commit f666370
Showing
19 changed files
with
901 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/prompts/AlertPromptWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.mozilla.vrbrowser.ui.widgets.prompts; | ||
|
||
import android.content.Context; | ||
import android.text.method.ScrollingMovementMethod; | ||
import android.util.AttributeSet; | ||
import android.widget.Button; | ||
|
||
import org.mozilla.geckoview.GeckoSession; | ||
import org.mozilla.vrbrowser.R; | ||
import org.mozilla.vrbrowser.audio.AudioEngine; | ||
|
||
public class AlertPromptWidget extends PromptWidget { | ||
|
||
private AudioEngine mAudio; | ||
private Button mOkButton; | ||
private GeckoSession.PromptDelegate.AlertCallback mCallback; | ||
|
||
public AlertPromptWidget(Context aContext) { | ||
super(aContext); | ||
initialize(aContext); | ||
} | ||
|
||
public AlertPromptWidget(Context aContext, AttributeSet aAttrs) { | ||
super(aContext, aAttrs); | ||
initialize(aContext); | ||
} | ||
|
||
public AlertPromptWidget(Context aContext, AttributeSet aAttrs, int aDefStyle) { | ||
super(aContext, aAttrs, aDefStyle); | ||
initialize(aContext); | ||
} | ||
|
||
@Override | ||
protected void initialize(Context aContext) { | ||
super.initialize(aContext); | ||
|
||
inflate(aContext, R.layout.prompt_alert, this); | ||
|
||
mAudio = AudioEngine.fromContext(aContext); | ||
|
||
mLayout = findViewById(R.id.layout); | ||
|
||
mTitle = findViewById(R.id.alertTitle); | ||
mMessage = findViewById(R.id.alertMessage); | ||
mMessage.setMovementMethod(new ScrollingMovementMethod()); | ||
|
||
mOkButton = findViewById(R.id.positiveButton); | ||
mOkButton.setSoundEffectsEnabled(false); | ||
mOkButton.setOnClickListener(view -> { | ||
if (mAudio != null) { | ||
mAudio.playSound(AudioEngine.Sound.CLICK); | ||
} | ||
|
||
onDismiss(); | ||
}); | ||
} | ||
|
||
@Override | ||
protected void onDismiss() { | ||
hide(REMOVE_WIDGET); | ||
|
||
if (mCallback != null) { | ||
mCallback.dismiss(); | ||
} | ||
} | ||
|
||
public void setDelegate(GeckoSession.PromptDelegate.AlertCallback delegate) { | ||
mCallback = delegate; | ||
} | ||
|
||
} |
Oops, something went wrong.