forked from littlecurl/AppProjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13bb738
commit fdb8445
Showing
107 changed files
with
2,210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches/build_file_checksums.ser | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.example.acer.myapplication" | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
|
||
implementation 'com.google.firebase:firebase-core:16.0.1' | ||
implementation 'com.google.firebase:firebase-auth:16.0.2' | ||
} | ||
apply plugin: 'com.google.gms.google-services' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "53242552378", | ||
"firebase_url": "https://kotlinmessager-bd8c4.firebaseio.com", | ||
"project_id": "kotlinmessager-bd8c4", | ||
"storage_bucket": "kotlinmessager-bd8c4.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:53242552378:android:f50c2ad6ed242e21", | ||
"android_client_info": { | ||
"package_name": "com.example.acer.myapplication" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "53242552378-kvai3d9v7ead6ohqddsg88dvrt3es374.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyBLr9j9ndNUYt3-DUT8yKpwnJTXAezrxCo" | ||
} | ||
], | ||
"services": { | ||
"analytics_service": { | ||
"status": 1 | ||
}, | ||
"appinvite_service": { | ||
"status": 1, | ||
"other_platform_oauth_client": [] | ||
}, | ||
"ads_service": { | ||
"status": 2 | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...ssager/app/src/androidTest/java/com/example/acer/myapplication/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.acer.myapplication | ||
|
||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.runner.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getTargetContext() | ||
assertEquals("com.example.acer.myapplication", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.acer.myapplication"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".LoginActivity"> | ||
|
||
</activity> | ||
</application> | ||
|
||
</manifest> |
30 changes: 30 additions & 0 deletions
30
KotlinMessager/app/src/main/java/com/example/acer/myapplication/LoginActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.acer.myapplication | ||
|
||
import android.support.v7.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.util.Log | ||
import com.google.firebase.auth.FirebaseAuth | ||
import kotlinx.android.synthetic.main.activity_login.* | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
class LoginActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_login) | ||
|
||
login_button_login.setOnClickListener(){ | ||
val email = email_edittext_login.text.toString() | ||
val password = password_edittext_login.text.toString() | ||
Log.d("Login","Attempt login with email/pw:$email/$password") | ||
|
||
FirebaseAuth.getInstance().signInWithEmailAndPassword(email,password) | ||
|
||
} | ||
|
||
back_to_register_button_login.setOnClickListener(){ | ||
finish() | ||
} | ||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
KotlinMessager/app/src/main/java/com/example/acer/myapplication/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.example.acer.myapplication | ||
|
||
import android.content.Intent | ||
import android.support.v7.app.AppCompatActivity | ||
import android.os.Bundle | ||
|
||
import android.util.Log | ||
import android.widget.Toast | ||
import com.google.firebase.auth.FirebaseAuth | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
register_button_register.setOnClickListener(){ | ||
performRegister() | ||
} | ||
already_have_a_count_textview_register.setOnClickListener(){ | ||
Log.d("MainActivity","try to show Login activity") | ||
|
||
val intent = Intent(this,LoginActivity::class.java) | ||
startActivity(intent) | ||
} | ||
|
||
} | ||
private fun performRegister(){ | ||
val email = email_edittext_register.text.toString() | ||
val password = password_edittext_register.text.toString() | ||
|
||
if(email.isEmpty() || password.isEmpty()){ | ||
Toast.makeText(this,"请输入用户名密码",Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
|
||
Log.d("MainActivity","Email is:"+email) | ||
Log.d("MainActivity","Password is:$password") | ||
|
||
FirebaseAuth.getInstance().createUserWithEmailAndPassword(email,password) | ||
.addOnCompleteListener{ | ||
if (!it.isSuccessful) | ||
return@addOnCompleteListener | ||
//else if successful | ||
Log.d("Main","成功创建一个用户,该用户的uid是:${it.result.user.uid}") | ||
} | ||
.addOnFailureListener{ | ||
Log.d("Main","创建用户失败:${it.message}") | ||
Toast.makeText(this,"创建用户失败:${it.message}",Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
} |
Oops, something went wrong.