refresh sharing tab
This commit is contained in:
parent
41288f000b
commit
c8145323c5
@ -82,9 +82,11 @@ public abstract class BaseActivity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getContentViewId());
|
||||
|
||||
drawerNavigationView = findViewById(R.id.nav_view);
|
||||
sideDrawer = findViewById(R.id.activity_container);
|
||||
feedbackUtils = new FeedbackUtils(BaseActivity.this);
|
||||
|
||||
drawerNavigationView.setNavigationItemSelectedListener(
|
||||
item -> {
|
||||
String itemName = (String) item.getTitle();
|
||||
|
@ -112,6 +112,7 @@ public class MapActivity extends BaseActivity
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
isTutor = PrefUtils.getIsTutor(this);
|
||||
myId = PrefUtils.getUserId(getApplicationContext());
|
||||
|
||||
@ -143,7 +144,6 @@ public class MapActivity extends BaseActivity
|
||||
handleBackgroundTaskLifeCycle();
|
||||
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,11 +2,13 @@ package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -40,8 +42,8 @@ import okhttp3.ResponseBody;
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
|
||||
public class SharingFragment extends PreferenceFragment {
|
||||
protected Preference locationSharing;
|
||||
public class SharingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
protected SwitchPreference locationSharing;
|
||||
protected Preference locationMode;
|
||||
protected ListPreference manualLocationList;
|
||||
protected PreferenceCategory preferenceCategory;
|
||||
@ -114,7 +116,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
locationSharing = findPreference("key_sharing_enabled");
|
||||
locationSharing = (SwitchPreference) findPreference("key_sharing_enabled");
|
||||
locationMode = findPreference("key_location_level");
|
||||
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
||||
manualLocationList = (ListPreference) findPreference("key_manual_location_value");
|
||||
@ -183,18 +185,20 @@ public class SharingFragment extends PreferenceFragment {
|
||||
EnableSharingDialog sharingDialog = new EnableSharingDialog();
|
||||
sharingDialog.show(getFragmentManager(), "Sharing");
|
||||
//refresh view -> get new values from xml
|
||||
|
||||
}
|
||||
|
||||
PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation());
|
||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), temp.getPredefinedCoordinateId());
|
||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String) lp.getEntries()[Integer.parseInt((String) newValue)]);
|
||||
lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]);
|
||||
getPreferenceScreen().removeAll();
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
/** Button 'choose from map' button listener **/
|
||||
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
@ -228,7 +232,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
Objects.requireNonNull(view).setBackgroundColor(getResources().getColor(android.R.color.white));
|
||||
;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -278,4 +282,22 @@ public class SharingFragment extends PreferenceFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
locationSharing.setChecked(PrefUtils.isEnableSharingLocalization(getApplicationContext()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user