সিস্টেমইউআইওভারলে উইন্ডো ম্যানেজমেন্ট সিস্টেম

SystemUIOverlayWindow ম্যানেজমেন্ট সিস্টেম আপনাকে SystemUIOverlayWindow এ ভিউ প্রদর্শন ও পরিচালনা করার একটি উপায় প্রদান করে। বর্তমানে, এই উইন্ডোটি পূর্ণ স্ক্রীন ব্যবহারকারী সুইচার, বিজ্ঞপ্তি প্যানেল এবং কীগার্ড সহ দর্শনের জন্য ব্যবহৃত হয়। এই পৃষ্ঠাটি নেই:

  • OEM উইন্ডোতে কী যোগ করতে পারে তার চারপাশে সীমাবদ্ধতা তৈরি করুন।
  • এই পৃষ্ঠায় বর্ণিত বিমূর্ততা গ্রহণ করতে আপনাকে বাধ্য করুন।

ওভারভিউ

আইনি নোটিশ, ফুলস্ক্রিন ব্যবহারকারী সুইচার, রিয়ার ভিউ ক্যামেরা, HVAC কন্ট্রোল এবং কীগার্ডের মতো ভিউ দেখাতে আপনি SystemUIOverlayWindow Management System ব্যবহার করতে পারেন। এই উইন্ডোটি অ্যাপ স্পেসের বাইরে অবস্থিত এবং আপনাকে ভিউয়ের জেড-অর্ডারিং, রিভিল/কনসিল ট্রিগার এবং ভিউ প্লেসমেন্ট, আকার, স্বচ্ছতা এবং রঙ সহ সামগ্রিক কাস্টমাইজেশনের উপর নিয়ন্ত্রণ দেয়। একই সময়ে, আপনাকে সিস্টেম বার বা অন্যান্য সিস্টেম UI অবজেক্টের অবস্থা নিয়ে উদ্বিগ্ন হওয়ার দরকার নেই যেগুলি লুকানো বা দেখানোর প্রয়োজন যখন তাদের নিজ নিজ ভিউ লুকানো বা দেখানো হয়।

SystemUIOverlayWindow এর সুবিধা নিতে, আপনি মধ্যস্থতাকারীদের দেখার জন্য ভিউ কন্ট্রোলার তৈরি করেন। মধ্যস্থতাকারীদের উইন্ডোর গ্লোবাল স্টেট কন্ট্রোলারের কাছে পাঠানো হয়। এই ভিউ মধ্যস্থতাকারী:

  • ভিউ কন্ট্রোলারের মধ্যে সমন্বয় করুন।
  • ভিউ কন্ট্রোলারের জন্য হাউস বিজনেস লজিক।

কন্ট্রোলার দেখুন (ভিউ মধ্যস্থতাকারীদের দ্বারা সমন্বিত):

  • এর দৃষ্টিভঙ্গির মালিক।
  • সেটার তৈরি করুন যার মাধ্যমে OverlayViewsMediator ব্যবসায়িক যুক্তি সংযুক্ত করতে পারে।
  • তাদের ভিউ এর প্রকাশ এবং গোপন অ্যানিমেশন তৈরি করুন.

SystemUIOverlayWindow Manager, একটি SystemUI কম্পোনেন্ট, গ্লোবাল স্টেট কন্ট্রোলারের সাথে মধ্যস্থতাকারীদের সূচনা ও নিবন্ধন করার জন্য একটি এন্ট্রি পয়েন্ট হিসাবে কাজ করে যখন গ্লোবাল স্টেট কন্ট্রোলার ভিউ কন্ট্রোলারের সাথে এমনভাবে সংযুক্ত থাকে যাতে মধ্যস্থতাকারীরা ভিউ কন্ট্রোলারদের সরাসরি কল করতে পারে ভিউ কন্ট্রোলারকে দেখাতে এবং লুকাতে। জানালা.

ওভারলেভিউ কন্ট্রোলার

OverlayViewController SystemUIOverlayWindow এ প্রদর্শিত ভিউয়ের জন্য দায়ী এবং ভিউটি কীভাবে প্রকাশ এবং লুকানো হয় তা নিয়ন্ত্রণ করে। এটি প্রয়োজনীয় শ্রোতাদের সংযুক্ত করতে সক্ষম করে যাতে এটি ব্যবসায়িক যুক্তির সাথে আবদ্ধ হতে পারে।

