{
void setText(String data);
void addText(String data);
+
+ void enableOperation(boolean isEnable);
}
import java.util.UUID;
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
-class FV100Communicator extends BluetoothGattCallback implements FV100ObjectPaser.ReceivedDataNotify, WifiConnector.WifiConnectNotify
+class FV100Communicator extends BluetoothGattCallback implements FV100ObjectPaser.ReceivedDataNotify, WifiConnector.WifiConnectNotify, FV100SendMessageProvider.MessageSequenceNotify
{
private String TAG = toString();
private final FragmentActivity context;
this.messageToShow = messageToShow;
this.receiveBuffer = new ByteArrayOutputStream();
this.objectParser = new FV100ObjectPaser(this);
- this.sendMessageProvider = new FV100SendMessageProvider();
+ this.sendMessageProvider = new FV100SendMessageProvider(this);
this.wifiConnector = new WifiConnector(context, messageToShow);
}
});
return;
}
- if ((setPropertyMessage != null)||(!sendMessageProvider.isMessageFinished()))
+ if ((setPropertyMessage != null)||(sendMessageProvider.isMessageSending()))
{
// ただいま通信中なので何もしないで終わる
context.runOnUiThread(new Runnable() {
String value = characteristic.getStringValue(0);
Log.v(TAG, " W: BluetoothGatt.GATT_SUCCESS " + characteristic.getUuid() + " (" + value + ") ");
- if (!sendMessageProvider.isMessageFinished())
+ if (sendMessageProvider.isMessageSending())
{
try
{
}
+ @Override
+ public void messageFinished(boolean isFinished)
+ {
+ dataUpdater.enableOperation(isFinished);
+ }
+
/*
@Override
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status)
}
}
*/
-
}
import android.util.Log;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.ByteArrayOutputStream;
class FV100SendMessageProvider
{
private final String TAG = toString();
+ private final MessageSequenceNotify notifier;
private List<Integer> msgIdList;
private List<String> typeList;
private List<String> paramList;
private int tokenId = 0;
private int index = 0;
private int offset = 0;
-
- private int sequene = 0;
private boolean isMessageFinished = false;
-
- FV100SendMessageProvider()
+ FV100SendMessageProvider(@NonNull MessageSequenceNotify notifier)
{
+ this.notifier = notifier;
initializeMsgIdList();
}
index = 0;
offset = 0;
isMessageFinished = false;
+ notifier.messageFinished(false);
}
void setTokenId(int tokenId)
{
index = 0;
isMessageFinished = true;
+ notifier.messageFinished(true);
Log.v(TAG, " - - - - - - - STATUS GET SEQUENCE FINISHED - - - - - - - ");
}
}
return (message);
}
- boolean isMessageFinished()
+ boolean isMessageSending()
{
- return (isMessageFinished);
+ return (!isMessageFinished);
}
private void initializeMsgIdList()
return (messageArray);
}
- private byte[] createSetPropertyMessage(@Nullable String type, @Nullable String param)
+ public interface MessageSequenceNotify
{
- String data = "{\"msg_id\":" + 2;
- if (param != null)
- {
- data = data + ",\"param\":\"" + param + "\"";
- }
- data = data + ",\"token\":" + tokenId;
- if (type != null)
- {
- data = data + ",\"type\":\"" + type + "\"";
- }
- data = data + "}";
-
- Log.v(TAG, " data to send : " + data);
-
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- try
- {
- byte[] header = {(byte) 0x01, (byte) 0x00, (byte) data.length()};
- output.write(header);
- output.write(data.getBytes());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (output.toByteArray());
+ void messageFinished(boolean isFinished);
}
-
-
}
import android.util.Log;
import android.view.View;
+import android.widget.ImageButton;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
}
@Override
+ public void enableOperation(final boolean isEnable)
+ {
+ try
+ {
+ context.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ final ImageButton wifiConnectButton = context.findViewById(R.id.wifi_connect_button);
+ if (wifiConnectButton != null)
+ {
+ wifiConnectButton.setEnabled(isEnable);
+ wifiConnectButton.setVisibility((isEnable? View.VISIBLE : View.INVISIBLE));
+ }
+
+ final ImageButton imageSizeButton = context.findViewById(R.id.change_image_size_button);
+ if (imageSizeButton != null)
+ {
+ imageSizeButton.setEnabled(isEnable);
+ imageSizeButton.setVisibility((isEnable? View.VISIBLE : View.INVISIBLE));
+ }
+
+ final ImageButton videoSizeButton = context.findViewById(R.id.change_video_size_button);
+ if (videoSizeButton != null)
+ {
+ videoSizeButton.setEnabled(isEnable);
+ videoSizeButton.setVisibility((isEnable? View.VISIBLE : View.INVISIBLE));
+ }
+ //Log.v(TAG, " >> ITextDataUpdater::enableOperation() : " + isEnable);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
public void setProperty(@NonNull final String propertyName, @NonNull final String propertyValue)
{
try
android:scaleType="fitCenter"
android:contentDescription="@string/blank"
app:srcCompat="@drawable/ic_image_aspect_ratio_black_24dp"
- android:visibility="visible" />
+ android:visibility="invisible" />
<ImageButton
android:id="@+id/change_video_size_button"
android:scaleType="fitCenter"
android:contentDescription="@string/blank"
app:srcCompat="@drawable/ic_videocam_black_24dp"
- android:visibility="visible" />
+ android:visibility="invisible" />
<ImageButton
android:id="@+id/dummy_button2"
android:scaleType="fitCenter"
android:contentDescription="@string/blank"
app:srcCompat="@drawable/ic_signal_wifi_4_bar_black_24dp"
- android:visibility="visible" />
+ android:visibility="invisible" />
</LinearLayout>
<View