Skip to content

Commit c030994

Browse files
committed
first commit
0 parents  commit c030994

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1327
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Oussama Bonnor
4+
5+
Copyright (c) 2023 Anindya Chatterjee
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Nitrite Database Demo
2+
3+
This is a trivial TODO app powered by Nitrite database.
4+
5+
** This application is a modified version of JetTodoList app
6+
[here](https://github.com/oussamabonnor1/TODOAppAndroid), where SQLite was replaced by Nitrite.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
namespace 'org.dizitart.nitrite.demo'
7+
compileSdk 33
8+
9+
packagingOptions {
10+
resources {
11+
excludes.add('META-INF/DEPENDENCIES.txt')
12+
excludes.add('META-INF/LICENSE.txt')
13+
excludes.add('META-INF/NOTICE.txt')
14+
excludes.add('META-INF/NOTICE')
15+
excludes.add('META-INF/LICENSE')
16+
excludes.add('META-INF/DEPENDENCIES')
17+
excludes.add('META-INF/notice.txt')
18+
excludes.add('META-INF/license.txt')
19+
excludes.add('META-INF/dependencies.txt')
20+
excludes.add('META-INF/LGPL2.1')
21+
}
22+
}
23+
24+
defaultConfig {
25+
applicationId "org.dizitart.nitrite.demo"
26+
minSdk 24
27+
targetSdk 33
28+
versionCode 1
29+
versionName "1.0"
30+
31+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
32+
}
33+
34+
buildTypes {
35+
release {
36+
minifyEnabled false
37+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
38+
}
39+
}
40+
41+
compileOptions {
42+
sourceCompatibility JavaVersion.VERSION_11
43+
targetCompatibility JavaVersion.VERSION_11
44+
}
45+
46+
buildFeatures {
47+
viewBinding true
48+
}
49+
}
50+
51+
dependencies {
52+
implementation platform('org.dizitart:nitrite-bom:4.1.1-SNAPSHOT')
53+
implementation 'org.dizitart:nitrite'
54+
implementation 'org.dizitart:nitrite-mvstore-adapter'
55+
56+
implementation 'androidx.appcompat:appcompat:1.6.1'
57+
implementation 'com.google.android.material:material:1.9.0'
58+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
59+
implementation 'androidx.navigation:navigation-fragment:2.6.0'
60+
implementation 'androidx.navigation:navigation-ui:2.6.0'
61+
implementation 'com.github.javafaker:javafaker:1.0.2'
62+
63+
testImplementation 'junit:junit:4.13.2'
64+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
65+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
66+
}
67+
68+
configurations.implementation {
69+
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
70+
}

app/proguard-rules.pro

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
23+
-keep class org.diztart.no2.** { *; }
24+
-keep class org.slf4j.** { *; }
25+
-keep class org.h2.** { *; }
26+
-keep class org.objenesis.** { *; }
27+
-keep class com.fasterxml.jackson.** { *; }
28+
29+
-keepnames class * implements java.io.Serializable
30+
31+
-keepclassmembers class * implements java.io.Serializable {
32+
static final long serialVersionUID;
33+
private static final java.io.ObjectStreamField[] serialPersistentFields;
34+
!static !transient <fields>;
35+
private void writeObject(java.io.ObjectOutputStream);
36+
private void readObject(java.io.ObjectInputStream);
37+
java.lang.Object writeReplace();
38+
java.lang.Object readResolve();
39+
}

app/src/main/AndroidManifest.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.dizitart.nitrite.demo">
4+
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
8+
<application
9+
android:allowBackup="true"
10+
android:icon="@mipmap/ic_launcher"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme.NoActionBar">
14+
<activity
15+
android:name="org.dizitart.nitrite.demo.Controllers.ToDoListActivity"
16+
android:label="Tasks"
17+
android:theme="@style/AppTheme.NoActionBar">
18+
</activity>
19+
<activity
20+
android:name="org.dizitart.nitrite.demo.Controllers.ListMenuActivity"
21+
android:label="@string/app_name"
22+
android:theme="@style/AppTheme.NoActionBar"
23+
android:exported="true">
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
</application>
30+
31+
</manifest>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package org.dizitart.nitrite.demo.Controllers;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.BaseAdapter;
8+
import android.widget.ImageButton;
9+
import android.widget.ListView;
10+
import android.widget.RelativeLayout;
11+
import android.widget.TextView;
12+
13+
import androidx.appcompat.app.AppCompatActivity;
14+
import androidx.core.content.ContextCompat;
15+
16+
import org.dizitart.nitrite.demo.Model.TodoList;
17+
import org.dizitart.nitrite.demo.R;
18+
19+
import java.util.ArrayList;
20+
21+
public class ListMenuActivity extends AppCompatActivity {
22+
ListView listView;
23+
24+
@Override
25+
protected void onCreate(Bundle savedInstanceState) {
26+
super.onCreate(savedInstanceState);
27+
setContentView(R.layout.activity_list_menu);
28+
listView = (ListView) findViewById(R.id.listMenu);
29+
ArrayList<TodoList> lists = new ArrayList<>();
30+
lists.add(new TodoList("Home", "blue"));
31+
lists.add(new TodoList("Work", "green"));
32+
lists.add(new TodoList("School", "violet"));
33+
CustomAdapter customAdapter = new CustomAdapter(lists);
34+
listView.setAdapter(customAdapter);
35+
}
36+
37+
public class CustomAdapter extends BaseAdapter {
38+
ArrayList<TodoList> lists;
39+
40+
public CustomAdapter(ArrayList<TodoList> lists) {
41+
this.lists = lists;
42+
}
43+
44+
@Override
45+
public int getCount() {
46+
return lists.size();
47+
}
48+
49+
@Override
50+
public Object getItem(int i) {
51+
return null;
52+
}
53+
54+
@Override
55+
public long getItemId(int i) {
56+
return i;
57+
}
58+
59+
@Override
60+
public View getView(int i, View view, ViewGroup viewGroup) {
61+
view = getLayoutInflater().inflate(R.layout.task_menu_item, null);
62+
63+
//region setting background color
64+
RelativeLayout layout = view.findViewById(R.id.itemBackground);
65+
final String color = lists.get(i).getColor();
66+
if (color.matches("blue"))
67+
layout.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.list_item_background_blue));
68+
else if (color.matches("green"))
69+
layout.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.list_item_background_green));
70+
else
71+
layout.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.list_item_background_violet));
72+
//endregion
73+
74+
final TextView title = view.findViewById(R.id.listName);
75+
title.setText(lists.get(i).getName());
76+
ImageButton button = view.findViewById(R.id.selectList);
77+
button.setOnClickListener(view1 -> listSelected(title.getText().toString(), color));
78+
79+
return view;
80+
}
81+
82+
void listSelected(String listName, String listColor) {
83+
Intent intent = new Intent(getApplicationContext(), ToDoListActivity.class);
84+
intent.putExtra("listName", listName);
85+
intent.putExtra("listColor", listColor);
86+
startActivity(intent);
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)