sharing tab redesigned
This commit is contained in:
parent
e0973ca732
commit
1acac4edc4
@ -31,6 +31,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:preference-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:support-v4:27.1.1'
|
||||
|
@ -10,7 +10,6 @@
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
@ -45,18 +44,16 @@
|
||||
android:label="@string/title_activity_login"
|
||||
android:launchMode="singleTask"
|
||||
android:noHistory="true" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
|
||||
<service
|
||||
android:name=".service.BackgroundLocalizationService"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop"
|
||||
android:enabled="true"
|
||||
/>
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
@ -2,6 +2,7 @@ package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -9,6 +10,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@ -43,14 +45,31 @@ public class SharingFragment extends PreferenceFragment {
|
||||
locationLevelMapping.put(0,"presence");
|
||||
locationLevelMapping.put(1,"approximated");
|
||||
locationLevelMapping.put(2,"exact");
|
||||
locationLevelMapping.put(3,"manual");
|
||||
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
Preference manualStatus = findPreference("key_manual_status");
|
||||
Preference locationSharing = findPreference("key_sharing_enabled");
|
||||
Preference locationMode = findPreference("key_location_level");
|
||||
Preference statusList = findPreference("key_status_value");
|
||||
|
||||
|
||||
Preference manualLocationList = findPreference("key_manual_location_value");
|
||||
Preference manualLocationButton = findPreference("manual_location_button");
|
||||
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
||||
String temp = PrefUtils.getLocationLevel(getApplicationContext());
|
||||
if(!temp.equals("manual")){
|
||||
preferenceCategory.removePreference(manualLocationList);
|
||||
preferenceCategory.removePreference(manualLocationButton);
|
||||
}
|
||||
manualLocationButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Toast.makeText(getApplicationContext(), "dupa", Toast.LENGTH_SHORT).show();
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(SharingFragment.this);
|
||||
fragmentTransaction.commit();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) findPreference("key_status_value");
|
||||
updateListPreference(lp, newValue, "manual_statuses");
|
||||
@ -62,6 +81,14 @@ public class SharingFragment extends PreferenceFragment {
|
||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
PrefUtils.storeLocationMode(getApplicationContext(),locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
||||
if(PrefUtils.getLocationLevel(getApplicationContext()) == "manual"){
|
||||
preferenceCategory.addPreference(manualLocationList);
|
||||
preferenceCategory.addPreference(manualLocationButton);
|
||||
|
||||
}else{
|
||||
preferenceCategory.removePreference(manualLocationList);
|
||||
preferenceCategory.removePreference(manualLocationButton);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -77,6 +104,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
((MapActivity)getActivity()).handleBackgroundTaskLifeCycle();
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static SharingFragment newInstance() {
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
|
||||
public class rightButtonPreference extends Preference {
|
||||
public rightButtonPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
// setLayoutResource(R.layout.preference_button_widget);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View onCreateView(ViewGroup parent) {
|
||||
View view = super.onCreateView(parent);
|
||||
LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||
return li.inflate( R.layout.preference_button_widget, parent, false);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
holder.itemView.setClickable(false); // disable parent click
|
||||
View button = holder.findViewById(R.id.theme_dark);
|
||||
button.setClickable(true); // enable custom view click
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
@ -6,7 +6,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_location">
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_category_location"
|
||||
android:key="category_sharing">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
@ -17,10 +19,20 @@
|
||||
android:defaultValue="1"
|
||||
android:dialogTitle="@string/settings_location_level"
|
||||
android:entries="@array/location_level_entries"
|
||||
android:entryValues="@array/location_levels_values"
|
||||
android:entryValues="@array/location_level_values"
|
||||
android:key="@string/key_location_level"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_location_level" />
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:key="key_manual_location_value"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_list_manual_location" />
|
||||
<com.uam.wmi.findmytutor.utils.rightButtonPreference
|
||||
android:key="manual_location_button"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_status">
|
||||
@ -45,26 +57,6 @@
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_manuallocation">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
android:key="key_manual_location_enabled"
|
||||
android:persistent="true"
|
||||
android:title="@string/manual_location"/>
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:key="key_manual_location_value"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_list_manual_location" />
|
||||
<EditTextPreference
|
||||
android:key="key_manual_location_custom"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_location"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
13
app/src/main/res/layout/preference_button_widget.xml
Normal file
13
app/src/main/res/layout/preference_button_widget.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
>
|
||||
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/button"
|
||||
android:text="@string/preference_manual_location_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
@ -44,11 +44,14 @@
|
||||
<item>@string/location_level_presence</item>
|
||||
<item>@string/location_level_approximated</item>
|
||||
<item>@string/location_level_precise</item>
|
||||
<item>@string/location_level_manual</item>
|
||||
</string-array>
|
||||
<string-array name="location_levels_values">
|
||||
<string-array name="location_level_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
|
||||
</string-array>
|
||||
<string-array name="status_entries">
|
||||
<item>@string/description_available</item>
|
||||
|
@ -47,7 +47,6 @@
|
||||
<string name="fmt_email">findmytutorwmi@gmail.com</string>
|
||||
|
||||
|
||||
|
||||
<!-- Strings related to SharingActivity -->
|
||||
|
||||
<string name="title_activity_sharing">Sharing</string>
|
||||
@ -56,7 +55,6 @@
|
||||
<!-- Strings related to settings -->
|
||||
|
||||
<string name="title_sharing">Sharing</string>
|
||||
|
||||
<string name="settings_category_location">Location sharing</string>
|
||||
<string name="settings_category_status">Status settings</string>
|
||||
<string name="settings_category_manuallocation">Manual location override</string>
|
||||
@ -64,6 +62,8 @@
|
||||
<string name="location_level_presence">Only presence</string>
|
||||
<string name="location_level_approximated">Approximated</string>
|
||||
<string name="location_level_precise">Exact</string>
|
||||
<string name="location_level_manual">Manual</string>
|
||||
<string name="preference_manual_location_button">Choose from map</string>
|
||||
<string name="settings_location_level">Location level</string>
|
||||
<string name="key_location_level">key_location_level</string>
|
||||
|
||||
@ -75,7 +75,6 @@
|
||||
<string name="title_manual_status">Add custom status</string>
|
||||
|
||||
|
||||
|
||||
<string name="settings_description">Descrition</string>
|
||||
<string name="key_description">key_description</string>
|
||||
|
||||
@ -207,4 +206,28 @@
|
||||
<string name="remove_location_updates" />
|
||||
<string name="map_activity_label">MapActivity</string>
|
||||
|
||||
<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
||||
<string name="pref_description_social_recommendations">Recommendations for people to contact
|
||||
based on your message history
|
||||
</string>
|
||||
|
||||
<string name="pref_title_display_name">Display name</string>
|
||||
<string name="pref_default_display_name">John Smith</string>
|
||||
|
||||
<string name="pref_title_add_friends_to_messages">Add friends to messages</string>
|
||||
|
||||
<string name="pref_title_sync_frequency">Sync frequency</string>
|
||||
|
||||
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||
|
||||
<!-- Example settings for Notifications -->
|
||||
<string name="pref_header_notifications">Notifications</string>
|
||||
|
||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
||||
|
||||
<string name="pref_title_ringtone">Ringtone</string>
|
||||
<string name="pref_ringtone_silent">Silent</string>
|
||||
|
||||
<string name="pref_title_vibrate">Vibrate</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user