1 package com.intel.realsense.camera;
3 import android.app.Activity;
4 import android.app.AlertDialog;
5 import android.app.Dialog;
6 import android.app.DialogFragment;
7 import android.content.Context;
8 import android.content.Intent;
9 import android.content.SharedPreferences;
10 import android.graphics.Color;
11 import android.graphics.drawable.ColorDrawable;
12 import android.os.Bundle;
13 import android.view.LayoutInflater;
14 import android.view.View;
15 import android.widget.Button;
16 import android.widget.CheckBox;
17 import android.widget.CompoundButton;
18 import android.widget.TextView;
43 if (recFw.equals(fw)){
44 mAlreadyLatestInstalled =
true;
45 return "The recommended firmware is already installed";
47 return "The firmware of the connected device is: " + fw +
48 "\n\nThe recommended firmware for this device is: " + recFw;
53 final Activity activity = getActivity();
54 Bundle bundle = getArguments();
56 final boolean fwUpdateRequest = bundle == null ?
false : bundle.getBoolean(getString(
R.string.firmware_update_request),
false);
57 final boolean fwUpdateRequired = bundle == null ?
false : bundle.getBoolean(getString(
R.string.firmware_update_required),
false);
59 LayoutInflater inflater = activity.getLayoutInflater();
60 View fragmentView = inflater.inflate(
R.layout.firmware_update_notification, null);
62 mDontAskAgainCheckBox = fragmentView.findViewById(
R.id.dontAskFwUpdateCheckBox);
63 mFwUpdateButton = fragmentView.findViewById(
R.id.startFwUpdateButton);
64 mSkipFwUpdateButton = fragmentView.findViewById(
R.id.skipFwUpdateButton);
65 mMessage = fragmentView.findViewById(
R.id.firmwareUpdateMessage);
66 mTitle = fragmentView.findViewById(
R.id.firmwareUpdateTitle);
69 mTitle.setText(
"Firmware update");
70 mSkipFwUpdateButton.setText(
"Cancel");
75 if(dl.getDeviceCount() > 0){
78 mMessage.setText(
"The current firmware version of the connected device is not supported by this librealsense version, update is required");
85 mFwUpdateButton = fragmentView.findViewById(
R.id.startFwUpdateButton);
86 mFwUpdateButton.setOnClickListener(
new View.OnClickListener() {
88 public void onClick(View
view) {
89 dismissAllowingStateLoss();
91 try(
Device d = dl.createDevice(0)){
95 dismissAllowingStateLoss();
101 if (mAlreadyLatestInstalled)
102 mFwUpdateButton.setEnabled(
false);
104 mSkipFwUpdateButton = fragmentView.findViewById(
R.id.skipFwUpdateButton);
105 mSkipFwUpdateButton.setOnClickListener(
new View.OnClickListener() {
107 public void onClick(View
view) {
108 dismissAllowingStateLoss();
109 if(!fwUpdateRequest){
111 startActivity(intent);
117 mSkipFwUpdateButton.setVisibility(View.GONE);
119 mDontAskAgainCheckBox = fragmentView.findViewById(
R.id.dontAskFwUpdateCheckBox);
120 mDontAskAgainCheckBox.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
122 public void onCheckedChanged(CompoundButton compoundButton,
boolean b) {
123 SharedPreferences sharedPref = activity.getSharedPreferences(getString(
R.string.app_settings), Context.MODE_PRIVATE);
124 SharedPreferences.Editor editor = sharedPref.edit();
126 editor.putBoolean(getString(
R.string.show_update_firmware), !mDontShowAgain);
130 if(fwUpdateRequest || fwUpdateRequired)
131 mDontAskAgainCheckBox.setVisibility(View.GONE);
133 AlertDialog.Builder builder =
new AlertDialog.Builder(getActivity());
134 builder.setView(fragmentView);
135 AlertDialog rv = builder.create();
136 rv.getWindow().setBackgroundDrawable(
new ColorDrawable(
Color.TRANSPARENT));
CheckBox mDontAskAgainCheckBox
GLboolean GLboolean GLboolean b
String getInfo(CameraInfo info)
T as(const std::vector< uint8_t > &data, size_t index)
RECOMMENDED_FIRMWARE_VERSION
::std_msgs::String_< std::allocator< void > > String
Dialog onCreateDialog(Bundle savedInstanceState)
Button mSkipFwUpdateButton
boolean mAlreadyLatestInstalled
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
String getFirmwareUpdateMessage(Device device)
DeviceList queryDevices()
boolean supportsInfo(CameraInfo info)