Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Ganttproject_mobile/.idea/assetWizardSettings.xml

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

Binary file modified Ganttproject_mobile/.idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion Ganttproject_mobile/.idea/misc.xml

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

6 changes: 6 additions & 0 deletions Ganttproject_mobile/.idea/vcs.xml

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

22 changes: 19 additions & 3 deletions Ganttproject_mobile/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ apply plugin: 'com.google.protobuf'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.bardsoftware.ganttproject_mobile"
minSdkVersion 15
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
Expand All @@ -19,6 +20,9 @@ android {
}
}

/*sourceSets {
main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite"
}*/
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0'
Expand All @@ -34,7 +38,7 @@ protobuf {
remove java
}
task.plugins {
javalite { }
javalite {}
}
}
}
Expand All @@ -44,9 +48,21 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:27.1.1'

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'

implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

implementation 'com.google.protobuf:protobuf-lite:3.0.0'

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
6 changes: 6 additions & 0 deletions Ganttproject_mobile/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bardsoftware.ganttproject_mobile">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -16,6 +21,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TasksActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.bardsoftware.ganttproject_mobile;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add copyright notice header to all Java source code files:

/*
Copyright 2018 BarD Software s.r.o, Alexandra Toropova

This file is part of GanttProject, an opensource project management tool.

GanttProject is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

GanttProject is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GanttProject.  If not, see <http://www.gnu.org/licenses/>.
*/


public class Constants {
public static final String FILE_PATH = "FilePath";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class MainActivity extends AppCompatActivity {

private static final int OPEN_FILE_CODE = 100 ;
private static final int OPEN_FILE_CODE = 100;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -16,14 +16,20 @@ protected void onCreate(Bundle savedInstanceState) {
}

public void openProtoFile(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("application/octet-stream");
startActivityForResult(intent, OPEN_FILE_CODE);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OPEN_FILE_CODE && resultCode == RESULT_OK && data != null)
{ String filePath = data.getDataString();
// do somthing...
if (requestCode == OPEN_FILE_CODE && resultCode == RESULT_OK && data != null) {
String filePath = data.getDataString();
Bundle b = new Bundle();
b.putString(Constants.FILE_PATH, filePath);
Class TasksActivity = TasksActivity.class;
Intent intent = new Intent(this, TasksActivity);
intent.putExtras(b);
startActivity(intent);
}
super.onActivityResult(requestCode, resultCode, data);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package com.bardsoftware.ganttproject_mobile;

import android.content.Context;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.TextView;
import android.view.View.OnClickListener;

import butterknife.BindView;
import butterknife.ButterKnife;

import static dataformat.Dataformat.Task;
import static dataformat.Dataformat.Tasks;

public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.TaskViewHolder> {
private Tasks.Builder tasksBuilder;
private SparseBooleanArray taskStateArray = new SparseBooleanArray();
private int currentSelectedPosition = RecyclerView.NO_POSITION;

@NonNull
@Override
public TaskViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.task_row, parent, false);
return new TaskAdapter.TaskViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull TaskViewHolder holder, final int position) {
if (tasksBuilder == null) return;
String taskName = tasksBuilder.getTask(position).getName();
boolean itemIsChecked = tasksBuilder.getTask(position).getIsDone();
taskStateArray.append(position, itemIsChecked);
holder.taskView.setText(taskName);
holder.taskCheckbox.setChecked(itemIsChecked);
if (itemIsChecked) {
holder.taskView.setPaintFlags(holder.taskView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else
holder.taskView.setPaintFlags(holder.taskView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
if (currentSelectedPosition == position) {
holder.deleteButton.setVisibility(View.VISIBLE);
holder.deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tasksBuilder.removeTask(position);
taskStateArray.delete(position);
currentSelectedPosition = RecyclerView.NO_POSITION;
notifyDataSetChanged();

}
});
} else {
holder.deleteButton.setVisibility(View.GONE);
}
}

@Override
public int getItemCount() {
if (tasksBuilder == null) return 0;
return tasksBuilder.getTaskCount();
}

public void setData(Tasks tasks1) {
tasksBuilder = tasks1.toBuilder();
notifyDataSetChanged();
}

public Tasks getTasks() {
Tasks.Builder tasks1 = Tasks.newBuilder();
for (int i = 0; i < getItemCount(); i++) {
Task task = Task.newBuilder()
.setName(tasksBuilder.getTask(i).getName())
.setIsDone(tasksBuilder.getTask(i).getIsDone())
.build();
tasks1.addTask(task);
}
return tasks1.build();
}

public void addTask(String name) {
Task task = Task.newBuilder().setName(name).setIsDone(false).build();
tasksBuilder.addTask(task);
taskStateArray.append(tasksBuilder.getTaskCount(), false);
notifyDataSetChanged();
}

public class TaskViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.task_textview)
TextView taskView;
@BindView(R.id.task_checkbox)
CheckBox taskCheckbox;
@BindView(R.id.delete_task_button)
ImageButton deleteButton;

TaskViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
taskView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
currentSelectedPosition = getAdapterPosition();
notifyDataSetChanged();
}
});
taskCheckbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
int adapterPosition = getAdapterPosition();
if (!taskStateArray.get(adapterPosition, false)) {
taskCheckbox.setChecked(true);
taskView.setPaintFlags(taskView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
taskStateArray.put(adapterPosition, true);
Task task1 = Task.newBuilder().setName(tasksBuilder.getTask(adapterPosition).getName()).setIsDone(true).build();
tasksBuilder.setTask(adapterPosition, task1);
} else {
taskCheckbox.setChecked(false);
taskStateArray.put(adapterPosition, false);
taskView.setPaintFlags(taskView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
Task task1 = Task.newBuilder().setName(tasksBuilder.getTask(adapterPosition).getName()).setIsDone(false).build();
tasksBuilder.setTask(adapterPosition, task1);
}
currentSelectedPosition = getAdapterPosition();
notifyDataSetChanged();
}
});
}
}
}
Loading