APP Android - Lar & Finanças
Android application with simple and intuitive dashboard, containing instant data updates.
Publicated: 2021-05-25
Android application with Google Auth authentication, without the need for registration and immediate update of the panel using RecycleView connected to the Room database
Pre-requisite:
To run this application, you must have Android Studio installed on your machine. Download link
Note:
When running the application it can be run on your Android device or via an emulator, using the Android Emulator the first screen will be the login screen, and login is done through your Google account, without the need to register, in other accesses you will directly access the main screen.
Getting Started:
- Download the project by running a git clone:
git clone https://github.com/andresinho20049/LarFinanca_appAndroid.git
- with the project on your machine, open Android Studio and select "Open an Existing Project", wait until the entire repository is installed in your application, if you have problems [read](https://developer.android.com/ studio/intro/update.html#download-with-gradle).
Note: The first run may take a while, as it will be downloading dependencies.
- Click Run or press SHIFT + F10.
Tools
- Android Studio
- Java 8
- Libraries
-
Google
- 'com.google.android.gms:play-services-auth:19.0.0'
-
Firebase
- 'com.google.firebase:firebase-database'
- 'com.google.firebase:firebase-storage'
- 'com.google.firebase:firebase-auth'
- 'com.google.firebase:firebase-analytics'
-
Room components
- "androidx.room:room-runtime:2.2.5"
- "androidx.room:room-compiler:2.2.5"
- "androidx.room:room-testing:2.2.5"
-
Lifecycle components
- 'androidx.fragment:fragment:1.2.1'
- "androidx.lifecycle:lifecycle-viewmodel:2.2.0"
- "androidx.lifecycle:lifecycle-livedata:2.2.0"
- "androidx.lifecycle:lifecycle-common-java8:2.2.0"
-
UI
- 'androidx.appcompat:appcompat:1.2.0'
- 'com.google.android.material:material:1.1.0-alpha06'
- 'androidx.constraintlayout:constraintlayout:2.0.4'
-
How it work
When starting the app, it is analyzed whether the user is logged in, then they are directed to the dashboard, otherwise they will be redirected to the login screen.
Login uses Google's Oauth2, in conjunction with FirebaseAuth, no registration is required, just log in with a Google account.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Google SingIn
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mSignInClient = GoogleSignIn.getClient(this, gso);
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
//Instace firebase
mFirebaseAuth = FirebaseAuth.getInstance();
if (savedInstanceState == null && mFirebaseAuth.getCurrentUser() == null) {
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container, new LoginFragment())
.commit();
}
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container, new DashFragment())
.commit();
}
The data is stored in the Room Database, a repository and class dao were developed, and the RecyclerView interface was used.
As soon as the base undergoes any change, an observe implemented in the view model is executed, ensuring that the interface is always updated, in this way synchronization with the data in the firebase is guaranteed.
// Set up the RecyclerView
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
final ExtratoRecyclerViewAdapter adapter = new ExtratoRecyclerViewAdapter(new ExtratoRecyclerViewAdapter.FinanceiroDiff());
recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 1, GridLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter);
financeiroViewModel = new ViewModelProvider(this).get(PagamentoViewModel.class);
financeiroViewModel.getAllPagamentos().observe(((MainActivity) getActivity()), pagamento -> {
adapter.submitList(pagamento);
});
READY! \
ACADEMIC PROJECT:
Student: André Carlos
Course: Computer Science.
Subject: Computing for Mobile Devices - 6th Semester.
Recommended projects
APP Android - Lar & Finanças
Android application with simple and intuitive dashboard, containing instant data updates.
Tags