-
Notifications
You must be signed in to change notification settings - Fork 4
latest reading, recent history and authentication features #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'kotlin-kapt' | ||
id 'com.google.dagger.hilt.android' | ||
id 'com.google.gms.google-services' | ||
} | ||
|
||
android { | ||
namespace 'com.tuf2000m.energymeter' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.tuf2000m.energymeter" | ||
minSdk 24 | ||
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_17 | ||
targetCompatibility JavaVersion.VERSION_17 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '17' | ||
} | ||
|
||
buildFeatures { | ||
dataBinding true | ||
viewBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'androidx.core:core-ktx:1.12.0' | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.9.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
|
||
// Retrofit | ||
def retrofitVersion = '2.9.0' | ||
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" | ||
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" | ||
implementation "com.squareup.okhttp3:okhttp:4.9.3" | ||
implementation "com.squareup.okhttp3:logging-interceptor:4.9.3" | ||
|
||
// Hilt | ||
def hiltVersion = '2.44' | ||
implementation("com.google.dagger:hilt-android:$hiltVersion") | ||
kapt "com.google.dagger:hilt-android-compiler:$hiltVersion" | ||
|
||
// Coroutines | ||
def coroutineVersion = '1.5.2' | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion" | ||
|
||
// Kotlin Extensions | ||
implementation "androidx.activity:activity-ktx:1.8.0" | ||
implementation "androidx.fragment:fragment-ktx:1.6.1" | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" | ||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2" | ||
implementation 'androidx.savedstate:savedstate:1.2.1' | ||
|
||
// Firebase | ||
implementation(platform("com.google.firebase:firebase-bom:32.3.1")) | ||
implementation("com.google.firebase:firebase-auth-ktx") | ||
|
||
// Navigation Components | ||
implementation "androidx.navigation:navigation-fragment-ktx:2.2.1" | ||
implementation "androidx.navigation:navigation-ui:2.7.4" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "154914327689", | ||
"project_id": "tuf-2000mmobileapp", | ||
"storage_bucket": "tuf-2000mmobileapp.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:154914327689:android:5e7ed85d6e06c7e71d0a58", | ||
"android_client_info": { | ||
"package_name": "com.tuf2000m.energymeter" | ||
} | ||
}, | ||
"oauth_client": [], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyDVbXOCACRUmIahXhLIYgljK4x8YOow1Ys" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [] | ||
} | ||
} | ||
}, | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:154914327689:android:088275fa4f98382f1d0a58", | ||
"android_client_info": { | ||
"package_name": "com.venkat.tuf2000m" | ||
} | ||
}, | ||
"oauth_client": [], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyDVbXOCACRUmIahXhLIYgljK4x8YOow1Ys" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.tuf2000m.energymeter | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* 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.tuf2000m.energymeter", appContext.packageName) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<!-- Required permissions --> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".MyApplication" | ||
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.MeterReader" | ||
tools:targetApi="31"> | ||
|
||
<!-- Main activity --> | ||
<activity | ||
android:name=".EnergyMeterActivity" | ||
android:exported="true"> | ||
|
||
<!-- Intent filter for main action --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.tuf2000m.energymeter | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.tuf2000m.energymeter.databinding.ActivityMainBinding | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class EnergyMeterActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityMainBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityMainBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.tuf2000m.energymeter | ||
|
||
import android.app.Application | ||
import com.google.firebase.FirebaseApp | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class MyApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
FirebaseApp.initializeApp(this) | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this Kotlin file, we have the base repository class. The |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.tuf2000m.energymeter.base | ||
|
||
import com.tuf2000m.energymeter.data.remote.NetworkResult | ||
import kotlinx.coroutines.flow.flow | ||
import retrofit2.HttpException | ||
import java.io.IOException | ||
|
||
abstract class BaseRepository { | ||
|
||
/** | ||
* Executes a safe API call using Kotlin Flow. | ||
* | ||
* @param apiCall The API call to be executed. | ||
* @return Flow emitting [NetworkResult] with the API response or error. | ||
*/ | ||
suspend fun <T> safeApiCall(apiCall: suspend () -> T) = flow { | ||
try { | ||
emit(NetworkResult.Loading(true)) | ||
emit(NetworkResult.Success(apiCall.invoke())) | ||
} catch (e: HttpException) { | ||
emit( | ||
NetworkResult.Failure( | ||
e.localizedMessage ?: "Something went wrong, please try again later." | ||
) | ||
) | ||
} catch (e: IOException) { | ||
emit(NetworkResult.Failure("No Internet. Please check your internet connection.")) | ||
} catch (e: Exception) { | ||
emit(NetworkResult.Failure(e.localizedMessage ?: "Error")) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.tuf2000m.energymeter.data.model.auth | ||
|
||
import com.google.firebase.auth.FirebaseUser | ||
|
||
sealed class AuthResult { | ||
data class Success(val user: FirebaseUser?) : AuthResult() | ||
data class Failure(val exception: Exception?) : AuthResult() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manifest file to launch the Main Activity which is EnergyMeterActivity