org.chromium.chrome.browser.infobar.InfoBar Java Examples

The following examples show how to use org.chromium.chrome.browser.infobar.InfoBar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TranslateInfoBar.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Based on the infobar and the button pressed figure out what action needs to happen.
 */
private int actionFor(boolean isPrimaryButton) {
    int action = InfoBar.ACTION_TYPE_NONE;
    int infobarType = getInfoBarType();
    switch (infobarType) {
        case TranslateInfoBar.BEFORE_TRANSLATE_INFOBAR:
            action = isPrimaryButton
                    ? InfoBar.ACTION_TYPE_TRANSLATE : InfoBar.ACTION_TYPE_CANCEL;
            break;
        case TranslateInfoBar.AFTER_TRANSLATE_INFOBAR:
            if (!isPrimaryButton) {
                action = InfoBar.ACTION_TYPE_TRANSLATE_SHOW_ORIGINAL;
            }
            break;
        case TranslateInfoBar.TRANSLATE_ERROR_INFOBAR:
            // retry
            action = InfoBar.ACTION_TYPE_TRANSLATE;
            break;
        default:
            break;
    }
    return action;
}
 
Example #2
Source File: TranslateCheckBox.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void createContent(Context context, InfoBarLayout layout) {
    CheckBox checkBox = new CheckBox(context);
    checkBox.setId(R.id.infobar_extra_check);
    checkBox.setText(context.getString(R.string.translate_always_text,
            mOptions.sourceLanguage()));
    checkBox.setChecked(mOptions.alwaysTranslateLanguageState());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            mOptions.toggleAlwaysTranslateLanguageState(isChecked);
            if (isChecked){
                mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
            } else {
                mListener.onOptionsChanged();
            }
        }
    });
    layout.addGroup(checkBox);
}
 
Example #3
Source File: TranslateCheckBox.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void createContent(Context context, InfoBarLayout layout) {
    CheckBox checkBox = new CheckBox(context);
    checkBox.setId(R.id.infobar_extra_check);
    checkBox.setText(context.getString(R.string.translate_always_text,
            mOptions.sourceLanguage()));
    checkBox.setChecked(mOptions.alwaysTranslateLanguageState());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            mOptions.toggleAlwaysTranslateLanguageState(isChecked);
            if (isChecked){
                mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
            } else {
                mListener.onOptionsChanged();
            }
        }
    });
    layout.addGroup(checkBox);
}
 
Example #4
Source File: TranslateInfoBar.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Based on the infobar and the button pressed figure out what action needs to happen.
 */
private int actionFor(boolean isPrimaryButton) {
    int action = InfoBar.ACTION_TYPE_NONE;
    int infobarType = getInfoBarType();
    switch (infobarType) {
        case TranslateInfoBar.BEFORE_TRANSLATE_INFOBAR:
            action = isPrimaryButton
                    ? InfoBar.ACTION_TYPE_TRANSLATE : InfoBar.ACTION_TYPE_CANCEL;
            break;
        case TranslateInfoBar.AFTER_TRANSLATE_INFOBAR:
            if (!isPrimaryButton) {
                action = InfoBar.ACTION_TYPE_TRANSLATE_SHOW_ORIGINAL;
            }
            break;
        case TranslateInfoBar.TRANSLATE_ERROR_INFOBAR:
            // retry
            action = InfoBar.ACTION_TYPE_TRANSLATE;
            break;
        default:
            break;
    }
    return action;
}
 
Example #5
Source File: TranslateNeverPanel.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onButtonClicked(boolean primary) {
    if (primary) {
        mOptions.toggleNeverTranslateDomainState(true);
    } else {
        mOptions.toggleNeverTranslateLanguageState(true);
    }
    mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
}
 
Example #6
Source File: ReaderModeManager.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onAddInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isFirst) {
    mIsInfoBarContainerShown = true;
    // If the panel is opened past the peeking state, obscure the infobar.
    if (mReaderModePanel != null && mReaderModePanel.isPanelOpened() && container != null) {
        container.setIsObscuredByOtherView(true);
    } else if (isFirst) {
        // Temporarily hides the reader mode button while the infobars are shown.
        closeReaderPanel(StateChangeReason.INFOBAR_SHOWN, false);
    }
}
 
