Merge branch 'addRemovingManuals' of s416084/find-my-tutor-android into develop

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-04 23:45:41 +00:00 committed by Gogs
commit eb4147557b
11 changed files with 331 additions and 38 deletions

View File

@ -44,6 +44,7 @@ import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.CoordinateService;
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
@ -356,7 +357,7 @@ public class MapActivity extends BaseActivity
private void sendLocation(String body, LatLng latLng) {
PredefinedStatusesService predefinedStatusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
PredefinedCoordinatesService predefinedCoordinatesService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel(
latLng.getLatitude(),
@ -370,7 +371,7 @@ public class MapActivity extends BaseActivity
CompositeDisposable disposable = new CompositeDisposable();
disposable.add(
predefinedStatusesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
predefinedCoordinatesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::SaveCurrentManualLocation, this::handleError)

View File

@ -1,7 +1,9 @@
package com.uam.wmi.findmytutor.activity;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
@ -21,15 +23,21 @@ import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
import com.uam.wmi.findmytutor.service.PredefinedDataService;
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
import com.uam.wmi.findmytutor.utils.Const;
import com.uam.wmi.findmytutor.utils.CustomListPreference2;
import com.uam.wmi.findmytutor.utils.EnableSharingDialog;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.RightButtonPreference;
import com.uam.wmi.findmytutor.utils.SharingLevel;
import org.apache.commons.collections4.BidiMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@ -45,19 +53,29 @@ import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class SharingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
protected SwitchPreference locationSharing;
protected SwitchPreference statusSwitch;
protected Preference locationMode;
protected ListPreference manualLocationList;
protected PreferenceCategory preferenceCategory;
protected RightButtonPreference manualLocationButton;
protected RightButtonPreference removeManualLocation;
protected RightButtonPreference removeManualStatus;
protected Preference manualStatus;
protected ListPreference statusList;
private HashMap<String,String> locationMap;
private ArrayList <String> locationUUIDs;
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
private HashMap<Integer, String> locationLevelMapping;
private HashMap<Integer, String> statusMapping;
private PredefinedStatusesService statusesService;
private PredefinedCoordinatesService locationService;
private CompositeDisposable disposable;
private AlertDialog.Builder builder;
private String[] statusesArray;
private boolean statusSwitchFlag;
private ArrayList<String> predefinedLocationsList;
public static SharingFragment newInstance() {
public static SharingFragment newInstance() {
return new SharingFragment();
}
@ -69,7 +87,13 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
.subscribeWith(new DisposableSingleObserver<List<String>>() {
@Override
public void onSuccess(List<String> strings) {
String[] statusesArray = strings.toArray(new String[strings.size()]);
statusesArray = strings.toArray(new String[strings.size()]);
if(strings.isEmpty()){
disableStatusPreferences();
}else{
enableStatusPreferences();
}
// Log.d("STATUSES",Integer.toString(statusesArray.length ));
setListPreferenceData(statusList, statusesArray, null);
}
@ -82,20 +106,47 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
}
void getLocations(CompositeDisposable disposable) {
disposable.add(statusesService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
disposable.add(locationService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<PredefinedCoordViewModel>>() {
@Override
public void onSuccess(List<PredefinedCoordViewModel> coords) {
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
locationMap = new HashMap<String,String>();
locationUUIDs = new ArrayList<String>();
for (PredefinedCoordViewModel i : coords) locationMap.put(i.getPredefinedCoordinateId(),i.getName());
for (PredefinedCoordViewModel i : coords) locationUUIDs.add(i.getPredefinedCoordinateId());
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList();
predefinedCoordsList.addAll(coords);
String[] stringnames = predefinedLocationsNames.toArray(new String[0]);
predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames));
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(removeManualLocation);
preferenceCategory.removePreference(manualLocationButton);
}else{
if(predefinedCoordsList.isEmpty()){
locationSharing.setEnabled(false);
locationSharing.setChecked(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
removeManualLocation.setEnabled(false);
manualLocationList.setEnabled(false);
manualLocationList.setSummary("");
}else{
manualLocationList.setEnabled(true);
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
removeManualLocation.setEnabled(true);
locationSharing.setEnabled(true);
}
}
List<Integer> activesId = Stream.of(coords).indexed()
.filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList();
@ -105,12 +156,14 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
else {
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
}
}
@Override
public void onError(Throwable e) {
Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show();
}
}));
}
@ -120,14 +173,21 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.pref_sharing);
locationSharing = (SwitchPreference) findPreference("key_sharing_enabled");
statusSwitch = (SwitchPreference) findPreference("key_status_enabled");
locationMode = findPreference("key_location_level");
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
manualLocationList = (ListPreference) findPreference("key_manual_location_value");
manualLocationButton = (RightButtonPreference) findPreference("manual_location_button");
removeManualLocation = (RightButtonPreference) findPreference("remove_manual_location");
builder = new AlertDialog.Builder(getActivity());
removeManualStatus = (RightButtonPreference) findPreference("remove_manual_status");
manualStatus = findPreference("key_manual_status");
statusList = (ListPreference) findPreference("key_status_value");
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
locationService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
disposable = new CompositeDisposable();
statusesArray = new String[0];
predefinedLocationsList = new ArrayList<String>();
getStatuses(disposable);
getLocations(disposable);
locationLevelMapping = new HashMap<Integer, String>();
@ -157,26 +217,29 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
((MapActivity) getActivity()).startBackgroundLocalizationTask();
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
if (!predefinedCoordsList.isEmpty()) {
preferenceCategory.addPreference(manualLocationList);
preferenceCategory.addPreference(manualLocationList);
preferenceCategory.addPreference(removeManualLocation);
}else{
locationSharing.setEnabled(false);
locationSharing.setChecked(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
}
preferenceCategory.addPreference(manualLocationButton);
} else {
locationSharing.setEnabled(true);
preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(manualLocationButton);
preferenceCategory.removePreference(removeManualLocation);
}
return true;
});
/** Manual location category hiding when location level is != manual **/
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(manualLocationButton);
}
/** Custom manual location list change listener **/
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
@ -208,7 +271,9 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
fragmentTransaction.commit();
return true;
});
statusSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
return true;
});
/** Status list change listener **/
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) preference;
@ -218,7 +283,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
return true;
});
/** Custom status list change listener **/
/** Custom status edittext change listener **/
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
@ -228,6 +293,39 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
return true;
});
removeManualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
showRemoveDialog(statusList.getEntries(),"status");
return true;
});
removeManualLocation.setOnPreferenceChangeListener(((preference, newValue) -> {
showRemoveDialog(manualLocationList.getEntries(),"location");
return true;
}));
}
public void showRemoveDialog(CharSequence[] entries, String service){
boolean [] checked = new boolean[entries.length];
ArrayList<String> tobeDeleted = new ArrayList<String>();
// Log.d("sharingDialog", "no to siup");
builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (int i=0; i< entries.length; i++){
if(checked[i] == true) {
tobeDeleted.add((String) entries[i]);
}
}
removeEntries(service,tobeDeleted);
// Log.d("MANAGE-PREF",tobeDeleted.toString());
}
});
builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
}
});
builder.create().show();
}
@Override
@ -238,6 +336,36 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
return view;
}
protected void removeEntries(String service, ArrayList<String> toBeDeleted){
// Log.d("MANAGE-PREF", toBeDeleted.toString());
if(service.equals("status")){
for (String uuid:toBeDeleted) {
disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleDeleteStatuses, this::handleError));
}
}else {
ArrayList<String> uuidsToBeDeleted = new ArrayList<String>();
for (String name:toBeDeleted) {
for (String uuid:locationUUIDs) {
if(locationMap.get(uuid).equals(name)){
uuidsToBeDeleted.add(uuid);
}
}
}
for (String uuid : uuidsToBeDeleted) {
// predefinedCoordsList.removeIf(x -> x.getPredefinedCoordinateId().equals(uuid));
predefinedCoordsList.removeAll(Stream.of(predefinedCoordsList).filter(x -> x.getPredefinedCoordinateId().equals(uuid)).toList());
disposable.add(locationService.deleteUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), uuid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleDeleteLocations, this::handleError));
}
}
}
protected void setListPreferenceData(ListPreference lp, String[] entries, Integer activeId) {
try {
@ -263,10 +391,15 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
;
private void handleResponse(List<String> resp) {
if(resp.size() == 1){
enableStatusPreferences();
if(PrefUtils.isStatusEnabled(getApplicationContext()) == false){
PrefUtils.enableStatus(getApplicationContext());
statusSwitch.setChecked(true);
}
}
String[] statusesArray = resp.toArray(new String[resp.size()]);
setListPreferenceData(statusList, statusesArray, resp.size() - 1);
statusList.setValueIndex(resp.size() - 1);
PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1));
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
@ -283,6 +416,73 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
}
}
private void handleDeleteStatuses(List<String> resp){
if(resp.isEmpty()){
disableStatusPreferences();
}else{
String[] statusesArray = resp.toArray(new String[resp.size()]);
setListPreferenceData(statusList, statusesArray, null);
String currentEntry = PrefUtils.getUserStatus(getApplicationContext());
if(resp.contains(currentEntry)){
statusList.setValueIndex(resp.indexOf(currentEntry));
}else{
statusList.setValueIndex(0);
statusList.setSummary(resp.get(0));
}
}
}
private void handleDeleteLocations(List<PredefinedCoordViewModel> resp){
getLocations(disposable);
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
if(resp.isEmpty()){
disableManualLocationPreferences();
}else{
if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty())
{
for (PredefinedCoordViewModel location: resp) {
if(location.getName().equals(currentEntry)){
manualLocationList.setValueIndex(resp.indexOf(location));
break;
}
}
}else{
manualLocationList.setValueIndex(0);
manualLocationList.setSummary(resp.get(0).getName());
//todo czy na pewno w shared pref sa dobre wartosci
}
}
}
private void disableStatusPreferences(){
removeManualStatus.setEnabled(false);
statusList.setEnabled(false);
statusSwitch.setEnabled(false);
statusList.setSummary("");
PrefUtils.disableStatus(getApplicationContext());
}
private void enableStatusPreferences(){
removeManualStatus.setEnabled(true);
statusList.setEnabled(true);
statusSwitch.setEnabled(true);
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
}
private void disableManualLocationPreferences(){
removeManualLocation.setEnabled(false);
manualLocationList.setEnabled(false);
manualLocationList.setSummary("");
locationSharing.setChecked(false);
locationSharing.setEnabled(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
}
private void enableManualLocationPreferences(){
removeManualLocation.setEnabled(true);
manualLocationList.setEnabled(true);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

View File

@ -11,12 +11,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
@ -114,16 +112,16 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
@Override
public void onClick(View v) {
try{
Log.d("DutyIndex bf rm size",Integer.toString(getItemCount()));
Log.d("DutyIndex bf rm pos",Integer.toString(holder.getLayoutPosition()));
// Log.d("DutyIndex bf rm size",Integer.toString(getItemCount()));
// Log.d("DutyIndex bf rm pos",Integer.toString(holder.getLayoutPosition()));
removeDuty(holder.getLayoutPosition());
Log.d("DutyIndex af rm pos",Integer.toString(holder.getLayoutPosition()));
// Log.d("DutyIndex af rm pos",Integer.toString(holder.getLayoutPosition()));
}catch(Error e){
Log.e("DutyIndex error",e.getMessage());
Log.e("DutyIndex size",Integer.toString(getItemCount()));
Log.e("DutyIndex pos",Integer.toString(holder.getAdapterPosition()));
// Log.e("DutyIndex error",e.getMessage());
// Log.e("DutyIndex size",Integer.toString(getItemCount()));
// Log.e("DutyIndex pos",Integer.toString(holder.getAdapterPosition()));
}

View File

@ -0,0 +1,24 @@
package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
import java.util.List;
import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface PredefinedCoordinatesService {
@GET("api/users/predefined/coordinate/{tutorId}")
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
@POST("api/users/predefined/coordinate/{tutorId}")
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
@HTTP(method = "DELETE", path = "api/users/predefined/coordinate/{tutorId}", hasBody = true)
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body String uuid);
}

View File

@ -5,25 +5,27 @@ import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface PredefinedStatusesService {
public interface PredefinedStatusesService {
@GET("api/users/predefined/status/{tutorId}")
Single<List<String>> getUserPredefinedStatuses(@Path("tutorId") String tutorId);
@POST("api/users/predefined/status/{tutorId}")
Single<List<String>> postUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
@DELETE("api/users/predefined/status/{tutorId}")
// @DELETE("api/users/predefined/status/{tutorId}")
@HTTP(method = "DELETE", path = "api/users/predefined/status/{tutorId}", hasBody = true)
Single<List<String>> deleteUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
@GET("api/users/predefined/coordinate/{tutorId}")
/* @GET("api/users/predefined/coordinate/{tutorId}")
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
@POST("api/users/predefined/coordinate/{tutorId}")
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
@DELETE("api/users/predefined/coordinate/{tutorId}")
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);*/
}

View File

@ -60,6 +60,16 @@ public class PrefUtils {
return getSharedPreferences(context).getBoolean("key_status_enabled", false);
}
public static void enableStatus(Context context){
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_status_enabled", true);
editor.apply();
}
public static void disableStatus(Context context) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_status_enabled", false);
editor.apply();
}
public static String getUserStatus(Context context) {
return getSharedPreferences(context).getString("status_entry", "Dostępny");
@ -94,6 +104,11 @@ public class PrefUtils {
public static boolean isEnableSharingLocalization(Context context) {
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
}
public static void disableSharing(Context context){
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_sharing_enabled", false);
editor.apply();
}
public static void storeEnableSharingLocalization(Context context, Boolean isChecked) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();

View File

@ -2,6 +2,8 @@ package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@ -9,25 +11,43 @@ import com.uam.wmi.findmytutor.R;
public class RightButtonPreference extends Preference {
private Button prefButton;
private String buttonText;
public RightButtonPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setWidgetLayoutResource(R.layout.preference_button_widget);
setWidgetLayoutResource(R.layout.preference_button_widget);
for (int i=0;i<attrs.getAttributeCount();i++) {
String attr = attrs.getAttributeName(i);
String val = attrs.getAttributeValue(i);
if (attr.equalsIgnoreCase("text")) {
// buttonText = val;
Log.d("RightButtonPreference", "step = " + val);
buttonText = context.getResources().getString(Integer.parseInt(val.substring(1)));
}
}
}
public void setText(String text){
prefButton.setText(text);
}
@Override
protected View onCreateView(ViewGroup parent) {
View view = super.onCreateView(parent);
// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
// View temp =li.inflate( R.layout.preference_button_widget, parent, false);
return view;
}
@Override
protected void onBindView(View view)
{
super.onBindView(view);
Button button = (Button)view.findViewById(R.id.button_choose_from_map);
if(button != null)
prefButton = (Button) view.findViewById(R.id.button_choose_from_map);
prefButton.setText(buttonText);
if(prefButton != null)
{
button.setOnClickListener(new View.OnClickListener() {
prefButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
callChangeListener(null);

View File

@ -30,6 +30,12 @@
android:title="@string/title_list_manual_location" />
<com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="manual_location_button"
android:text="@string/preference_manual_location_button"
/>
<com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_location"
android:text="@string/preference_manual_location_button_remove"
/>
</PreferenceCategory>
@ -51,6 +57,11 @@
android:singleLine="true"
android:title="@string/title_manual_status"
/>
<com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_status"
android:text="@string/preference_manual_status_button_remove"
/>
</PreferenceCategory>

View File

@ -243,6 +243,9 @@
<string name="negative_dialog_button">Nie</string>
<string name="enable_sharing_question">Aby skorzystać z tej funkcji musisz pozwolić na udostępnianie lokalizacji. Zgadzasz sie?</string>
<string name="sharing_modal_title">Udostępnianie</string>
<string name="preference_manual_location_button_remove">Zarządzaj zapisanymi</string>
<string name="preference_manual_status_button_remove">Zarządzaj zapisanymi</string>
<string name="blacklist">Czarna lista</string>
<string name="can_not_be_empty">Pole nie może być puste</string>
<string name="user_added">Użytkownik dodany</string>

View File

@ -74,6 +74,7 @@
<item>2</item>
</string-array>
<string-array name="language_entries">
<item>@string/lang_eng</item>
<item>@string/lang_pol</item>
</string-array>
@ -81,4 +82,19 @@
<item>0</item>
<item>1</item>
</string-array>
<string-array name="yourArray">
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
<item>Item 4</item>
</string-array>
<string-array name="yourValues">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
</resources>

View File

@ -68,6 +68,9 @@
<string name="location_level_precise">Exact</string>
<string name="location_level_manual">Manual</string>
<string name="preference_manual_location_button">Choose from map</string>
<string name="preference_manual_location_button_remove">Manage saved</string>
<string name="preference_manual_status_button_remove">Manage saved</string>
<string name="settings_location_level">Location level</string>
<string name="key_location_level">key_location_level</string>