added activity for setting preferences, also added polish translations for strings used in preferences
This commit is contained in:
parent
02db1722a2
commit
d294f97a49
@ -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'
|
||||
|
@ -11,7 +11,6 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@ -19,30 +18,30 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity android:name=".activity.StartupActivity"
|
||||
<activity
|
||||
android:name=".activity.StartupActivity"
|
||||
android:label="@string/title_activity_startup"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:launchMode="singleTop">
|
||||
</activity>
|
||||
|
||||
android:launchMode="singleTop"></activity>
|
||||
<activity
|
||||
android:name=".activity.LoginActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:launchMode="singleTask"
|
||||
android:label="@string/title_activity_login"
|
||||
android:noHistory="true">
|
||||
</activity>
|
||||
android:launchMode="singleTask"
|
||||
android:noHistory="true"></activity>
|
||||
<activity
|
||||
android:name=".activity.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -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;
|
||||
}
|
||||
}
|
@ -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)));
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -7,4 +7,39 @@
|
||||
<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="settings_category_location">Udostępnianie lokalizacji</string>
|
||||
<string name="title_location_level">Poziom udostępniania</string>
|
||||
<string name="location_level_presence">Obecność</string>
|
||||
<string name="location_level_approximated">Przybliżona</string>
|
||||
<string name="location_level_precise">Dokładna</string>
|
||||
<string name="settings_location_level">Sczegółowość udostępniania</string>
|
||||
<string name="key_location_level">key_location_level</string>
|
||||
|
||||
<string name="title_description">Status</string>
|
||||
<string name="description_notdisturb">Nie przeszkadzać</string>
|
||||
<string name="description_awaiting">Czekam na studentów</string>
|
||||
<string name="description_onholidays">Na wakacjach</string>
|
||||
<string name="settings_description">Opis</string>
|
||||
<string name="key_description">key_description</string>
|
||||
|
||||
<string name="settings_category_general">Ogólne</string>
|
||||
<string name="key_notifications_enabled">key_notifications_enabled</string>
|
||||
<string name="title_notification">Włącz powiadomienia</string>
|
||||
<string name="title_language">Język</string>
|
||||
<string name="lang_eng">Angielski</string>
|
||||
<string name="lang_pol">Polski</string>
|
||||
<string name="settings_language">Wybierz język</string>
|
||||
|
||||
<string name="pref_header_about">O aplikacji</string>
|
||||
<string name="summary_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 !</string>
|
||||
<string name="app_version">0.1.0</string>
|
||||
<string name="summary_support">Masz jakieś pytania? Uwagi? Chętnie odpiszemy!</string>
|
||||
<string name="title_send_feedback">Skontaktuj się z nami</string>
|
||||
<string name="privacy_policy">Polityka Prywatności</string>
|
||||
<string name="url_privacy">http://findmytutor.projektstudencki.pl/privacy-policy/</string>
|
||||
<string name="title_terms">Warunki korzystania</string>
|
||||
<string name="url_terms">http://findmytutor.projektstudencki.pl/terms-of-service/</string>
|
||||
<string name="title_version">Wersja</string>
|
||||
<string name="choose_email_client">Wybierz klienta poczty</string>
|
||||
</resources>
|
@ -40,4 +40,32 @@
|
||||
<item name="grey_500" type="color">#9e9e9e</item>
|
||||
<item name="blue_grey_500" type="color">#607d8b</item>
|
||||
</array>
|
||||
<string-array name="location_level_entries">
|
||||
<item>@string/location_level_presence</item>
|
||||
<item>@string/location_level_approximated</item>
|
||||
<item>@string/location_level_precise</item>
|
||||
</string-array>
|
||||
<string-array name="location_levels_values">
|
||||
<item>0</item>
|
||||
<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>
|
||||
<string-array name="description_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
<string-array name="language_entries">
|
||||
<item>@string/lang_eng</item>
|
||||
<item>@string/lang_pol</item>
|
||||
</string-array>
|
||||
<string-array name="language_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -37,4 +37,45 @@
|
||||
<string name="access_token" translatable="false">pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew</string>
|
||||
<string name="action_black_list">Black List</string>
|
||||
<string name="action_white_list">White List</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
||||
<!-- Strings related to settings -->
|
||||
<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="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="settings_description">Descrition</string>
|
||||
<string name="key_description">key_description</string>
|
||||
|
||||
<string name="settings_category_general">General</string>
|
||||
<string name="key_notifications_enabled">key_notifications_enabled</string>
|
||||
<string name="title_notification">Enable notifications</string>
|
||||
|
||||
<string name="title_language">Language</string>
|
||||
<string name="lang_eng">English</string>
|
||||
<string name="lang_pol">Polish</string>
|
||||
<string name="settings_language">Choose language</string>
|
||||
<string name="key_language">key_language</string>
|
||||
|
||||
|
||||
<string name="pref_header_about">About</string>
|
||||
<string name="summary_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 !</string>
|
||||
<string name="app_version">0.1.0</string>
|
||||
<string name="summary_support">Got any queries? We are happy to help!</string>
|
||||
<string name="title_send_feedback">Send Feedback</string>
|
||||
<string name="key_send_feedback">key_send_feedback</string>
|
||||
<string name="privacy_policy">Privacy Policy</string>
|
||||
<string name="url_privacy">http://findmytutor.projektstudencki.pl/privacy-policy/</string>
|
||||
<string name="title_terms">Terms & Conditions</string>
|
||||
<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>
|
||||
</resources>
|
||||
|
69
app/src/main/res/xml/pref_main.xml
Normal file
69
app/src/main/res/xml/pref_main.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<?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">
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:dialogTitle="@string/settings_language"
|
||||
android:entries="@array/language_entries"
|
||||
android:entryValues="@array/language_values"
|
||||
android:key="@string/key_language"
|
||||
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>
|
Loading…
Reference in New Issue
Block a user