we going back

This commit is contained in:
Domagalski 2018-10-20 11:54:41 +02:00
parent bd775d5d0d
commit 2b4b83a0d2
8 changed files with 103 additions and 7 deletions

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1

6
app/.classpath Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

View File

@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1

View File

@ -43,9 +43,9 @@
<activity
android:name=".activity.SharingActivity"
android:label="@string/title_activity_sharing" />
<activity
android:name=".activity.MainActivity"
android:label="@string/title_activity_sharing" />
<service
android:name=".service.BackgroundLocalizationService"

View File

@ -45,6 +45,7 @@ public class MainActivity extends AppCompatActivity {
private FrameLayout mMainFrame;
private boolean isTutor;
private MapFragment mapFragment;
private SharingFragment sharingFragment;
private NotificationFragment notificationFragment;
private ProfileFragment profileFragment;;
@ -117,6 +118,7 @@ public class MainActivity extends AppCompatActivity {
}
mapFragment = new MapFragment();
sharingFragment = new SharingFragment();
notificationFragment = new NotificationFragment();
profileFragment = new ProfileFragment();
@ -129,7 +131,8 @@ public class MainActivity extends AppCompatActivity {
switch (item.getItemId()) {
case R.id.nav_map:
setFragment(mapFragment);
// setFragment(mapFragment);
setFragment(sharingFragment);
return true;
case R.id.nav_notif:
setFragment(notificationFragment);

View File

@ -0,0 +1,76 @@
package com.uam.wmi.findmytutor.activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.util.Log;
import com.uam.wmi.findmytutor.R;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
//public class SharingFragment {
//}
public class SharingFragment extends PreferenceFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_sharing);
Preference manualStatus = findPreference("key_manual_status");
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) findPreference("key_status_value");
updateListPreference(lp, newValue, "manual_statuses");
return true;
});
/* Preference manualLocation = findPreference("key_sharing_enabled");
manualLocation.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) findPreference("key_sharing_enabled");
updateListPreference(lp, newValue, "sharing_enabled");
return true;
});*/
Preference sharingLocation = findPreference("key_sharing_enabled");
sharingLocation.setOnPreferenceChangeListener((preference, o) -> {
Log.e("change", "1");
return false;
});
}
protected void updateListPreference(ListPreference lp,Object newValue,String storageKey){
CharSequence [] entries = lp.getEntries();
Set<String> defaultEntries = new HashSet(Arrays.asList(entries));
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
Set <String> manualStatusSet = sharedPref.getStringSet(storageKey,defaultEntries);
manualStatusSet.add((String) newValue);
String [] manualStatusArr = manualStatusSet.toArray(new String[0]);
Arrays.sort(manualStatusArr);
setListPreferenceData(lp.getKey(),manualStatusArr);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putStringSet(storageKey,manualStatusSet);
editor.commit();
}
protected ListPreference setListPreferenceData(String lp_name, String [] entries) {
ListPreference lp = (ListPreference) findPreference(lp_name);
lp.setEntries(entries);
CharSequence[] entryValues = new CharSequence [entries.length];
for (int i = 0; i < entries.length; i++){
entryValues[i] = Integer.toString(i+1);
}
lp.setDefaultValue("1");
lp.setEntryValues(entryValues);
return lp;
}
}

View File

@ -2,8 +2,9 @@ package com.uam.wmi.findmytutor.activity;
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.uam.wmi.findmytutor.utils.PrefUtils;
@ -14,7 +15,7 @@ public class StartupActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
if (PrefUtils.isLoggedIn(getApplicationContext())){
Intent startupIntent = new Intent(this, MapActivity.class);
Intent startupIntent = new Intent(this, MainActivity.class);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(startupIntent);
finish();
@ -30,7 +31,7 @@ public class StartupActivity extends AppCompatActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Intent startupIntent = new Intent(this, MapActivity.class);
Intent startupIntent = new Intent(this, MainActivity.class);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(startupIntent);
}