Merge branch 'sharing-tab-rest' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
19ba07beba
@ -33,7 +33,6 @@ dependencies {
|
|||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||||
implementation 'com.android.support:design:27.1.1'
|
implementation 'com.android.support:design:27.1.1'
|
||||||
|
|
||||||
implementation 'com.android.support:support-v4:27.1.1'
|
implementation 'com.android.support:support-v4:27.1.1'
|
||||||
implementation 'com.android.support:support-vector-drawable:27.1.1'
|
implementation 'com.android.support:support-vector-drawable:27.1.1'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
@ -106,4 +107,6 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
return mDelegate;
|
return mDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private boolean isTutor;
|
private boolean isTutor;
|
||||||
private MapFragment mapFragment;
|
private MapFragment mapFragment;
|
||||||
private NotificationFragment notificationFragment;
|
private NotificationFragment notificationFragment;
|
||||||
private ProfileFragment profileFragment;
|
private ProfileFragment profileFragment;;
|
||||||
|
|
||||||
|
|
||||||
private static final int REQUEST_PERMISSIONS = 100;
|
private static final int REQUEST_PERMISSIONS = 100;
|
||||||
boolean boolean_permission;
|
boolean boolean_permission;
|
||||||
|
@ -12,6 +12,7 @@ import android.preference.ListPreference;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
|
|
||||||
@ -19,8 +20,10 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
public class SharingActivity extends AppCompatPreferenceActivity {
|
|
||||||
|
public class SharingActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -34,26 +37,29 @@ public class SharingActivity extends AppCompatPreferenceActivity {
|
|||||||
public void onCreate(final Bundle savedInstanceState) {
|
public void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.pref_sharing);
|
addPreferencesFromResource(R.xml.pref_sharing);
|
||||||
|
|
||||||
Preference manualStatus = findPreference("key_manual_status");
|
Preference manualStatus = findPreference("key_manual_status");
|
||||||
manualStatus.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
@Override
|
ListPreference lp = (ListPreference) findPreference("key_status_value");
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
updateListPreference(lp, newValue, "manual_statuses");
|
||||||
ListPreference lp = (ListPreference) findPreference("key_status_value");
|
return true;
|
||||||
updateListPreference(lp ,newValue,"manual_statuses");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Preference manualLoction = findPreference("key_manual_location_custom");
|
|
||||||
manualLoction.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
ListPreference lp = (ListPreference) findPreference("manual_location_list_title");
|
|
||||||
updateListPreference(lp ,newValue,"manual_locations");
|
|
||||||
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){
|
protected void updateListPreference(ListPreference lp,Object newValue,String storageKey){
|
||||||
CharSequence [] entries = lp.getEntries();
|
CharSequence [] entries = lp.getEntries();
|
||||||
Set <String> defaultEntries = new HashSet(Arrays.asList(entries));
|
Set <String> defaultEntries = new HashSet(Arrays.asList(entries));
|
||||||
@ -67,15 +73,19 @@ public class SharingActivity extends AppCompatPreferenceActivity {
|
|||||||
editor.putStringSet(storageKey,manualStatusSet);
|
editor.putStringSet(storageKey,manualStatusSet);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ListPreference setListPreferenceData(String lp_name, String [] entries) {
|
protected ListPreference setListPreferenceData(String lp_name, String [] entries) {
|
||||||
ListPreference lp = (ListPreference) findPreference(lp_name);
|
ListPreference lp = (ListPreference) findPreference(lp_name);
|
||||||
lp.setEntries(entries);
|
lp.setEntries(entries);
|
||||||
CharSequence[] entryValues = new CharSequence [entries.length];
|
CharSequence[] entryValues = new CharSequence [entries.length];
|
||||||
|
|
||||||
for (int i = 0; i < entries.length; i++){
|
for (int i = 0; i < entries.length; i++){
|
||||||
entryValues[i] = Integer.toString(i+1);
|
entryValues[i] = Integer.toString(i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lp.setDefaultValue("1");
|
lp.setDefaultValue("1");
|
||||||
lp.setEntryValues(entryValues);
|
lp.setEntryValues(entryValues);
|
||||||
|
|
||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,13 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
|
|
||||||
public class StartupActivity extends AppCompatActivity {
|
public class StartupActivity extends AppCompatActivity {
|
||||||
private static final int AUTHENTICATION_REQUEST_CODE = 666;
|
private static final int AUTHENTICATION_REQUEST_CODE = 666;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (PrefUtils.isLoggedIn(getApplicationContext())){
|
||||||
if (isLoggedIn()){
|
|
||||||
|
|
||||||
Intent startupIntent = new Intent(this, MainActivity.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);
|
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(startupIntent);
|
startActivity(startupIntent);
|
||||||
@ -25,14 +22,11 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
Intent loginIntent = new Intent(this, LoginActivity.class);
|
Intent loginIntent = new Intent(this, LoginActivity.class);
|
||||||
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLoggedIn() {
|
|
||||||
return PrefUtils.isLoggedIn(getApplicationContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
tools:ignore="MissingDefaultResource">
|
||||||
<PreferenceCategory android:title="@string/settings_category_location">
|
<PreferenceCategory android:title="@string/settings_category_location">
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
Loading…
Reference in New Issue
Block a user