Commit f261a1f5 authored by Chengzhao Li's avatar Chengzhao Li
Browse files

- init with basic layout

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
NCMultipeerChat
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/ncmultipeerconnectivity" />
</set>
</option>
<option name="myModules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/ncmultipeerconnectivity" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/NCMultipeerChat.iml" filepath="$PROJECT_DIR$/NCMultipeerChat.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/ncmultipeerconnectivity/ncmultipeerconnectivity.iml" filepath="$PROJECT_DIR$/ncmultipeerconnectivity/ncmultipeerconnectivity.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.nclab.ncmultipeerchat"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':ncmultipeerconnectivity')
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/chl848/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
package com.nclab.ncmultipeerchat;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nclab.ncmultipeerchat">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingActivity"
android:screenOrientation="landscape" />
<activity
android:name=".LobbyActivity"
android:screenOrientation="landscape" />
<activity
android:name=".ChatActivity"
android:screenOrientation="landscape" />
</application>
</manifest>
\ No newline at end of file
package com.nclab.ncmultipeerchat;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
public class ChatActivity extends Activity {
private TextView txtChatHist;
private TextView txtLocalPlayer;
private TextView txtPlayer1;
private TextView txtPlayer2;
private TextView txtPlayer3;
private Button btnSendTo1;
private Button btnSendTo2;
private Button btnSendTo3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
txtChatHist = (TextView)this.findViewById(R.id.txtChatHist);
txtPlayer1 = (TextView)this.findViewById(R.id.txtSendToPlayer1);
txtPlayer2 = (TextView)this.findViewById(R.id.txtSendToPlayer2);
txtPlayer3 = (TextView)this.findViewById(R.id.txtSendToPlayer3);
txtLocalPlayer = (TextView)this.findViewById(R.id.txtPlayerLocal);
btnSendTo1 = (Button)this.findViewById(R.id.btnSendTo1);
btnSendTo2 = (Button)this.findViewById(R.id.btnSendTo2);
btnSendTo3 = (Button)this.findViewById(R.id.btnSendTo3);
}
public String getChatMsg() {
TextView user = (TextView)this.findViewById(R.id.txtChatMsg);
return user.getText().toString();
}
}
package com.nclab.ncmultipeerchat;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
public class LobbyActivity extends Activity {
private TextView lbMsg;
private TextView txtPlayer1;
private TextView txtPlayer2;
private TextView txtPlayer3;
private TextView txtPlayer4;
private ImageButton btnStartGame;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lobby);
ImageButton btnBack = (ImageButton)this.findViewById(R.id.btnBackToSC);
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
backToSettingActivity();
}
});
btnStartGame = (ImageButton)this.findViewById(R.id.btnStartGame);
lbMsg = (TextView)this.findViewById(R.id.lbMsg);
txtPlayer1 = (TextView)this.findViewById(R.id.txtPlayer1);
txtPlayer2 = (TextView)this.findViewById(R.id.txtPlayer2);
txtPlayer3 = (TextView)this.findViewById(R.id.txtPlayer3);
txtPlayer4 = (TextView)this.findViewById(R.id.txtPlayer4);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
backToSettingActivity();
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
private void backToSettingActivity() {
Intent intent = new Intent();
intent.setClass(LobbyActivity.this, SettingActivity.class);
LobbyActivity.this.startActivity(intent);
LobbyActivity.this.finish();
}
}
package com.nclab.ncmultipeerchat;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
public class LoginActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ImageButton btnStart=(ImageButton)this.findViewById(R.id.btnStart);
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user = getUserName();
if (!user.isEmpty() && user.length() >= 3 && user.length() <= 8) {
Intent intent = new Intent();
intent.setClass(LoginActivity.this, SettingActivity.class);
LoginActivity.this.startActivity(intent);
LoginActivity.this.finish();
} else {
String msg = "The length of user name must be between 3 and 8 letters";
new AlertDialog.Builder(LoginActivity.this).setTitle(getResources().getString(R.string.title)).setMessage(msg).setPositiveButton(getResources().getString(R.string.ok), null).show();
}
}
});
}
public String getUserName() {
TextView user = (TextView)this.findViewById(R.id.userName);
return user.getText().toString();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
exit();
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
private void exit() {
new AlertDialog.Builder(LoginActivity.this).setTitle("Warning").setMessage("Do you want to quit?").setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
System.exit(0);
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//
}
}).show();
}
}
package com.nclab.ncmultipeerchat;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
public class SettingActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
Button btnServer = (Button)this.findViewById(R.id.btnServer);
btnServer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//GameManager.getInstance().setIsHost(true);
gotoLobby();
}
});
Button btnClient = (Button)this.findViewById(R.id.btnClient);
if (BluetoothAdapter.getDefaultAdapter().isMultipleAdvertisementSupported()) {
btnClient.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//GameManager.getInstance().setIsHost(false);
gotoLobby();
}
});
} else {
btnClient.setEnabled(false);
btnClient.setVisibility(View.INVISIBLE);
}
ImageButton btnBack = (ImageButton)this.findViewById(R.id.btnBack);
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoLogin();
}
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
gotoLogin();
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
private void gotoLobby() {
Intent intent = new Intent();
intent.setClass(SettingActivity.this, LobbyActivity.class);
SettingActivity.this.startActivity(intent);
SettingActivity.this.finish();
}
private void gotoLogin() {
Intent intent = new Intent();
intent.setClass(SettingActivity.this, LoginActivity.class);
SettingActivity.this.startActivity(intent);
SettingActivity.this.finish();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment