Fix logging

This commit is contained in:
Mieszko Wrzeszczyński 2018-10-13 14:23:10 +02:00
parent 1de4b0a2ab
commit 5511e5b40e
6 changed files with 36 additions and 29 deletions

View File

@ -33,7 +33,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7: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-vector-drawable:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

View File

@ -1,5 +1,6 @@
package com.uam.wmi.findmytutor.activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
@ -106,4 +107,6 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
}
return mDelegate;
}
}

View File

@ -50,8 +50,7 @@ public class MainActivity extends AppCompatActivity {
private boolean isTutor;
private MapFragment mapFragment;
private NotificationFragment notificationFragment;
private ProfileFragment profileFragment;
private ProfileFragment profileFragment;;
private static final int REQUEST_PERMISSIONS = 100;
boolean boolean_permission;

View File

@ -12,6 +12,7 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.MenuItem;
import com.uam.wmi.findmytutor.R;
@ -19,8 +20,10 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import static android.content.ContentValues.TAG;
public class SharingActivity extends AppCompatPreferenceActivity {
public class SharingActivity extends AppCompatPreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -34,26 +37,29 @@ public class SharingActivity extends AppCompatPreferenceActivity {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_sharing);
Preference manualStatus = findPreference("key_manual_status");
manualStatus.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ListPreference lp = (ListPreference) findPreference("key_status_value");
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;
}
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));
@ -67,15 +73,19 @@ public class SharingActivity extends AppCompatPreferenceActivity {
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

@ -7,16 +7,13 @@ import android.os.Bundle;
import com.uam.wmi.findmytutor.utils.PrefUtils;
public class StartupActivity extends AppCompatActivity {
private static final int AUTHENTICATION_REQUEST_CODE = 666;
@Override
protected void onCreate(Bundle savedInstanceState) {
if (isLoggedIn()){
if (PrefUtils.isLoggedIn(getApplicationContext())){
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);
@ -25,14 +22,11 @@ public class StartupActivity extends AppCompatActivity {
Intent loginIntent = new Intent(this, LoginActivity.class);
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
}
super.onCreate(savedInstanceState);
}
private boolean isLoggedIn() {
return PrefUtils.isLoggedIn(getApplicationContext());
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {

View File

@ -1,5 +1,7 @@
<?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">
<SwitchPreference
android:defaultValue="false"