Skip to content

Commit

Permalink
Merge pull request #140 from sebastiangoetz/android-client-2024
Browse files Browse the repository at this point in the history
Add Git Support to Android and RCP
  • Loading branch information
sebastiangoetz committed Jun 19, 2024
2 parents 423eee3 + 62c1eda commit 50b5f3c
Show file tree
Hide file tree
Showing 240 changed files with 2,927 additions and 8,580 deletions.
3 changes: 2 additions & 1 deletion android-client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
keystore.properties
local.properties

!/gradle/wrapper/gradle-wrapper.jar
!/gradle/wrapper/gradle-wrapper.jar
/.idea/deploymentTargetDropDown.xml
10 changes: 10 additions & 0 deletions android-client/.idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions android-client/.idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions android-client/.idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion android-client/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions android-client/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,24 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'io.github.amrdeveloper:treeview:1.1.4'

implementation 'org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r'
implementation 'org.jbibtex:jbibtex:1.0.20'
implementation 'com.lorentzos.swipecards:library:1.0.9'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'androidx.viewpager2:viewpager2:1.1.0'

implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.5'

implementation 'com.github.jaiselrahman:FilePicker:1.3.2' //File Picker
implementation 'com.github.jaiselrahman:FilePicker:1.3.2'
//File Picker

def nav_version = '2.6.0'
//noinspection GradleDependency
Expand Down
86 changes: 86 additions & 0 deletions android-client/app/doc/overview.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@startuml
package Database {
class AppDatabase
class Author {
- name
- affiliation
- email
}
class BibEntry {
- name
- doi
- ...
}
enum Status {
OPEN
KEEP
DISCARD
}
BibEntry -> Status
class Keyword {
- name
}
class Repo {
- local_path
- remote_url
- username
- token
- git_name
- git_email
--
- name
- textAbstract
- taxonomyDescription
}
class Taxonomy {
- name
- hasChildren
- path
}

abstract class RepoDao
abstract class AuthorDao
abstract class BibEntryDao
abstract class KeywordDao
abstract class TaxonomyDao

AppDatabase --> BibEntryDao
AppDatabase --> RepoDao
AppDatabase --> AuthorDao
AppDatabase --> KeywordDao
AppDatabase --> TaxonomyDao

BibEntryDao ..> BibEntry
RepoDao ..> Repo
AuthorDao ..> Author
KeywordDao ..> Keyword
TaxonomyDao ..> Taxonomy

Author --> Repo
Keyword --> Repo
Taxonomy --> Repo
Taxonomy --> "parent" Taxonomy
BibEntry --> Repo

note "Repo combines Project and Git." as n1
}

package Repository {
class AuthorRepository
class BibEntryRepository
class KeywordRepository
class RepoRepository
class TaxonomyRepository
}

package ViewModel {
class RepoViewModel
class ProjectViewModel
class ClassificationViewModel
class AnalyzeViewModel
class TaxonomiesViewModel
}

Repository -> Database
ViewModel -> Repository
@enduml
2 changes: 1 addition & 1 deletion android-client/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
android:name="de.slrtoolkit.AnalyzeActivity"
android:exported="false" />
<activity
android:name="de.slrtoolkit.TaxonomiesActivity"
android:name="de.slrtoolkit.EntriesByTaxonomiesActivity"
android:exported="false" />
<activity
android:name="de.slrtoolkit.ClassificationActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,28 @@
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;

import de.slrtoolkit.R;
import de.slrtoolkit.fragments.TaxonomyListFragment;
import de.slrtoolkit.fragments.EntriesByTaxonomiesFragment;
import de.slrtoolkit.viewmodels.TaxonomiesViewModel;

public class
TaxonomiesActivity extends AppCompatActivity {
private int repoId;
EntriesByTaxonomiesActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_taxonomies);
setContentView(R.layout.activity_entries_by_taxonomies);

Bundle extras = getIntent().getExtras();
TaxonomiesViewModel taxonomiesViewModel = new ViewModelProvider(this).get(TaxonomiesViewModel.class);

if (extras != null) {
repoId = extras.getInt("repo");
int repoId = extras.getInt("repo");
taxonomiesViewModel.setCurrentRepoId(repoId);
}

Fragment taxonomyFragment = TaxonomyListFragment.newInstance(0);
Fragment entriesByTaxonomyFragment = EntriesByTaxonomiesFragment.newInstance(0);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.taxonomies_fragment_container_view, taxonomyFragment);
ft.replace(R.id.entries_by_taxonomies_fragment_container_view, entriesByTaxonomyFragment);
ft.commit();
}
}
75 changes: 27 additions & 48 deletions android-client/app/src/main/java/de/slrtoolkit/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
package de.slrtoolkit;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.navigation.fragment.NavHostFragment;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputEditText;

