Commit 9832c508 by Chayaa852

Socket related changes

parent 84d408af
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature <uses-feature
android:name="android.hardware.camera" android:name="android.hardware.camera"
......
...@@ -19,6 +19,7 @@ import android.os.Bundle; ...@@ -19,6 +19,7 @@ import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.PowerManager;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener; import android.speech.tts.UtteranceProgressListener;
...@@ -115,7 +116,7 @@ import static com.vsoft.vera.db.DBManager.DATABASE_NAME; ...@@ -115,7 +116,7 @@ import static com.vsoft.vera.db.DBManager.DATABASE_NAME;
*/ */
public class ChatActivity extends AppCompatActivity implements OnDSListener, OnDSPermissionsListener { public class ChatActivity extends AppCompatActivity implements OnDSListener, OnDSPermissionsListener {
private static final String TAG = "ChatActivity"; private static final String TAG = ChatActivity.class.getName();//"ChatActivity";
private static String NEW_MESSAGE = "new message"; private static String NEW_MESSAGE = "new message";
private static String AUTHENTICATED = "authenticated"; private static String AUTHENTICATED = "authenticated";
private static String UNAUTHORIZED = "unauthorized"; private static String UNAUTHORIZED = "unauthorized";
...@@ -180,7 +181,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD ...@@ -180,7 +181,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
private static final String HTTPS = "https://"; private static final String HTTPS = "https://";
private static final String HTTP = "http://"; private static final String HTTP = "http://";
private LinearLayout mainLayt; private LinearLayout mainLayt;
private PowerManager.WakeLock wl;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
...@@ -197,6 +198,14 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD ...@@ -197,6 +198,14 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
} }
}); });
PowerManager pm = (PowerManager)getApplicationContext().getSystemService(
Context.POWER_SERVICE);
this.wl = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK
| PowerManager.ON_AFTER_RELEASE,
TAG);
wl.acquire();
mLoggedInUserSysId = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_SYS_ID); mLoggedInUserSysId = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_SYS_ID);
mLoggedInUsername = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_FIRST_NAME); mLoggedInUsername = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_FIRST_NAME);
userSysId = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_SYS_ID); userSysId = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_SYS_ID);
...@@ -1334,6 +1343,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD ...@@ -1334,6 +1343,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
mSocket.off(AUTHENTICATED, authenticated); mSocket.off(AUTHENTICATED, authenticated);
mSocket.off(UNAUTHORIZED, unAuthorized); mSocket.off(UNAUTHORIZED, unAuthorized);
} }
wl.release();
if(speaker != null) { if(speaker != null) {
speaker.destroy(); speaker.destroy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment