diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin
index 3ea66c5..6828989 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock
index eab5f0f..92e3332 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin
index 89e8e8b..1299ffe 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock
index 3e2cc2c..d7f5188 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
index a7431fb..ac5377a 100644
Binary files a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin
index 95cef8a..be20110 100644
Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/jarAnalysis.bin b/.gradle/5.4.1/javaCompile/jarAnalysis.bin
index 6def626..c02118d 100644
Binary files a/.gradle/5.4.1/javaCompile/jarAnalysis.bin and b/.gradle/5.4.1/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock
index b665136..049946e 100644
Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/5.4.1/javaCompile/taskHistory.bin b/.gradle/5.4.1/javaCompile/taskHistory.bin
index ea8eb2e..e126ac6 100644
Binary files a/.gradle/5.4.1/javaCompile/taskHistory.bin and b/.gradle/5.4.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 93a000a..a88ee5f 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index 9ef6dd2..ff3d50f 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 83c4056..c44602a 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 45b5654..88ea3aa 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,8 +1,5 @@
-
-
-
diff --git a/.idea/dictionaries/phoenix.xml b/.idea/dictionaries/phoenix.xml
deleted file mode 100644
index 0a47e59..0000000
--- a/.idea/dictionaries/phoenix.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 15a15b2..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..169fd0d 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -12,6 +12,7 @@
+
diff --git a/.idea/modules/mear.iml b/.idea/modules/mear.iml
deleted file mode 100644
index 848c4c3..0000000
--- a/.idea/modules/mear.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/render.experimental.xml b/.idea/render.experimental.xml
deleted file mode 100644
index 8abbf83..0000000
--- a/.idea/render.experimental.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 3d15997..f99df51 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f94c2be..3fc4992 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,174 +5,36 @@
-
-
-
-
-
-
-
- org.jetbrains.kotlin
- kotlin-stdlib-jdk7
- 1.3.41
- JCenter
-
-
- com.ealva
- ealvalog
- 0.5.0
- JCenter
-
-
- com.android.support
- appcompat-v7
- 28.0.0
- Google
-
-
- com.android.support
- design
- 28.0.0
- Google
-
-
- com.android.support
- cardview-v7
- 28.0.0
- Google
-
-
- com.squareup.picasso
- picasso
- 2.71828
- JCenter
-
-
- com.ealva
- ealvatag
- 0.4.3
- JCenter
-
-
- com.android.support
- support-v4
- 28.0.0
- Google
-
-
- com.google.guava
- guava
- 28.0-jre
- JCenter
-
-
- com.android.support.constraint
- constraint-layout
- 2.0.0-beta2
- Google
-
-
- junit
- junit
- 4.13-beta-3
- JCenter
-
-
- com.ealva
- ealvalog-core
- 0.5.0
- JCenter
-
-
- com.android.support.test
- runner
- 1.0.2
- Google
-
-
- com.ealva
- ealvalog-android
- 0.5.0
- JCenter
-
-
- com.squareup.okio
- okio
- 2.2.2
- JCenter
-
-
- com.android.support.test.espresso
- espresso-core
- 3.0.2
- Google
-
-
- 1564017826053
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -191,17 +53,7 @@
-
-
-
-
-
-
-
-
-
-
-
+
@@ -209,119 +61,109 @@
-
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
@@ -334,67 +176,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
@@ -402,9 +206,6 @@
-
-
-
@@ -415,42 +216,63 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -486,7 +308,7 @@
-
+
@@ -531,559 +353,161 @@
-
- 1564017463922
+
+ 1570724397030
- 1564017463922
+ 1570724397030
-
- 1570311037655
-
-
-
- 1570311037656
-
-
- 1570328051146
-
-
-
- 1570328051146
-
-
- 1570499060130
-
-
-
- 1570499060130
-
-
-
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
- file://$PROJECT_DIR$/app/src/main/java/com/example/mear/playback/service/MusicService.kt
- 130
+ file://$PROJECT_DIR$/app/src/main/java/com/example/mear/activities/LoginActivity.kt
+ 91
-
+
file://$PROJECT_DIR$/app/src/main/java/com/example/mear/activities/LoginActivity.kt
- 45
+ 87
-
-
-
- file://$PROJECT_DIR$/app/src/main/java/com/example/mear/activities/LoginActivity.kt
- 85
-
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/BaseRepository.cpp
- 70
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/BaseRepository.cpp
- 19
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/BaseRepository.cpp
- 47
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 49
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 54
-
+
file://$PROJECT_DIR$/app/src/main/cpp/Demo.cpp
- 165
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 72
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 64
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 106
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 39
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/UserRepository.cpp
- 94
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/Demo.cpp
- 163
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/Demo.cpp
- 166
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/BaseRepository.cpp
- 51
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/BaseRepository.cpp
- 37
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/Demo.cpp
- 95
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/Demo.cpp
- 217
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/SongRepository.cpp
- 29
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/SongRepository.cpp
- 13
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/Demo.cpp
- 50
-
-
-
- file://$PROJECT_DIR$/app/src/main/cpp/SongRepository.cpp
- 55
-
+ 285
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
+
+
-
-
-
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/cpp/Demo.cpp b/app/src/main/cpp/Demo.cpp
index ad25924..53eb973 100644
--- a/app/src/main/cpp/Demo.cpp
+++ b/app/src/main/cpp/Demo.cpp
@@ -251,7 +251,7 @@ Java_com_example_mear_activities_LoginActivity_retrieveSong(
extern "C"
JNIEXPORT jobject
JNICALL
-Java_com_example_mear_activities_LoginActivity_retrieveUserCredentials(
+Java_com_example_mear_repositories_UserRepository_retrieveUserCredentials(
JNIEnv *env,
jobject thisObj,
jstring dataPath
@@ -275,6 +275,43 @@ Java_com_example_mear_activities_LoginActivity_retrieveUserCredentials(
return userObj;
}
+extern "C"
+JNIEXPORT jobject
+JNICALL
+Java_com_example_mear_repositories_UserRepository_logUser(
+ JNIEnv *env,
+ jobject thisObj,
+ jobject user,
+ jstring apiUri ) {
+ jclass userClass = env->GetObjectClass(user);
+ //auto tok = env->CallObjectMethod(token, env->GetMethodID(tokenClass, "setAccessToken", "(Ljava/lang/String;)V"));
+ auto passwordField = env->GetFieldID(userClass, "getPassword", "(Ljava/lang/String;)V");
+ //auto passwordM = env->CallObjectMethod(user, env->GetMethodID(userClass, "password", "(Ljava/lang/String;)V"));
+ //auto passwordMOne = env->CallObjectMethod(user, env->GetMethodID(userClass, "getPassword", "(Ljava/lang/String;)V"));
+ auto password = env->GetObjectField(user, passwordField);
+ //auto username = env->CallObjectMethod(user, env->GetMethodID(userClass, "setUsername", "(Ljava/lang/String;)V"));
+ auto usernameField = env->GetFieldID(userClass, "setUsername", "(Ljava/lang/String;)V");
+ auto username = env->GetObjectField(user, usernameField);
+
+ const std::string usr = env->GetStringUTFChars((jstring)username, nullptr);
+ const std::string pass = env->GetStringUTFChars((jstring)password, nullptr);
+ const std::string api = env->GetStringUTFChars(apiUri, nullptr);
+
+ model::Token token(fetchToken(usr, pass, api));
+
+ jclass tokenClass = env->FindClass( "com/example/mear/models/Token");
+ jmethodID jconstructor = env->GetMethodID( tokenClass, "", "()V" );
+ jobject tokenObj = env->NewObject( tokenClass, jconstructor );
+
+ jmethodID tokenAccess = env->GetMethodID( tokenClass, "setAccessToken", "(Ljava/lang/String;)V" );
+
+ jstring title = env->NewStringUTF(token.accessToken.c_str());
+
+ env->CallVoidMethod(tokenObj, tokenAccess, title);
+
+ return tokenObj;
+}
+
extern "C"
JNIEXPORT jstring
@@ -299,7 +336,7 @@ Java_com_example_mear_activities_LoginActivity_logUser(
extern "C"
JNIEXPORT jboolean
JNICALL
-Java_com_example_mear_activities_LoginActivity_isUserTableEmpty(
+Java_com_example_mear_repositories_UserRepository_isUserTableEmpty(
JNIEnv *env,
jobject thisObj,
jstring dataPath
@@ -313,7 +350,7 @@ Java_com_example_mear_activities_LoginActivity_isUserTableEmpty(
extern "C"
JNIEXPORT jboolean
JNICALL
-Java_com_example_mear_activities_LoginActivity_doesDatabaseExist(
+Java_com_example_mear_repositories_BaseRepository_doesDatabaseExist(
JNIEnv *env,
jobject thidObj,
jstring dataPath
diff --git a/app/src/main/java/com/example/mear/activities/LoginActivity.kt b/app/src/main/java/com/example/mear/activities/LoginActivity.kt
index 363702b..719d23e 100644
--- a/app/src/main/java/com/example/mear/activities/LoginActivity.kt
+++ b/app/src/main/java/com/example/mear/activities/LoginActivity.kt
@@ -11,7 +11,9 @@ import kotlinx.android.synthetic.main.content_login.*
import org.jetbrains.anko.toast
import com.example.mear.models.Song
+import com.example.mear.models.Token
import com.example.mear.models.User
+import com.example.mear.repositories.UserRepository
class LoginActivity : BaseServiceActivity() {
@@ -24,12 +26,12 @@ class LoginActivity : BaseServiceActivity() {
private external fun retrieveSong(tok: String, api: String, songId: Int): Song
- private external fun retrieveUserCredentials(path: String): User
+ //private external fun retrieveUserCredentials(path: String): User
private external fun logUser(usr: String, pass: String, api: String): String
- private external fun doesDatabaseExist(path: String): Boolean
- private external fun isUserTableEmpty(path: String): Boolean
+ //private external fun doesDatabaseExist(path: String): Boolean
+ //private external fun isUserTableEmpty(path: String): Boolean
private external fun pathIteratorDemo(path: String)
private external fun saveUserCredentials(username: String, password: String, appDir: String)
@@ -41,8 +43,9 @@ class LoginActivity : BaseServiceActivity() {
setSupportActionBar(toolbar)
val pa = appDirectory()
- if (doesDatabaseExist(pa) && !isUserTableEmpty(pa)) {
- val usr = retrieveUserCredentials(pa)
+ val usrRepo = UserRepository()
+ if (usrRepo.databaseExist(pa) && !usrRepo.isTableEmpty(pa)) {
+ val usr = usrRepo.retrieveCredentials(pa)
username.setText(usr.username)
password.setText(usr.password)
}
@@ -71,22 +74,26 @@ class LoginActivity : BaseServiceActivity() {
val saveCred = saveUserCred.isChecked
- val usernameStr = username.text.toString()
- val passwordStr = password.text.toString()
var apiUriStr = apiUri.text.toString()
+ val usr = User()
+ usr.username = username.text.toString()
+ usr.password = password.text.toString()
if (apiUriStr.isEmpty()) {
- apiUriStr = ""
+ apiUriStr = "https://www.soaricarus.com"
}
- val token = logUser(usernameStr, passwordStr, apiUriStr)
+ val myToken = Token(logUser(usr.username, usr.password, apiUriStr))
+ //val token = logUser(usernameStr, passwordStr, apiUriStr)
+ val usrRepo = UserRepository()
+ //val newToken = usrRepo.fetchToken(usr, apiUriStr)
try {
val songId = 4
- val song = retrieveSong(token, apiUriStr, songId)
+ val song = retrieveSong(myToken.accessToken, apiUriStr, songId)
val pa = appDirectory()
- if (saveCred && isUserTableEmpty(pa)) {
- saveUserCredentials(usernameStr, passwordStr, pa)
+ if (saveCred && usrRepo.isTableEmpty(pa)) {
+ saveUserCredentials(usr.username, usr.password, pa)
}
//startActivity(Intent(this, IcarusSongActivity::class.java))
}
diff --git a/app/src/main/java/com/example/mear/repositories/BaseRepository.kt b/app/src/main/java/com/example/mear/repositories/BaseRepository.kt
new file mode 100644
index 0000000..1c77177
--- /dev/null
+++ b/app/src/main/java/com/example/mear/repositories/BaseRepository.kt
@@ -0,0 +1,17 @@
+package com.example.mear.repositories
+
+open class BaseRepository {
+
+ companion object {
+ init {
+ System.loadLibrary("native-lib")
+ }
+ }
+
+
+ private external fun doesDatabaseExist(path: String): Boolean
+
+ fun databaseExist(path: String): Boolean {
+ return doesDatabaseExist(path)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mear/repositories/UserRepository.kt b/app/src/main/java/com/example/mear/repositories/UserRepository.kt
new file mode 100644
index 0000000..3db3548
--- /dev/null
+++ b/app/src/main/java/com/example/mear/repositories/UserRepository.kt
@@ -0,0 +1,37 @@
+package com.example.mear.repositories
+
+import com.example.mear.models.Token
+import com.example.mear.models.User
+
+class UserRepository : BaseRepository() {
+
+ private external fun logUser(user: User, apiUri: String) : Token
+
+ private external fun retrieveUserCredentials(path: String) : User
+
+ private external fun isUserTableEmpty(path: String): Boolean
+
+ private external fun saveUserCredentials(username: User)
+
+
+ fun fetchToken(user: User, apiUri: String): Token {
+ val usr = logUser(user, apiUri)
+
+ return usr
+ }
+
+
+ fun retrieveCredentials(path: String): User {
+ return retrieveUserCredentials(path)
+ }
+
+
+ fun isTableEmpty(path: String): Boolean {
+ return isUserTableEmpty(path)
+ }
+
+
+ fun saveCredentials(user: User) {
+ saveUserCredentials(user)
+ }
+}
\ No newline at end of file