Search in sources :

Example 1 with CustomTabActivityHelper

use of com.ichi2.compat.customtabs.CustomTabActivityHelper in project AnkiChinaAndroid by ankichinateam.

the class AnkiActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Timber.i("AnkiActivity::onCreate - %s-%d", mActivityName, getStatusBarColorAttr());
    // The hardware buttons should control the music volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    // Set the theme
    TypedValue value = new TypedValue();
    getTheme().resolveAttribute(getStatusBarColorAttr(), value, true);
    Timber.i("AnkiActivity::onCreate - %s-%d", mActivityName, value.resourceId);
    Themes.setTheme(this, isStatusBarTransparent(), getStatusBarColorAttr());
    super.onCreate(savedInstanceState);
    // Disable the notifications bar if running under the test monkey.
    if (AdaptionUtil.isUserATestClient()) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    mCustomTabActivityHelper = new CustomTabActivityHelper();
}
Also used : CustomTabActivityHelper(com.ichi2.compat.customtabs.CustomTabActivityHelper) TypedValue(android.util.TypedValue)

Example 2 with CustomTabActivityHelper

use of com.ichi2.compat.customtabs.CustomTabActivityHelper in project Anki-Android by ankidroid.

the class AnkiActivity method onCreate.

// #9332: UI Visibility -> Insets
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    Timber.i("AnkiActivity::onCreate - %s", mActivityName);
    // The hardware buttons should control the music volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    // Set the theme
    Themes.setTheme(this);
    Themes.disableXiaomiForceDarkMode(this);
    super.onCreate(savedInstanceState);
    // Disable the notifications bar if running under the test monkey.
    if (AdaptionUtil.isUserATestClient()) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    mCustomTabActivityHelper = new CustomTabActivityHelper();
}
Also used : CustomTabActivityHelper(com.ichi2.compat.customtabs.CustomTabActivityHelper)

Example 3 with CustomTabActivityHelper

use of com.ichi2.compat.customtabs.CustomTabActivityHelper in project AnkiChinaAndroid by ankichinateam.

the class AnkiActivity method openUrl.

public void openUrl(Uri url) {
    // DEFECT: We might want a custom view for the toast, given i8n may make the text too long for some OSes to
    // display the toast
    Timber.i("final get url:%s", url);
    if (!AdaptionUtil.hasWebBrowser(this)) {
        UIUtils.showThemedToast(this, getResources().getString(R.string.no_browser_notification) + url, false);
        return;
    }
    CustomTabActivityHelper helper = getCustomTabActivityHelper();
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(helper.getSession());
    builder.setToolbarColor(ContextCompat.getColor(this, R.color.material_light_blue_500)).setShowTitle(true);
    builder.setStartAnimations(this, R.anim.slide_right_in, R.anim.slide_left_out);
    builder.setExitAnimations(this, R.anim.slide_left_in, R.anim.slide_right_out);
    builder.setCloseButtonIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_arrow_back_white_24dp));
    CustomTabsIntent customTabsIntent = builder.build();
    CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);
    CustomTabActivityHelper.openCustomTab(this, customTabsIntent, url, new CustomTabsFallback());
}
Also used : CustomTabActivityHelper(com.ichi2.compat.customtabs.CustomTabActivityHelper) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) CustomTabsFallback(com.ichi2.compat.customtabs.CustomTabsFallback)

Example 4 with CustomTabActivityHelper

use of com.ichi2.compat.customtabs.CustomTabActivityHelper in project Anki-Android by ankidroid.

the class AnkiActivity method openUrl.

public void openUrl(@NonNull Uri url) {
    // display the toast
    if (!AdaptionUtil.hasWebBrowser(this)) {
        UIUtils.showThemedToast(this, getResources().getString(R.string.no_browser_notification) + url, false);
        return;
    }
    int toolbarColor = Themes.getColorFromAttr(this, R.attr.colorPrimary);
    int navBarColor = Themes.getColorFromAttr(this, R.attr.customTabNavBarColor);
    CustomTabColorSchemeParams colorSchemeParams = new CustomTabColorSchemeParams.Builder().setToolbarColor(toolbarColor).setNavigationBarColor(navBarColor).build();
    CustomTabActivityHelper helper = getCustomTabActivityHelper();
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(helper.getSession()).setShowTitle(true).setStartAnimations(this, R.anim.slide_right_in, R.anim.slide_left_out).setExitAnimations(this, R.anim.slide_left_in, R.anim.slide_right_out).setCloseButtonIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_back_arrow_custom_tab)).setColorScheme(getColorScheme()).setDefaultColorSchemeParams(colorSchemeParams);
    CustomTabsIntent customTabsIntent = builder.build();
    CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);
    CustomTabActivityHelper.openCustomTab(this, customTabsIntent, url, new CustomTabsFallback());
}
Also used : CustomTabActivityHelper(com.ichi2.compat.customtabs.CustomTabActivityHelper) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) CustomTabColorSchemeParams(androidx.browser.customtabs.CustomTabColorSchemeParams) CustomTabsFallback(com.ichi2.compat.customtabs.CustomTabsFallback)

Aggregations

CustomTabActivityHelper (com.ichi2.compat.customtabs.CustomTabActivityHelper)4 CustomTabsIntent (androidx.browser.customtabs.CustomTabsIntent)2 CustomTabsFallback (com.ichi2.compat.customtabs.CustomTabsFallback)2 TypedValue (android.util.TypedValue)1 CustomTabColorSchemeParams (androidx.browser.customtabs.CustomTabColorSchemeParams)1