From 7dbb637283ab545c36fee624cca5157248cf1d37 Mon Sep 17 00:00:00 2001 From: sebastianstein Date: Tue, 18 Jul 2017 18:31:10 +0200 Subject: [PATCH 1/6] added first implementation for: - card list - adding cards --- app/build.gradle | 5 + app/src/main/AndroidManifest.xml | 31 +++- .../activities/CardsActivity.java | 107 ++++++++++++ .../activities/CardsDetailActivity.java | 100 +++++++++++ .../ActivityForLoadingInBackground.java | 2 + .../activities/generic/BaseActivity.java | 15 +- .../activities/generic/ProgressActivity.java | 8 + .../adapters/StudyCardListAdapter.java | 66 ++++++++ .../in/tumcampusapp/api/TUMCabeClient.java | 17 ++ .../auxiliary/DrawerMenuHelper.java | 2 + .../models/cards/CardActivityState.java | 32 ++++ .../tumcampusapp/models/cards/StudyCard.java | 155 ++++++++++++++++++ .../in/tumcampusapp/widgets/MVVWidget.java | 1 + app/src/main/res/drawable/ic_add.xml | 9 + app/src/main/res/drawable/ic_clear.xml | 9 + app/src/main/res/drawable/ic_filter_list.xml | 9 + app/src/main/res/drawable/ic_layers.xml | 9 + app/src/main/res/drawable/ic_play_arrow.xml | 9 + app/src/main/res/layout/activity_cards.xml | 147 +++++++++++++++++ .../main/res/layout/activity_cards_detail.xml | 108 ++++++++++++ .../res/layout/activity_cards_list_item.xml | 15 ++ app/src/main/res/menu/menu_activity_cards.xml | 10 ++ .../res/menu/menu_activity_cards_detail.xml | 10 ++ app/src/main/res/values-de/strings.xml | 11 +- app/src/main/res/values/arrays.xml | 2 +- app/src/main/res/values/strings.xml | 9 +- app/src/main/res/xml/settings.xml | 2 +- build.gradle | 3 +- 28 files changed, 890 insertions(+), 13 deletions(-) create mode 100644 app/src/main/java/de/tum/in/tumcampusapp/activities/CardsActivity.java create mode 100644 app/src/main/java/de/tum/in/tumcampusapp/activities/CardsDetailActivity.java create mode 100644 app/src/main/java/de/tum/in/tumcampusapp/adapters/StudyCardListAdapter.java create mode 100644 app/src/main/java/de/tum/in/tumcampusapp/models/cards/CardActivityState.java create mode 100644 app/src/main/java/de/tum/in/tumcampusapp/models/cards/StudyCard.java create mode 100644 app/src/main/res/drawable/ic_add.xml create mode 100644 app/src/main/res/drawable/ic_clear.xml create mode 100644 app/src/main/res/drawable/ic_filter_list.xml create mode 100644 app/src/main/res/drawable/ic_layers.xml create mode 100644 app/src/main/res/drawable/ic_play_arrow.xml create mode 100644 app/src/main/res/layout/activity_cards.xml create mode 100644 app/src/main/res/layout/activity_cards_detail.xml create mode 100644 app/src/main/res/layout/activity_cards_list_item.xml create mode 100644 app/src/main/res/menu/menu_activity_cards.xml create mode 100644 app/src/main/res/menu/menu_activity_cards_detail.xml diff --git a/app/build.gradle b/app/build.gradle index 3e5193662e..fb48053347 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,7 @@ android { versionCode 99999 versionName "1.4.10-dev" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true } lintOptions { checkAllWarnings true @@ -42,6 +43,9 @@ android { exclude 'META-INF/maven/com.google.guava/guava/pom.xml' } + dataBinding { + enabled = true + } publishNonDefault true } @@ -80,6 +84,7 @@ dependencies { compile 'net.danlew:android.joda:2.9.9' compile 'com.github.franmontiel:PersistentCookieJar:v1.0.0' compile 'com.github.barteksc:android-pdf-viewer:2.5.1' + compile 'com.android.support.constraint:constraint-layout:1.0.2' androidTestCompile "com.android.support:support-annotations:$androidSupportVersion" androidTestCompile 'com.android.support.test:runner:0.5' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 44c25becb4..ee534158ea 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -497,6 +497,25 @@ android:name="android.support.PARENT_ACTIVITY" android:value="de.tum.in.tumcampusapp.activities.MainActivity" /> + + + + + + + - > + @@ -533,11 +553,12 @@ android:name=".widgets.MVVWidgetService" android:permission="android.permission.BIND_REMOTEVIEWS" /> - @@ -577,7 +598,7 @@ > + android:label="@string/timetable_widget"> diff --git a/app/src/main/java/de/tum/in/tumcampusapp/activities/CardsActivity.java b/app/src/main/java/de/tum/in/tumcampusapp/activities/CardsActivity.java new file mode 100644 index 0000000000..51f8e6ae69 --- /dev/null +++ b/app/src/main/java/de/tum/in/tumcampusapp/activities/CardsActivity.java @@ -0,0 +1,107 @@ +package de.tum.in.tumcampusapp.activities; + +import android.content.Intent; +import android.databinding.DataBindingUtil; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ListView; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import de.tum.in.tumcampusapp.R; +import de.tum.in.tumcampusapp.activities.generic.ActivityForLoadingInBackground; +import de.tum.in.tumcampusapp.adapters.NoResultsAdapter; +import de.tum.in.tumcampusapp.adapters.StudyCardListAdapter; +import de.tum.in.tumcampusapp.api.TUMCabeClient; +import de.tum.in.tumcampusapp.auxiliary.Utils; +import de.tum.in.tumcampusapp.databinding.ActivityCardsBinding; +import de.tum.in.tumcampusapp.models.cards.CardActivityState; +import de.tum.in.tumcampusapp.models.cards.StudyCard; + +public class CardsActivity extends ActivityForLoadingInBackground> implements AdapterView.OnItemClickListener { + + private ListView cardList; + + CardActivityState state; + private StudyCardListAdapter adapter; + + public CardsActivity() { + super(); + this.state = new CardActivityState(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ActivityCardsBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_cards); + binding.setState(this.state); + + this.setUpDrawer(); + this.setUpToolbar(); + this.setUpProgress(); + + // bind UI elements + cardList = (ListView) findViewById(R.id.card_list); + cardList.setOnItemClickListener(this); + } + + @Override + protected void onResume() { + super.onResume(); + startLoading(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.menu_activity_cards, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle item selection + switch (item.getItemId()) { + case R.id.create_card: + Intent intent = new Intent(this, CardsDetailActivity.class); + startActivity(intent); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected List onLoadInBackground(Void... arg) { + List cards = new ArrayList(); + try { + cards = TUMCabeClient.getInstance(this).getStudyCards(); + } catch (IOException e) { + Utils.log(e); + } + return cards; + } + + @Override + protected void onLoadFinished(List cards) { + showLoadingEnded(); + if (cards.size() == 0) { + cardList.setAdapter(new NoResultsAdapter(this)); + } else { + // set ListView to data via the LecturesListAdapter + adapter = new StudyCardListAdapter(this, cards); + cardList.setAdapter(adapter); + } + } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + // TODO open edit/view + } +} \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/activities/CardsDetailActivity.java b/app/src/main/java/de/tum/in/tumcampusapp/activities/CardsDetailActivity.java new file mode 100644 index 0000000000..49373d4bfd --- /dev/null +++ b/app/src/main/java/de/tum/in/tumcampusapp/activities/CardsDetailActivity.java @@ -0,0 +1,100 @@ +package de.tum.in.tumcampusapp.activities; + +import android.content.Context; +import android.databinding.DataBindingUtil; +import android.os.AsyncTask; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; + +import java.io.IOException; + +import de.tum.in.tumcampusapp.R; +import de.tum.in.tumcampusapp.api.TUMCabeClient; +import de.tum.in.tumcampusapp.auxiliary.Const; +import de.tum.in.tumcampusapp.auxiliary.Utils; +import de.tum.in.tumcampusapp.databinding.ActivityCardsDetailBinding; +import de.tum.in.tumcampusapp.exceptions.NoPrivateKey; +import de.tum.in.tumcampusapp.models.cards.StudyCard; +import de.tum.in.tumcampusapp.models.tumcabe.ChatMember; +import de.tum.in.tumcampusapp.models.tumcabe.ChatVerification; + +public class CardsDetailActivity extends AppCompatActivity { + StudyCard card; + ActivityCardsDetailBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + this.card = new StudyCard(); + + binding = DataBindingUtil.setContentView(this, R.layout.activity_cards_detail); + binding.setCard(card); + + // TODO handle different states (add/view/edit) + setTitle("add Card"); + + Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); + setSupportActionBar(toolbar); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_clear); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.menu_activity_cards_detail, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + case R.id.save_card: + if (save()) { + finish(); + } + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + private boolean save() { + if (card.is_valid()) { + try { + final ChatVerification v = new ChatVerification(this, Utils.getSetting(this, Const.CHAT_MEMBER, ChatMember.class)); + final Context c = this; + + AsyncTask t = new AsyncTask() { + @Override + protected Object doInBackground(Object[] objects) { + try { + TUMCabeClient.getInstance(c).addStudyCard(card, v); + } catch (IOException e) { + System.out.println(e.toString()); + e.printStackTrace(); + } + return "Uploaded"; + } + }; + t.execute(""); + } catch (NoPrivateKey noPrivateKey) { + noPrivateKey.printStackTrace(); + } + return true; + } else { + return false; + } + } +} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ActivityForLoadingInBackground.java b/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ActivityForLoadingInBackground.java index 5c37b6b2ad..617e2149bf 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ActivityForLoadingInBackground.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ActivityForLoadingInBackground.java @@ -38,6 +38,8 @@ public ActivityForLoadingInBackground(int layoutId) { super(layoutId); } + public ActivityForLoadingInBackground() { super(); } + /** * Starts a new background task. * The work that should be done in background must be specified in the {@link #onLoadInBackground(Object[])} method. diff --git a/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/BaseActivity.java b/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/BaseActivity.java index 62a8b95be6..9972e306c0 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/BaseActivity.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/BaseActivity.java @@ -34,7 +34,7 @@ public abstract class BaseActivity extends AppCompatActivity { /** * Default layouts for user interaction */ - private final int mLayoutId; + protected final Integer mLayoutId; protected DrawerLayout mDrawerLayout; protected NavigationView mDrawerList; @@ -50,12 +50,21 @@ public BaseActivity(int layoutId) { mLayoutId = layoutId; } + public BaseActivity() { mLayoutId = null;} + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ImplicitCounter.count(this); - setContentView(mLayoutId); + if (this.mLayoutId != null) { + setContentView(mLayoutId); + this.setUpDrawer(); + this.setUpToolbar(); + } + } + + public void setUpDrawer() { // Get handles to navigation drawer mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (NavigationView) findViewById(R.id.left_drawer); @@ -83,7 +92,9 @@ protected void onCreate(Bundle savedInstanceState) { // Set the NavigationDrawer's click listener mDrawerList.setNavigationItemSelectedListener(helper); } + } + public void setUpToolbar() { String parent = NavUtils.getParentActivityName(this); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); diff --git a/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ProgressActivity.java b/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ProgressActivity.java index ab5ffc87bf..52d52cf954 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ProgressActivity.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/activities/generic/ProgressActivity.java @@ -51,10 +51,18 @@ public ProgressActivity(int layoutId) { super(layoutId); } + public ProgressActivity() { super(); } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if (this.mLayoutId != null) { + this.setUpProgress(); + } + } + + public void setUpProgress() { // Get handles to all error layouts allErrorsLayout = (LinearLayout) findViewById(R.id.errors_layout); progressLayout = (RelativeLayout) findViewById(R.id.progress_layout); diff --git a/app/src/main/java/de/tum/in/tumcampusapp/adapters/StudyCardListAdapter.java b/app/src/main/java/de/tum/in/tumcampusapp/adapters/StudyCardListAdapter.java new file mode 100644 index 0000000000..8d9bad69f1 --- /dev/null +++ b/app/src/main/java/de/tum/in/tumcampusapp/adapters/StudyCardListAdapter.java @@ -0,0 +1,66 @@ +package de.tum.in.tumcampusapp.adapters; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import java.util.List; + +import de.tum.in.tumcampusapp.R; +import de.tum.in.tumcampusapp.models.cards.StudyCard; + +public class StudyCardListAdapter extends BaseAdapter { + private LayoutInflater inflater; + private List items; + + // the layout of the list + static class ViewHolder { + TextView title; + } + + // constructor + public StudyCardListAdapter(Context context, List items) { + super(); + this.items = items; + this.inflater = LayoutInflater.from(context); + } + + @Override + public int getCount() { + return this.items.size(); + } + + @Override + public StudyCard getItem(int position) { + return this.items.get(position); + } + + @Override + public long getItemId(int position) { + return this.items.get(position).getId(); + } + + @Override + public View getView(int position, View view, ViewGroup parent) { + StudyCard card = getItem(position); + + ViewHolder viewHolder; + if (view == null) { + viewHolder = new ViewHolder(); + view = inflater.inflate(R.layout.activity_cards_list_item, parent, false); + viewHolder.title = (TextView) view.findViewById(R.id.card_title); + view.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) view.getTag(); + } + + if (card != null) { + viewHolder.title.setText(card.getTitle()); + } + + return view; + } +} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/TUMCabeClient.java b/app/src/main/java/de/tum/in/tumcampusapp/api/TUMCabeClient.java index f1bac993ff..b7973e7a64 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/TUMCabeClient.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/TUMCabeClient.java @@ -6,6 +6,7 @@ import java.util.List; import de.tum.in.tumcampusapp.auxiliary.Const; +import de.tum.in.tumcampusapp.models.cards.StudyCard; import de.tum.in.tumcampusapp.models.gcm.GCMNotification; import de.tum.in.tumcampusapp.models.gcm.GCMNotificationLocation; import de.tum.in.tumcampusapp.models.tumcabe.BugReport; @@ -38,6 +39,7 @@ public class TUMCabeClient { private static final String API_HOSTNAME = Const.API_HOSTNAME; private static final String API_BASEURL = "/Api/"; + private static final String API_CARD = "cards/"; private static final String API_CHAT = "chat/"; private static final String API_CHAT_ROOMS = API_CHAT + "rooms/"; private static final String API_CHAT_MEMBERS = API_CHAT + "members/"; @@ -141,6 +143,15 @@ public ChatMember createMember(ChatMember chatMember) throws IOException { return service.createMember(chatMember).execute().body(); } + public List getStudyCards() throws IOException { + return service.getStudyCards().execute().body(); + } + + public StudyCard addStudyCard(StudyCard card, ChatVerification verification) throws IOException { + verification.setData(card); + return service.addStudyCard(verification).execute().body(); + } + public void leaveChatRoom(ChatRoom chatRoom, ChatVerification verification, Callback cb) { service.leaveChatRoom(chatRoom.getId(), verification).enqueue(cb); } @@ -264,6 +275,12 @@ private interface TUMCabeAPIService { @POST(API_CHAT_MEMBERS) Call createMember(@Body ChatMember chatMember); + @GET(API_CARD) + Call> getStudyCards(); + + @PUT(API_CARD) + Call addStudyCard(@Body ChatVerification verification); + @GET(API_CHAT_MEMBERS + "{lrz_id}/") Call getMember(@Path("lrz_id") String lrzId); diff --git a/app/src/main/java/de/tum/in/tumcampusapp/auxiliary/DrawerMenuHelper.java b/app/src/main/java/de/tum/in/tumcampusapp/auxiliary/DrawerMenuHelper.java index 0941b11f42..7e5940e58f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/auxiliary/DrawerMenuHelper.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/auxiliary/DrawerMenuHelper.java @@ -12,6 +12,7 @@ import de.tum.in.tumcampusapp.R; import de.tum.in.tumcampusapp.activities.CafeteriaActivity; import de.tum.in.tumcampusapp.activities.CalendarActivity; +import de.tum.in.tumcampusapp.activities.CardsActivity; import de.tum.in.tumcampusapp.activities.ChatRoomsActivity; import de.tum.in.tumcampusapp.activities.CurriculaActivity; import de.tum.in.tumcampusapp.activities.GradesActivity; @@ -46,6 +47,7 @@ public class DrawerMenuHelper implements NavigationView.OnNavigationItemSelected new SideNavigationItem(R.string.study_rooms, R.drawable.ic_group_work, StudyRoomsActivity.class, false, false), new SideNavigationItem(R.string.opening_hours, R.drawable.ic_time, OpeningHoursListActivity.class, false, false), new SideNavigationItem(R.string.quiz_title, R.drawable.ic_pie_chart, SurveyActivity.class, true, false), + new SideNavigationItem(R.string.study_cards_title, R.drawable.ic_layers, CardsActivity.class, true, true), new SideNavigationItem(R.string.person_search, R.drawable.ic_users, PersonsSearchActivity.class, true, false), new SideNavigationItem(R.string.organisations, R.drawable.ic_organisations, OrganisationActivity.class, true, false), new SideNavigationItem(R.string.study_plans, R.drawable.ic_study_plans, CurriculaActivity.class, false, false) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/cards/CardActivityState.java b/app/src/main/java/de/tum/in/tumcampusapp/models/cards/CardActivityState.java new file mode 100644 index 0000000000..bf0166202b --- /dev/null +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/cards/CardActivityState.java @@ -0,0 +1,32 @@ +package de.tum.in.tumcampusapp.models.cards; + +import java.util.ArrayList; + +public class CardActivityState { + // TODO rethink all states + public enum CardState { + OVERVIEW, SEARCH, DELETE, ADD + } + + public enum BoxFilter { + ALL_CARDS, ALL_BOXES, SELECTED_BOXES + } + + public enum LectureFilter { + ALL_LECTURES, OWN_LECTURES, SELECTED_LECTURES + } + + public CardState state; + public BoxFilter boxFilter; + public ArrayList selectedBoxes; + public LectureFilter lectureFilter; + public ArrayList selectedLectures; + + public CardActivityState() { + this.state = CardState.OVERVIEW; + this.boxFilter = BoxFilter.ALL_BOXES; + this.selectedBoxes = new ArrayList<>(); + this.lectureFilter = LectureFilter.OWN_LECTURES; + this.selectedLectures = new ArrayList<>(); + } +} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/cards/StudyCard.java b/app/src/main/java/de/tum/in/tumcampusapp/models/cards/StudyCard.java new file mode 100644 index 0000000000..3aca6afd49 --- /dev/null +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/cards/StudyCard.java @@ -0,0 +1,155 @@ +package de.tum.in.tumcampusapp.models.cards; + +import android.databinding.BaseObservable; +import android.databinding.Bindable; + +import com.google.gson.annotations.SerializedName; + +import de.tum.in.tumcampusapp.BR; +import de.tum.in.tumcampusapp.models.tumcabe.ChatMember; + + +public class StudyCard extends BaseObservable { + + private int id; + //private ChatMember member; + private int member; + //private Lecture lecture; + private int lecture; + //private CardType card_type; + private int card_type; + private String title; + private String front_text; + private String front_image; + private String back_text; + private String back_image; + private boolean can_shift; + + public StudyCard() { + this.setLecture(1); + this.setCard_type(1); + this.setTitle(""); + this.setFront_text(""); + this.setFront_image(""); + this.setBack_text(""); + this.setBack_image(""); + this.setCan_shift(false); + } + + public StudyCard(int id, int member, int lecture, String title, String front_text, String front_image, String back_text, String back_image, boolean can_shift) { + this.setId(id); + this.setMember(member); + this.setLecture(lecture); + this.setTitle(title); + this.setFront_text(front_text); + this.setFront_image(front_image); + this.setBack_text(back_text); + this.setBack_image(back_image); + this.setCan_shift(can_shift); + } + + @Bindable + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + notifyPropertyChanged(BR.id); + } + + @Bindable + public int getLecture() { + return lecture; + } + + public void setLecture(int lecture) { + this.lecture = lecture; + notifyPropertyChanged(BR.lecture); + } + + @Bindable + public int getMember() { + return member; + } + + public void setMember(int member) { + this.member = member; + notifyPropertyChanged(BR.member); + } + + @Bindable + public int getCard_type() { + return card_type; + } + + public void setCard_type(int card_type) { + this.card_type = card_type; + notifyPropertyChanged(BR.card_type); + } + + @Bindable + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + notifyPropertyChanged(BR.title); + } + + @Bindable + public String getFront_text() { + return front_text; + } + + public void setFront_text(String front_text) { + this.front_text = front_text; + notifyPropertyChanged(BR.front_text); + } + + @Bindable + public String getFront_image() { + return front_image; + } + + public void setFront_image(String front_image) { + this.front_image = front_image; + notifyPropertyChanged(BR.front_image); + } + + @Bindable + public String getBack_text() { + return back_text; + } + + public void setBack_text(String back_text) { + this.back_text = back_text; + notifyPropertyChanged(BR.back_text); + } + + @Bindable + public String getBack_image() { + return back_image; + } + + public void setBack_image(String back_image) { + this.back_image = back_image; + notifyPropertyChanged(BR.back_image); + } + + @Bindable + public boolean isCan_shift() { + return can_shift; + } + + public void setCan_shift(boolean can_shift) { + this.can_shift = can_shift; + notifyPropertyChanged(BR.can_shift); + } + + public boolean is_valid() { + // TODO + return !this.getTitle().isEmpty(); + } +} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/widgets/MVVWidget.java b/app/src/main/java/de/tum/in/tumcampusapp/widgets/MVVWidget.java index c6e87de31d..d3f81041ce 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/widgets/MVVWidget.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/widgets/MVVWidget.java @@ -127,6 +127,7 @@ static void updateAppWidgets(Context context, AppWidgetManager appWidgetManager, static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, boolean forceLoadData) { // Get the settings for this widget from the database + if (transportManager == null) transportManager = new TransportManager(context); WidgetDepartures widgetDepartures = transportManager.getWidget(appWidgetId); // Instantiate the RemoteViews object for the app widget layout. diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml new file mode 100644 index 0000000000..b9b8eca8b9 --- /dev/null +++ b/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_clear.xml b/app/src/main/res/drawable/ic_clear.xml new file mode 100644 index 0000000000..d11cc5c9c4 --- /dev/null +++ b/app/src/main/res/drawable/ic_clear.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_filter_list.xml b/app/src/main/res/drawable/ic_filter_list.xml new file mode 100644 index 0000000000..7d435fa2b8 --- /dev/null +++ b/app/src/main/res/drawable/ic_filter_list.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_layers.xml b/app/src/main/res/drawable/ic_layers.xml new file mode 100644 index 0000000000..84f5bb50aa --- /dev/null +++ b/app/src/main/res/drawable/ic_layers.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_play_arrow.xml b/app/src/main/res/drawable/ic_play_arrow.xml new file mode 100644 index 0000000000..81a8f74f6e --- /dev/null +++ b/app/src/main/res/drawable/ic_play_arrow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_cards.xml b/app/src/main/res/layout/activity_cards.xml new file mode 100644 index 0000000000..9a86d40103 --- /dev/null +++ b/app/src/main/res/layout/activity_cards.xml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + +