Skip to content

Commit

Permalink
1.2.0.0
Browse files Browse the repository at this point in the history
Add tutorial page.
Fix loading csv oover smb.
  • Loading branch information
kurema committed Jun 9, 2018
1 parent cdb2dd8 commit bf49f4e
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -150,6 +153,15 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable\Title.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\tutorial_github.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\tutorial_wpf.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\tutorial_network.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionCode="3" android:versionName="1.1.1.0" package="com.github.kurema.BDVideoLibraryManager">
<uses-sdk android:minSdkVersion="15" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionCode="4" android:versionName="1.2.0.0" package="com.github.kurema.BDVideoLibraryManager">
<uses-sdk android:minSdkVersion="16" />
<application android:label="BDVideoLibraryManagerXF" android:icon="@drawable/icon"></application>
</manifest>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@
<ItemGroup>
<BundleResource Include="Resources\Title.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\tutorial_github.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\tutorial_wpf.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\tutorial_network.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<Compile Include="Views\TopPage.xaml.cs">
<DependentUpon>TopPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TutorialPage.xaml.cs">
<DependentUpon>TutorialPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\VideoDetailPage.xaml.cs">
<DependentUpon>VideoDetailPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -132,5 +135,11 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\TutorialPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,58 @@ public static async Task<Library> GetLocalData()
return Library = new Library(d.ToArray());
}

public static bool TestAccess(string serverName, string remotePath, string UserName, string Password)

public static bool TestAccess(string serverName, string remotePath, string UserName, string Password, out SharpCifs.Smb.SmbFile smbFolder)
{
if (!remotePath.EndsWith("/")) { remotePath += "/"; }
if (! TestAccessSingle(serverName,remotePath,UserName,Password,out smbFolder))
{
remotePath += "csv/";
if (!TestAccessSingle(serverName, remotePath, UserName, Password, out smbFolder))
{
smbFolder = null;
return false;
}
else
{
return true;
}
}
return true;
}

public static bool TestAccessSingle(string serverName, string remotePath, string UserName, string Password, out SharpCifs.Smb.SmbFile smbFolder)
{
try
{
var folder = new SharpCifs.Smb.SmbFile("smb://" + UserName + ":" + Password + "@" + serverName + "/" + remotePath);
if (!folder.Exists() || !folder.IsDirectory()) { return false; }
if (!folder.Exists() || !folder.IsDirectory())
{
smbFolder = null;
return false;
}

bool Sucess = false;
foreach (var item in folder.ListFiles())
{
if (item.IsFile() && System.IO.Path.GetExtension(item.GetName()) == ".csv")
{
Sucess = true;
break;
}
}
if (!Sucess)
{
smbFolder = null;
return false;
}
smbFolder = folder;
}
catch
{
smbFolder = null;
return false;
}
catch { return false; }
return true;
}

Expand All @@ -56,17 +100,13 @@ public static async Task<bool> CopyToLocal()
return await CopyToLocal(SettingStorage.SMBServerName, SettingStorage.SMBPath, SettingStorage.SMBID, SettingStorage.SMBPassword);
}


