release 0.1 #30
@ -13,7 +13,7 @@
|
||||
android:supportsRtl="true"
|
||||
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||
|
||||
<activity android:name=".view.LoginActivity" />
|
||||
|
||||
@ -22,6 +22,16 @@
|
||||
android:label="@string/title_activity_new_board"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name=".view.BoardViewActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name=".view.WListsListActivity"
|
||||
android:label="WList"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".view.BoardsListsActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
@ -31,11 +41,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".view.BoardViewActivity"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||
<activity android:name=".view.WListsListActivity"
|
||||
android:label="WList"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -19,7 +19,7 @@ public interface WListDao {
|
||||
LiveData<List<WList>> getAllWList();
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
/**Completable**/ void insert(WList wList);
|
||||
void insert(WList wList);
|
||||
|
||||
@Delete
|
||||
void delete(WList wList);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package it.unisannio.ding.ids.wedroid.app.data.repository
|
||||
|
||||
import android.util.Log
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
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.convert
|
||||
@ -18,8 +20,9 @@ class WListRepository(
|
||||
private val service: ListService,
|
||||
private val reader: PreferenceReader
|
||||
) {
|
||||
val allWLists by lazy{
|
||||
dao.getAllWList()
|
||||
|
||||
val allWLists: LiveData<MutableList<WList>> by lazy{
|
||||
dao.allWList
|
||||
}
|
||||
|
||||
init {
|
||||
@ -46,7 +49,7 @@ class WListRepository(
|
||||
})
|
||||
}
|
||||
|
||||
private suspend fun synchronizeCallback(
|
||||
private fun synchronizeCallback(
|
||||
response: Response<MutableList<it.unisannio.ding.ids.wedroid.wrapper.entity.WList>>)
|
||||
{
|
||||
if (!response.isSuccessful) {
|
||||
@ -90,19 +93,21 @@ class WListRepository(
|
||||
|
||||
}
|
||||
|
||||
private suspend fun addNewWListToDb(wLists: Collection<WList>) {
|
||||
private fun addNewWListToDb(wLists: Collection<WList>) {
|
||||
wLists.forEach {
|
||||
dao.insert(it)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun removeOldWListsFromDb(wLists: Collection<WList>) {
|
||||
|
||||
private fun removeOldWListsFromDb(wLists: Collection<WList>) {
|
||||
allWLists.value?.minus(wLists)
|
||||
?.forEach {
|
||||
dao.delete(it)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
private fun logNetworkError(message: String?) {
|
||||
Log.e("RETROFIT", message)
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
package it.unisannio.ding.ids.wedroid.app.util
|
||||
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.BoardService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.CardCommentService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.CardService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.ChecklistService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.ListService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.SwimlanesService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.UserService
|
||||
import it.unisannio.ding.ids.wedroid.wrapper.api.*
|
||||
import okhttp3.OkHttpClient
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
||||
|
||||
class ServicesFactory(
|
||||
reader: PreferenceReader
|
||||
) {
|
||||
|
@ -3,7 +3,6 @@ package it.unisannio.ding.ids.wedroid.app.util
|
||||
import android.content.Context
|
||||
|
||||
class SharedPreferenceHelper(context : Context) : PreferenceReader, PreferenceWriter {
|
||||
|
||||
private val sp = context.getSharedPreferences("userinfo", Context.MODE_PRIVATE)
|
||||
|
||||
override fun getBaseUrl(): String? {
|
||||
@ -21,6 +20,7 @@ class SharedPreferenceHelper(context: Context) : PreferenceReader, PreferenceWri
|
||||
override fun setBaseUrl(baseUrl: String?) {
|
||||
val editor = sp.edit()
|
||||
editor.putString("url", baseUrl).apply()
|
||||
|
||||
}
|
||||
|
||||
override fun setUserId(userId: String?) {
|
||||
@ -42,4 +42,3 @@ class SharedPreferenceHelper(context: Context) : PreferenceReader, PreferenceWri
|
||||
editor.putString("boardId", token).apply()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -43,6 +43,7 @@ public class BoardViewActivity extends AppCompatActivity {
|
||||
private ServicesFactory service;
|
||||
private Toolbar myToolbar;
|
||||
private Board board;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -51,6 +52,9 @@ public class BoardViewActivity extends AppCompatActivity {
|
||||
myToolbar = findViewById(R.id.my_toolbar);
|
||||
setSupportActionBar(myToolbar);
|
||||
|
||||
swipeRefreshLayout = findViewById(R.id.pullToRefresh);
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
|
||||
Intent i = getIntent();
|
||||
idBoard= i.getStringExtra("idBoard");
|
||||
|
||||
@ -80,6 +84,14 @@ public class BoardViewActivity extends AppCompatActivity {
|
||||
startActivityForResult(i, WLISTS_REQUEST);
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
initializeUI(idBoard);
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeUI(String idBoard) {
|
||||
@ -87,8 +99,16 @@ public class BoardViewActivity extends AppCompatActivity {
|
||||
service.getBoardService().getBoard(idBoard).enqueue(new Callback<Board>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Call<Board> call, @NotNull Response<Board> response) {
|
||||
assert response.body() != null;
|
||||
board = response.body();
|
||||
|
||||
if (board.getId()==null) {
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
getApplicationContext().getString(R.string.board_deleted),
|
||||
Toast.LENGTH_LONG)
|
||||
.show();
|
||||
getListsButton.setEnabled(false);
|
||||
} else {
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(board.getTitle());
|
||||
myToolbar.setBackgroundColor(Color.parseColor(encodeColor(
|
||||
board.getBackgroundColor().toString())));
|
||||
@ -108,8 +128,13 @@ public class BoardViewActivity extends AppCompatActivity {
|
||||
for (int i = 0; i < board.getMembers().size(); i++) {
|
||||
replaceIDUserToUsername(board.getMembers().get(i).getUserId());
|
||||
}
|
||||
creationDate.append("\n" + board.getCreatedAt());
|
||||
lastModificationDate.append("\n" + board.getModifiedAt());
|
||||
|
||||
creationDate.setText(R.string.created_at);
|
||||
creationDate.append("\n"
|
||||
+ board.getCreatedAt());
|
||||
lastModificationDate.setText(R.string.modified_at);
|
||||
lastModificationDate.append("\n"
|
||||
+ board.getModifiedAt());
|
||||
|
||||
divider1.setBackgroundColor(boardColor);
|
||||
divider2.setBackgroundColor(boardColor);
|
||||
@ -123,10 +148,12 @@ public class BoardViewActivity extends AppCompatActivity {
|
||||
android.R.layout.simple_list_item_1, labelsTitle);
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure (@NotNull Call < Board > call, @NotNull Throwable t){
|
||||
//TODO
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getApplicationContext().getString(R.string.board_deleted),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -22,10 +22,11 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import it.unisannio.ding.ids.wedroid.app.R;
|
||||
|
||||
import it.unisannio.ding.ids.wedroid.app.viewmodel.WListsListViewModel;
|
||||
import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
|
||||
import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper;
|
||||
import it.unisannio.ding.ids.wedroid.app.view.adapter.WListsAdapter;
|
||||
import it.unisannio.ding.ids.wedroid.app.viewModel.WListsListViewModel;
|
||||
|
||||
public class WListsListActivity extends AppCompatActivity {
|
||||
|
||||
|
@ -38,9 +38,11 @@ class BoardsListAdapter internal constructor(
|
||||
holder.boardTitle.text = board.title
|
||||
|
||||
holder.itemView.setOnClickListener {
|
||||
val intent = Intent(it.context, BoardViewActivity::class.java)
|
||||
|
||||
val intent = Intent(holder.itemView.context, BoardViewActivity::class.java)
|
||||
intent.putExtra("idBoard", board.id)
|
||||
it.context.startActivity(intent)
|
||||
holder.itemView.context.startActivity(intent)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,47 @@
|
||||
package it.unisannio.ding.ids.wedroid.app.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.unisannio.ding.ids.wedroid.app.data.database.WListDatabase;
|
||||
import it.unisannio.ding.ids.wedroid.app.data.entity.WList;
|
||||
import it.unisannio.ding.ids.wedroid.app.data.repository.WListRepository;
|
||||
import it.unisannio.ding.ids.wedroid.app.util.PreferenceReader;
|
||||
import it.unisannio.ding.ids.wedroid.app.util.ServicesFactory;
|
||||
import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper;
|
||||
|
||||
|
||||
public class WListsListViewModel extends AndroidViewModel {
|
||||
private WListRepository wListRepository;
|
||||
private LiveData<List<WList>> allWLists;
|
||||
|
||||
public WListsListViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
PreferenceReader reader = new SharedPreferenceHelper(application);
|
||||
wListRepository = new WListRepository(
|
||||
WListDatabase.getDatabase(application).wListDao(),
|
||||
ServicesFactory.Companion.getInstance(reader).getListService(),
|
||||
reader);
|
||||
allWLists = wListRepository.getAllWLists();
|
||||
}
|
||||
|
||||
public LiveData<List<WList>> getAllWLists(){
|
||||
return allWLists;
|
||||
}
|
||||
|
||||
public void deleteWList(int position, String idBoard) {
|
||||
List<WList> wList = allWLists.getValue();
|
||||
|
||||
if (wList != null)
|
||||
wListRepository.deleteWList(idBoard, wList.get(position).getId());
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
wListRepository.synchronize();
|
||||
}
|
||||
}
|
@ -1,16 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/pullToRefresh"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollIndicators="right"
|
||||
android:scrollbarStyle="insideOverlay"
|
||||
android:scrollbars="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/my_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
@ -196,3 +209,4 @@
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
@ -21,6 +21,7 @@
|
||||
<string name="on_null_new_board_name">There was a problem with the name of the new board</string>
|
||||
<string name="on_add_new_board_error">It was not possible to add a new board</string>
|
||||
<string name="on_add_new_board_empty_name">Name cannot be empty</string>
|
||||
<string name="board_deleted">The selected board has been deleted</string>
|
||||
|
||||
<string-array name="board_background_colors">
|
||||
<item>Belize</item>
|
||||
|
Loading…
Reference in New Issue
Block a user