Skip to content

Commit c152b06

Browse files
committed
upload code
1 parent d0132e0 commit c152b06

File tree

103 files changed

+3747
-0
lines changed

Some content is hidden

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

103 files changed

+3747
-0
lines changed

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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
namespace 'xyz.tannhatcms.searchdictionary'
8+
//noinspection GradleCompatible
9+
compileSdk 33
10+
defaultConfig {
11+
applicationId "xyz.tannhatcms.searchdictionary"
12+
minSdk 26
13+
targetSdk 33
14+
versionCode 1
15+
versionName "1.0"
16+
minSdkVersion 26
17+
targetSdk 33
18+
//noinspection OldTargetApi
19+
multiDexEnabled true
20+
vectorDrawables.useSupportLibrary = true
21+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
22+
}
23+
buildTypes {
24+
android.applicationVariants.all { variant ->
25+
variant.outputs.all {
26+
outputFileName = "TraTuDien v${variant.versionName}-${variant.versionCode}.apk"
27+
}
28+
}
29+
30+
release {
31+
minifyEnabled false
32+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
33+
signingConfig signingConfigs.debug
34+
}
35+
debug {
36+
signingConfig signingConfigs.debug
37+
}
38+
}
39+
compileOptions {
40+
sourceCompatibility JavaVersion.VERSION_1_8
41+
targetCompatibility JavaVersion.VERSION_1_8
42+
}
43+
buildFeatures {
44+
buildConfig = true
45+
viewBinding true
46+
}
47+
lint {
48+
abortOnError false
49+
checkReleaseBuilds false
50+
}
51+
buildToolsVersion '33.0.0'
52+
}
53+
54+
dependencies {
55+
implementation group: 'androidx.annotation', name: 'annotation', version: '1.7.0-alpha02'
56+
implementation 'com.google.android.material:material:1.9.0'
57+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
58+
testImplementation 'junit:junit:4.13.2'
59+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
60+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
61+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package xyz.tannhatcms.searchdictionary;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("xyz.tannhatcms.searchdictionary", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.TraTuDien"
14+
tools:targetApi="31">
15+
<activity android:name=".ui.SplashScreen"
16+
android:theme="@style/Theme.TraTuDien.NoActionBar"
17+
android:exported="true">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity android:name=".ui.MainActivity" />
24+
<activity
25+
android:name=".ui.HistoryTestActivity"
26+
android:parentActivityName=".ui.MainActivity">
27+
</activity>
28+
<activity
29+
android:name=".ui.HistoryActivity"
30+
android:parentActivityName=".ui.HistoryTestActivity"
31+
android:theme="@style/Theme.TraTuDien.NoActionBar"
32+
/>
33+
<activity
34+
android:name=".ui.GrammarListActivity"
35+
android:parentActivityName=".ui.MainActivity" />
36+
<activity
37+
android:name=".ui.GrammarActivity"
38+
android:parentActivityName=".ui.GrammarListActivity" />
39+
<activity
40+
android:name=".ui.QuestionActivity"
41+
android:theme="@style/Theme.TraTuDien.NoActionBar" />
42+
<activity
43+
android:name=".ui.SearchActivity"
44+
/>
45+
<activity android:name=".ui.SearchDictionaryAtivity"
46+
android:parentActivityName=".ui.MainActivity"
47+
android:theme="@style/Theme.TraTuDien.NoActionBar"
48+
/>
49+
<activity
50+
android:name=".ui.NoteActivity"
51+
android:parentActivityName=".ui.MainActivity" />
52+
<activity
53+
android:name=".ui.NoteEditActivity"
54+
android:parentActivityName=".ui.NoteActivity" />
55+
<activity
56+
android:name=".ui.NoteAddActivity"
57+
android:parentActivityName=".ui.NoteActivity" />
58+
<activity
59+
android:name=".ui.SettingActivity"
60+
android:parentActivityName=".ui.MainActivity" />
61+
</application>
62+
</manifest>

app/src/main/assets/luutru.sqlite

16.8 MB
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package xyz.tannhatcms.searchdictionary;
2+
3+
import android.app.Application;
4+
5+
public class MyApplication extends Application {
6+
7+
public static final String TAG = MyApplication.class
8+
.getSimpleName();
9+
10+
11+
12+
private static MyApplication mInstance;
13+
14+
@Override
15+
public void onCreate() {
16+
super.onCreate();
17+
mInstance = this;
18+
}
19+
20+
public static synchronized MyApplication getInstance() {
21+
return mInstance;
22+
}
23+
24+
25+
26+
27+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package xyz.tannhatcms.searchdictionary.adapter;
2+
3+
import android.annotation.SuppressLint;
4+
import android.content.Context;
5+
import android.content.Intent;
6+
import android.os.Bundle;
7+
8+
import android.view.LayoutInflater;
9+
import android.view.View;
10+
import android.view.ViewGroup;
11+
import android.widget.ArrayAdapter;
12+
import android.widget.ImageView;
13+
import android.widget.TextView;
14+
15+
16+
import androidx.annotation.LayoutRes;
17+
import androidx.annotation.NonNull;
18+
19+
import org.jetbrains.annotations.Nullable;
20+
21+
import java.util.ArrayList;
22+
import xyz.tannhatcms.searchdictionary.ui.GrammarActivity;
23+
import xyz.tannhatcms.searchdictionary.R;
24+
import xyz.tannhatcms.searchdictionary.model.Grammar;
25+
26+
public class GrammarAdapter extends ArrayAdapter<Grammar> {
27+
private Context context;
28+
private int resource;
29+
private ArrayList<Grammar>arr;
30+
private ArrayAdapter<Grammar>adp;
31+
public GrammarAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull ArrayList<Grammar> arr) {
32+
super(context, resource, arr);
33+
this.context=context;
34+
this.resource=resource;
35+
this.arr=arr;
36+
}
37+
38+
@SuppressLint("ViewHolder")
39+
@NonNull
40+
@Override
41+
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
42+
convertView= LayoutInflater.from(context).inflate(R.layout.item_nguphap,parent,false);
43+
ImageView imageView=(ImageView)convertView.findViewById(R.id.imgNguPhap);
44+
final TextView txtTenNguPhap=(TextView)convertView.findViewById(R.id.txt_TenNguPhap);
45+
Grammar nguPhap=arr.get(position);
46+
txtTenNguPhap.setText(nguPhap.getTen());
47+
convertView.setOnClickListener(v -> {
48+
Intent in=new Intent(v.getContext(), GrammarActivity.class);
49+
Bundle bundle=new Bundle();
50+
bundle.putString("Ten",txtTenNguPhap.getText().toString());
51+
in.putExtras(bundle);
52+
context.startActivity(in);
53+
});
54+
return convertView;
55+
}
56+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package xyz.tannhatcms.searchdictionary.adapter;
2+
3+
4+
import android.app.Activity;
5+
import android.content.Context;
6+
import android.util.SparseBooleanArray;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
import android.widget.ArrayAdapter;
11+
import android.widget.TextView;
12+
13+
import java.util.ArrayList;
14+
15+
import xyz.tannhatcms.searchdictionary.R;
16+
import xyz.tannhatcms.searchdictionary.model.Grammar;
17+
import xyz.tannhatcms.searchdictionary.model.History;
18+
19+
20+
public class HistoryApdater extends ArrayAdapter {
21+
Context context = null;
22+
ArrayList<History> myArray = null;
23+
private SparseBooleanArray selectedListItemsIds;
24+
int a = 0;
25+
26+
int layoutId;
27+
28+
public HistoryApdater(Context context, int layoutId, ArrayList<History> arr) {
29+
super(context,layoutId, arr );
30+
this.context = context;
31+
this.layoutId = layoutId;
32+
this.selectedListItemsIds = new SparseBooleanArray();
33+
this.myArray = new ArrayList<>();
34+
this.myArray = arr;
35+
}
36+
public class Holder
37+
{
38+
TextView tvTme, tvDiem, tvNgay;
39+
}
40+
41+
42+
43+
@Override
44+
public View getView(final int position, View convertView, ViewGroup parent) {
45+
Holder holder = null;
46+
final History lichsu = myArray.get(position);
47+
convertView = null;
48+
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
49+
if (convertView == null) {
50+
holder= new Holder();
51+
convertView = mInflater.inflate(layoutId, null);
52+
holder.tvTme = convertView.findViewById(R.id.tvTimethi);
53+
holder.tvNgay = convertView.findViewById(R.id.tvTime);
54+
holder.tvDiem = convertView.findViewById(R.id.tvdiem);
55+
}
56+
holder.tvTme.setText(lichsu.getTimeThi());
57+
holder.tvNgay.setText(lichsu.getNgay());
58+
holder.tvDiem.setText(lichsu.getDiem() + "/10");
59+
return convertView;
60+
}
61+
public void remove(History history) {
62+
myArray.remove(history);
63+
notifyDataSetChanged();
64+
}
65+
66+
public void toggleSelection(int position) {
67+
selectView(position, !selectedListItemsIds.get(position));
68+
}
69+
public void removeSelection() {
70+
this.selectedListItemsIds = new SparseBooleanArray();
71+
notifyDataSetChanged();
72+
}
73+
74+
public void selectView(int position, boolean value) {
75+
if (value)
76+
selectedListItemsIds.put(position, value);
77+
else
78+
selectedListItemsIds.delete(position);
79+
notifyDataSetChanged();
80+
}
81+
82+
public int getSelectedCount() {
83+
return myArray.size();
84+
}
85+
86+
public SparseBooleanArray getSelectedIds() {
87+
return selectedListItemsIds;
88+
}
89+
}

0 commit comments

Comments
 (0)