Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.5 #62

Merged
merged 68 commits into from
Jun 23, 2019
Merged

v2.5 #62

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1cf49d0
Merge pull request #44 from yazdipour/master
yazdipour Apr 27, 2019
41e6010
Update README
yazdipour Apr 27, 2019
721ae0f
Add Theme
yazdipour May 7, 2019
87c45cb
deprecated items
yazdipour May 7, 2019
302f084
Add VM Classes
yazdipour May 7, 2019
e2f3ab8
Rm Dotnet Core Test
yazdipour May 7, 2019
4c69336
Add LoggerLib
yazdipour May 7, 2019
2111e61
Add UnitTest
yazdipour May 7, 2019
d689f94
Clean Code
yazdipour May 7, 2019
16e0a53
Use Logger
yazdipour May 7, 2019
098a718
Rename Source Folder for clarification
yazdipour May 7, 2019
988d70d
Update README
yazdipour May 7, 2019
29c8d0f
Oops :)
yazdipour May 7, 2019
26f8c34
RM old keys
yazdipour May 7, 2019
edf3069
Rm OldUnitTestProj
yazdipour May 7, 2019
861e0f9
UI Changes
yazdipour May 7, 2019
d47e029
Resharper suggestions
yazdipour May 8, 2019
43dc2fc
Add ui concepts And Little ui changes
yazdipour May 10, 2019
ae0e9c7
ui update
yazdipour May 11, 2019
2eeebb1
ui improvements
yazdipour May 12, 2019
491231f
improv Login + Singlton PocketHandler + Cleaning a bit
yazdipour May 12, 2019
4cc6f27
Update UiUtil
yazdipour May 14, 2019
fc76ff0
VM in MainPage
yazdipour May 14, 2019
e41caac
VM in MainPage
yazdipour May 14, 2019
e8ad0e9
Half VM for MainContent
yazdipour May 14, 2019
72898a9
New navview (#45)
yazdipour May 18, 2019
438e13a
Fix Minor Problems
yazdipour May 19, 2019
9f6bbd0
Encapsulate InAppNotification
yazdipour May 19, 2019
d5ca4e1
Fix InAppNotif UI
yazdipour May 19, 2019
baa6782
Fix WhiteTheme
yazdipour May 19, 2019
bea639f
Rm UserInfo from Settings
yazdipour May 19, 2019
0d378ec
Improve binding
yazdipour May 19, 2019
5d4d667
Fix Minor UI Bugs
yazdipour May 19, 2019
c439ef9
UPdate README
yazdipour May 19, 2019
71f4788
Rm TagListCtrl
yazdipour May 20, 2019
9133a7d
little ui changes
yazdipour May 20, 2019
8019718
Fix WebViewBtn on Error Page (Issue #53)
yazdipour May 21, 2019
1c70e50
UpdateGitIgnore
yazdipour May 21, 2019
091a401
Minor fixes
yazdipour May 21, 2019
4c538ef
If there is no tag, get center
yazdipour May 21, 2019
4068201
Fix Caching the List
yazdipour May 21, 2019
add3091
Making sure first remove cache then Delete it from server - in case o…
yazdipour May 21, 2019
cef911e
Better tag loading
yazdipour May 21, 2019
e72c8e6
Cache User Info
yazdipour May 21, 2019
fef81a5
Add UserStatistics
yazdipour May 23, 2019
4caeb6a
Merge branch 'master' into dev
yazdipour May 23, 2019
1d0ae71
Fix Delete Icon in Swiping Action
yazdipour May 23, 2019
9f852ee
Minor Changes
yazdipour May 23, 2019
45860fb
Add TagEditing Feature
yazdipour May 23, 2019
b7f9b08
Merge branch 'dev' of https://github.com/yazdipour/pocketx into dev
yazdipour May 23, 2019
b6ad52c
Delete Tags
yazdipour May 23, 2019
ebba20e
Xaml Styling
yazdipour May 24, 2019
a807366
move arr2str converter
yazdipour May 24, 2019
a59d4da
ConsoleWL to DebugWL
yazdipour May 24, 2019
a166b82
Fix performance issue
yazdipour May 24, 2019
6982d36
Mv Ctrl
yazdipour May 27, 2019
51a404a
fix user info theme
yazdipour May 27, 2019
fd9338f
Update Font
yazdipour May 28, 2019
4e65cae
Del Cache on Archive
yazdipour May 29, 2019
887c002
Fix Problem Made by Resharper Renamer :)
yazdipour May 31, 2019
697dd99
Fix Placeholder to Uniform
yazdipour May 31, 2019
2dcddbf
Impl #61
yazdipour Jun 21, 2019
a4346d0
Add LruCache + Performance Enhancement
yazdipour Jun 21, 2019
62c1594
Use CancellationToken + Performance Imprv
yazdipour Jun 21, 2019
16a6cb5
Rename LruGet to LruTryGet
yazdipour Jun 21, 2019
e109d33
Revert "Rename LruGet to LruTryGet"
yazdipour Jun 21, 2019
318874b
Rename LruGet to LruTryToGet
yazdipour Jun 21, 2019
d91724d
v2.5
yazdipour Jun 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Source/PocketX/Package.StoreAssociation.xml
Source/PocketX/Handlers/Keys.cs
22 changes: 22 additions & 0 deletions Source/CacheManager/CacheManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Reactive.Linq;
using System.Threading.Tasks;
using Akavache;
using static Akavache.BlobCache;

namespace CacheManager
{
public static class CacheManager
{
public static void Kill()
{
LocalMachine.InvalidateAll();
LocalMachine.Vacuum();
}

public static async Task<T> GetObject<T>(string key, T defaultValue)
=> await LocalMachine.GetObject<T>(key).Catch(Observable.Return(defaultValue));

public static async Task InsertObject<T>(string key, T value)
=> await LocalMachine.InsertObject(key, value);
}
}
11 changes: 11 additions & 0 deletions Source/CacheManager/CacheManager.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="akavache" Version="6.5.9" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions Source/CacheManager/ILru.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CacheManager
{
internal interface ILru<K, V>
{
V TryToGet(K key);
void Put(K key, V value);
void InsertAtHead(Node<K, V> node);
void MoveToHead(Node<K, V> node);
}
}
22 changes: 22 additions & 0 deletions Source/CacheManager/Lru.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections;
using System.Threading.Tasks;

namespace CacheManager
{
public class Lru<K, V>
{
private static LruCache<K, V> _lruCache;

public static bool IsOpen => _lruCache != null;

public static void Init(int capacity, IDictionary oldDictionary) => _lruCache = new LruCache<K, V>(capacity, oldDictionary);

public static async Task SaveAllToCache(string key)
=> await CacheManager.InsertObject(key, _lruCache.GetAll());

public static void Put(K key, V valueTuple) => _lruCache.Put(key, valueTuple);

public static V Get(K key) => _lruCache.TryToGet(key);

}
}
111 changes: 111 additions & 0 deletions Source/CacheManager/LruCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System.Collections;
using System.Collections.Generic;

namespace CacheManager
{
internal class LruCache<K, V> : ILru<K, V>
{
private readonly Dictionary<K, Node<K, V>> _memory;
private readonly int _capacity;
private int _currentMemoryInUse;
private Node<K, V> _head;
private Node<K, V> _tail;

public LruCache(int capacity, IDictionary oldMemory = null)
{
_capacity = capacity;
_memory = new Dictionary<K, Node<K, V>>();
if (oldMemory != null)
foreach (var k in oldMemory.Keys)
Put((K)k, ((Node<K, V>) oldMemory[k]).Value);
_currentMemoryInUse = (int)_memory?.Count;
}

public IDictionary GetAll() => _memory;

public V TryToGet(K key)
{
if (!_memory.ContainsKey(key)) return default;
var result = _memory[key];
//Move node to head
MoveToHead(result);
return result.Value;
}

public void Put(K key, V value)
{
Node<K, V> node;
if (_memory.ContainsKey(key))
{
//Parameter key exists in hash-map
node = _memory[key];
node.Value = value;
MoveToHead(node);
return;
}

node = new Node<K, V>(key, value)
{
Key = key,
Value = value
};

//Parameter key is new and there is capacity
if (_currentMemoryInUse < _capacity)
{
if (_head == null)
_head = _tail = node;
else
InsertAtHead(node);
_memory[key] = node;
_currentMemoryInUse++;
}
else //Parameter key is new and there is no capacity.
{
var keyToRemove = _tail.Key;

if (_head != _tail)
{
_tail.Previous.Next = null;
_tail = _tail.Previous;
}
_memory.Remove(keyToRemove);
_currentMemoryInUse--;
InsertAtHead(node);
_memory[key] = node;
_currentMemoryInUse++;
}
}

public void InsertAtHead(Node<K, V> node)
{
node.Previous = null;
node.Next = _head;
_head.Previous = node;
_head = node;
}

public void MoveToHead(Node<K, V> node)
{
if (node.Previous == null) return;
if (node.Next == null)
_tail = node.Previous;
else
node.Next.Previous = node.Previous;
node.Previous.Next = node.Next;
InsertAtHead(node);
}

public string Log()
{
var headReference = _head;
var items = new List<string>();
while (headReference != null)
{
items.Add($"[{headReference.Key}: {headReference.Value}]");
headReference = headReference.Next;
}
return string.Join(",", items);
}
}
}
20 changes: 20 additions & 0 deletions Source/CacheManager/Node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace CacheManager
{
public class Node<TK, TV>
{
public TV Value;
public TK Key;
[Newtonsoft.Json.JsonIgnore]
public Node<TK, TV> Next;
[Newtonsoft.Json.JsonIgnore]
public Node<TK, TV> Previous;

public Node(TK key, TV value)
{
Key = key;
Value = value;
Next = null;
Previous = null;
}
}
}
23 changes: 11 additions & 12 deletions Source/Logger/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
using Microsoft.AppCenter;
using static System.Diagnostics.Debug;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;

using static System.Console;

namespace Logger
{
public static class Logger
{
private static bool DebugEnabled = false;
private static bool AppCenterEnabled = false;
private static bool _debugEnabled = false;
private static bool _appCenterEnabled = false;

public static void InitOnlineLogger(string token)
{
AppCenter.Start(token, typeof(Analytics), typeof(Crashes));
AppCenter.LogLevel = LogLevel.Error;
AppCenterEnabled = true;
_appCenterEnabled = true;
}

public static void SetDebugMode(bool debug) => DebugEnabled = debug;
public static void SetDebugMode(bool debug) => _debugEnabled = debug;

public static void L(string message)
{
var TAG = "[LOGGER] ";
if (DebugEnabled) WriteLine(TAG + message);
if (AppCenterEnabled) Analytics.TrackEvent(TAG + message);
const string TAG = "[LOGGER] ";
if (_debugEnabled) WriteLine(TAG + message);
if (_appCenterEnabled) Analytics.TrackEvent(TAG + message);
}
public static void E(System.Exception e)
{
if (DebugEnabled) WriteLine("[LOGGER-ERR] " + e.Message);
if (AppCenterEnabled) Crashes.TrackError(e);
if (_debugEnabled) WriteLine("[LOGGER-ERR] " + e.Message);
if (_appCenterEnabled) Crashes.TrackError(e);
}
}
}
22 changes: 22 additions & 0 deletions Source/PocketX.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logger", "Logger\Logger.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketX.UnitTest", "PocketX.UnitTest\PocketX.UnitTest.csproj", "{30FDD3F9-AADC-478E-9FF4-0D1890605A09}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CacheManager", "CacheManager\CacheManager.csproj", "{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -91,6 +93,26 @@ Global
{30FDD3F9-AADC-478E-9FF4-0D1890605A09}.Release|x86.ActiveCfg = Release|x86
{30FDD3F9-AADC-478E-9FF4-0D1890605A09}.Release|x86.Build.0 = Release|x86
{30FDD3F9-AADC-478E-9FF4-0D1890605A09}.Release|x86.Deploy.0 = Release|x86
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|ARM.ActiveCfg = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|ARM.Build.0 = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|ARM64.Build.0 = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|x64.ActiveCfg = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|x64.Build.0 = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|x86.ActiveCfg = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Debug|x86.Build.0 = Debug|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|Any CPU.Build.0 = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|ARM.ActiveCfg = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|ARM.Build.0 = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|ARM64.ActiveCfg = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|ARM64.Build.0 = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|x64.ActiveCfg = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|x64.Build.0 = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|x86.ActiveCfg = Release|Any CPU
{00A36BBD-1B69-4449-8EC5-82D2DB0110AD}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions Source/PocketX/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<GradientStop Color="#FFFF2525" />
</LinearGradientBrush>

<FontFamily x:Key="GothamPro">/Assets/Fonts/GothamPro.ttf#Gotham Pro</FontFamily>

<Color x:Key="AccentColor">#ED243B</Color>
<Color x:Key="AcrylicBrushTintColor1">#fefefe</Color>
<Color x:Key="AcrylicBrushFallbackColor1">#eee</Color>
Expand Down
Binary file added Source/PocketX/Assets/Fonts/GothamPro.ttf
Binary file not shown.
9 changes: 0 additions & 9 deletions Source/PocketX/Assets/Icons/ChangeLog.md

This file was deleted.

Binary file added Source/PocketX/Assets/Icons/Thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading