diff --git a/app/build.gradle b/app/build.gradle index 3da8726a..c6b0323d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "info.dvkr.screenstream" minSdkVersion 21 targetSdkVersion 24 - versionCode 14 - versionName "1.1.7" + versionCode 15 + versionName "1.1.8" resConfigs "en", "ru" } @@ -37,7 +37,7 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:design:24.2.1' - compile 'com.google.firebase:firebase-crash:9.4.0' + compile 'com.google.firebase:firebase-crash:9.6.0' compile 'org.greenrobot:eventbus:3.0.0' } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 227fc43f..ddd8a518 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -17,11 +17,7 @@ #} # EventBus 3.0 --keepclassmembers class ** { - public void onMessageEvent*(**); -} - -# EventBus 3.0 annotation +-keepattributes *Annotation* -keepclassmembers class * { @org.greenrobot.eventbus.Subscribe ; } diff --git a/app/src/main/java/info/dvkr/screenstream/ScreenStreamApplication.java b/app/src/main/java/info/dvkr/screenstream/ScreenStreamApplication.java index 8de2be4e..0ea69564 100644 --- a/app/src/main/java/info/dvkr/screenstream/ScreenStreamApplication.java +++ b/app/src/main/java/info/dvkr/screenstream/ScreenStreamApplication.java @@ -5,24 +5,24 @@ import info.dvkr.screenstream.data.AppData; import info.dvkr.screenstream.data.local.PreferencesHelper; import info.dvkr.screenstream.service.ForegroundService; -import info.dvkr.screenstream.viewModel.MainActivityViewModel; +import info.dvkr.screenstream.viewmodel.MainActivityViewModel; public class ScreenStreamApplication extends Application { private static ScreenStreamApplication sAppInstance; + private AppData mAppData; private MainActivityViewModel mMainActivityViewModel; private PreferencesHelper mPreferencesHelper; - private AppData mAppData; @Override public void onCreate() { super.onCreate(); sAppInstance = this; + mAppData = new AppData(this); mMainActivityViewModel = new MainActivityViewModel(this); mPreferencesHelper = new PreferencesHelper(this); - mAppData = new AppData(this); startService(ForegroundService.getStartIntent(this)); } diff --git a/app/src/main/java/info/dvkr/screenstream/data/AppData.java b/app/src/main/java/info/dvkr/screenstream/data/AppData.java index 6f7d19e0..88e89ecb 100644 --- a/app/src/main/java/info/dvkr/screenstream/data/AppData.java +++ b/app/src/main/java/info/dvkr/screenstream/data/AppData.java @@ -127,7 +127,7 @@ public String getServerAddress() { } public boolean isWiFiConnected() { - return mWifiManager.getConnectionInfo().getIpAddress() > 0; + return mWifiManager.getConnectionInfo().getIpAddress() != 0; } //Private diff --git a/app/src/main/java/info/dvkr/screenstream/service/ForegroundService.java b/app/src/main/java/info/dvkr/screenstream/service/ForegroundService.java index ef00f5d5..0dd967b5 100644 --- a/app/src/main/java/info/dvkr/screenstream/service/ForegroundService.java +++ b/app/src/main/java/info/dvkr/screenstream/service/ForegroundService.java @@ -57,6 +57,7 @@ public final class ForegroundService extends Service { private HttpServer mHttpServer; private ImageGenerator mImageGenerator; private NotifyImageGenerator mNotifyImageGenerator; + private HandlerThread mHandlerThread; private ForegroundServiceHandler mForegroundServiceTaskHandler; private BroadcastReceiver mLocalNotificationReceiver; private BroadcastReceiver mBroadcastReceiver; @@ -107,10 +108,11 @@ public void onStop() { mNotifyImageGenerator.addDefaultScreen(); // Starting thread Handler - final HandlerThread looperThread = - new HandlerThread(ForegroundService.class.getSimpleName(), Process.THREAD_PRIORITY_MORE_FAVORABLE); - looperThread.start(); - mForegroundServiceTaskHandler = new ForegroundServiceHandler(looperThread.getLooper()); + mHandlerThread = new HandlerThread( + ForegroundService.class.getSimpleName(), + Process.THREAD_PRIORITY_MORE_FAVORABLE); + mHandlerThread.start(); + mForegroundServiceTaskHandler = new ForegroundServiceHandler(mHandlerThread.getLooper()); //Local notifications final IntentFilter localNotificationIntentFilter = new IntentFilter(); @@ -200,7 +202,7 @@ public void onDestroy() { unregisterReceiver(mBroadcastReceiver); unregisterReceiver(mLocalNotificationReceiver); if (mMediaProjection != null) mMediaProjection.unregisterCallback(mProjectionCallback); - mForegroundServiceTaskHandler.getLooper().quit(); + mHandlerThread.quit(); } @Subscribe diff --git a/app/src/main/java/info/dvkr/screenstream/view/MainActivity.java b/app/src/main/java/info/dvkr/screenstream/view/MainActivity.java index 3460c687..930fb518 100644 --- a/app/src/main/java/info/dvkr/screenstream/view/MainActivity.java +++ b/app/src/main/java/info/dvkr/screenstream/view/MainActivity.java @@ -24,6 +24,7 @@ import org.greenrobot.eventbus.ThreadMode; import info.dvkr.screenstream.R; +import info.dvkr.screenstream.data.AppData; import info.dvkr.screenstream.data.BusMessages; import info.dvkr.screenstream.databinding.ActivityMainBinding; import info.dvkr.screenstream.service.ForegroundService; @@ -84,7 +85,6 @@ protected void onStart() { getAppData().setActivityRunning(true); } - @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onMessageEvent(BusMessages busMessage) { switch (busMessage.getMessage()) { diff --git a/app/src/main/java/info/dvkr/screenstream/viewModel/MainActivityViewModel.java b/app/src/main/java/info/dvkr/screenstream/viewModel/MainActivityViewModel.java index 5e9ffac0..12686981 100644 --- a/app/src/main/java/info/dvkr/screenstream/viewModel/MainActivityViewModel.java +++ b/app/src/main/java/info/dvkr/screenstream/viewModel/MainActivityViewModel.java @@ -1,4 +1,4 @@ -package info.dvkr.screenstream.viewModel; +package info.dvkr.screenstream.viewmodel; import android.content.Context; import android.databinding.BaseObservable; @@ -138,7 +138,7 @@ public String getConnectedClientsText() { } public void onToggleButtonClick(View v) { - if (getAppData().isStreamRunning()) { + if (mIsStreaming) { EventBus.getDefault().post(new BusMessages(BusMessages.MESSAGE_ACTION_STREAMING_STOP)); } else { ((ToggleButton) v).setChecked(false); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5b4e5dfe..fa5c53a2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ + type="info.dvkr.screenstream.viewmodel.MainActivityViewModel"/>