Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Android and sync fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjch-krl committed Jan 20, 2015
1 parent 73818d5 commit bad055f
Show file tree
Hide file tree
Showing 19 changed files with 369 additions and 241 deletions.
47 changes: 11 additions & 36 deletions PiggySync/PiggySync.AndroidApp/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
using PiggySync.GuiShared;
using PiggySync.Common;
using System;
using PiggySync.StandardTypeResolver;
using PiggySync.Model;
using SQLite.Net.Platform.XamarinAndroid;
using Android.Content.PM;

namespace PiggySync.AndroidApp
{
[Android.App.Activity (Label = "PiggySync.AndroidApp", Theme = "@style/Theme.AppCompat", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : ActionBarActivity, IMainView, Android.Support.V7.App.ActionBar.ITabListener
[Android.App.Activity (Label = "PiggySync.AndroidApp", Theme = "@style/Theme.AppCompat", MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : ActionBarActivity, Android.Support.V7.App.ActionBar.ITabListener
{
Android.Support.V4.App.Fragment[] _fragments;

protected override void OnCreate (Bundle bundle)
{
TypeResolver.Factory = new Resolver ();
DatabaseManager.Init (new SQLitePlatformAndroid());
base.OnCreate (bundle);
SupportActionBar.NavigationMode = Android.Support.V7.App.ActionBar.NavigationModeTabs;
SetContentView(Resource.Layout.Main);
Expand All @@ -34,20 +40,20 @@ protected override void OnCreate (Bundle bundle)

public void OnTabReselected(Android.Support.V7.App.ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
{
System.Diagnostics.Debug.WriteLine ( "The tab {0} was re-selected.", tab.Text);
System.Diagnostics.Debug.WriteLine ( "The tab {0} was re-selected.", (object)tab.Text);
}

public void OnTabSelected(Android.Support.V7.App.ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
{
System.Diagnostics.Debug.WriteLine ( "The tab {0} has been selected.", tab.Text);
System.Diagnostics.Debug.WriteLine ( "The tab {0} has been selected.", (object)tab.Text);
var frag = _fragments[tab.Position];
ft.Replace(Resource.Id.frameLayout1, frag);
}

public void OnTabUnselected(Android.Support.V7.App.ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
{
// perform any extra work associated with saving fragment state here.
System.Diagnostics.Debug.WriteLine ("The tab {0} as been unselected.", tab.Text);
System.Diagnostics.Debug.WriteLine ("The tab {0} as been unselected.", (object)tab.Text);
}

void AddTabToActionBar(string tabName)
Expand All @@ -57,37 +63,6 @@ void AddTabToActionBar(string tabName)
.SetTabListener(this);
SupportActionBar.AddTab(tab);
}

public double ProgresLevel
{
get
{
throw new NotImplementedException ();
}
set
{
throw new NotImplementedException ();
}
}

public SyncStatus SyncStatus
{
set
{
throw new NotImplementedException ();
}
}

public bool ProgresEnabled
{
set
{
throw new NotImplementedException ();

//var progresbar =
}
}

}
}

Expand Down
35 changes: 23 additions & 12 deletions PiggySync/PiggySync.AndroidApp/MainFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,47 @@
using Android.Support.V4.App;
using Android.Views;
using Android.OS;
using PiggySync.GuiShared;
using Android.Widget;
using PiggySync.Common;

namespace PiggySync.AndroidApp
{
public class MainFragment: Fragment, IMainView
{
private MainPresenter presenter;
private ProgressBar progresBar;

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
private TextView statusLabel;
private ImageView statusImage;

public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.mainlayout, null);
this.presenter = new MainPresenter(this);
this.progresBar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
View view = inflater.Inflate (Resource.Layout.mainlayout, null);
this.progresBar = view.FindViewById<ProgressBar> (Resource.Id.progressBar1);
this.statusLabel = view.FindViewById<TextView> (Resource.Id.statusTextView);
this.statusImage = view.FindViewById<ImageView> (Resource.Id.statusImageView);
statusImage.Click += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine ("dddD");
};
this.presenter = new MainPresenter (this);
return view;
}
public double ProgresLevel

public double ProgresLevel
{
get { return progresBar.Progress / 100.0; }
set { progresBar.Progress = Convert.ToIn32(value * 100); }
set { progresBar.Progress = Convert.ToInt32 (value * 100); }
}

public SyncStatus SyncStatus
public SyncStatus SyncStatus
{
set { throw new NotImplementedException(); }
set { statusLabel.Text = String.Format ("Sync status:\n{0}", value); }
}

public bool ProgresEnabled
public bool ProgresEnabled
{
set { throw new NotImplementedException(); }
set { progresBar.Visibility = !value ? ViewStates.Invisible : ViewStates.Visible; }
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions PiggySync/PiggySync.AndroidApp/PiggySync.AndroidApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<Reference Include="Xamarin.Android.Support.v7.AppCompat">
<HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.21.0.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net">
<HintPath>..\packages\SQLite.Net-PCL.2.5\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net.Platform.XamarinAndroid">
<HintPath>..\packages\SQLite.Net.Platform.XamarinAndroid.2.5\lib\MonoAndroid\SQLite.Net.Platform.XamarinAndroid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
3 changes: 3 additions & 0 deletions PiggySync/PiggySync.AndroidApp/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<uses-sdk android:minSdkVersion="10" />
<application android:label="PiggySync.AndroidApp">
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
86 changes: 53 additions & 33 deletions PiggySync/PiggySync.AndroidApp/Resources/Resource.designer.cs

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

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<ImageView
android:layout_width="match_parent"
android:layout_height="263.3dp"
android:id="@+id/imageView1"
android:id="@+id/statusImageView"
android:layout_marginBottom="21.8dp"
android:src="@drawable/Icon"
android:layout_marginTop="34.1dp" />
Expand All @@ -39,7 +39,7 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:id="@+id/statusTextView"
android:layout_marginLeft="18.5dp" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
Expand Down
Loading

0 comments on commit bad055f

Please sign in to comment.