Commit 86ad4f28 authored by Fabius's avatar Fabius

New CanteenModule in Asist Core with own Settings. Removed Canteen Settings...

New CanteenModule in Asist Core with own Settings. Removed Canteen Settings from general settings and added function, that starttree opens CanteenModule.
parent 2ef68476
......@@ -14,53 +14,55 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />-->
<uses-permission android:name="android.permission.FLASHLIGHT" />
-->
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" /> -->
<!-- <uses-permission android:name="android.permission.CALL_PHONE" /> -->
<!-- for camera api -->
<!--<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />-->
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!--<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />-->
<!--android:icon="@drawable/app_icon" icon disabledm set back here if needed: -->
<!--
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
-->
<!-- android:icon="@drawable/app_icon" icon disabledm set back here if needed: -->
<application
android:name="de.bps.asist.core.ASiSTApplication"
android:name=".core.ASiSTApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:largeHeap="true"
android:logo="@android:color/transparent"
android:label="@string/app_name"
android:theme="@style/ASiSTTheme">
<receiver android:name="de.bps.asist.core.manager.update.UpdateAlarmReceiver"/>
<service
android:name="de.bps.asist.core.receiver.FirebaseReceiver">
<receiver android:name=".core.manager.update.UpdateAlarmReceiver" />
<service android:name=".core.receiver.FirebaseReceiver">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="de.bps.asist.core.manager.push.FirebaseIDService">
<service android:name=".core.manager.push.FirebaseIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver
android:name="de.bps.asist.core.manager.update.DateReceiver"
android:name=".core.manager.update.DateReceiver"
android:enabled="true"
android:exported="false" >
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.DATE_CHANGED" />
</intent-filter>
</receiver>
<uses-library android:name="com.google.android.maps" />
<activity
android:name="de.bps.asist.module.start.AsistStartActivity"
android:name=".module.start.AsistStartActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name">
<intent-filter>
......@@ -70,73 +72,76 @@
</intent-filter>
</activity>
<activity
android:name="de.bps.asist.module.olat.OlatActivity"
android:label="@string/module_olat_name" />
android:name=".module.olat.OlatActivity"
android:label="@string/module_olat_name" />
<activity
android:name=".module.feeds.FeedActivity"
android:label="@string/module_feeds_name" />
<activity
android:name="de.bps.asist.module.feeds.FeedActivity"
android:label="@string/module_feeds_name" />
android:name=".module.lostandfound.LostAndFoundActivity"
android:label="@string/module_lostandfound_name" />
<activity
android:name="de.bps.asist.module.lostandfound.LostAndFoundActivity"
android:label="@string/module_lostandfound_name" />
android:name=".module.canteen.CanteenActivity"
android:label="@string/module_canteen_name" />
<activity android:name=".module.feeds.SingleFeedActivity" />
<activity
android:name="de.bps.asist.module.canteen.CanteenActivity"
android:label="@string/module_canteen_name" />
<activity android:name="de.bps.asist.module.feeds.SingleFeedActivity" />
android:name=".gui.detail.DetailsActivity"
android:label="@string/title_activity_details" />
<activity
android:name="de.bps.asist.gui.detail.DetailsActivity"
android:name=".module.canteen.MenuDetailsActivity"
android:label="@string/title_activity_details" />
<activity
android:name="de.bps.asist.module.library.LibraryAccountActivity"
android:name=".module.library.LibraryAccountActivity"
android:label="@string/module_library_home_nav_account"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.library.LibraryBarcodeActivity"
android:name=".module.library.LibraryBarcodeActivity"
android:label="@string/module_library_home_nav_scan"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.library.LibraryFavoritesActivity"
android:name=".module.library.LibraryFavoritesActivity"
android:label="@string/module_library_home_nav_fav"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.timetable.TimetableSelectioncodeAddActivity"
android:name=".module.timetable.TimetableSelectioncodeAddActivity"
android:label="@string/module_timetable_name" />
<activity
android:name="de.bps.asist.module.timetable.TimetableDetailActivity"
android:label="@string/module_timetable_name" />
android:name=".module.timetable.TimetableDetailActivity"
android:label="@string/module_timetable_name" />
<activity
android:name="de.bps.asist.module.library.LibraryExtendedSearchActivity"
android:name=".module.library.LibraryExtendedSearchActivity"
android:label="@string/module_library_extended_search" />
<activity
android:name="de.bps.asist.module.canteen.MenuDetailActivity"
android:name=".module.canteen.MenuDetailActivity"
android:label="@string/title_activity_details"
android:screenOrientation="portrait" />
<activity android:name="de.bps.asist.module.canteen.SingleCanteenActivity" />
<activity android:name=".module.canteen.SingleCanteenActivity" />
<activity android:name="asist.bps.de.mytuc.module.publictransportationsystem.SingleStationActivity" />
<activity
android:name="de.bps.asist.gui.detail.DetailedTableActivity"
android:name=".gui.detail.DetailedTableActivity"
android:label="@string/title_activity_details"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.poi.PoiActivity"
android:name=".module.poi.PoiActivity"
android:label="@string/title_activity_details"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.lostandfound.LostFoundListActivity"
android:name=".module.lostandfound.LostFoundListActivity"
android:label="Details"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.lostandfound.LostFoundDetailActivity"
android:name=".module.lostandfound.LostFoundDetailActivity"
android:label="Details" />
<activity
android:name="de.bps.asist.module.feedback.FeedbackActivity"
android:name=".module.feedback.FeedbackActivity"
android:label="Feedback"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.feedback.FeedbackQuestion"
android:name=".module.feedback.FeedbackQuestion"
android:label="@string/module_feedback_question_title"
android:screenOrientation="portrait" />
<activity
android:name="de.bps.asist.module.feedback.FeedbackConfigActivity"
android:name=".module.feedback.FeedbackConfigActivity"
android:label="@string/module_feedback_config"
android:screenOrientation="portrait" />
......@@ -148,26 +153,26 @@
android:value="AIzaSyDTZSeTZNdLyH8-6XPMLhfKA2jWGZhbG4E" />
<activity
android:name="de.bps.asist.module.telephonedirectory.TelephoneDirectoryDetailsActivity"
android:name=".module.telephonedirectory.TelephoneDirectoryDetailsActivity"
android:label="@string/title_activity_telephone_directory_details" />
<activity
android:name="de.bps.asist.module.lostandfound.LostFoundAddActivity"
android:name=".module.lostandfound.LostFoundAddActivity"
android:label="@string/module_lostfound_title" />
<activity
android:name="de.bps.asist.module.library.details.LibraryDetailsActivity"
android:name=".module.library.details.LibraryDetailsActivity"
android:label="@string/title_activity_details" />
<activity
android:name="de.bps.asist.module.library.details.LibraryHoldingsActivity"
android:name=".module.library.details.LibraryHoldingsActivity"
android:label="@string/title_activity_details" />
<activity
android:name="de.bps.asist.module.eportfolio.PortfolioCameraActivity"
android:name=".module.eportfolio.PortfolioCameraActivity"
android:label="@string/portfolio_name"
android:launchMode="singleTop" />
<activity
android:name="de.bps.asist.module.survey.CreateSurveyActivity"
android:name=".module.survey.CreateSurveyActivity"
android:label="@string/survey_name" />
<activity
android:name="de.bps.asist.module.officehours.OfficeHoursDetailActivity"
android:name=".module.officehours.OfficeHoursDetailActivity"
android:label="@string/title_activity_office_hours_detail" />
<activity
android:name=".module.occupancy.OccupancyDetailActivity"
......@@ -175,26 +180,27 @@
<activity
android:name=".module.survey.SurveyAnswerFreeTextActivity"
android:label="@string/title_activity_details" />
<activity
android:name=".module.survey.SurveyFreetextActivity"
android:label="@string/survey_name" />
<activity android:name=".module.survey.SurveyAnswerOptionsActivity"
<activity
android:name=".module.survey.SurveyAnswerOptionsActivity"
android:label="@string/title_activity_details" />
<activity android:name=".module.survey.SurveyEditOptionsActivity"
<activity
android:name=".module.survey.SurveyEditOptionsActivity"
android:label="@string/survey_edit_button_title" />
<activity android:name=".module.survey.SurveyEvaluationActivity"
<activity
android:name=".module.survey.SurveyEvaluationActivity"
android:label="@string/title_activity_details" />
<activity android:name=".module.survey.SurveyOverviewActivity"
<activity
android:name=".module.survey.SurveyOverviewActivity"
android:label="@string/survey_name" />
<activity android:name=".gui.code.GenericAddActivity"
android:label="@string/survey_name" android:theme="@style/GenericAddTheme" />
<activity
android:name=".gui.code.GenericAddActivity"
android:label="@string/survey_name"
android:theme="@style/GenericAddTheme" />
<activity android:name=".module.canteen.CanteenSettingsActivity"
android:theme="@style/SettingsTheme"></activity>
</application>
</manifest>
\ No newline at end of file
......@@ -35,9 +35,10 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
useLibrary 'org.apache.http.legacy'
useLibrary 'org.apache.http.legacy'
versionCode 1
versionName '1.0'
vectorDrawables.useSupportLibrary = true
}
dexOptions {
javaMaxHeapSize "4g"
......@@ -98,6 +99,7 @@ android {
abortOnError false
}
}
android.libraryVariants.all { variant ->
......@@ -119,9 +121,9 @@ def version = '1.0'
def parseFile(name) {
File valuesFile = file(name)
println("Replacing revision number in " + valuesFile)
println("Build number = " + ${rootUrl})
println("Build number = " + $ { rootUrl })
String content = valuesFile.getText('UTF-8')
content = content.replaceAll('asistUrl', ${rootUrl})
content = content.replaceAll('asistUrl', $ { rootUrl })
valuesFile.write(content, 'UTF-8')
}
......@@ -146,6 +148,9 @@ dependencies {
compile 'com.loopj.android:android-async-http:1.4.5'
compile 'org.greenrobot:eventbus:3.0.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-vector-drawable:24.2.1'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.android.support:preference-v7:25.3.1'
}
allprojects {
......
......@@ -11,12 +11,15 @@ import java.util.Comparator;
import java.util.List;
import de.bps.asist.R;
import de.bps.asist.core.manager.database.DatabaseManager;
import de.bps.asist.gui.AbstractASiSTFragment;
import de.bps.asist.gui.list.AbstractGenericListCallback;
import de.bps.asist.gui.list.GenericListViewAdapter;
import de.bps.asist.module.canteen.model.Canteen;
/**
* Not longer in use
*/
public class CanteenFragment extends AbstractASiSTFragment {
private boolean started = false;
......
......@@ -53,7 +53,7 @@ public class CanteenModule extends AbstractAsistModule {
@Override
public android.support.v4.app.Fragment getInitialFragment() {
return new CanteenFragment();
return new MensaFragment();
}
@Override
......
......@@ -10,6 +10,7 @@ import de.bps.asist.module.settings.model.SettingsSection;
/**
* Created by litho on 30.10.14.
* Settings for Canteen Module, containing price information as well as preferred canteen information
* Not longer used
*/
public class CanteenSettings extends SettingsConfig {
......
package de.bps.asist.module.canteen;
import android.os.Bundle;
import de.bps.asist.R;
import de.bps.asist.module.AsistModuleActivity;
public class CanteenSettingsActivity extends AsistModuleActivity {
//Activity for new CanteenSettings
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_canteen_settings);
getSupportActionBar().setTitle(R.string.module_canteen_settings);
getFragmentManager().beginTransaction().replace(R.id.list_container, new CanteenSettingsFragment()).commit();
}
}
package de.bps.asist.module.canteen;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import de.bps.asist.R;
import de.bps.asist.module.canteen.model.Canteen;
public class CanteenSettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{
ListPreference listPreference;
ListPreference listPreference1;
//PreferenceFragment for new Canteen Settings
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_canteen);
listPreference = (ListPreference)findPreference("canteenPrices");
listPreference1 = (ListPreference)findPreference("canteens");
load_ListPreferences();
setSummary();
}
//Makes ListPreferences dynamic loads it with all canteens
private void load_ListPreferences(){
ListPreference listPreference = (ListPreference)findPreference("canteens");
//get Canteens
final List<Canteen> canteens = CanteenDatabaseManager.getInstance().getAllCanteens(getActivity());
//sort
Collections.sort(canteens, new Comparator<Canteen>() {
@Override
public int compare(Canteen canteen2, Canteen canteen1) {
if (canteen1 == null || canteen2 == null || canteen1.getTitle() == null) {
return 0;
}
return canteen1.getTitle().compareTo(canteen2.getTitle());
}
});
CharSequence canteenTitels[] = new String[canteens.size()];
CharSequence entryValues[] = new String[canteens.size()];
int i = 0;
for(Canteen canteen : canteens){
canteenTitels[i] = canteen.getTitle();
entryValues[i] = Integer.toString(i);
i++;
}
listPreference.setEntries(canteenTitels);
listPreference.setEntryValues(canteenTitels);
}
private void setSummary(){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
//TODO change Strings with R.string
listPreference.setSummary(sharedPreferences.getString("canteenPrices",null));
SharedPreferences sharedPreferences1 = PreferenceManager.getDefaultSharedPreferences(getActivity());
listPreference1.setSummary(sharedPreferences1.getString("canteens",null));
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
listPreference.setSummary(listPreference.getEntry().toString());
listPreference1.setSummary(listPreference1.getEntry().toString());
}
@Override
public void onResume() {
super.onResume();
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onPause() {
super.onPause();
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
}
package de.bps.asist.module.canteen;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import de.bps.asist.R;
import de.bps.asist.gui.AbstractASiSTFragment;
import de.bps.asist.module.canteen.model.Canteen;
import de.bps.asist.module.canteen.model.CanteenMenu;
public class ExpandableMensaList extends AbstractASiSTFragment {
private ExpandableListView listView;
Calendar calendar = Calendar.getInstance();
ExpandableMensaListAdapter expandableMensaListAdapter;
List<String> daten; //Saves the dates for the header of the ExpandableListView
HashMap<String, List<CanteenMenu>> menus; //HashMap for the ExpandableListView
Canteen selectedCanteen;
public ExpandableMensaList() {
// Required empty public constructor
}
@SuppressLint("ValidFragment")
public ExpandableMensaList(Canteen canteen) {
// Required empty public constructor
selectedCanteen = canteen;
}
private static final String DATE_Format = "dd.MM.yyyy";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
super.onCreateView(inflater,container,savedInstanceState);
View view = inflater.inflate(R.layout.expandablelistview, container, false);
listView = getView(view,R.id.listView_id);
prepareListData();
expandableMensaListAdapter = new ExpandableMensaListAdapter(getContext(),daten, menus);
try{
listView.setAdapter(expandableMensaListAdapter);
listView.expandGroup(0);
} catch (Exception e){
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setMessage(de.bps.asist.R.string.serverErrorText).setTitle(de.bps.asist.R.string.serverError);
builder.setPositiveButton("OK",null);
builder.create();
builder.show();
}
//Child Click!
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i1, long l) {
Intent intent = new Intent(getContext(), MenuDetailsActivity.class);
//TODO change name
intent.putExtra("1",menus.get(daten.get(i)).get(i1));
startActivity(intent);
return false;
}
});
return view;
}
//Prepares the ListData to sort the menus to it's dates
private void prepareListData(){
daten = new ArrayList<String>();
menus = new HashMap<String, List<CanteenMenu>>();
//Adding Daten
for(int i = 0;i < 5;i++){
daten.add(cleanDate(calendar));
List<CanteenMenu> firstMenuList = new ArrayList<CanteenMenu>();
firstMenuList.addAll(selectedCanteen.getMenuItems());
//Sorts for Categorys (Menu 1 should be on top)
Collections.sort(firstMenuList, new Comparator<CanteenMenu>() {
@Override
public int compare(CanteenMenu canteenMenu1, CanteenMenu canteenMenu2) {
if(canteenMenu1 == null || canteenMenu2 == null || canteenMenu1.getCategory() == null){
return 0;
}
return canteenMenu1.getCategory().compareTo(canteenMenu2.getCategory());
}
});
List<CanteenMenu> menuListWithMatchingDates = new ArrayList<CanteenMenu>();
//Compares all menus with the dates of the current Day to provide a List with matching dates and menus
Calendar cal = Calendar.getInstance();
for(final CanteenMenu menu : firstMenuList){
cal.setTime(menu.getDate());
if(cleanDate(cal).equals(cleanDate(calendar))){
menuListWithMatchingDates.add(menu);
}
}
firstMenuList.clear();
add(calendar);
menus.put(daten.get(i), menuListWithMatchingDates);
}
}
//Calendar goes one Day ahead
private void add(Calendar cal) {
int toAdd = 1;
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {
toAdd = 3;
}
cal.add(Calendar.DAY_OF_WEEK, toAdd);
}
//Calendar goes to the previous day
private void reduce(Calendar cal) {
int toAdd = -1;
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
toAdd = -3;
}
cal.add(Calendar.DAY_OF_WEEK, toAdd);
}
//Provides a clean Date String for the Headers
private String cleanDate(Calendar cal) {
SimpleDateFormat format = new SimpleDateFormat(DATE_Format);
return format.format(cal.getTime());
}
}
package de.bps.asist.module.canteen;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import de.bps.asist.R;
import de.bps.asist.core.manager.image.ASiSTImageManager;
import de.bps.asist.module.canteen.model.CanteenMenu;
import de.bps.asist.module.canteen.model.MenuPriceDescription;
public class ExpandableMensaListAdapter extends BaseExpandableListAdapter {
private Context context;
private List<String> dataHeader; //Tittel der ExpandableList (Datum)
private HashMap<String, List<CanteenMenu>> listDataMenus;
public ExpandableMensaListAdapter(Context context, List<String> dataHeader, HashMap<String, List<CanteenMenu>> listDataMenus) {
this.context = context;
this.dataHeader = dataHeader;
this.listDataMenus = listDataMenus;
}
@Override
public int getGroupCount() {