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) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getContentViewId());
|
setContentView(getContentViewId());
|
||||||
|
|
||||||
drawerNavigationView = findViewById(R.id.nav_view);
|
drawerNavigationView = findViewById(R.id.nav_view);
|
||||||
sideDrawer = findViewById(R.id.activity_container);
|
sideDrawer = findViewById(R.id.activity_container);
|
||||||
feedbackUtils = new FeedbackUtils(BaseActivity.this);
|
feedbackUtils = new FeedbackUtils(BaseActivity.this);
|
||||||
|
|
||||||
drawerNavigationView.setNavigationItemSelectedListener(
|
drawerNavigationView.setNavigationItemSelectedListener(
|
||||||
item -> {
|
item -> {
|
||||||
String itemName = (String) item.getTitle();
|
String itemName = (String) item.getTitle();
|
||||||
|
@ -112,6 +112,7 @@ public class MapActivity extends BaseActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
isTutor = PrefUtils.getIsTutor(this);
|
isTutor = PrefUtils.getIsTutor(this);
|
||||||
myId = PrefUtils.getUserId(getApplicationContext());
|
myId = PrefUtils.getUserId(getApplicationContext());
|
||||||
|
|
||||||
@ -143,7 +144,6 @@ public class MapActivity extends BaseActivity
|
|||||||
handleBackgroundTaskLifeCycle();
|
handleBackgroundTaskLifeCycle();
|
||||||
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
||||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,11 +2,13 @@ package com.uam.wmi.findmytutor.activity;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.preference.SwitchPreference;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -40,8 +42,8 @@ import okhttp3.ResponseBody;
|
|||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
|
|
||||||
|
|
||||||
public class SharingFragment extends PreferenceFragment {
|
public class SharingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
protected Preference locationSharing;
|
protected SwitchPreference locationSharing;
|
||||||
protected Preference locationMode;
|
protected Preference locationMode;
|
||||||
protected ListPreference manualLocationList;
|
protected ListPreference manualLocationList;
|
||||||
protected PreferenceCategory preferenceCategory;
|
protected PreferenceCategory preferenceCategory;
|
||||||
@ -114,7 +116,7 @@ public class SharingFragment extends PreferenceFragment {
|
|||||||
public void onCreate(final Bundle savedInstanceState) {
|
public void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.layout.pref_sharing);
|
addPreferencesFromResource(R.layout.pref_sharing);
|
||||||
locationSharing = findPreference("key_sharing_enabled");
|
locationSharing = (SwitchPreference) findPreference("key_sharing_enabled");
|
||||||
locationMode = findPreference("key_location_level");
|
locationMode = findPreference("key_location_level");
|
||||||
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
||||||
manualLocationList = (ListPreference) findPreference("key_manual_location_value");
|
manualLocationList = (ListPreference) findPreference("key_manual_location_value");
|
||||||
@ -183,18 +185,20 @@ public class SharingFragment extends PreferenceFragment {
|
|||||||
EnableSharingDialog sharingDialog = new EnableSharingDialog();
|
EnableSharingDialog sharingDialog = new EnableSharingDialog();
|
||||||
sharingDialog.show(getFragmentManager(), "Sharing");
|
sharingDialog.show(getFragmentManager(), "Sharing");
|
||||||
//refresh view -> get new values from xml
|
//refresh view -> get new values from xml
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation());
|
PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation());
|
||||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), temp.getPredefinedCoordinateId());
|
PrefUtils.putCurrentManualLocation(getApplicationContext(), temp.getPredefinedCoordinateId());
|
||||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String) lp.getEntries()[Integer.parseInt((String) newValue)]);
|
PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String) lp.getEntries()[Integer.parseInt((String) newValue)]);
|
||||||
lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]);
|
lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]);
|
||||||
getPreferenceScreen().removeAll();
|
|
||||||
addPreferencesFromResource(R.layout.pref_sharing);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 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();
|
||||||
@ -228,7 +232,7 @@ public class SharingFragment extends PreferenceFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
Objects.requireNonNull(view).setBackgroundColor(getResources().getColor(android.R.color.white));
|
Objects.requireNonNull(view).setBackgroundColor(getResources().getColor(android.R.color.white));
|
||||||
;
|
|
||||||
return view;
|
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