work in progress, splited activity into two, sharing tab and settings
This commit is contained in:
parent
4bbd4f65db
commit
c78757da65
@ -32,16 +32,19 @@
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:launchMode="singleTop"></activity>
|
||||
android:launchMode="singleTop" />
|
||||
<activity
|
||||
android:name=".activity.LoginActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:label="@string/title_activity_login"
|
||||
android:launchMode="singleTask"
|
||||
android:noHistory="true"></activity>
|
||||
android:noHistory="true" />
|
||||
<activity
|
||||
android:name=".activity.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
<activity
|
||||
android:name=".activity.SharingActivity"
|
||||
android:label="@string/title_activity_sharing" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -1,5 +1,6 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@ -43,6 +44,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,134 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.MenuItem;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
|
||||
|
||||
public class SharingActivity extends AppCompatPreferenceActivity {
|
||||
//rivate static final String TAG = SettingsActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// load settings fragment
|
||||
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
|
||||
}
|
||||
|
||||
public static class MainPreferenceFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_sharing);
|
||||
//setListPreferenceData("key_description",getActivity());
|
||||
// feedback preference click listener
|
||||
/* Preference myPref = findPreference(getString(R.string.key_send_feedback));
|
||||
myPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
sendFeedback(getActivity());
|
||||
return true;
|
||||
}
|
||||
});*/
|
||||
}
|
||||
protected ListPreference setListPreferenceData(String lp_name, Activity mActivity) {
|
||||
ListPreference lp = (ListPreference) findPreference(lp_name);
|
||||
|
||||
CharSequence[] entries = { "One", "Two", "Three" };
|
||||
CharSequence[] entryValues = { "1", "2", "3" };
|
||||
if(lp == null)
|
||||
lp = new ListPreference(mActivity);
|
||||
lp.setEntries(entries);
|
||||
lp.setDefaultValue("1");
|
||||
lp.setEntryValues(entryValues);
|
||||
lp.setTitle("Number Of blahs");
|
||||
lp.setSummary(lp.getEntry());
|
||||
lp.setDialogTitle("Number of Blah objects");
|
||||
lp.setKey(lp_name);
|
||||
return lp;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private static void bindPreferenceSummaryToValue(Preference preference) {
|
||||
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
|
||||
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* A preference value change listener that updates the preference's summary
|
||||
* to reflect its new value.
|
||||
*/
|
||||
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String stringValue = newValue.toString();
|
||||
|
||||
if (preference instanceof ListPreference) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
int index = listPreference.findIndexOfValue(stringValue);
|
||||
|
||||
// Set the summary to reflect the new value.
|
||||
preference.setSummary(
|
||||
index >= 0
|
||||
? listPreference.getEntries()[index]
|
||||
: null);
|
||||
|
||||
} else if (preference instanceof EditTextPreference) {
|
||||
if (preference.getKey().equals("key_gallery_name")) {
|
||||
// update the changed gallery name to summary filed
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
} else {
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Email client intent to send support mail
|
||||
* Appends the necessary device information to email body
|
||||
* useful when providing support
|
||||
*/
|
||||
public static void sendFeedback(Context context) {
|
||||
String body = null;
|
||||
try {
|
||||
body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
||||
body = "\n\n-----------------------------\nPlease don't remove this information\n Device OS: Android \n Device OS version: " +
|
||||
Build.VERSION.RELEASE + "\n App Version: " + body + "\n Device Brand: " + Build.BRAND +
|
||||
"\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("message/rfc822");
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"team@findmytutor.com"});
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "Query from android app");
|
||||
intent.putExtra(Intent.EXTRA_TEXT, body);
|
||||
context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_email_client)));
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public class StartupActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//uncomment for testin settings activity and comment the rest of onCreate body
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
startActivity(new Intent(this, SharingActivity.class));
|
||||
|
||||
/* if (isLoggedIn()){
|
||||
Intent startupIntent = new Intent(this, MainActivity.class);
|
||||
|
@ -67,7 +67,7 @@
|
||||
|
||||
<Switch
|
||||
android:id="@+id/tutor_login_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="192dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Login as Tutor" />
|
||||
|
||||
|
@ -7,7 +7,11 @@
|
||||
<string name="error_invalid_password">Hasło jest zbyt krótkie</string>
|
||||
<string name="error_invalid_email">Nieprawidłowy mail</string>
|
||||
<string name="error_field_required">To pole jest wymagane</string>
|
||||
|
||||
|
||||
|
||||
<!--Ustawienia-->
|
||||
<string name="title_sharing">Udostępnianie</string>
|
||||
<string name="settings_category_location">Udostępnianie lokalizacji</string>
|
||||
<string name="title_location_level">Poziom udostępniania</string>
|
||||
<string name="location_level_presence">Obecność</string>
|
||||
|
@ -50,12 +50,12 @@
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
<string-array name="description_entries">
|
||||
<item>@string/description_awaiting</item>
|
||||
<item>@string/description_notdisturb</item>
|
||||
<item>@string/description_onholidays</item>
|
||||
<string-array name="status_entries">
|
||||
<item>@string/description_available</item>
|
||||
<item>@string/description_busy</item>
|
||||
<item>@string/description_consultation</item>
|
||||
</string-array>
|
||||
<string-array name="description_values">
|
||||
<string-array name="status_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
|
@ -39,22 +39,41 @@
|
||||
<string name="action_white_list">White List</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
||||
|
||||
|
||||
<!-- Strings related to SharingActivity -->
|
||||
|
||||
<string name="title_activity_sharing">Sharing</string>
|
||||
|
||||
|
||||
<!-- Strings related to settings -->
|
||||
|
||||
<string name="title_sharing">Sharing</string>
|
||||
|
||||
<string name="settings_category_location">Location sharing</string>
|
||||
<string name="title_location_level">Sharing level</string>
|
||||
<string name="location_level_presence">Only presence</string>
|
||||
<string name="location_level_approximated">Approximated</string>
|
||||
<string name="location_level_precise">Precise</string>
|
||||
<string name="location_level_precise">Exact</string>
|
||||
<string name="settings_location_level">Location level</string>
|
||||
<string name="key_location_level">key_location_level</string>
|
||||
|
||||
<string name="title_description">Status</string>
|
||||
<string name="description_notdisturb">Do not disturb</string>
|
||||
<string name="description_awaiting">Awaiting for students</string>
|
||||
<string name="description_onholidays">On Holidays</string>
|
||||
<string name="status_list_title">Choose status</string>
|
||||
<string name="status_switch_title">Status</string>
|
||||
<string name="description_busy">Busy</string>
|
||||
<string name="description_available">Available</string>
|
||||
<string name="description_consultation">Consultation</string>
|
||||
<string name="title_manual_status">Add custom status</string>
|
||||
|
||||
|
||||
|
||||
<string name="settings_description">Descrition</string>
|
||||
<string name="key_description">key_description</string>
|
||||
|
||||
|
||||
<string name="manual_location">Manual location</string>
|
||||
<string name="title_manual_location">Add custom location</string>
|
||||
|
||||
<string name="settings_category_general">General</string>
|
||||
<string name="key_notifications_enabled">key_notifications_enabled</string>
|
||||
<string name="title_notification">Enable notifications</string>
|
||||
@ -78,4 +97,77 @@
|
||||
<string name="url_terms">http://findmytutor.projektstudencki.pl/terms-of-service/</string>
|
||||
<string name="title_version">Version</string>
|
||||
<string name="choose_email_client">Choose email client</string>
|
||||
<string name="title_activity_settings2">Settings</string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
<!-- Example General settings -->
|
||||
<string name="pref_header_general">General</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-array name="pref_example_list_titles">
|
||||
<item>Always</item>
|
||||
<item>When possible</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_example_list_values">
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Example settings for Data & Sync -->
|
||||
<string name="pref_header_data_sync">Data & sync</string>
|
||||
|
||||
<string name="pref_title_sync_frequency">Sync frequency</string>
|
||||
<string-array name="pref_sync_frequency_titles">
|
||||
<item>15 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
<item>1 hour</item>
|
||||
<item>3 hours</item>
|
||||
<item>6 hours</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_sync_frequency_values">
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>180</item>
|
||||
<item>360</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="list_preference_entries">
|
||||
<item>Entry 1</item>
|
||||
<item>Entry 2</item>
|
||||
<item>Entry 3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="list_preference_entry_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="multi_select_list_preference_default_value" />
|
||||
|
||||
<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>
|
||||
|
@ -1,26 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/settings_category_location">
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:dialogTitle="@string/settings_location_level"
|
||||
android:entries="@array/location_level_entries"
|
||||
android:entryValues="@array/location_levels_values"
|
||||
android:key="@string/key_location_level"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_location_level" />
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:dialogTitle="@string/settings_description"
|
||||
android:entries="@array/description_entries"
|
||||
android:entryValues="@array/description_values"
|
||||
android:key="@string/key_description"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_description" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_general">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_notifications_enabled"
|
||||
android:title="@string/title_notification" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:dialogTitle="@string/settings_language"
|
||||
@ -30,40 +16,7 @@
|
||||
android:summary="%s"
|
||||
android:title="@string/title_language" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_notifications_enabled"
|
||||
android:title="@string/title_notification" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/pref_header_about">
|
||||
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:summary="@string/summary_about" />
|
||||
<Preference
|
||||
android:summary="@string/app_version"
|
||||
android:title="@string/title_version" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_send_feedback"
|
||||
android:summary="@string/summary_support"
|
||||
android:title="@string/title_send_feedback" />
|
||||
|
||||
<!-- preference opens url in browser -->
|
||||
|
||||
<Preference android:title="@string/privacy_policy">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="@string/url_privacy" />
|
||||
</Preference>
|
||||
|
||||
<Preference android:title="@string/title_terms">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="@string/url_terms" />
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
57
app/src/main/res/xml/pref_sharing.xml
Normal file
57
app/src/main/res/xml/pref_sharing.xml
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/settings_category_location">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
android:key="key_sharing_enabled"
|
||||
android:persistent="true"
|
||||
android:title="@string/title_sharing"/>
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:dialogTitle="@string/settings_location_level"
|
||||
android:entries="@array/location_level_entries"
|
||||
android:entryValues="@array/location_levels_values"
|
||||
android:key="@string/key_location_level"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_location_level" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
android:key="key_status_enabled"
|
||||
android:persistent="true"
|
||||
android:title="@string/status_switch_title"/>
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:key="key_status_value"
|
||||
android:entries="@array/status_entries"
|
||||
android:entryValues="@array/status_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/status_list_title" />
|
||||
<EditTextPreference
|
||||
android:key="key_manual_status"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_status"
|
||||
/>
|
||||
<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: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>
|
Loading…
Reference in New Issue
Block a user