গুরুত্বপূর্ণ পদ্ধতি স্বাক্ষর

/**
 * Owns a {@link View} that is present in SystemUIOverlayWindow.
 */
public class OverlayViewController {

    /**
     * Shows content of {@link OverlayViewController}.
     *
     * Should be used to show view externally and in particular by {@link OverlayViewMediator}.
     */
    public final void start();

    /**
     * Hides content of {@link OverlayViewController}.
     *
     * Should be used to hide view externally and in particular by {@link OverlayViewMediator}.
     */
    public final void stop();

    /**
     * Inflate layout owned by controller.
     */
    public final void inflate(ViewGroup baseLayout);

    /**
     * Called once inflate finishes.
     */
    protected void onFinishInflate();

    /**
     * Returns {@code true} if layout owned by controller has been inflated.
     */
    public final boolean isInflated();

    /**
     * Subclasses should override this method to implement reveal animations and implement logic
     * specific to when the layout owned by the controller is shown.
     *
     * Should only be overridden by Superclass but not called by any {@link OverlayViewMediator}.
     */
    protected void showInternal();

    /**
     * Subclasses should override this method to implement conceal animations and implement logic
     * specific to when the layout owned by the controller is hidden.
     *
     * Should only be overridden by Superclass but not called by any {@link OverlayViewMediator}.
     */
    protected void hideInternal();

    /**
     * Provides access to layout owned by controller.
     */
    protected final View getLayout();

    /** Returns the {@link OverlayViewGlobalStateController}. */
    protected final OverlayViewGlobalStateController getOverlayViewGlobalStateController();

    /** Returns whether the view controlled by this controller is visible. */
    public final boolean isVisible();

    /**
     * Returns the ID of the focus area that should receive focus when this view is the
     * topmost view or {@link View#NO_ID} if there is no focus area.
     */
    @IdRes
    protected int getFocusAreaViewId();

    /** Returns whether the view controlled by this controller has rotary focus. */
    protected final boolean hasRotaryFocus();

    /**
     * Sets whether this view allows rotary focus. This should be set to {@code true} for the
     * topmost layer in the overlay window and {@code false} for the others.
     */
    public void setAllowRotaryFocus(boolean allowRotaryFocus);

    /**
     * Refreshes the rotary focus in this view if we are in rotary mode. If the view already has
     * rotary focus, it leaves the focus alone. Returns {@code true} if a new view was focused.
     */
    public boolean refreshRotaryFocusIfNeeded();

    /**
     * Returns {@code true} if heads up notifications should be displayed over this view.
     */
    protected boolean shouldShowHUN();

    /**
     * Returns {@code true} if navigation bar insets should be displayed over this view. Has no
     * effect if {@link #shouldFocusWindow} returns {@code false}.
     */
    protected boolean shouldShowNavigationBarInsets();

    /**
     * Returns {@code true} if status bar insets should be displayed over this view. Has no
     * effect if {@link #shouldFocusWindow} returns {@code false}.
     */
    protected boolean shouldShowStatusBarInsets();

    /**
     * Returns {@code true} if this view should be hidden during the occluded state.
     */
    protected boolean shouldShowWhenOccluded();

    /**
     * Returns {@code true} if the window should be focued when this view is visible. Note that
     * returning {@code false} here means that {@link #shouldShowStatusBarInsets} and
     * {@link #shouldShowNavigationBarInsets} will have no effect.
     */
    protected boolean shouldFocusWindow();

    /**
     * Returns {@code true} if the window should use stable insets. Using stable insets means that
     * even when system bars are temporarily not visible, inset from the system bars will still be
     * applied.
     *
     * NOTE: When system bars are hidden in transient mode, insets from them will not be applied
     * even when the system bars become visible. Setting the return value to {@true} here can
     * prevent the OverlayView from overlapping with the system bars when that happens.
     */
    protected boolean shouldUseStableInsets();

    /**
     * Returns the insets types to fit to the sysui overlay window when this
     * {@link OverlayViewController} is in the foreground.
     */
    @WindowInsets.Type.InsetsType
    protected int getInsetTypesToFit();

