release 0.1 #30
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
@ -29,7 +29,7 @@ public class DriverActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
sharedPreferences.setBaseUrl("https://board.norangeb.it/");
|
sharedPreferences.setBaseUrl("https://board.norangeb.it/");
|
||||||
sharedPreferences.setToken("4waGrVlk0fkLhiQRDgN_rkbIamp4IyB6mThS0IpKbPx");
|
sharedPreferences.setToken("4waGrVlk0fkLhiQRDgN_rkbIamp4IyB6mThS0IpKbPx");
|
||||||
sharedPreferences.setUserId("");
|
sharedPreferences.setUserId("jPdkf3a9bmfZWx3GR");
|
||||||
|
|
||||||
idBoard = findViewById(R.id.idBoard);
|
idBoard = findViewById(R.id.idBoard);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import androidx.room.RoomDatabase;
|
|||||||
import it.unisannio.ding.ids.wedroid.app.data.dao.WListDao;
|
import it.unisannio.ding.ids.wedroid.app.data.dao.WListDao;
|
||||||
import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
|
import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
|
||||||
|
|
||||||
@Database(entities = WList.class, version = 1, exportSchema = false)
|
@Database(entities = WList.class, version = 2, exportSchema = false)
|
||||||
public abstract class WListDatabase extends RoomDatabase {
|
public abstract class WListDatabase extends RoomDatabase {
|
||||||
private static volatile WListDatabase INSTANCE;
|
private static volatile WListDatabase INSTANCE;
|
||||||
public abstract WListDao wListDao();
|
public abstract WListDao wListDao();
|
||||||
@ -22,10 +22,9 @@ public abstract class WListDatabase extends RoomDatabase {
|
|||||||
context.getApplicationContext(),
|
context.getApplicationContext(),
|
||||||
WListDatabase.class,
|
WListDatabase.class,
|
||||||
"wlist_database"
|
"wlist_database"
|
||||||
).build();
|
).fallbackToDestructiveMigration().build();
|
||||||
|
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package it.unisannio.ding.ids.wedroid.app.view;
|
package it.unisannio.ding.ids.wedroid.app.view;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -24,6 +26,8 @@ import it.unisannio.ding.ids.wedroid.app.viewModel.WListsListViewModel;
|
|||||||
public class WListsListActivity extends AppCompatActivity {
|
public class WListsListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
Toolbar myToolbar;
|
Toolbar myToolbar;
|
||||||
|
String boardTitle;
|
||||||
|
int barColor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@ -33,9 +37,9 @@ public class WListsListActivity extends AppCompatActivity {
|
|||||||
setSupportActionBar(myToolbar);
|
setSupportActionBar(myToolbar);
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
|
|
||||||
String boardTitle = i.getStringExtra("barTitle");
|
boardTitle = i.getStringExtra("barTitle");
|
||||||
Objects.requireNonNull(getSupportActionBar()).setTitle(boardTitle);
|
Objects.requireNonNull(getSupportActionBar()).setTitle(boardTitle);
|
||||||
int barColor = i.getIntExtra("barColor", 0);
|
barColor = i.getIntExtra("barColor", 0);
|
||||||
myToolbar.setBackgroundColor(barColor);
|
myToolbar.setBackgroundColor(barColor);
|
||||||
|
|
||||||
PreferenceReader reader =new SharedPreferenceHelper(this);
|
PreferenceReader reader =new SharedPreferenceHelper(this);
|
||||||
|
@ -2,14 +2,19 @@ package it.unisannio.ding.ids.wedroid.app.view.adapter;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -20,6 +25,7 @@ import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
|
|||||||
import it.unisannio.ding.ids.wedroid.app.util.ServicesFactory;
|
import it.unisannio.ding.ids.wedroid.app.util.ServicesFactory;
|
||||||
import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper;
|
import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper;
|
||||||
import it.unisannio.ding.ids.wedroid.wrapper.entity.Card;
|
import it.unisannio.ding.ids.wedroid.wrapper.entity.Card;
|
||||||
|
import it.unisannio.ding.ids.wedroid.wrapper.entity.Swimlane;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -29,19 +35,25 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
|
|||||||
private final LayoutInflater mInflater;
|
private final LayoutInflater mInflater;
|
||||||
private List<WList> mWLists; // Cached copy of words
|
private List<WList> mWLists; // Cached copy of words
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private ServicesFactory service;
|
||||||
|
private SharedPreferenceHelper sp;
|
||||||
|
|
||||||
public WListsAdapter(Context context){
|
public WListsAdapter(Context context){
|
||||||
mInflater = LayoutInflater.from(context);
|
mInflater = LayoutInflater.from(context);
|
||||||
mContext=context;
|
mContext=context;
|
||||||
|
sp = new SharedPreferenceHelper(mContext);
|
||||||
|
service = new ServicesFactory(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
class WListViewHolder extends RecyclerView.ViewHolder{
|
class WListViewHolder extends RecyclerView.ViewHolder{
|
||||||
private final TextView wListItemView;
|
private final TextView wListItemView;
|
||||||
ListView listView;
|
ListView listView;
|
||||||
|
Button button;
|
||||||
private WListViewHolder(View itemView){
|
private WListViewHolder(View itemView){
|
||||||
super(itemView);
|
super(itemView);
|
||||||
wListItemView= itemView.findViewById(R.id.wListTitle);
|
wListItemView= itemView.findViewById(R.id.wListTitle);
|
||||||
listView = itemView.findViewById(R.id.listViewCard);
|
listView = itemView.findViewById(R.id.listViewCard);
|
||||||
|
button = itemView.findViewById(R.id.buttonAddCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,8 +70,6 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
|
|||||||
if (mWLists != null) {
|
if (mWLists != null) {
|
||||||
final WList current = mWLists.get(position);
|
final WList current = mWLists.get(position);
|
||||||
final List<String> cardTitle = new ArrayList<>();
|
final List<String> cardTitle = new ArrayList<>();
|
||||||
SharedPreferenceHelper sp = new SharedPreferenceHelper(mContext);
|
|
||||||
ServicesFactory service = new ServicesFactory(sp);
|
|
||||||
service.getCardService().getAllCards(sp.getBoardId(), current.getId()).enqueue(
|
service.getCardService().getAllCards(sp.getBoardId(), current.getId()).enqueue(
|
||||||
new Callback<List<Card>>() {
|
new Callback<List<Card>>() {
|
||||||
@Override
|
@Override
|
||||||
@ -71,6 +81,13 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
|
|||||||
android.R.layout.simple_list_item_1, cardTitle);
|
android.R.layout.simple_list_item_1, cardTitle);
|
||||||
holder.listView.setAdapter(adapter);
|
holder.listView.setAdapter(adapter);
|
||||||
holder.wListItemView.setText(current.getTitle());
|
holder.wListItemView.setText(current.getTitle());
|
||||||
|
holder.button.setText("Add Card to " + current.getTitle());
|
||||||
|
holder.button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
showInputDialog(current.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<List<Card>> call, Throwable t) {
|
public void onFailure(Call<List<Card>> call, Throwable t) {
|
||||||
@ -96,4 +113,81 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
|
|||||||
mWLists = wList;
|
mWLists = wList;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showInputDialog(final String current) {
|
||||||
|
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
|
||||||
|
View promptView = layoutInflater.inflate(R.layout.alert_new_card, null);
|
||||||
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
|
||||||
|
alertDialogBuilder.setView(promptView);
|
||||||
|
|
||||||
|
final EditText editText = promptView.findViewById(R.id.edittext);
|
||||||
|
// setup a dialog window
|
||||||
|
alertDialogBuilder.setCancelable(false)
|
||||||
|
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
if(!editText.getText().toString().matches("")) {
|
||||||
|
service.getSwimlanesService().getAllSwimlanes(sp.getBoardId()).enqueue(new Callback<List<Swimlane>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<Swimlane>> call, Response<List<Swimlane>> response) {
|
||||||
|
String idDefaultSwimlane = null;
|
||||||
|
for(Swimlane swim: response.body()){
|
||||||
|
if(swim.getTitle().equalsIgnoreCase("default"))
|
||||||
|
idDefaultSwimlane=swim.getTitle();
|
||||||
|
}
|
||||||
|
final Card card = new Card();
|
||||||
|
card.setTitle(editText.getText().toString());
|
||||||
|
card.setAuthorId(sp.getUserId());
|
||||||
|
card.setSwimlaneId(idDefaultSwimlane);
|
||||||
|
System.out.println("****************" + idDefaultSwimlane);
|
||||||
|
//card.setDescription("new card from app");
|
||||||
|
service.getListService().getList(sp.getBoardId(), current).enqueue(new Callback<it.unisannio.ding.ids.wedroid.wrapper.entity.WList>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> call, Response<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> response) {
|
||||||
|
|
||||||
|
service.getCardService().newCard(sp.getBoardId(), current, card).enqueue(new Callback<Card>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<Card> call, Response<Card> response){
|
||||||
|
if(response.isSuccessful())
|
||||||
|
Toast.makeText(mContext, "card posted" ,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
|
Toast.makeText(mContext, "card unposted" ,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<Card> call, Throwable t) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> call, Throwable t) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<List<Swimlane>> call, Throwable t) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Toast.makeText(mContext, "cancel", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("Cancel",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// create an alert dialog
|
||||||
|
AlertDialog alert = alertDialogBuilder.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
20
app/src/main/res/layout/alert_new_card.xml
Normal file
20
app/src/main/res/layout/alert_new_card.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/enter_card_name"
|
||||||
|
android:id="@+id/textView" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edittext"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/enter_text_here"
|
||||||
|
android:padding="10dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -14,10 +14,16 @@
|
|||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/listViewCard"
|
android:id="@+id/listViewCard"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" >
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonAddCard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/add_card_button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -9,4 +9,7 @@
|
|||||||
<string name="labels">-Labels:</string>
|
<string name="labels">-Labels:</string>
|
||||||
<string name="modified_at">Modified at:</string>
|
<string name="modified_at">Modified at:</string>
|
||||||
<string name="created_at">Created at:</string>
|
<string name="created_at">Created at:</string>
|
||||||
|
<string name="add_card_button">Add Card</string>
|
||||||
|
<string name="enter_text_here">Enter text here...</string>
|
||||||
|
<string name="enter_card_name">Enter card name</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user