Merge branch 'fix-bugs-related-to-network' of s416084/find-my-tutor-android into develop

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-05 19:39:01 +00:00 committed by Gogs
commit 72eea53a8c
7 changed files with 193 additions and 209 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "com.uam.wmi.findmytutor" applicationId "com.uam.wmi.findmytutor"
minSdkVersion 22 minSdkVersion 22
targetSdkVersion 27 targetSdkVersion 27
versionCode 35 versionCode 36
versionName "0.9.6-beta" versionName "0.9.6-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true

View File

@ -98,6 +98,7 @@ public class BlackList extends AppCompatActivity {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
setContentView(R.layout.activity_black_list); setContentView(R.layout.activity_black_list);
ButterKnife.bind(this); ButterKnife.bind(this);
tutorId = PrefUtils.getUserId(getApplicationContext()); tutorId = PrefUtils.getUserId(getApplicationContext());
userService = ApiClient.getClient(getApplicationContext()) userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class); .create(UserService.class);

View File

@ -31,6 +31,8 @@ import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.RightButtonPreference; import com.uam.wmi.findmytutor.utils.RightButtonPreference;
import com.uam.wmi.findmytutor.utils.SharingLevel; import com.uam.wmi.findmytutor.utils.SharingLevel;
import org.apache.commons.collections4.BidiMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -57,9 +59,9 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
protected RightButtonPreference removeManualStatus; protected RightButtonPreference removeManualStatus;
protected Preference manualStatus; protected Preference manualStatus;
protected ListPreference statusList; protected ListPreference statusList;
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
private HashMap<String,String> locationMap; private HashMap<String,String> locationMap;
private ArrayList <String> locationUUIDs; private ArrayList <String> locationUUIDs;
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
private HashMap<Integer, String> locationLevelMapping; private HashMap<Integer, String> locationLevelMapping;
private HashMap<Integer, String> statusMapping; private HashMap<Integer, String> statusMapping;
private PredefinedStatusesService statusesService; private PredefinedStatusesService statusesService;
@ -112,10 +114,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext()); String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
locationMap = new HashMap<String,String>(); locationMap = new HashMap<String,String>();
locationUUIDs = new ArrayList<String>(); locationUUIDs = new ArrayList<String>();
for (PredefinedCoordViewModel i : coords) for (PredefinedCoordViewModel i : coords) locationMap.put(i.getPredefinedCoordinateId(),i.getName());
locationMap.put(i.getPredefinedCoordinateId(), i.getName()); for (PredefinedCoordViewModel i : coords) locationUUIDs.add(i.getPredefinedCoordinateId());
for (PredefinedCoordViewModel i : coords)
locationUUIDs.add(i.getPredefinedCoordinateId());
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList(); List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList(); List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList();
predefinedCoordsList.addAll(coords); predefinedCoordsList.addAll(coords);
@ -149,7 +149,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
if( activesId.size() == 0){ if( activesId.size() == 0){
setListPreferenceData(manualLocationList, stringnames, null); setListPreferenceData(manualLocationList, stringnames, null);
} else { }
else {
setListPreferenceData(manualLocationList, stringnames, activesId.get(0)); setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
} }
@ -239,8 +240,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
/** Custom manual location list change listener **/ /** Custom manual location list change listener **/
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> { manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) preference; ListPreference lp = (ListPreference) preference;
CharSequence[] entries = lp.getEntries(); CharSequence[] entries = lp.getEntries();
PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0); PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0);
@ -261,6 +260,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
}); });
/** Button 'choose from map' button listener **/ /** Button 'choose from map' button listener **/
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> { manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
@ -300,7 +300,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
})); }));
} }
public void showRemoveDialog(CharSequence[] entries, String service){ public void showRemoveDialog(CharSequence[] entries, String service){
boolean [] checked = new boolean[entries.length]; boolean [] checked = new boolean[entries.length];
ArrayList<String> tobeDeleted = new ArrayList<String>(); ArrayList<String> tobeDeleted = new ArrayList<String>();
@ -414,7 +413,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show(); "Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
} }
} }
private void handleDeleteStatuses(List<String> resp){ private void handleDeleteStatuses(List<String> resp){
if(resp.isEmpty()){ if(resp.isEmpty()){
disableStatusPreferences(); disableStatusPreferences();
@ -431,14 +429,14 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
} }
} }
private void handleDeleteLocations(List<PredefinedCoordViewModel> resp){ private void handleDeleteLocations(List<PredefinedCoordViewModel> resp){
getLocations(disposable); getLocations(disposable);
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext()); String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
if(resp.isEmpty()){ if(resp.isEmpty()){
disableManualLocationPreferences(); disableManualLocationPreferences();
}else{ }else{
if (!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty()) { if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty())
{
for (PredefinedCoordViewModel location: resp) { for (PredefinedCoordViewModel location: resp) {
if(location.getName().equals(currentEntry)){ if(location.getName().equals(currentEntry)){
manualLocationList.setValueIndex(resp.indexOf(location)); manualLocationList.setValueIndex(resp.indexOf(location));
@ -453,7 +451,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
} }
} }
private void disableStatusPreferences(){ private void disableStatusPreferences(){
removeManualStatus.setEnabled(false); removeManualStatus.setEnabled(false);
statusList.setEnabled(false); statusList.setEnabled(false);
@ -462,14 +459,12 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
PrefUtils.disableStatus(getApplicationContext()); PrefUtils.disableStatus(getApplicationContext());
} }
private void enableStatusPreferences(){ private void enableStatusPreferences(){
removeManualStatus.setEnabled(true); removeManualStatus.setEnabled(true);
statusList.setEnabled(true); statusList.setEnabled(true);
statusSwitch.setEnabled(true); statusSwitch.setEnabled(true);
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext())); statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
} }
private void disableManualLocationPreferences(){ private void disableManualLocationPreferences(){
removeManualLocation.setEnabled(false); removeManualLocation.setEnabled(false);
manualLocationList.setEnabled(false); manualLocationList.setEnabled(false);
@ -480,7 +475,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
} }
private void enableManualLocationPreferences(){ private void enableManualLocationPreferences(){
removeManualLocation.setEnabled(true); removeManualLocation.setEnabled(true);
manualLocationList.setEnabled(true); manualLocationList.setEnabled(true);

View File

@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableCompletableObserver; import io.reactivex.observers.DisposableCompletableObserver;
@ -61,9 +62,10 @@ public class TutorTab extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
setContentView(R.layout.content_tutor_tab); setContentView(R.layout.content_tutor_tab);
ButterKnife.bind(this);
userName = findViewById(R.id.userName); userName = findViewById(R.id.userName);
userNote = (TextInputEditText) findViewById(R.id.userNote); userNote = (TextInputEditText) findViewById(R.id.userNote);
@ -149,7 +151,6 @@ public class TutorTab extends AppCompatActivity {
showError(e); showError(e);
} }
})); }));
} }
private void addEmptyDuty(DutyHoursAdapter adapter){ private void addEmptyDuty(DutyHoursAdapter adapter){

View File

@ -11,7 +11,6 @@ import com.uam.wmi.findmytutor.R;
public class RightButtonPreference extends Preference { public class RightButtonPreference extends Preference {
private Button prefButton; private Button prefButton;
private String buttonText; private String buttonText;
@ -22,9 +21,6 @@ public class RightButtonPreference extends Preference {
String attr = attrs.getAttributeName(i); String attr = attrs.getAttributeName(i);
String val = attrs.getAttributeValue(i); String val = attrs.getAttributeValue(i);
if (attr.equalsIgnoreCase("text")) { if (attr.equalsIgnoreCase("text")) {
// buttonText = val;
Log.d("RightButtonPreference", "step = " + val);
buttonText = context.getResources().getString(Integer.parseInt(val.substring(1))); buttonText = context.getResources().getString(Integer.parseInt(val.substring(1)));
} }
} }
@ -35,24 +31,19 @@ public class RightButtonPreference extends Preference {
} }
@Override @Override
protected View onCreateView(ViewGroup parent) { protected View onCreateView(ViewGroup parent) {
View view = super.onCreateView(parent); return super.onCreateView(parent);
return view;
} }
@Override @Override
protected void onBindView(View view) protected void onBindView(View view)
{ {
super.onBindView(view); super.onBindView(view);
prefButton = (Button) view.findViewById(R.id.button_choose_from_map); prefButton = view.findViewById(R.id.button_choose_from_map);
prefButton.setText(buttonText); prefButton.setText(buttonText);
if(prefButton != null) if(prefButton != null)
{ {
prefButton.setOnClickListener(new View.OnClickListener() { prefButton.setOnClickListener(view1 -> {
@Override
public void onClick(View view) {
callChangeListener(null); callChangeListener(null);
notifyChanged(); notifyChanged();
}
}); });
} }
} }

View File

@ -7,8 +7,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <LinearLayout
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -16,7 +16,7 @@
android:persistent="true" android:persistent="true"
android:title="@string/title_sharing"/> android:title="@string/title_sharing"/>
<ListPreference <ListPreference
android:defaultValue="1" android:defaultValue="2"
android:dialogTitle="@string/settings_location_level" android:dialogTitle="@string/settings_location_level"
android:entries="@array/location_level_entries" android:entries="@array/location_level_entries"
android:entryValues="@array/location_level_values" android:entryValues="@array/location_level_values"
@ -33,7 +33,6 @@
<com.uam.wmi.findmytutor.utils.RightButtonPreference <com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="manual_location_button" android:key="manual_location_button"
android:text="@string/preference_manual_location_button" android:text="@string/preference_manual_location_button"
/> />
<com.uam.wmi.findmytutor.utils.RightButtonPreference <com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_location" android:key="remove_manual_location"