    /**
     * Optionally returns the sides of enabled system bar insets to fit to the sysui overlay window
     * when this {@link OverlayViewController} is in the foreground.
     *
     * For example, if the bottom and left system bars are enabled and this method returns
     * WindowInsets.Side.LEFT, then the inset from the bottom system bar will be ignored.
     *
     * NOTE: By default, this method returns {@link #INVALID_INSET_SIDE}, so insets to fit are
     * defined by {@link #getInsetTypesToFit()}, and not by this method, unless it is overridden
     * by subclasses.
     *
     * NOTE: {@link #NO_INSET_SIDE} signifies no insets from any system bars will be honored. Each
     * {@link OverlayViewController} can first take this value and add sides of the system bar
     * insets to honor to it.
     *
     * NOTE: If getInsetSidesToFit is overridden to return {@link WindowInsets.Side}, it always
     * takes precedence over {@link #getInsetTypesToFit()}. That is, the return value of {@link
     * #getInsetTypesToFit()} will be ignored.
     */
    @WindowInsets.Side.InsetsSide
    protected int getInsetSidesToFit();
}

ওভারলে প্যানেলভিউ কন্ট্রোলার

OverlayPanelViewController কন্ট্রোলার OverlayViewController প্রসারিত করে এবং এর সুপারক্লাসে অতিরিক্ত ড্র্যাগিং অ্যানিমেশন ক্ষমতা প্রদান করে।

OverlayViewMediator

OverlayViewMediator ব্যবসায়িক যুক্তি রাখে যা একাধিক OverlayViewController দৃষ্টান্ত প্রকাশ করে বা লুকিয়ে রাখে, তাই, এটি একটি উপায়ে ভিউ কন্ট্রোলারের মধ্যে সমন্বয়ও পরিচালনা করে।

/**
 * Controls when to show and hide {@link OverlayViewController}(s).
 */
public interface OverlayViewMediator {

    /**
     * Register listeners that could use ContentVisibilityAdjuster to show/hide content.
     *
     * Note that we do not unregister listeners because SystemUI components are expected to live
     * for the lifecycle of the device.
     */
    void registerListeners();

    /**
     * Allows for post-inflation callbacks and listeners to be set inside required {@link
     * OverlayViewController}(s).
     */
    void setupOverlayContentViewControllers();
}

SystemUIOverlayWindowManager

SystemUIOverlayWindowManager হল SystemUI অবজেক্ট হওয়ার জন্য দায়ী যা SystemUIOverlayWindow ম্যানেজমেন্ট সিস্টেমের জন্য একটি এন্ট্রি পয়েন্ট পরিবেশন করে OverlayViewMediator ইনস্ট্যান্সগুলিকে OverlayViewGlobalStateController এর সাথে আরম্ভ এবং নিবন্ধন করতে।

ভিউ ফ্লো দেখান
চিত্র 1. SystemUIOverlayWindowManager

OverlayViewGlobalStateController

OverlayViewGlobalStateController নিজেকে প্রকাশ বা গোপন করার জন্য OverlayViewController দৃষ্টান্ত থেকে কল গ্রহণ করে। তাই, SystemUIOverlayWindow এ যা দেখানো বা লুকানো আছে তার অবস্থাও এটি ধারণ করে।

শো ভিউ ফ্লো নীচে চিত্রিত করা হয়েছে:

ভিউ ফ্লো দেখান
চিত্র 2. দৃশ্য প্রবাহ দেখান

ভিউ প্রবাহ লুকান

লুকানো দৃশ্য প্রবাহ নীচে চিত্রিত করা হয়েছে:

ভিউ প্রবাহ লুকান
চিত্র 3. দৃশ্য প্রবাহ লুকান

পাবলিক পদ্ধতি স্বাক্ষর

পাবলিক পদ্ধতি স্বাক্ষর নিম্নলিখিত হিসাবে এনকোড করা হয়:

​/**
 * This controller is responsible for the following:
 * <p><ul>
 * <li>Holds the global state for SystemUIOverlayWindow.
 * <li>Allows {@link SystemUIOverlayWindowManager} to register {@link OverlayViewMediator}(s).
 * <li>Enables {@link OverlayViewController)(s) to reveal/conceal themselves while respecting the
 * global state of SystemUIOverlayWindow.
 * </ul>
 */
