-
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
0 parents
commit 94c3915
Showing
68 changed files
with
1,956 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,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
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,57 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'com.google.gms.google-services' | ||
} | ||
|
||
android { | ||
namespace 'com.qdot.fitgo' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.qdot.fitgo" | ||
minSdk 28 | ||
targetSdk 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
buildFeatures { | ||
viewBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.10.1' | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.9.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0' | ||
implementation 'androidx.navigation:navigation-ui-ktx:2.6.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
implementation platform('com.google.firebase:firebase-bom:32.1.1') | ||
implementation 'com.google.firebase:firebase-analytics-ktx' | ||
implementation("com.google.firebase:firebase-auth-ktx") | ||
implementation 'id.passage.android:passage:1.0.0' | ||
implementation("com.github.kittinunf.fuel:fuel:3.0.0-alpha1") | ||
|
||
implementation "androidx.health.connect:connect-client:1.1.0-alpha02" | ||
} |
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,47 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "216962382574", | ||
"project_id": "fitgo-e355d", | ||
"storage_bucket": "fitgo-e355d.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:216962382574:android:724134293882df3d2fd1ff", | ||
"android_client_info": { | ||
"package_name": "com.qdot.fitgo" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "216962382574-ke4km15vrj9p19lr8173110mn99gem7e.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.qdot.fitgo", | ||
"certificate_hash": "217b604705642c34209bfc4151cf3cb7c4c7d4eb" | ||
} | ||
}, | ||
{ | ||
"client_id": "216962382574-hnhroh907ie8ngbt7hedqee6v7urq2oh.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyAesYfg6xMDEyg9ALfhYq1Sz9qSqgs0SGc" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "216962382574-hnhroh907ie8ngbt7hedqee6v7urq2oh.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"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
app/src/androidTest/java/com/qdot/fitgo/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.qdot.fitgo | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext | ||
assertEquals("com.qdot.fitgo", 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,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.health.READ_HEART_RATE"/> | ||
<uses-permission android:name="android.permission.health.READ_STEPS"/> | ||
<uses-permission android:name="android.permission.health.READ_EXERCISE"/> | ||
<uses-permission android:name="android.permission.health.READ_TOTAL_CALORIES_BURNED"/> | ||
<uses-permission android:name="android.permission.health.READ_WEIGHT"/> | ||
<uses-permission android:name="android.permission.health.READ_DISTANCE"/> | ||
<uses-permission android:name="android.permission.health.READ_SPEED"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.FitGo" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.FitGo"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/> | ||
<category android:name="android.intent.category.HEALTH_PERMISSIONS"/> | ||
</intent-filter> | ||
</activity> | ||
<meta-data | ||
android:name="asset_statements" | ||
android:resource="@string/asset_statements" /> | ||
</application> | ||
|
||
<queries> | ||
<package android:name="com.google.android.apps.healthdata" /> | ||
<intent> | ||
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" /> | ||
</intent> | ||
</queries> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,110 @@ | ||
package com.qdot.fitgo | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import com.google.firebase.auth.FirebaseAuth | ||
import com.qdot.fitgo.databinding.AuthSheetLayoutBinding | ||
import fuel.Fuel | ||
import fuel.get | ||
import id.passage.android.Passage | ||
import id.passage.android.exceptions.RegisterWithPasskeyException | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import org.json.JSONObject | ||
|
||
class AuthBottomSheet(private val passage: Passage, private val auth : FirebaseAuth, | ||
private val loginInterface : LoginInterface) : BottomSheetDialogFragment() { | ||
private var _binding: AuthSheetLayoutBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = AuthSheetLayoutBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.loginNow.setOnClickListener { | ||
if (binding.mobText.text.isNullOrEmpty()){ | ||
Toast.makeText(requireContext(), | ||
"Enter email", | ||
Toast.LENGTH_SHORT).show() | ||
} | ||
else { | ||
CoroutineScope(Dispatchers.IO).launch { | ||
try { | ||
passage.loginWithPasskey(binding.mobText.text.toString()) | ||
val user = passage.getCurrentUser() ?: return@launch | ||
loginWithFirebase(user.id!!,user.email!!) | ||
} catch (e: RegisterWithPasskeyException) { | ||
loginInterface.loginStatus(false,e.message.toString()) | ||
dismiss() | ||
} | ||
} | ||
} | ||
} | ||
|
||
binding.signupNow.setOnClickListener { | ||
if (binding.mobText.text.isNullOrEmpty()){ | ||
Toast.makeText(requireContext(), | ||
"Enter email", | ||
Toast.LENGTH_SHORT).show() | ||
} | ||
else { | ||
CoroutineScope(Dispatchers.IO).launch { | ||
try { | ||
passage.registerWithPasskey(binding.mobText.text.toString()) | ||
val user = passage.getCurrentUser() ?: return@launch | ||
loginWithFirebase(user.id!!,user.email!!) | ||
} catch (e: RegisterWithPasskeyException) { | ||
loginInterface.loginStatus(false,e.message.toString()) | ||
dismiss() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private suspend fun loginWithFirebase(id: String,email:String) { | ||
try { | ||
val responseDat = Fuel.get("https://iamtoken-1-g1882055.deta.app/user/create/$id").body | ||
val jsonObject = JSONObject(responseDat) | ||
if (jsonObject.getBoolean("ok")){ | ||
auth.signInWithCustomToken(jsonObject.getString("data")) | ||
.addOnCompleteListener { | ||
if (it.isSuccessful){ | ||
if (auth.currentUser?.email.isNullOrEmpty()) { | ||
auth.currentUser?.updateEmail(email) | ||
} | ||
loginInterface.loginStatus(true,"") | ||
dismiss() | ||
}else{ | ||
loginInterface.loginStatus(false,"FB auth is not completed") | ||
dismiss() | ||
} | ||
} | ||
}else{ | ||
loginInterface.loginStatus(false,"Can not create token") | ||
dismiss() | ||
} | ||
}catch (e:Exception){ | ||
loginInterface.loginStatus(false,e.message.toString()) | ||
dismiss() | ||
} | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
Oops, something went wrong.