import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.Objects;

import de.slrtoolkit.R;
import de.slrtoolkit.fragments.CreateProject1Fragment;

public class MainActivity extends AppCompatActivity {

private FloatingActionButton fab;
private FloatingActionButton btnAddProject;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -41,39 +28,31 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

fab = findViewById(R.id.fab_add_project);

fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
View view1 = LayoutInflater.from(MainActivity.this).inflate(R.layout.choose_option_dialog_layout, null);
Button button_create_project_with_git = view1.findViewById(R.id.button_create_project_with_git);
Button button_create_project_manually = view1.findViewById(R.id.button_create_project_manualy);

AlertDialog alertDialog = new MaterialAlertDialogBuilder(MainActivity.this)
.setTitle("Choose option to add a new project")
.setView(view1)
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).create();
alertDialog.show();

button_create_project_with_git.setOnClickListener(view2 -> {
alertDialog.dismiss();
NavHostFragment.findNavController(
Objects.requireNonNull(getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment)))
.navigate(R.id.action_ProjectsFragment_to_AddProjectFragment);
});
button_create_project_manually.setOnClickListener(view2 -> {
alertDialog.dismiss();
NavHostFragment.findNavController(
Objects.requireNonNull(getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment)))
.navigate((R.id.actionProjectsFragment_to_CreateProjectFragment));
});
}
btnAddProject = findViewById(R.id.fab_add_project);

btnAddProject.setOnClickListener(view -> {
View view1 = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_create_project_choose_option, null);
Button buttonAddProjectFromGit = view1.findViewById(R.id.button_add_project_from_git);
Button buttonCreateProjectLocally = view1.findViewById(R.id.button_create_project_locally);

AlertDialog alertDialog = new MaterialAlertDialogBuilder(MainActivity.this)
.setTitle("Choose option to add a new project")
.setView(view1)
.setNegativeButton("Close", (dialogInterface, i) -> dialogInterface.dismiss()).create();
alertDialog.show();

buttonAddProjectFromGit.setOnClickListener(view2 -> {
alertDialog.dismiss();
NavHostFragment.findNavController(
Objects.requireNonNull(getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment)))
.navigate(R.id.action_ProjectsFragment_to_AddProjectFromGitFragment);
});
buttonCreateProjectLocally.setOnClickListener(view2 -> {
alertDialog.dismiss();
NavHostFragment.findNavController(
Objects.requireNonNull(getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment)))
.navigate((R.id.actionProjectsFragment_to_CreateLocalProjectFragment));
});
});
}

Expand All @@ -99,6 +78,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

public FloatingActionButton getFloatingActionButton() {
return fab;
return btnAddProject;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ protected void onCreate(Bundle savedInstanceState) {

Bundle extras = getIntent().getExtras();
ProjectViewModel projectViewModel = new ViewModelProvider(this).get(ProjectViewModel.class);
RepoViewModel repoViewModel = new ViewModelProvider(this).get(RepoViewModel.class);


if (extras != null) {
int id = extras.getInt("repo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Database(entities = {Repo.class, Entry.class, Taxonomy.class, EntryTaxonomyCrossRef.class, Keyword.class, Author.class}, version = 3, exportSchema = false)
@Database(entities = {Repo.class, BibEntry.class, Taxonomy.class, BibEntryTaxonomyCrossRef.class, Keyword.class, Author.class}, version = 3, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
private static final int NUMBER_OF_THREADS = 4;
public static final ExecutorService databaseWriteExecutor =
Expand All @@ -31,7 +31,7 @@ public static AppDatabase getDatabase(final Context context) {

public abstract RepoDao repoDao();

public abstract EntryDao entryDao();
public abstract BibEntryDao entryDao();

public abstract TaxonomyDao taxonomyDao();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import androidx.room.TypeConverters;

@Entity
public class Entry {
public class BibEntry {
private final String key;
private final String title;
@PrimaryKey(autoGenerate = true)
Expand All @@ -23,10 +23,11 @@ public class Entry {
private String doi;
private String keywords;
private String type;
private String classes;
@TypeConverters(StatusConverter.class)
private Status status;

public Entry(String key, String title) {
public BibEntry(String key, String title) {
this.key = key;
this.title = title;
this.status = Status.OPEN;
Expand Down Expand Up @@ -156,6 +157,10 @@ public void setType(String type) {
this.type = type;
}

public String getClasses() { return classes; }

public void setClasses(String classes) { this.classes = classes; }

public enum Status {
OPEN(0), KEEP(1), DISCARD(2);

Expand Down
Loading

0 comments on commit 50b5f3c

Please sign in to comment.