public static async Task<bool> CopyToLocal(string serverName, string remotePath,string UserName,string Password)
{
SharpCifs.Smb.SmbFile folder;
if (!remotePath.EndsWith("/")) { remotePath += "/"; }
try
{
folder = new SharpCifs.Smb.SmbFile("smb://" + UserName + ":" + Password + "@" + serverName + "/" + remotePath);
if (!folder.Exists() || !folder.IsDirectory()) { return false; }
if (! TestAccess(serverName, remotePath, UserName, Password, out folder)){
return false;
}
catch { return false; }
if (Copying) { return false; }
Copying = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<vm:LibraryViewModel/>
</ContentPage.BindingContext>
<ContentPage.ToolbarItems>
<ToolbarItem Text="検索" Clicked="Search_Toggle" />
<ToolbarItem x:Name="Search_button" Text="検索" Clicked="Search_Toggle" />
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ private void ListView_Refreshing(object sender, EventArgs e)

private void Search_Toggle(object sender, EventArgs e)
{
var ts = (DateTime.Now - SearchBarLastClosedTime);
if (!String.IsNullOrEmpty(SearchBar.Text))
{
ViewModel.SearchCommand.Execute(null);
}
else
else if(ts.TotalMilliseconds>100 || ts.TotalMilliseconds < 0)
{
SearchBar.IsVisible = !SearchBar.IsVisible;
if (SearchBar.IsVisible)
var b = !SearchBar.IsVisible;
SearchBar.IsVisible = b;
if (b)
{
SearchBar.Focus();
}
Expand All @@ -100,6 +102,9 @@ async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
return;
var item = args.SelectedItem as VideoLibraryManagerCommon.Library.VideoBD;

// Manually deselect item
LibraryListView.SelectedItem = null;

int maxVideoCount = 50;

VideoLibraryManagerCommon.Library.DiskVideoPair result = null;
Expand Down Expand Up @@ -130,13 +135,26 @@ async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
await Navigation.PushAsync(new VideosDetailPage(list, result));
}

// Manually deselect item
LibraryListView.SelectedItem = null;

}

//検索ボタンクリック時にSearchBarのフォーカスも外れるので強引に時間差で対応。
public DateTime SearchBarLastClosedTime = new DateTime();

private void SearchBar_OnUnfocused(object sender, FocusEventArgs e)
{
ViewModel.SearchCommand.Execute(null);
if (String.IsNullOrEmpty(SearchBar.Text))
{
if (SearchBar.IsVisible)
{
SearchBarLastClosedTime = DateTime.Now;
SearchBar.IsVisible = false;
}
}
else
{
ViewModel.SearchCommand.Execute(null);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
<Label Text="パス" TextColor="Black"/>
<Entry x:Name="Label_Smb_Path" />
<Button Text="保存" Clicked="Button_Clicked"/>
<Button Text="チュートリアル" Clicked="Button_Clicked_Tutorial" Margin="0,10,0,0"/>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace BDVideoLibraryManagerXF.Views
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SettingPage : ContentPage
{
public MasterDetailPage ParentMasterDetailPage;

public SettingPage()
{
InitializeComponent();
Expand All @@ -24,7 +26,8 @@ public SettingPage()

private async void Button_Clicked(object sender, EventArgs e)
{
if(Storages.LibraryStorage.TestAccess(Label_Smb_Name.Text, Label_Smb_Path.Text, Label_Smb_User.Text, Label_Smb_Password.Text))
SharpCifs.Smb.SmbFile folder;
if (Storages.LibraryStorage.TestAccess(Label_Smb_Name.Text, Label_Smb_Path.Text, Label_Smb_User.Text, Label_Smb_Password.Text,out folder))
{
Storages.SettingStorage.SMBID = Label_Smb_User.Text;
Storages.SettingStorage.SMBPassword = Label_Smb_Password.Text;
Expand All @@ -33,11 +36,26 @@ private async void Button_Clicked(object sender, EventArgs e)
await DisplayAlert("結果", "アクセスに成功しました。設定を保存します。", "OK");
await Storages.LibraryStorage.CopyToLocal(Label_Smb_Name.Text, Label_Smb_Path.Text, Label_Smb_User.Text, Label_Smb_Password.Text);

if (Parent is MasterDetailPage)
{
((MasterDetailPage)Parent).Detail = new NavigationPage(new LibraryPage() { Title = "一覧" });
}
}
else
{
await DisplayAlert("結果", "アクセスに失敗しました。", "OK");
}
}

private void Button_Clicked_Tutorial(object sender, EventArgs e)
{
if (Parent is MasterDetailPage)
{
((MasterDetailPage)Parent).Detail = new NavigationPage(new TutorialPage() { Title = "チュートリアル" });
}else if(Parent is NavigationPage)
{
Navigation.PushAsync(new TutorialPage() { Title = "チュートリアル" });
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public TopPage()
InitializeComponent();

if (SettingStorage.IsSet)
Navigation.PushAsync(new LibraryPage(){Title = "一覧"});
//Navigation.PushAsync(new TutorialPage() { Title = "チュートリアル" });
Navigation.PushAsync(new LibraryPage() { Title = "一覧" });
else
Navigation.PushAsync(new SettingPage() { Title = "設定" });
//Navigation.PushAsync(new SettingPage() { Title = "設定" });
Navigation.PushAsync(new TutorialPage() { Title = "チュートリアル" });

MasterSide.ListView.ItemSelected += ListView_ItemSelected;
}
Expand Down
Loading

0 comments on commit bf49f4e

Please sign in to comment.