Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
deftelf committed Jan 15, 2017
0 parents commit cff713b
Show file tree
Hide file tree
Showing 93 changed files with 2,137 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
54 changes: 54 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "org.standardnotes.notes"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "0.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"


compile 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.madgag.spongycastle:core:1.54.0.0'
compile 'com.madgag.spongycastle:prov:1.54.0.0'
compile 'com.madgag.spongycastle:pkix:1.54.0.0'
compile 'com.madgag.spongycastle:pg:1.54.0.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'net.danlew:android.joda:2.9.4.1'
testCompile 'junit:junit:4.12'
}
repositories {
mavenCentral()
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/carl/android-sdk-linux_86/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 *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.standardnotes.notes;

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 org.junit.Assert.*;

/**
* 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("org.standardnotes.notes", appContext.getPackageName());
}
}
43 changes: 43 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.standardnotes.notes">

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:name=".SApplication"
android:theme="@style/AppTheme">
<activity
android:name=".StarterActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity
android:name=".NoteActivity"
android:windowSoftInputMode="adjustResize"
/>
</application>

</manifest>
77 changes: 77 additions & 0 deletions app/src/main/java/org/standardnotes/notes/LoginActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.standardnotes.notes

import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button
import android.widget.TextView
import android.widget.Toast

import org.standardnotes.notes.comms.Crypt
import org.standardnotes.notes.comms.data.AuthParamsResponse
import org.standardnotes.notes.comms.data.SigninResponse
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

/**
* A login screen that offers login via email/password.
*/
class LoginActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
// Set up the login form.

val mEmailSignInButton = findViewById(R.id.email_sign_in_button) as Button
mEmailSignInButton.setOnClickListener {
val email = (findViewById(R.id.email) as TextView).text.toString()
SApplication.instance!!.comms.api.getAuthParamsForEmail(email).enqueue(object : Callback<AuthParamsResponse> {
override fun onResponse(call: Call<AuthParamsResponse>, response: Response<AuthParamsResponse>) {
try {
val params = response.body()
val key = Crypt.generateKey((findViewById(R.id.password) as TextView).text.toString().toByteArray(Charsets.UTF_8),
//Base64.decode(params.getPwSalt(), base64Flags),
params.pwSalt.toByteArray(Charsets.UTF_8),
params.pwCost!!,
params.pwKeySize!!)
val fullHashedPassword = Crypt.bytesToHex(key)
val serverHashedPassword = fullHashedPassword.substring(0, fullHashedPassword.length / 2)
val mk = fullHashedPassword.substring(fullHashedPassword.length / 2)
SApplication.instance!!.comms.api.signin(email, serverHashedPassword).enqueue(object : Callback<SigninResponse> {
override fun onResponse(call: Call<SigninResponse>, response: Response<SigninResponse>) {
if (response.isSuccessful) {
SApplication.instance!!.valueStore.setTokenAndMasterKey(response.body().token, mk)
startActivity(Intent(this@LoginActivity, MainActivity::class.java))
finish()


} else {
Toast.makeText(this@LoginActivity, "Incorrect details", Toast.LENGTH_SHORT).show()
}
}

override fun onFailure(call: Call<SigninResponse>, t: Throwable) {
toString()
}
})
} catch (e: Exception) {
e.printStackTrace()
}

}

override fun onFailure(call: Call<AuthParamsResponse>, t: Throwable) {
toString()
}
})
}
}


}

Loading

0 comments on commit cff713b

Please sign in to comment.