Skip to content

Commit 2bb4fdf

Browse files
authored
Merge pull request #66 from fpvout/feature/beta-ui-polishing
Pre-beta polishing
2 parents 2add981 + e038a84 commit 2bb4fdf

33 files changed

+244
-173
lines changed

app/build.gradle

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ plugins {
33
}
44

55
android {
6+
signingConfigs {
7+
digiview {
8+
try{
9+
storeFile file(digiviewStoreFile)
10+
storePassword digiviewStorePassword
11+
keyPassword digiviewKeyPassword
12+
keyAlias digiviewKeyAlias
13+
}
14+
catch (ex) {
15+
println("You should define mStoreFile, mStorePassword, mKeyPassword and mKeyAlias in ~/.gradle/gradle.properties.")
16+
}
17+
}
18+
}
19+
620
compileSdkVersion 30
721
buildToolsVersion "30.0.3"
822

@@ -11,16 +25,36 @@ android {
1125
minSdkVersion 21
1226
targetSdkVersion 30
1327
versionCode 1
14-
versionName "1.0"
15-
28+
versionName '1.0.0'
29+
resConfigs "en", "de", "fr", "es", "zh", "pt"
1630
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1731
}
1832

1933
buildTypes {
34+
debug {
35+
applicationIdSuffix '.debug'
36+
versionNameSuffix '-debug'
37+
signingConfig debug.signingConfig
38+
debuggable true
39+
}
40+
alpha {
41+
//applicationIdSuffix '.alpha'
42+
versionNameSuffix '-alpha'
43+
signingConfig signingConfigs.digiview
44+
}
45+
beta {
46+
//applicationIdSuffix '.beta'
47+
minifyEnabled false
48+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
49+
versionNameSuffix '-beta'
50+
signingConfig signingConfigs.digiview
51+
}
2052
release {
2153
minifyEnabled false
2254
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
55+
signingConfig signingConfigs.digiview
2356
}
57+
2458
}
2559

2660
compileOptions {

app/src/main/java/com/fpvout/digiview/DataCollectionAgreementPopupActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package com.fpvout.digiview;
22

33
import android.app.AlertDialog;
4-
import android.content.Context;
54
import android.content.Intent;
65
import android.content.SharedPreferences;
76
import android.os.Bundle;
87

98
import androidx.appcompat.app.AppCompatActivity;
9+
import androidx.preference.PreferenceManager;
1010

1111
public class DataCollectionAgreementPopupActivity extends AppCompatActivity {
1212
private SharedPreferences preferences;
1313
private AlertDialog.Builder builder;
1414

1515
protected void onCreate(Bundle savedInstanceState) {
1616
super.onCreate(savedInstanceState);
17-
preferences = this.getApplicationContext().getSharedPreferences("com.fpvout.digiview", Context.MODE_PRIVATE);
17+
preferences = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
1818
builder = new AlertDialog.Builder(this);
1919
initializeUI();
2020
}

app/src/main/java/com/fpvout/digiview/MainActivity.java

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.hardware.usb.UsbDevice;
1212
import android.hardware.usb.UsbManager;
1313
import android.os.Bundle;
14+
import android.os.Handler;
1415
import android.util.Log;
1516
import android.view.GestureDetector;
1617
import android.view.MotionEvent;
@@ -110,13 +111,15 @@ public void onClick(View v) {
110111
setupGestureDetectors();
111112

112113
mUsbMaskConnection = new UsbMaskConnection();
113-
mVideoReader = new VideoReaderExoplayer(fpvView, overlayView, this);
114+
Handler videoReaderEventListener = new Handler(this.getMainLooper(), msg -> onVideoReaderEvent((VideoReaderExoplayer.VideoReaderEventMessageCode) msg.obj));
115+
116+
mVideoReader = new VideoReaderExoplayer(fpvView, this, videoReaderEventListener);
114117

115118
if (!usbConnected) {
116119
if (searchDevice()) {
117120
connect();
118121
} else {
119-
overlayView.showOpaque(R.string.waiting_for_usb_device, OverlayStatus.Disconnected);
122+
showOverlay(R.string.waiting_for_usb_device, OverlayStatus.Disconnected);
120123
}
121124
}
122125
}
@@ -157,6 +160,11 @@ public boolean onTouchEvent(MotionEvent event) {
157160
}
158161

159162
private void updateWatermark() {
163+
if (overlayView.getVisibility() == View.VISIBLE) {
164+
watermarkView.setAlpha(0);
165+
return;
166+
}
167+
160168
if (sharedPreferences.getBoolean(ShowWatermark, true)) {
161169
watermarkView.setAlpha(0.3F);
162170
} else {
@@ -172,9 +180,27 @@ private void updateVideoZoom() {
172180
}
173181
}
174182

183+
private void cancelButtonAnimation() {
184+
Handler handler = settingsButton.getHandler();
185+
if (handler != null) {
186+
settingsButton.getHandler().removeCallbacksAndMessages(null);
187+
}
188+
}
189+
190+
private void showSettingsButton() {
191+
cancelButtonAnimation();
192+
193+
if (overlayView.getVisibility() == View.VISIBLE) {
194+
buttonAlpha = 1;
195+
settingsButton.setAlpha(1);
196+
}
197+
}
198+
175199
private void toggleSettingsButton() {
200+
if (buttonAlpha == 1 && overlayView.getVisibility() == View.VISIBLE) return;
201+
176202
// cancel any pending delayed animations first
177-
settingsButton.getHandler().removeCallbacksAndMessages(null);
203+
cancelButtonAnimation();
178204

179205
if (buttonAlpha == 1) {
180206
buttonAlpha = 0;
@@ -194,6 +220,7 @@ public void onAnimationEnd(Animator animation) {
194220
}
195221

196222
private void autoHideSettingsButton() {
223+
if (overlayView.getVisibility() == View.VISIBLE) return;
197224
if (buttonAlpha == 0) return;
198225

199226
settingsButton.postDelayed(new Runnable() {
@@ -211,14 +238,14 @@ public void run() {
211238
public void usbDeviceApproved(UsbDevice device) {
212239
Log.i(TAG, "USB - usbDevice approved");
213240
usbDevice = device;
214-
overlayView.showOpaque(R.string.usb_device_approved, OverlayStatus.Connected);
241+
showOverlay(R.string.usb_device_approved, OverlayStatus.Connected);
215242
connect();
216243
}
217244

218245
@Override
219246
public void usbDeviceDetached() {
220247
Log.i(TAG, "USB - usbDevice detached");
221-
overlayView.showOpaque(R.string.usb_device_detached_waiting, OverlayStatus.Disconnected);
248+
showOverlay(R.string.usb_device_detached_waiting, OverlayStatus.Disconnected);
222249
this.onStop();
223250
}
224251

@@ -233,7 +260,7 @@ private boolean searchDevice() {
233260
if (device.getVendorId() == VENDOR_ID && device.getProductId() == PRODUCT_ID) {
234261
if (usbManager.hasPermission(device)) {
235262
Log.i(TAG, "USB - usbDevice attached");
236-
overlayView.showOpaque(R.string.usb_device_found, OverlayStatus.Connected);
263+
showOverlay(R.string.usb_device_found, OverlayStatus.Connected);
237264
usbDevice = device;
238265
return true;
239266
}
@@ -251,6 +278,9 @@ private void connect() {
251278
mVideoReader.setUsbMaskConnection(mUsbMaskConnection);
252279
overlayView.hide();
253280
mVideoReader.start();
281+
updateWatermark();
282+
autoHideSettingsButton();
283+
showOverlay(R.string.waiting_for_video, OverlayStatus.Connected);
254284
}
255285

256286
@Override
@@ -275,7 +305,7 @@ public void onResume() {
275305
Log.d(TAG, "APP - On Resume usbDevice device found");
276306
connect();
277307
} else {
278-
overlayView.showOpaque(R.string.waiting_for_usb_device, OverlayStatus.Disconnected);
308+
showOverlay(R.string.waiting_for_usb_device, OverlayStatus.Connected);
279309
}
280310
}
281311

@@ -285,6 +315,30 @@ public void onResume() {
285315
updateVideoZoom();
286316
}
287317

318+
private boolean onVideoReaderEvent(VideoReaderExoplayer.VideoReaderEventMessageCode m) {
319+
if (VideoReaderExoplayer.VideoReaderEventMessageCode.WAITING_FOR_VIDEO.equals(m)) {
320+
Log.d(TAG, "event: WAITING_FOR_VIDEO");
321+
showOverlay(R.string.waiting_for_video, OverlayStatus.Connected);
322+
} else if (VideoReaderExoplayer.VideoReaderEventMessageCode.VIDEO_PLAYING.equals(m)) {
323+
Log.d(TAG, "event: VIDEO_PLAYING");
324+
hideOverlay();
325+
}
326+
return false; // false to continue listening
327+
}
328+
329+
private void showOverlay(int textId, OverlayStatus connected) {
330+
overlayView.show(textId, connected);
331+
updateWatermark();
332+
showSettingsButton();
333+
}
334+
335+
private void hideOverlay() {
336+
overlayView.hide();
337+
updateWatermark();
338+
showSettingsButton();
339+
autoHideSettingsButton();
340+
}
341+
288342
@Override
289343
protected void onStop() {
290344
super.onStop();
@@ -319,7 +373,7 @@ protected void onDestroy() {
319373
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
320374
super.onActivityResult(requestCode, resultCode, data);
321375

322-
SharedPreferences preferences = getApplicationContext().getSharedPreferences("com.fpvout.digiview", Context.MODE_PRIVATE);
376+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
323377
boolean dataCollectionAccepted = preferences.getBoolean("dataCollectionAccepted", false);
324378

325379
if (requestCode == 1) { // Data Collection agreement Activity
@@ -336,7 +390,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
336390
} //onActivityResult
337391

338392
private void checkDataCollectionAgreement() {
339-
SharedPreferences preferences = getApplicationContext().getSharedPreferences("com.fpvout.digiview", Context.MODE_PRIVATE);
393+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
340394
boolean dataCollectionAccepted = preferences.getBoolean("dataCollectionAccepted", false);
341395
boolean dataCollectionReplied = preferences.getBoolean("dataCollectionReplied", false);
342396
if (!dataCollectionReplied) {

app/src/main/java/com/fpvout/digiview/OverlayView.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,13 @@ public void hide(){
2626
setVisibility(View.GONE);
2727
}
2828

29-
public void showOverlay(int textResourceId, OverlayStatus status){
30-
showOverlay(getContext().getString(textResourceId), status);
29+
public void show(int textResourceId, OverlayStatus status){
30+
showInfo(getContext().getString(textResourceId), status);
3131
}
3232

33-
public void showOverlay(String text, OverlayStatus status){
34-
showInfo(text, status, 0.6f);
35-
}
36-
37-
public void showOpaque(int textResourceId, OverlayStatus status){
38-
showOpaque(getContext().getString(textResourceId), status);
39-
}
40-
41-
public void showOpaque(String text, OverlayStatus status){
42-
showInfo(text, status, 1f);
43-
}
44-
45-
private void showInfo(String text, OverlayStatus status, float alpha){
33+
private void showInfo(String text, OverlayStatus status){
4634

4735
setVisibility(View.VISIBLE);
48-
setAlpha(alpha);
4936

5037
textView.setText(text);
5138

app/src/main/java/com/fpvout/digiview/PerformancePreset.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ private PerformancePreset(int mH264ReaderMaxSyncFrameSize, int mH264ReaderSample
2323
dataSourceType = mDataSourceType;
2424
}
2525

26-
public enum PresetType {
27-
DEFAULT,
28-
CONSERVATIVE,
29-
AGGRESSIVE,
30-
LEGACY
31-
}
32-
33-
public enum DataSourceType {
34-
INPUT_STREAM,
35-
BUFFERED_INPUT_STREAM
36-
}
37-
3826
static PerformancePreset getPreset(PresetType p) {
3927
switch (p) {
4028
case CONSERVATIVE:
@@ -43,12 +31,19 @@ static PerformancePreset getPreset(PresetType p) {
4331
return new PerformancePreset(131072, 7000, 50, 2000, 17, 17, DataSourceType.INPUT_STREAM);
4432
case LEGACY:
4533
return new PerformancePreset(30720, 200, 32768, 65536, 0, 0, DataSourceType.BUFFERED_INPUT_STREAM);
34+
case LEGACY_BUFFERED:
35+
return new PerformancePreset(30720, 300, 32768, 65536, 34, 34, DataSourceType.BUFFERED_INPUT_STREAM);
4636
case DEFAULT:
4737
default:
4838
return new PerformancePreset(131072, 10000, 500, 2000, 17, 17, DataSourceType.INPUT_STREAM);
4939
}
5040
}
5141

42+
public enum DataSourceType {
43+
INPUT_STREAM,
44+
BUFFERED_INPUT_STREAM
45+
}
46+
5247
static PerformancePreset getPreset(String p) {
5348
switch (p) {
5449
case "conservative":
@@ -57,12 +52,22 @@ static PerformancePreset getPreset(String p) {
5752
return getPreset(PresetType.AGGRESSIVE);
5853
case "legacy":
5954
return getPreset(PresetType.LEGACY);
55+
case "new_legacy":
56+
return getPreset(PresetType.LEGACY_BUFFERED);
6057
case "default":
6158
default:
6259
return getPreset(PresetType.DEFAULT);
6360
}
6461
}
6562

63+
public enum PresetType {
64+
DEFAULT,
65+
CONSERVATIVE,
66+
AGGRESSIVE,
67+
LEGACY,
68+
LEGACY_BUFFERED
69+
}
70+
6671
@Override
6772
public String toString() {
6873
return "PerformancePreset{" +

0 commit comments

Comments
 (0)