From d294f97a49705380ebb416e426cd584a5cb41aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Fri, 28 Sep 2018 02:42:43 +0200 Subject: [PATCH 1/7] added activity for setting preferences, also added polish translations for strings used in preferences --- app/build.gradle | 5 +- app/src/main/AndroidManifest.xml | 19 ++- .../activity/AppCompatPreferenceActivity.java | 109 ++++++++++++++++ .../activity/SettingsActivity.java | 119 ++++++++++++++++++ .../findmytutor/activity/StartupActivity.java | 5 +- app/src/main/res/values-pl/strings.xml | 35 ++++++ app/src/main/res/values/array.xml | 28 +++++ app/src/main/res/values/strings.xml | 41 ++++++ app/src/main/res/xml/pref_main.xml | 69 ++++++++++ 9 files changed, 417 insertions(+), 13 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/AppCompatPreferenceActivity.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java create mode 100644 app/src/main/res/xml/pref_main.xml diff --git a/app/build.gradle b/app/build.gradle index 6f6f95d..1403eca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,6 +13,7 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true } buildTypes { release { @@ -22,7 +23,7 @@ android { } } -repositories{ +repositories { maven { url 'http://dl.bintray.com/amulyakhare/maven' } @@ -33,6 +34,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.2' + implementation 'com.android.support:support-v4:27.1.1' + implementation 'com.android.support:support-vector-drawable:27.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5f227e5..6ec636c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,7 +11,6 @@ - - - + - - - + android:launchMode="singleTop"> - + android:launchMode="singleTask" + android:noHistory="true"> + \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/AppCompatPreferenceActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/AppCompatPreferenceActivity.java new file mode 100644 index 0000000..789cc5e --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/AppCompatPreferenceActivity.java @@ -0,0 +1,109 @@ +package com.uam.wmi.findmytutor.activity; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.support.annotation.LayoutRes; +import android.support.annotation.Nullable; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.widget.Toolbar; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls + * to be used with AppCompat. + */ +public abstract class AppCompatPreferenceActivity extends PreferenceActivity { + + private AppCompatDelegate mDelegate; + + @Override + protected void onCreate(Bundle savedInstanceState) { + getDelegate().installViewFactory(); + getDelegate().onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + getDelegate().onPostCreate(savedInstanceState); + } + + public ActionBar getSupportActionBar() { + return getDelegate().getSupportActionBar(); + } + + public void setSupportActionBar(@Nullable Toolbar toolbar) { + getDelegate().setSupportActionBar(toolbar); + } + + @Override + public MenuInflater getMenuInflater() { + return getDelegate().getMenuInflater(); + } + + @Override + public void setContentView(@LayoutRes int layoutResID) { + getDelegate().setContentView(layoutResID); + } + + @Override + public void setContentView(View view) { + getDelegate().setContentView(view); + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().setContentView(view, params); + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().addContentView(view, params); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getDelegate().onPostResume(); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + super.onTitleChanged(title, color); + getDelegate().setTitle(title); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getDelegate().onConfigurationChanged(newConfig); + } + + @Override + protected void onStop() { + super.onStop(); + getDelegate().onStop(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + getDelegate().onDestroy(); + } + + public void invalidateOptionsMenu() { + getDelegate().invalidateOptionsMenu(); + } + + private AppCompatDelegate getDelegate() { + if (mDelegate == null) { + mDelegate = AppCompatDelegate.create(this, null); + } + return mDelegate; + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java new file mode 100644 index 0000000..c96bd42 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java @@ -0,0 +1,119 @@ +package com.uam.wmi.findmytutor.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 SettingsActivity extends AppCompatPreferenceActivity { + private 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_main); + + //TODO add on change listeners for preferences + + // 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; + } + }); + } + } + + @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))); + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index 257b01f..a1214b3 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -12,17 +12,18 @@ 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)); if (isLoggedIn()){ 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); + startActivity(startupIntent);gi finish(); } else { Intent loginIntent = new Intent(this, LoginActivity.class); startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE); } - super.onCreate(savedInstanceState); //to nie ma miec layoutu wiec elo diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 6a4f18b..392f881 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -7,4 +7,39 @@ Hasło jest zbyt krótkie Nieprawidłowy mail To pole jest wymagane + + Udostępnianie lokalizacji + Poziom udostępniania + Obecność + Przybliżona + Dokładna + Sczegółowość udostępniania + key_location_level + + Status + Nie przeszkadzać + Czekam na studentów + Na wakacjach + Opis + key_description + + Ogólne + key_notifications_enabled + Włącz powiadomienia + Język + Angielski + Polski + Wybierz język + + O aplikacji + We are just like you :)\nA group of people trying to shape our everyday life into something useful. We hope to bring you the best product and quality of service.\nThank you for using our app ! + 0.1.0 + Masz jakieś pytania? Uwagi? Chętnie odpiszemy! + Skontaktuj się z nami + Polityka Prywatności + http://findmytutor.projektstudencki.pl/privacy-policy/ + Warunki korzystania + http://findmytutor.projektstudencki.pl/terms-of-service/ + Wersja + Wybierz klienta poczty \ No newline at end of file diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index aadfc8e..5d3ce73 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -40,4 +40,32 @@ #9e9e9e #607d8b + + @string/location_level_presence + @string/location_level_approximated + @string/location_level_precise + + + 0 + 1 + 2 + + + @string/description_awaiting + @string/description_notdisturb + @string/description_onholidays + + + 0 + 1 + 2 + + + @string/lang_eng + @string/lang_pol + + + 0 + 1 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc72b2f..c000d31 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,4 +37,45 @@ pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew Black List White List + Settings + + + Location sharing + Sharing level + Only presence + Approximated + Precise + Location level + key_location_level + + Status + Do not disturb + Awaiting for students + On Holidays + Descrition + key_description + + General + key_notifications_enabled + Enable notifications + + Language + English + Polish + Choose language + key_language + + + About + We are just like you :)\nA group of people trying to shape our everyday life into something useful. We hope to bring you the best product and quality of service.\nThank you for using our app ! + 0.1.0 + Got any queries? We are happy to help! + Send Feedback + key_send_feedback + Privacy Policy + http://findmytutor.projektstudencki.pl/privacy-policy/ + Terms & Conditions + http://findmytutor.projektstudencki.pl/terms-of-service/ + Version + Choose email client diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml new file mode 100644 index 0000000..e73fc95 --- /dev/null +++ b/app/src/main/res/xml/pref_main.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4bbd4f65db4dbe2bb2133576c9bd2f6fc1718c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Fri, 28 Sep 2018 02:47:39 +0200 Subject: [PATCH 2/7] fixed typo --- .../com/uam/wmi/findmytutor/activity/StartupActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index a1214b3..1839d37 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -13,17 +13,17 @@ 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, SettingsActivity.class)); - if (isLoggedIn()){ +/* if (isLoggedIn()){ 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);gi + startActivity(startupIntent); finish(); } else { Intent loginIntent = new Intent(this, LoginActivity.class); startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE); - } + }*/ super.onCreate(savedInstanceState); //to nie ma miec layoutu wiec elo From c78757da658cda76695b0ef6931118e42e62a2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Wed, 10 Oct 2018 09:35:31 +0200 Subject: [PATCH 3/7] work in progress, splited activity into two, sharing tab and settings --- app/src/main/AndroidManifest.xml | 7 +- .../activity/SettingsActivity.java | 2 + .../findmytutor/activity/SharingActivity.java | 134 ++++++++++++++++++ .../findmytutor/activity/StartupActivity.java | 2 +- app/src/main/res/layout/activity_login.xml | 2 +- app/src/main/res/values-pl/strings.xml | 4 + app/src/main/res/values/array.xml | 10 +- app/src/main/res/values/strings.xml | 102 ++++++++++++- app/src/main/res/xml/pref_main.xml | 55 +------ app/src/main/res/xml/pref_sharing.xml | 57 ++++++++ 10 files changed, 310 insertions(+), 65 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java create mode 100644 app/src/main/res/xml/pref_sharing.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6ec636c..5e716d0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,16 +32,19 @@ + android:launchMode="singleTop" /> + android:noHistory="true" /> + \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java index c96bd42..13b75a1 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java @@ -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 diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java new file mode 100644 index 0000000..625359d --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java @@ -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))); + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index 1839d37..66dc07d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -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); diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index c843678..6383218 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -67,7 +67,7 @@ diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 392f881..5a62888 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -7,7 +7,11 @@ Hasło jest zbyt krótkie Nieprawidłowy mail To pole jest wymagane + + + + Udostępnianie Udostępnianie lokalizacji Poziom udostępniania Obecność diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 5d3ce73..53655a8 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -50,12 +50,12 @@ 1 2 - - @string/description_awaiting - @string/description_notdisturb - @string/description_onholidays + + @string/description_available + @string/description_busy + @string/description_consultation - + 0 1 2 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c000d31..d6e0c35 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -39,22 +39,41 @@ White List Settings + + + + + Sharing + + + + Sharing + Location sharing Sharing level Only presence Approximated - Precise + Exact Location level key_location_level - Status - Do not disturb - Awaiting for students - On Holidays + Choose status + Status + Busy + Available + Consultation + Add custom status + + + Descrition key_description + + Manual location + Add custom location + General key_notifications_enabled Enable notifications @@ -78,4 +97,77 @@ http://findmytutor.projektstudencki.pl/terms-of-service/ Version Choose email client + Settings + + + + + General + + Enable social recommendations + Recommendations for people to contact + based on your message history + + + Display name + John Smith + + Add friends to messages + + Always + When possible + Never + + + 1 + 0 + -1 + + + + Data & sync + + Sync frequency + + 15 minutes + 30 minutes + 1 hour + 3 hours + 6 hours + Never + + + 15 + 30 + 60 + 180 + 360 + -1 + + + + Entry 1 + Entry 2 + Entry 3 + + + + 1 + 2 + 3 + + + + + System sync settings + + + Notifications + + New message notifications + + Ringtone + Silent + + Vibrate diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index e73fc95..0c13e23 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -1,26 +1,12 @@ - - - - + - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/pref_sharing.xml b/app/src/main/res/xml/pref_sharing.xml new file mode 100644 index 0000000..cc0ab6b --- /dev/null +++ b/app/src/main/res/xml/pref_sharing.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + \ No newline at end of file From a98a500f08af35bce325f7f1169abde9d47997e9 Mon Sep 17 00:00:00 2001 From: Marcin Jedynski Date: Thu, 11 Oct 2018 12:53:50 +0200 Subject: [PATCH 4/7] added layout file for sharing tab --- app/src/main/res/xml/pref_sharing.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/xml/pref_sharing.xml b/app/src/main/res/xml/pref_sharing.xml index cc0ab6b..413ba87 100644 --- a/app/src/main/res/xml/pref_sharing.xml +++ b/app/src/main/res/xml/pref_sharing.xml @@ -42,7 +42,7 @@ android:title="@string/manual_location"/> Date: Thu, 11 Oct 2018 12:54:52 +0200 Subject: [PATCH 5/7] updated strings --- app/src/main/res/values/array.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 12 insertions(+) diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 53655a8..e656610 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -60,6 +60,16 @@ 1 2 + + @string/description_available + @string/description_busy + @string/description_consultation + + + 0 + 1 + 2 + @string/lang_eng @string/lang_pol diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d6e0c35..3933cd6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,6 +72,8 @@ Manual location + Choose manual location + Add custom location General From c765ac078267549f043fb5e09a4902ed2ceb9ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Fri, 12 Oct 2018 01:57:24 +0200 Subject: [PATCH 6/7] added overriding status/location list when manual entry added --- .../findmytutor/activity/SharingActivity.java | 108 +++++++----------- app/src/main/res/values/array.xml | 6 +- app/src/main/res/values/strings.xml | 5 +- app/src/main/res/xml/pref_sharing.xml | 2 + 4 files changed, 52 insertions(+), 69 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java index 625359d..1c0743d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java @@ -3,6 +3,7 @@ package com.uam.wmi.findmytutor.activity; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; @@ -14,16 +15,17 @@ import android.preference.PreferenceManager; import android.view.MenuItem; import com.uam.wmi.findmytutor.R; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + 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(); } @@ -32,30 +34,48 @@ public class SharingActivity extends AppCompatPreferenceActivity { 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()); + 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; } - });*/ - } - protected ListPreference setListPreferenceData(String lp_name, Activity mActivity) { - ListPreference lp = (ListPreference) findPreference(lp_name); + }); + 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; + } + }); - CharSequence[] entries = { "One", "Two", "Three" }; - CharSequence[] entryValues = { "1", "2", "3" }; - if(lp == null) - lp = new ListPreference(mActivity); + } + protected void updateListPreference(ListPreference lp,Object newValue,String storageKey){ + CharSequence [] entries = lp.getEntries(); + Set defaultEntries = new HashSet(Arrays.asList(entries)); + SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); + Set 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); - lp.setTitle("Number Of blahs"); - lp.setSummary(lp.getEntry()); - lp.setDialogTitle("Number of Blah objects"); - lp.setKey(lp_name); return lp; } } @@ -68,54 +88,12 @@ public class SharingActivity extends AppCompatPreferenceActivity { 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) { +/* public static void sendFeedback(Context context) { String body = null; try { body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; @@ -130,5 +108,5 @@ public class SharingActivity extends AppCompatPreferenceActivity { 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))); - } + }*/ } diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index e656610..815402b 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -61,9 +61,9 @@ 2 - @string/description_available - @string/description_busy - @string/description_consultation + @string/assembly_c + @string/assembly_a + @string/passage_d 0 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3933cd6..c983375 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -73,8 +73,11 @@ Manual location Choose manual location - Add custom location + Assembly Hall A + Assembly Hall C + Passage D + General key_notifications_enabled diff --git a/app/src/main/res/xml/pref_sharing.xml b/app/src/main/res/xml/pref_sharing.xml index 413ba87..3e056d1 100644 --- a/app/src/main/res/xml/pref_sharing.xml +++ b/app/src/main/res/xml/pref_sharing.xml @@ -43,6 +43,8 @@ Date: Fri, 12 Oct 2018 02:02:57 +0200 Subject: [PATCH 7/7] reversed changes on startup activity --- .../com/uam/wmi/findmytutor/activity/StartupActivity.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index 66dc07d..16d923b 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -12,10 +12,9 @@ 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, SharingActivity.class)); -/* if (isLoggedIn()){ + + if (isLoggedIn()){ 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); @@ -23,7 +22,7 @@ public class StartupActivity extends AppCompatActivity { } else { Intent loginIntent = new Intent(this, LoginActivity.class); startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE); - }*/ + } super.onCreate(savedInstanceState); //to nie ma miec layoutu wiec elo