feat(android): adjust ui layout and text

This commit is contained in:
John Zhao 2019-03-01 11:38:36 +08:00
parent 8f096612a3
commit dc4a21d635
4 changed files with 20 additions and 14 deletions

View File

@ -17,6 +17,7 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import com.slightech.mynteye.DeviceUsbInfo; import com.slightech.mynteye.DeviceUsbInfo;
import com.slightech.mynteye.Frame; import com.slightech.mynteye.Frame;
import com.slightech.mynteye.ImuData;
import com.slightech.mynteye.MotionData; import com.slightech.mynteye.MotionData;
import com.slightech.mynteye.Stream; import com.slightech.mynteye.Stream;
import com.slightech.mynteye.StreamData; import com.slightech.mynteye.StreamData;
@ -156,10 +157,10 @@ public class MainActivity extends BaseActivity implements CameraDialog.CameraDia
} }
menu.findItem(R.id.check_imu_data).setChecked(mImuEnabled); menu.findItem(R.id.check_imu_data).setChecked(mImuEnabled);
boolean featuresUsable = mMynteye != null && mMynteye.isOpened(); boolean featuresUsable = mMynteye != null && mMynteye.isOpened();
menu.findItem(R.id.show_device_infos).setVisible(featuresUsable); menu.findItem(R.id.show_device_infos).setEnabled(featuresUsable);
menu.findItem(R.id.show_image_params).setVisible(featuresUsable); menu.findItem(R.id.show_image_params).setEnabled(featuresUsable);
menu.findItem(R.id.show_imu_params).setVisible(featuresUsable); menu.findItem(R.id.show_imu_params).setEnabled(featuresUsable);
menu.findItem(R.id.show_option_infos).setVisible(featuresUsable); menu.findItem(R.id.show_option_infos).setEnabled(featuresUsable);
return super.onPrepareOptionsMenu(menu); return super.onPrepareOptionsMenu(menu);
} }
@ -173,7 +174,7 @@ public class MainActivity extends BaseActivity implements CameraDialog.CameraDia
actionClose(); actionClose();
return true; return true;
case R.id.check_imu_data: case R.id.check_imu_data:
mImuEnabled = !item.isChecked(); mImuEnabled = !mImuEnabled;
item.setChecked(mImuEnabled); item.setChecked(mImuEnabled);
return true; return true;
case R.id.show_device_infos: case R.id.show_device_infos:
@ -194,6 +195,7 @@ public class MainActivity extends BaseActivity implements CameraDialog.CameraDia
} }
private void actionOpen() { private void actionOpen() {
mTextView.setText("");
if (mMynteye == null) { if (mMynteye == null) {
CameraDialog.showDialog(this); CameraDialog.showDialog(this);
} else { } else {
@ -281,7 +283,13 @@ public class MainActivity extends BaseActivity implements CameraDialog.CameraDia
@Override @Override
public void onMotionDataReceive(ArrayList<MotionData> datas, Handler handler) { public void onMotionDataReceive(ArrayList<MotionData> datas, Handler handler) {
if (datas.isEmpty()) return; if (datas.isEmpty()) return;
mTextView.post(() -> mTextView.setText(datas.get(0).imu().toString())); ImuData data = datas.get(0).imu();
mTextView.post(() -> {
StringBuffer sb = new StringBuffer();
sb.append("Accel: ").append(data.getAccel());
sb.append("\nGyro: ").append(data.getGyro());
mTextView.setText(sb.toString());
});
} }
private void toast(int textId) { private void toast(int textId) {

View File

@ -11,12 +11,11 @@
<TextView <TextView
android:id="@+id/text" android:id="@+id/text"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:text="Hello World!" android:text="@string/tip_open"
app:layout_constraintBottom_toTopOf="@id/layout_image"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -29,7 +28,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text" app:layout_constraintTop_toTopOf="parent"
> >
<ImageView <ImageView

View File

@ -10,9 +10,6 @@
android:title="@string/close" android:title="@string/close"
app:showAsAction="ifRoom|withText" /> app:showAsAction="ifRoom|withText" />
<item android:title="Features"
android:enabled="false" />
<item <item
android:id="@+id/check_imu_data" android:id="@+id/check_imu_data"
android:title="@string/imu_data" android:title="@string/imu_data"

View File

@ -1,5 +1,7 @@
<resources> <resources>
<string name="app_name">mynteye</string> <string name="app_name">MYNTEYE-S SDK Sample</string>
<string name="tip_open">Please \"Open\" the camera!</string>
<string name="open">Open</string> <string name="open">Open</string>
<string name="close">Close</string> <string name="close">Close</string>