Example #7
Source File: TranslateInfoBarDelegate.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@CalledByNative
InfoBar showTranslateInfoBar(
        int nativeInfoBar, int translateBarType,
        int sourceLanguageIndex, int targetLanguageIndex, boolean autoTranslatePair,
        boolean showNeverInfobar, String[] languages) {
    mInfoBar = new TranslateInfoBar(nativeInfoBar, this, translateBarType,
            sourceLanguageIndex, targetLanguageIndex, autoTranslatePair, showNeverInfobar,
            languages);
    return mInfoBar;
}
 
Example #8
Source File: TranslateLanguagePanel.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onButtonClicked(boolean primary) {
    if (primary) {
        mOptions.setSourceLanguage(mSessionOptions.sourceLanguageIndex());
        mOptions.setTargetLanguage(mSessionOptions.targetLanguageIndex());
    }
    mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
}
 
Example #9
Source File: TranslateAlwaysPanel.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onButtonClicked(boolean primary) {
    if (primary) {
        mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
    } else {
        mListener.onPanelClosed(InfoBar.ACTION_TYPE_TRANSLATE_SHOW_ORIGINAL);
    }
}
 
Example #10
Source File: TranslateNeverPanel.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onButtonClicked(boolean primary) {
    if (primary) {
        mOptions.toggleNeverTranslateDomainState(true);
    } else {
        mOptions.toggleNeverTranslateLanguageState(true);
    }
    mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
}
 
Example #11
Source File: TranslateInfoBarDelegate.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@CalledByNative
InfoBar showTranslateInfoBar(
        int nativeInfoBar, int translateBarType,
        int sourceLanguageIndex, int targetLanguageIndex, boolean autoTranslatePair,
        boolean showNeverInfobar, String[] languages) {
    mInfoBar = new TranslateInfoBar(nativeInfoBar, this, translateBarType,
            sourceLanguageIndex, targetLanguageIndex, autoTranslatePair, showNeverInfobar,
            languages);
    return mInfoBar;
}
 
Example #12
Source File: TranslateLanguagePanel.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onButtonClicked(boolean primary) {
    if (primary) {
        mOptions.setSourceLanguage(mSessionOptions.sourceLanguageIndex());
        mOptions.setTargetLanguage(mSessionOptions.targetLanguageIndex());
    }
    mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
}
 
Example #13
Source File: TranslateAlwaysPanel.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onButtonClicked(boolean primary) {
    if (primary) {
        mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
    } else {
        mListener.onPanelClosed(InfoBar.ACTION_TYPE_TRANSLATE_SHOW_ORIGINAL);
    }
}
 
Example #14
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onRemoveInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isLast) {
    // Re-shows the reader mode button if necessary once the infobars are dismissed.
    if (isLast) {
        mIsInfoBarContainerShown = false;
        requestReaderPanelShow(StateChangeReason.INFOBAR_HIDDEN);
    }
}
 
Example #15
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onAddInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isFirst) {
    mIsInfoBarContainerShown = true;
    // If the panel is opened past the peeking state, obscure the infobar.
    if (mReaderModePanel != null && mReaderModePanel.isPanelOpened() && container != null) {
        container.setIsObscuredByOtherView(true);
    } else if (isFirst) {
        // Temporarily hides the reader mode button while the infobars are shown.
        closeReaderPanel(StateChangeReason.INFOBAR_SHOWN, false);
    }
}
 
Example #16
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onRemoveInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isLast) {
    // Re-shows the reader mode button if necessary once the infobars are dismissed.
    if (isLast) {
        mIsInfoBarContainerShown = false;
        requestReaderPanelShow(StateChangeReason.INFOBAR_HIDDEN);
    }
}
 
Example #17
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onAddInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isFirst) {
    mIsInfoBarContainerShown = true;
    // If the panel is opened past the peeking state, obscure the infobar.
    if (mReaderModePanel != null && mReaderModePanel.isPanelOpened() && container != null) {
        container.setIsObscuredByOtherView(true);
    } else if (isFirst) {
        // Temporarily hides the reader mode button while the infobars are shown.
        closeReaderPanel(StateChangeReason.INFOBAR_SHOWN, false);
    }
}
 
Example #18
Source File: ReaderModeManager.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onRemoveInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isLast) {
    // Re-shows the reader mode button if necessary once the infobars are dismissed.
    if (isLast) {
        mIsInfoBarContainerShown = false;
        requestReaderPanelShow(StateChangeReason.INFOBAR_HIDDEN);
    }
}