2017-03-11 21:25:37 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
using Android.App;
|
|
|
|
|
using Android.Content;
|
|
|
|
|
using Android.OS;
|
|
|
|
|
using Android.Runtime;
|
|
|
|
|
using Android.Views;
|
|
|
|
|
using Android.Widget;
|
|
|
|
|
using Android.Preferences;
|
2017-09-07 21:07:18 +00:00
|
|
|
|
using Orarend;
|
2017-03-11 21:25:37 +00:00
|
|
|
|
|
|
|
|
|
namespace OrarendAndroidApp
|
|
|
|
|
{
|
|
|
|
|
[Activity(Label = "Be<42>ll<6C>t<EFBFBD>sok", Theme = "@android:style/Theme.Holo.Light")]
|
2017-09-07 21:07:18 +00:00
|
|
|
|
public class SettingsActivity : PreferenceActivity, ISharedPreferencesOnSharedPreferenceChangeListener, Preference.IOnPreferenceClickListener
|
2017-03-11 21:25:37 +00:00
|
|
|
|
{
|
|
|
|
|
protected override void OnCreate(Bundle savedInstanceState)
|
|
|
|
|
{
|
|
|
|
|
ActivityBase.SetTheme(this);
|
|
|
|
|
/*var settings = PreferenceManager.GetDefaultSharedPreferences(this);
|
|
|
|
|
bool darktheme = settings.GetBoolean("pref_theme", false);
|
|
|
|
|
//SetTheme(darktheme ? Android.Resource.Style.ThemeDeviceDefault : Android.Resource.Style.ThemeDeviceDefaultLight);
|
|
|
|
|
SetTheme(darktheme ? Android.Resource.Style.ThemeHolo : Android.Resource.Style.ThemeHoloLight);*/
|
|
|
|
|
base.OnCreate(savedInstanceState);
|
|
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete
|
|
|
|
|
AddPreferencesFromResource(Resource.Xml.preferences);
|
2017-09-07 21:07:18 +00:00
|
|
|
|
FindPreference("pref_commonnames").OnPreferenceClickListener = this;
|
2017-03-11 21:25:37 +00:00
|
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
|
PreferenceManager.SetDefaultValues(this, Resource.Xml.preferences, false);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-07 21:07:18 +00:00
|
|
|
|
private Intent intent;
|
2017-03-11 21:25:37 +00:00
|
|
|
|
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
|
|
|
|
|
{
|
2017-09-07 21:07:18 +00:00
|
|
|
|
switch (key)
|
|
|
|
|
{
|
|
|
|
|
case "pref_theme":
|
|
|
|
|
Recreate();
|
|
|
|
|
break;
|
|
|
|
|
case "pref_commonnames":
|
|
|
|
|
API.Be<EFBFBD>ll<EFBFBD>t<EFBFBD>sok.UseCommonNames();
|
|
|
|
|
Toast.MakeText(this, "<22>ranevek friss<73>tve", ToastLength.Short).Show();
|
|
|
|
|
break;
|
|
|
|
|
case "pref_offset":
|
|
|
|
|
API.Be<EFBFBD>ll<EFBFBD>t<EFBFBD>sok.<EFBFBD>raOffset = sbyte.Parse(sharedPreferences.GetString(key, "0"));
|
|
|
|
|
intent = new Intent(Intent);
|
|
|
|
|
intent.PutExtra("offsetchanged", true);
|
|
|
|
|
SetResult(Result.Ok, intent);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-03-11 21:25:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResume()
|
|
|
|
|
{
|
|
|
|
|
base.OnResume();
|
|
|
|
|
PreferenceManager.GetDefaultSharedPreferences(this).RegisterOnSharedPreferenceChangeListener(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPause()
|
|
|
|
|
{
|
|
|
|
|
base.OnPause();
|
|
|
|
|
PreferenceManager.GetDefaultSharedPreferences(this).UnregisterOnSharedPreferenceChangeListener(this);
|
|
|
|
|
}
|
2017-09-07 21:07:18 +00:00
|
|
|
|
|
|
|
|
|
public override void OnBackPressed()
|
|
|
|
|
{
|
|
|
|
|
SetResult(Result.Ok, intent);
|
|
|
|
|
//base.OnBackPressed();
|
|
|
|
|
Finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnPreferenceClick(Preference preference)
|
|
|
|
|
{
|
|
|
|
|
if (preference.Key == "pref_commonnames")
|
|
|
|
|
{
|
|
|
|
|
API.Be<EFBFBD>ll<EFBFBD>t<EFBFBD>sok.UseCommonNames();
|
|
|
|
|
Toast.MakeText(this, "<22>ranevek friss<73>tve", ToastLength.Short).Show();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-03-11 21:25:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|