Beállítások menü és sötét/világos téma hozzáadva!

Több óra próbálkozással
De működik
This commit is contained in:
Norbi Peti 2017-03-11 22:25:37 +01:00
parent 665b3327f7
commit de330e854c
18 changed files with 268 additions and 118 deletions

View file

@ -14,8 +14,8 @@ namespace Orarend
{
[DataContract]
public class API
{ //TODO: Beállítások: Téma (sötét, világos) (Android; platformfüggő beállítások), Előre megadott egyedi nevek használata
internal static API példány = new API();
{ //TODO: Előre megadott egyedi nevek használata
internal static API példány = new API(); //TODO: FrissítésHa1ÓraEltelt() mentés
private API()
{
}
@ -28,7 +28,7 @@ namespace Orarend
public Osztály[] osztályok { get; private set; }
[DataMember(Order = 2)]
public List<Órarend> órarendek { get; private set; } = new List<Órarend>();
[DataMember]
//[DataMember]
public Settings beállítások { get; private set; } = new Settings();
/// <summary>
/// <para>Visszatér az osztályok listájával.</para>

View file

@ -7,13 +7,9 @@ using System.Threading.Tasks;
namespace Orarend
{
[DataContract]
[DataContract] //
public class Settings
{
[DataMember]
public bool DarkTheme { get; set; }
[DataMember]
public TimeSpan Difference { get; set; } //TODO
public void UseCommonNames()
{
set("mateme", "Matek");

View file

@ -0,0 +1,27 @@
using Android.App;
using Android.OS;
using Android.Preferences;
namespace OrarendAndroidApp
{
public class ActivityBase : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetTheme(this);
}
public static void SetTheme(Activity activity)
{
var settings = PreferenceManager.GetDefaultSharedPreferences(activity);
bool darktheme = settings.GetBoolean("pref_theme", false);
if (activity is ActivityBase)
(activity as ActivityBase).DarkTheme = darktheme;
activity.SetTheme(darktheme ? Android.Resource.Style.ThemeDeviceDefault : Android.Resource.Style.ThemeDeviceDefaultLight);
}
public bool DarkTheme;
}
}

View file

@ -11,11 +11,12 @@ using Android.Views;
using Android.Widget;
using Orarend;
using Android.Graphics;
using Android.Preferences;
namespace OrarendAndroidApp
{
[Activity(Label = "AddActivity", Theme = "@android:style/Theme.Holo.Light")]
public class EditActivity : Activity
public class EditActivity : ActivityBase
{
private bool add;
private int index;

View file

@ -13,25 +13,32 @@ using System.Threading.Tasks;
using System.Threading;
using System.IO;
using System.Net;
using Android.Preferences;
namespace OrarendAndroidApp
{
[Activity(Label = "Órarend", MainLauncher = true, Theme = "@android:style/Theme.Holo.Light")]
public class MainActivity : Activity
public class MainActivity : ActivityBase
{
private Handler handler;
private Órarend órarend;
private Timer timer;
private const int EDIT_ADD_ACT_REQUEST = 1;
private const int SETTINGS_ACT_REQUEST = 2;
public const string DATA_FILENAME = "data.json";
protected override void OnCreate(Bundle bundle)
{
AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser;
base.OnCreate(bundle);
//RequestWindowFeature(WindowFeatures.ActionBar);
SetContentView(Resource.Layout.MainLayout);
//SetActionBar(new Toolbar(this));
ActionBar.SetDisplayShowTitleEnabled(false);
ActionBar.CustomView = FindViewById<Spinner>(Resource.Id.spinner);
//ActionBar.CustomView = new Spinner(this);
//ActionBar.CustomView = FindViewById<Spinner>(Resource.Id.spinner);
//ActionBar.SetCustomView(FindViewById<Spinner>(Resource.Id.spinner), new ActionBar.LayoutParams(GravityFlags.Left));
handler = new Handler();
string[] list = FileList();
if (list.Contains(DATA_FILENAME))
@ -39,11 +46,18 @@ namespace OrarendAndroidApp
timer = new Timer(CsengőTimer, null, new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 5));
}
private void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
{
if (!e.Handled)
Hiba("Kezeletlen hiba!\n" + e.Exception);
e.Handled = true;
}
private Spinner list;
private void órarendlistafrissítés()
{
handler.Post(() =>
{
var list = FindViewById<Spinner>(Resource.Id.spinner);
int selected = list.SelectedItemPosition;
int count = list.Count;
ArrayAdapter adapter;
@ -78,7 +92,7 @@ namespace OrarendAndroidApp
textview.SetText(text, TextView.BufferType.Normal);
textview.SetTextColor(color);
textview.SetPadding(10, 10, 10, 10);
textview.SetBackgroundResource(Resource.Drawable.cell_shape_light);
textview.SetBackgroundResource(DarkTheme ? Resource.Drawable.cell_shape_dark : Resource.Drawable.cell_shape_light);
textview.Tag = tag;
textview.Clickable = true;
textview.Click += ÓraClick;
@ -88,11 +102,11 @@ namespace OrarendAndroidApp
private void HelyettesítésFrissítés(bool internethiba = true)
{
var bar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
var menu = FindViewById<ActionMenuView>(Resource.Id.actionMenuView1);
//var menu = FindViewById<ActionMenuView>(Resource.Id.actionMenuView1);
Action loadstart = () =>
{
bar.Visibility = ViewStates.Visible;
menu.Enabled = false;
//menu.Enabled = false;
};
handler.Post(loadstart);
API.HelyettesítésFrissítés(() => OpenFileOutput(DATA_FILENAME, FileCreationMode.Private)).ContinueWith(t =>
@ -101,7 +115,7 @@ namespace OrarendAndroidApp
handler.Post(() =>
{
bar.Visibility = ViewStates.Gone;
menu.Enabled = true;
//menu.Enabled = true;
if (TaskHiba(t, internethiba))
{
órarendfrissítés();
@ -115,11 +129,11 @@ namespace OrarendAndroidApp
private void ÓrarendFrissítés(Órarend ór = null)
{
var bar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
var menu = FindViewById<ActionMenuView>(Resource.Id.actionMenuView1);
//var menu = FindViewById<ActionMenuView>(Resource.Id.actionMenuView1);
Action loadstart = () =>
{
bar.Visibility = ViewStates.Visible;
menu.Enabled = false;
//menu.Enabled = false;
};
handler.Post(loadstart);
API.Frissítés(() => OpenFileOutput(DATA_FILENAME, FileCreationMode.Private), ór).ContinueWith(t =>
@ -151,9 +165,9 @@ namespace OrarendAndroidApp
if (órarend == null)
return;
TableRow tr = new TableRow(this);
addCell(API.AHét ? "A" : "B", Color.Black, tr);
addCell(API.AHét ? "A" : "B", DarkTheme ? Color.White : Color.Black, tr);
for (int i = 0; i < Napok.Length; i++)
addCell(Napok[i], Color.Black, tr);
addCell(Napok[i], DarkTheme ? Color.White : Color.Black, tr);
table.AddView(tr, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
for (int j = 0; j < 16; j++)
{
@ -169,14 +183,13 @@ namespace OrarendAndroidApp
}
if (notnull)
{
addCell((j + 1).ToString(), Color.Black, tr);
addCell((j + 1).ToString(), DarkTheme ? Color.White : Color.Black, tr);
for (int i = 0; i < 6; i++)
{
var innenide = helyettesítésInnenIde(i, j);
var helyettesítés = innenide[0];
var helyettesítésIde = innenide[1];
//addCell(helyettesítés?.ÚjÓra?.EgyediNév ?? órarend.Órák[i][j]?.EgyediNév ?? "", helyettesítés == null ? Color.Black : Color.Red, tr, new int[2] { i, j });
addCell(helyettesítésIde != null ? helyettesítésIde.ÚjÓra.EgyediNév : helyettesítés != null ? helyettesítés.EredetiNap != helyettesítés.ÚjNap || helyettesítés.EredetiSorszám != helyettesítés.ÚjSorszám ? "Áthelyezve" : helyettesítés.ÚjÓra?.EgyediNév ?? "elmarad" : órarend.Órák[i][j]?.EgyediNév ?? "", helyettesítés == null ? Color.Black : Color.Red, tr, new int[2] { i, j });
addCell(helyettesítésIde != null ? helyettesítésIde.ÚjÓra.EgyediNév : helyettesítés != null ? helyettesítés.EredetiNap != helyettesítés.ÚjNap || helyettesítés.EredetiSorszám != helyettesítés.ÚjSorszám ? "Áthelyezve" : helyettesítés.ÚjÓra?.EgyediNév ?? "elmarad" : órarend.Órák[i][j]?.EgyediNév ?? "", helyettesítés == null ? (DarkTheme ? Color.WhiteSmoke : Color.Black) : Color.Red, tr, new int[2] { i, j });
}
table.AddView(tr, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
}
@ -212,7 +225,7 @@ namespace OrarendAndroidApp
var tv = (TextView)sender;
var ij = (int[])tv.Tag;
if (selected != null && selected != sender)
selected.SetBackgroundResource(Resource.Drawable.cell_shape_light);
selected.SetBackgroundResource(DarkTheme ? Resource.Drawable.cell_shape_dark : Resource.Drawable.cell_shape_light);
Óra óra;
Helyettesítés helyettesítésInnen = null;
Helyettesítés helyettesítésIde = null;
@ -227,7 +240,7 @@ namespace OrarendAndroidApp
deselect();
return;
}
tv.SetBackgroundResource(Resource.Drawable.cell_shape_selected_light);
tv.SetBackgroundResource(DarkTheme ? Resource.Drawable.cell_shape_selected_dark : Resource.Drawable.cell_shape_selected_light);
selected = tv;
var kivora = FindViewById<TextView>(Resource.Id.kivoraTV);
if (óra == null)
@ -268,6 +281,15 @@ namespace OrarendAndroidApp
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.main_menu_light, menu);
ActionBar.SetCustomView(list = new Spinner(this, SpinnerMode.Dropdown), new ActionBar.LayoutParams(ActionBar.LayoutParams.MatchParent, ActionBar.LayoutParams.MatchParent, GravityFlags.Left));
ActionBar.SetDisplayShowCustomEnabled(true);
if (DarkTheme)
{
menu.FindItem(Resource.Id.menu_add).SetIcon(Resource.Drawable.ic_add_white_24dp);
menu.FindItem(Resource.Id.menu_edit).SetIcon(Resource.Drawable.ic_create_white_24dp);
menu.FindItem(Resource.Id.menu_refresh).SetIcon(Resource.Drawable.ic_autorenew_white_24dp);
menu.FindItem(Resource.Id.menu_preferences).SetIcon(Resource.Drawable.ic_settings_white_24dp);
}
if (API.Osztályok == null || API.Osztályok.Length == 0)
ÓrarendFrissítés();
else
@ -304,8 +326,12 @@ namespace OrarendAndroidApp
StartActivityForResult(intent, EDIT_ADD_ACT_REQUEST);
break;
}
case Resource.Id.menu_preferences: //TODO
case Resource.Id.menu_preferences:
{
var intent = new Intent(this, typeof(SettingsActivity));
StartActivityForResult(intent, SETTINGS_ACT_REQUEST);
break;
}
case Resource.Id.menu_fullrefresh:
{
ÓrarendFrissítés();
@ -360,7 +386,7 @@ namespace OrarendAndroidApp
return;
}
var most = DateTime.Now - DateTime.Today;
//var most = new TimeSpan(13, 46, 0);
//var most = new TimeSpan(9, 46, 0);
bool talált = false;
var kovora = FindViewById<TextView>(Resource.Id.kovoraTV);
nincstöbbóra = false;
@ -375,15 +401,17 @@ namespace OrarendAndroidApp
var vége = órarend.Órakezdetek[i].Add(new TimeSpan(0, 45, 0));
bool becsengetés;
int x = (int)DateTime.Today.DayOfWeek - 1; //TODO: A mai nap és ez az egész az API-ba
//x = 2; //TODO: TMP
Óra óra;
var innenide = helyettesítésInnenIde(x, i);
Func<TimeSpan, string> óraperc = ts => ts.Hours > 0 ? ts.ToString("h\\ómm\\p") : ts.ToString("mm") + " perc";
if (x != -1 && x < 6 && (óra = innenide[1] != null ? innenide[1].ÚjÓra : innenide[0] != null ? innenide[0].EredetiNap != innenide[0].ÚjNap || innenide[0].EredetiSorszám != innenide[0].ÚjSorszám ? null : innenide[0].ÚjÓra : órarend.Órák[x][i]) != null)
{ //-1: Vasárnap
if (most > órarend.Órakezdetek[i])
{
if (most < vége)
{
kezdveg.Text = "Kicsengetés: " + (vége - most).ToString("hh\\:mm\\:ss");
kezdveg.Text = "Kicsengetés: " + óraperc(vége - most);
talált = true;
becsengetés = false;
}
@ -392,7 +420,7 @@ namespace OrarendAndroidApp
}
else
{
kezdveg.Text = "Becsengetés: " + (órarend.Órakezdetek[i] - most).ToString("hh\\:mm\\:ss");
kezdveg.Text = "Becsengetés: " + óraperc(órarend.Órakezdetek[i] - most);
talált = true;
becsengetés = true;
}
@ -415,11 +443,11 @@ namespace OrarendAndroidApp
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == EDIT_ADD_ACT_REQUEST)
{
if (resultCode == Result.Canceled)
return;
int index = data.Extras.GetBoolean("add") ? API.Órarendek.Count - 1 : data.Extras.GetInt("index");
if (requestCode == EDIT_ADD_ACT_REQUEST)
{
if (!data.Extras.GetBoolean("deleted"))
ÓrarendFrissítés(API.Órarendek[index]);
else
@ -429,6 +457,10 @@ namespace OrarendAndroidApp
}
órarendlistafrissítés();
}
else if (requestCode == SETTINGS_ACT_REQUEST)
{
Recreate();
}
}
public override void OnWindowFocusChanged(bool hasFocus)

View file

@ -57,10 +57,12 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ActivityBase.cs" />
<Compile Include="EditActivity.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsActivity.cs" />
</ItemGroup>
<ItemGroup>
<None Include="GettingStarted.Xamarin" />
@ -117,15 +119,30 @@
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\cell_shape_removed_light.xml">
<AndroidResource Include="Resources\xml\preferences.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\cell_shape_dark.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\cell_shape_added_light.xml">
<AndroidResource Include="Resources\drawable\cell_shape_selected_dark.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\ic_add_white_24dp.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\ic_autorenew_white_24dp.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\ic_create_white_24dp.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\ic_settings_white_24dp.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.github.norbipeti.orarend" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" />
<uses-sdk android:minSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Orarend"></application>
</manifest>

View file

@ -45,13 +45,13 @@ namespace OrarendAndroidApp
{
// aapt resource value: 0x7f020000
public const int cell_shape_added_light = 2130837504;
public const int cell_shape_dark = 2130837504;
// aapt resource value: 0x7f020001
public const int cell_shape_light = 2130837505;
// aapt resource value: 0x7f020002
public const int cell_shape_removed_light = 2130837506;
public const int cell_shape_selected_dark = 2130837506;
// aapt resource value: 0x7f020003
public const int cell_shape_selected_light = 2130837507;
@ -60,16 +60,28 @@ namespace OrarendAndroidApp
public const int ic_add_black_24dp = 2130837508;
// aapt resource value: 0x7f020005
public const int ic_autorenew_black_24dp = 2130837509;
public const int ic_add_white_24dp = 2130837509;
// aapt resource value: 0x7f020006
public const int ic_create_black_24dp = 2130837510;
public const int ic_autorenew_black_24dp = 2130837510;
// aapt resource value: 0x7f020007
public const int ic_settings_black_24dp = 2130837511;
public const int ic_autorenew_white_24dp = 2130837511;
// aapt resource value: 0x7f020008
public const int Icon = 2130837512;
public const int ic_create_black_24dp = 2130837512;
// aapt resource value: 0x7f020009
public const int ic_create_white_24dp = 2130837513;
// aapt resource value: 0x7f02000a
public const int ic_settings_black_24dp = 2130837514;
// aapt resource value: 0x7f02000b
public const int ic_settings_white_24dp = 2130837515;
// aapt resource value: 0x7f02000c
public const int Icon = 2130837516;
static Drawable()
{
@ -84,89 +96,83 @@ namespace OrarendAndroidApp
public partial class Id
{
// aapt resource value: 0x7f06000d
public const int ScrollView01 = 2131099661;
// aapt resource value: 0x7f07000d
public const int ScrollView01 = 2131165197;
// aapt resource value: 0x7f06000a
public const int ScrollView02 = 2131099658;
// aapt resource value: 0x7f07000a
public const int ScrollView02 = 2131165194;
// aapt resource value: 0x7f060015
public const int actionMenuView1 = 2131099669;
// aapt resource value: 0x7f070009
public const int container = 2131165193;
// aapt resource value: 0x7f060009
public const int container = 2131099657;
// aapt resource value: 0x7f070005
public const int csoportokEditText = 2131165189;
// aapt resource value: 0x7f060005
public const int csoportokEditText = 2131099653;
// aapt resource value: 0x7f070008
public const int deleteButton = 2131165192;
// aapt resource value: 0x7f060008
public const int deleteButton = 2131099656;
// aapt resource value: 0x7f070011
public const int helyTV = 2131165201;
// aapt resource value: 0x7f060011
public const int helyTV = 2131099665;
// aapt resource value: 0x7f07000e
public const int horizontalView = 2131165198;
// aapt resource value: 0x7f06000e
public const int horizontalView = 2131099662;
// aapt resource value: 0x7f070012
public const int kezdvegTV = 2131165202;
// aapt resource value: 0x7f060012
public const int kezdvegTV = 2131099666;
// aapt resource value: 0x7f070010
public const int kivoraTV = 2131165200;
// aapt resource value: 0x7f060010
public const int kivoraTV = 2131099664;
// aapt resource value: 0x7f070013
public const int kovoraTV = 2131165203;
// aapt resource value: 0x7f060013
public const int kovoraTV = 2131099667;
// aapt resource value: 0x7f070016
public const int menu_add = 2131165206;
// aapt resource value: 0x7f060018
public const int menu_add = 2131099672;
// aapt resource value: 0x7f070017
public const int menu_edit = 2131165207;
// aapt resource value: 0x7f060019
public const int menu_edit = 2131099673;
// aapt resource value: 0x7f070019
public const int menu_fullrefresh = 2131165209;
// aapt resource value: 0x7f06001b
public const int menu_fullrefresh = 2131099675;
// aapt resource value: 0x7f070018
public const int menu_preferences = 2131165208;
// aapt resource value: 0x7f06001a
public const int menu_preferences = 2131099674;
// aapt resource value: 0x7f070015
public const int menu_refresh = 2131165205;
// aapt resource value: 0x7f060017
public const int menu_refresh = 2131099671;
// aapt resource value: 0x7f070001
public const int névEditText = 2131165185;
// aapt resource value: 0x7f060001
public const int névEditText = 2131099649;
// aapt resource value: 0x7f070014
public const int osztalylistaTV = 2131165204;
// aapt resource value: 0x7f060014
public const int osztalylistaTV = 2131099668;
// aapt resource value: 0x7f070003
public const int osztálySpinner = 2131165187;
// aapt resource value: 0x7f060003
public const int osztálySpinner = 2131099651;
// aapt resource value: 0x7f07000c
public const int progressBar1 = 2131165196;
// aapt resource value: 0x7f06000c
public const int progressBar1 = 2131099660;
// aapt resource value: 0x7f070007
public const int saveButton = 2131165191;
// aapt resource value: 0x7f060007
public const int saveButton = 2131099655;
// aapt resource value: 0x7f07000b
public const int scrollLinearLayout = 2131165195;
// aapt resource value: 0x7f06000b
public const int scrollLinearLayout = 2131099659;
// aapt resource value: 0x7f07000f
public const int tableLayout1 = 2131165199;
// aapt resource value: 0x7f060016
public const int spinner = 2131099670;
// aapt resource value: 0x7f070000
public const int textView1 = 2131165184;
// aapt resource value: 0x7f06000f
public const int tableLayout1 = 2131099663;
// aapt resource value: 0x7f070002
public const int textView2 = 2131165186;
// aapt resource value: 0x7f060000
public const int textView1 = 2131099648;
// aapt resource value: 0x7f070004
public const int textView3 = 2131165188;
// aapt resource value: 0x7f060002
public const int textView2 = 2131099650;
// aapt resource value: 0x7f060004
public const int textView3 = 2131099652;
// aapt resource value: 0x7f060006
public const int textView4 = 2131099654;
// aapt resource value: 0x7f070006
public const int textView4 = 2131165190;
static Id()
{
@ -203,8 +209,8 @@ namespace OrarendAndroidApp
public partial class Menu
{
// aapt resource value: 0x7f050000
public const int main_menu_light = 2131034112;
// aapt resource value: 0x7f060000
public const int main_menu_light = 2131099648;
static Menu()
{
@ -219,11 +225,11 @@ namespace OrarendAndroidApp
public partial class String
{
// aapt resource value: 0x7f040001
public const int ApplicationName = 2130968577;
// aapt resource value: 0x7f050001
public const int ApplicationName = 2131034113;
// aapt resource value: 0x7f040000
public const int Hello = 2130968576;
// aapt resource value: 0x7f050000
public const int Hello = 2131034112;
static String()
{
@ -234,6 +240,22 @@ namespace OrarendAndroidApp
{
}
}
public partial class Xml
{
// aapt resource value: 0x7f040000
public const int preferences = 2130968576;
static Xml()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Xml()
{
}
}
}
}
#pragma warning restore 1591

View file

@ -2,6 +2,6 @@
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "rectangle" >
<solid android:color="#eee"/>
<stroke android:width="1dp" android:color="#00d"/>
<solid android:color="#222"/>
<stroke android:width="1dp" android:color="#fff"/>
</shape>

View file

@ -2,6 +2,6 @@
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "rectangle" >
<solid android:color="#eee"/>
<stroke android:width="1dp" android:color="#0d0"/>
<solid android:color="#333"/>
<stroke android:width="1dp" android:color="#fff"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="fill_parent"
@ -96,10 +97,4 @@
android:visibility="gone" />
</LinearLayout>
</ScrollView>
<ActionMenuView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/actionMenuView1" />
</LinearLayout>

View file

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/spinner"
<!-- <item android:id="@+id/spinner"
android:title="will be replaced anyway"
android:showAsAction="always"
android:actionViewClass="android.widget.Spinner" />
android:actionViewClass="android.widget.Spinner"
android:layout_width="fill_parent" /> -->
<item
android:id="@+id/menu_refresh"
android:icon="@drawable/ic_autorenew_black_24dp"

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="pref_theme"
android:title="Sötét téma"
android:summary="Sötét téma"
android:defaultValue="false" />
</PreferenceScreen>

View file

@ -0,0 +1,51 @@
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;
namespace OrarendAndroidApp
{
[Activity(Label = "Beállítások", Theme = "@android:style/Theme.Holo.Light")]
public class SettingsActivity : PreferenceActivity, ISharedPreferencesOnSharedPreferenceChangeListener
{
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);
#pragma warning restore CS0618 // Type or member is obsolete
PreferenceManager.SetDefaultValues(this, Resource.Xml.preferences, false);
}
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
{
if (key == "pref_theme")
Recreate();
}
protected override void OnResume()
{
base.OnResume();
PreferenceManager.GetDefaultSharedPreferences(this).RegisterOnSharedPreferenceChangeListener(this);
}
protected override void OnPause()
{
base.OnPause();
PreferenceManager.GetDefaultSharedPreferences(this).UnregisterOnSharedPreferenceChangeListener(this);
}
}
}