This source file includes following definitions.
- onYesPressed
- onNoPressed
- create
- initialize
- disableUI
- dismiss
- onViewClicked
- onViewPressed
- onViewSwipedAway
package org.chromium.chrome.browser.dom_distiller;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageButton;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.banners.SwipableOverlayView;
import org.chromium.content.browser.ContentView;
public class DomDistillerFeedbackReportingView extends SwipableOverlayView {
private static final int VIEW_LAYOUT = R.layout.dom_distiller_feedback_reporting_view;
private FeedbackObserver mFeedbackObserver;
private ImageButton mNoButton;
private ImageButton mYesButton;
private boolean mSelectionMade;
interface FeedbackObserver {
void onYesPressed(DomDistillerFeedbackReportingView view);
void onNoPressed(DomDistillerFeedbackReportingView view);
}
public static DomDistillerFeedbackReportingView create(ContentView contentView,
FeedbackObserver feedbackObserver) {
Context context = contentView.getContext().getApplicationContext();
DomDistillerFeedbackReportingView view =
(DomDistillerFeedbackReportingView) LayoutInflater.from(context)
.inflate(VIEW_LAYOUT, null);
view.initialize(feedbackObserver);
view.addToView(contentView);
return view;
}
public DomDistillerFeedbackReportingView(Context context, AttributeSet attrs) {
super(context, attrs);
}
private void initialize(FeedbackObserver feedbackObserver) {
mFeedbackObserver = feedbackObserver;
mNoButton = (ImageButton) findViewById(R.id.distillation_quality_answer_no);
mYesButton = (ImageButton) findViewById(R.id.distillation_quality_answer_yes);
mNoButton.setClickable(true);
mYesButton.setClickable(true);
mNoButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mSelectionMade) return;
mSelectionMade = true;
mNoButton.setImageResource(R.drawable.distillation_quality_answer_no_pressed);
disableUI();
if (mFeedbackObserver != null) {
mFeedbackObserver.onNoPressed(DomDistillerFeedbackReportingView.this);
}
}
});
mYesButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mSelectionMade) return;
mSelectionMade = true;
mYesButton.setImageResource(R.drawable.distillation_quality_answer_yes_pressed);
disableUI();
if (mFeedbackObserver != null) {
mFeedbackObserver.onYesPressed(DomDistillerFeedbackReportingView.this);
}
}
});
}
private void disableUI() {
mNoButton.setOnClickListener(null);
mYesButton.setOnClickListener(null);
mNoButton.setEnabled(false);
mYesButton.setEnabled(false);
}
@Override
protected boolean dismiss(boolean horizontally) {
return super.dismiss(horizontally);
}
@Override
protected void onViewClicked() {
}
@Override
protected void onViewPressed(MotionEvent event) {
}
@Override
protected void onViewSwipedAway() {
}
}