Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] Issue with custom widgets #152

Open
huongta157 opened this issue Mar 22, 2024 · 10 comments
Open

[Help] Issue with custom widgets #152

huongta157 opened this issue Mar 22, 2024 · 10 comments

Comments

@huongta157
Copy link

huongta157 commented Mar 22, 2024

I customize the battery widget like this, but the battery widget is not showing
Note: show normal when I used battery widget default
Please help me check it.

class CustomBatteryWidget : BatteryWidget {

    constructor(context: Context) : super(context, null, 0)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs, 0)
    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
        context,
        attrs,
        defStyle
    )

    private var textviewBatteryValue: TextView? = null

    override fun initView(context: Context, p1: AttributeSet, p2: Int) {
        Log.i(TAG, "initView: ")
        val view = LayoutInflater.from(context).inflate(R.layout.customized_battery_widget, this)
        textviewBatteryValue = view.findViewById<View>(R.id.textview_battery_value) as TextView
        val batteryIcon = view.findViewById<View>(R.id.imageview_battery_icon) as ImageView
        textviewBatteryValue?.text = "0%"
        batteryIcon.setImageResource(R.drawable.ic_mode_photo)
    }

    /** Called when battery percentage changes */
    override fun onBatteryPercentageChange(percentage: Int) {
        Log.i(TAG, "onBatteryPercentageChange textviewBatteryValue: $textviewBatteryValue")
        Log.i(TAG, "onBatteryPercentageChange percentage: $percentage")
        textviewBatteryValue?.text = "$percentage %"
    }

    /** Called when battery state changes from error to normal or vice versa */
    override fun onBatteryConnectionStateChange(status: ConnectionState?) {
        Log.i(TAG, "onBatteryConnectionStateChange: $status")
    }
}
<LinearLayout
        android:id="@+id/topWidgetBar"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:background="#80000000"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <xxx.xx.xx.CustomBatteryWidget
            android:layout_width="96dp"
            android:layout_height="28dp"
            custom:excludeView="singleVoltage|doubleVoltage" />
    </LinearLayout>
@huongta157 huongta157 changed the title Issue with custom battery widget [Help] Issue with custom battery widget Mar 22, 2024
@dji-dev
Copy link
Contributor

dji-dev commented Mar 22, 2024

Agent comment from yating.liao in Zendesk ticket #103335:

Your code has overridden the original initView of BatteryWidget, causing changes in the initialization of the widget. We do not recommend doing this.
Are you trying to implement your own battery component? In fact, we provide an open-source version that you can modify based on:https://github.com/dji-sdk/Mobile-UXSDK-Beta-Android

°°°

@dji-dev
Copy link
Contributor

dji-dev commented Mar 25, 2024

Agent comment from yating.liao in Zendesk ticket #103335:

The recommendation is not to make custom modifications on the controls of the UXSDK, but your requirements can be met with the open-source version. The open-source version includes most of the controls in the UXSDK.

°°°

@huongta157
Copy link
Author

@dji-dev I got it, thank you so much.
I have a new question, How to update the flight mode (Normal/ Sport/ Cine) for drone?
Is this SDK supported or not?

@dji-dev
Copy link
Contributor

dji-dev commented Mar 26, 2024

Agent comment from yating.liao in Zendesk ticket #103335:

Do you want to change the flight mode (Normal/ Sport/ Cine) through the SDK? This is not possible on the SDK as it can only listen to its changes. To make modifications, you will need to do it on the remote controller.

°°°

@huongta157
Copy link
Author

@dji-dev thank you so much

@dji-dev
Copy link
Contributor

dji-dev commented Mar 27, 2024

Agent comment from yating.liao in Zendesk ticket #103335:

I am glad to help you.

°°°

@huongta157
Copy link
Author

@dji-dev Is this SDK supported to zoom in/out camera?

@huongta157 huongta157 changed the title [Help] Issue with custom battery widget [Help] Issue with custom widgets Mar 28, 2024
@dji-dev
Copy link
Contributor

dji-dev commented Mar 28, 2024

Agent comment from yating.liao in Zendesk ticket #103335:

Could you please inform us about the model of the drone you are using? The SDK supports controlling the camera zoom.

°°°

@huongta157
Copy link
Author

Drone model: Dji Air 2s
Could you share with me the widget/function to implement camera zoom?

@dji-dev
Copy link
Contributor

dji-dev commented Mar 29, 2024

Agent comment from yating.liao in Zendesk ticket #103335:

The UXSDK does not provide zoom widget. There is an article here that provides the interface for zooming on the DJI AIR 2S, which you can use as a basis for implementing zoom functionality. It is important to note that the DJI AIR 2S can only zoom in camera recording mode.
https://sdk-forum.dji.net/hc/en-us/articles/10716410128537-How-does-DJI-Air-2S-zoom

°°°

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants