Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…et.io#2823

2. Android Studio 2.3.0-beta4, Api25, gradle 3.3 changes.
3. works with Pixel XL emulator, Api23
  • Loading branch information
Vamsee Lakamsani committed Feb 20, 2017
1 parent 61c9326 commit 5a4a514
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 39 deletions.
31 changes: 13 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'

repositories {
jcenter()
}


android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId 'com.github.nkzawa.socketio.androidchat'
minSdkVersion 15
targetSdkVersion 21
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -34,9 +24,14 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile ('io.socket:socket.io-client:0.8.1') {
compile 'com.android.support:appcompat-v7:25.0.+'
compile 'com.android.support:recyclerview-v7:25.0.+'
compile ('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.nkzawa.socketio.androidchat;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static junit.framework.Assert.assertEquals;


/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.github.nkzawa.socketio.androidchat", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.github.nkzawa.socketio.androidchat;

public class Constants {
public static final String CHAT_SERVER_URL = "http://chat.socket.io";
public static final String CHAT_SERVER_URL = "https://socketio-chat.now.sh/";
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.nkzawa.socketio.androidchat;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;


public class MainActivity extends ActionBarActivity {
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -22,20 +23,24 @@
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import io.socket.client.Socket;
import io.socket.emitter.Emitter;


/**
* A chat fragment containing messages view and input form.
*/
public class MainFragment extends Fragment {

private static final String TAG = "MainFragment";

private static final int REQUEST_LOGIN = 0;

private static final int TYPING_TIMER_LENGTH = 600;
Expand Down Expand Up @@ -290,6 +295,7 @@ public void call(Object... args) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Log.i(TAG, "diconnected");
isConnected = false;
Toast.makeText(getActivity().getApplicationContext(),
R.string.disconnect, Toast.LENGTH_LONG).show();
Expand All @@ -304,6 +310,7 @@ public void call(Object... args) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Log.e(TAG, "Error connecting");
Toast.makeText(getActivity().getApplicationContext(),
R.string.error_connect, Toast.LENGTH_LONG).show();
}
Expand All @@ -324,6 +331,7 @@ public void run() {
username = data.getString("username");
message = data.getString("message");
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
return;
}

Expand All @@ -347,6 +355,7 @@ public void run() {
username = data.getString("username");
numUsers = data.getInt("numUsers");
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
return;
}

Expand All @@ -370,6 +379,7 @@ public void run() {
username = data.getString("username");
numUsers = data.getInt("numUsers");
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
return;
}

Expand All @@ -392,6 +402,7 @@ public void run() {
try {
username = data.getString("username");
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
return;
}
addTyping(username);
Expand All @@ -411,6 +422,7 @@ public void run() {
try {
username = data.getString("username");
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
return;
}
removeTyping(username);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:2.3.0-beta4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 23 22:20:48 JST 2015
#Mon Feb 20 01:28:27 PST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 comments on commit 5a4a514

Please sign in to comment.