@SysUISingleton
public class OverlayViewGlobalStateController {
    /**
     * Register {@link OverlayViewMediator} to use in SystemUIOverlayWindow.
     */
    public void registerMediator(OverlayViewMediator overlayViewMediator);

    /**
     * Show content in Overlay Window using {@link OverlayPanelViewController}.
     *
     * This calls {@link OverlayViewGlobalStateController#showView(OverlayViewController, Runnable)}
     * where the runnable is nullified since the actual showing of the panel is handled by the
     * controller itself.
     */
    public void showView(OverlayPanelViewController panelViewController);

    /**
     * Show content in Overlay Window using {@link OverlayViewController}.
     */
    public void showView(OverlayViewController viewController, @Nullable Runnable show);

    /**
     * Hide content in Overlay Window using {@link OverlayPanelViewController}.
     *
     * This calls {@link OverlayViewGlobalStateController#hideView(OverlayViewController, Runnable)}
     * where the runnable is nullified since the actual hiding of the panel is handled by the
     * controller itself.
     */
    public void hideView(OverlayPanelViewController panelViewController);

    /**
     * Hide content in Overlay Window using {@link OverlayViewController}.
     */
    public void hideView(OverlayViewController viewController, @Nullable Runnable hide);

    /** Returns {@code true} is the window is visible. */
    public boolean isWindowVisible();

    /**
     * Sets the {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flag of the
     * sysui overlay window.
     */
    public void setWindowNeedsInput(boolean needsInput);

    /** Returns {@code true} if the window is focusable. */
    public boolean isWindowFocusable();

    /** Sets the focusable flag of the sysui overlawy window. */
    public void setWindowFocusable(boolean focusable);

    /** Inflates the view controlled by the given view controller. */
    public void inflateView(OverlayViewController viewController);

    /**
     * Return {@code true} if OverlayWindow is in a state where HUNs should be displayed above it.
     */
    public boolean shouldShowHUN();

    /**
     * Set the OverlayViewWindow to be in occluded or unoccluded state. When OverlayViewWindow is
     * occluded, all views mounted to it that are not configured to be shown during occlusion will
     * be hidden.
     */
    public void setOccluded(boolean occluded);
}

কিভাবে SysUIOverlayWindow-এ একটি ভিউ যোগ করবেন

বিস্তারিত জানার জন্য, কোডল্যাব দেখুন।

ধাপ 1: SysUIOverlayWindow-এ একটি ViewStub যোগ করুন

উইন্ডো লেআউটে ViewStub যোগ করুন।

ধাপ 2: একটি OverlayViewController তৈরি করুন

একটি নতুন ইনজেকশনযোগ্য OverlayViewController তৈরি করতে নতুন ViewStub ব্যবহার করুন।

ধাপ 3: OverlayViewMediator

একটি নতুন ইনজেকশনযোগ্য OverlayViewMediator তৈরি করুন বা একটি বিদ্যমান একটি ব্যবহার করুন (ধাপ 4 এড়িয়ে যান) এবং নতুন OverlayViewController লুকাতে বা দেখানোর জন্য শ্রোতাদের নিবন্ধন করুন।

ধাপ 4: নতুন OverlayViewMediator কনফিগার করুন

OverlayWindowModule এবং config_carSystemUIOverlayViewsMediator এ আপনার নতুন OverlayViewMediator যোগ করুন।

সতর্কতা

যখন SysUIPrimaryWindow পুরো স্ক্রীনকে কভার করে, তখন উইন্ডোর নিচে থাকা কোনো উপাদান স্পর্শ ইভেন্ট নিবন্ধন করে না। অতএব, যখন উইন্ডোটি পুরো স্ক্রীনকে কভার করে কিন্তু এর বিষয়বস্তু কিছু নেতিবাচক স্থান ছেড়ে দেয়, আপনি নেতিবাচক স্থানটি ঝাপসা করতে এবং উইন্ডোতে বিষয়বস্তু খারিজ করতে শ্রোতাদের সেই স্থানটিতে সংযুক্ত করতে বেছে নিতে পারেন।