添加项目文件。
19
XXCpzs.Android/Assets/AboutAssets.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Any raw assets you want to be deployed with your application can be placed in
|
||||
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||
|
||||
These files will be deployed with your package and will be accessible using Android's
|
||||
AssetManager, like this:
|
||||
|
||||
public class ReadAsset : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
InputStream input = Assets.Open ("my_asset.txt");
|
||||
}
|
||||
}
|
||||
|
||||
Additionally, some Android functions will automatically load asset files:
|
||||
|
||||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
||||
71
XXCpzs.Android/DownloadReceiver.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using System;
|
||||
|
||||
namespace XXCpzs.Droid
|
||||
{
|
||||
[BroadcastReceiver]
|
||||
|
||||
/// <summary>
|
||||
/// 下载通知接收器
|
||||
/// </summary>
|
||||
public class DownloadReceiver : BroadcastReceiver
|
||||
{
|
||||
public long downloadId = 0;
|
||||
public DownloadReceiver()
|
||||
{
|
||||
|
||||
}
|
||||
public DownloadReceiver(long downloadId)
|
||||
{
|
||||
this.downloadId = downloadId;
|
||||
}
|
||||
public override void OnReceive(Context context, Intent intent)
|
||||
{
|
||||
if (intent.Action == DownloadManager.ActionDownloadComplete)
|
||||
{
|
||||
#region 下载完成
|
||||
DownloadManager manager = (DownloadManager)context.GetSystemService(Context.DownloadService);
|
||||
//获取下载id,默认值-1
|
||||
var downId = intent.GetLongExtra(DownloadManager.ExtraDownloadId, -1);
|
||||
if (downId == downloadId)
|
||||
{
|
||||
Android.Database.ICursor cursor = null;
|
||||
try
|
||||
{
|
||||
DownloadManager.Query query = new DownloadManager.Query();
|
||||
query.SetFilterById(downId);
|
||||
cursor = manager.InvokeQuery(query);
|
||||
if (cursor.MoveToFirst())
|
||||
{
|
||||
//获取文件下载路径
|
||||
var downloadedTo = cursor.GetString(cursor.GetColumnIndex(DownloadManager.ColumnLocalUri));
|
||||
//var apkUri = manager.GetUriForDownloadedFile(downId);//错误路径
|
||||
|
||||
var installIntent = new Intent(Intent.ActionView);
|
||||
installIntent.SetDataAndType(Android.Net.Uri.Parse(downloadedTo), "application/vnd.android.package-archive");
|
||||
//给目标程序读改uri的权限。
|
||||
installIntent.AddFlags(ActivityFlags.NewTask);
|
||||
if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.M)
|
||||
installIntent.AddFlags(ActivityFlags.GrantReadUriPermission);
|
||||
// installIntent.SetFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.NewTask);
|
||||
context.StartActivity(installIntent);
|
||||
|
||||
}
|
||||
if (cursor != null)
|
||||
cursor.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
context.UnregisterReceiver(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else if (intent.Action == DownloadManager.ActionNotificationClicked)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
115
XXCpzs.Android/FileDownload.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Widget;
|
||||
using System;
|
||||
|
||||
namespace XXCpzs.Droid
|
||||
{
|
||||
public class FileDownload
|
||||
{
|
||||
#region --自动更新--
|
||||
|
||||
/// <summary>
|
||||
/// 使用DownloadManager下载安装文件
|
||||
/// </summary>
|
||||
/// <param name="mContext"></param>
|
||||
/// <param name="apkAddress"></param>
|
||||
public static void DownloadUpdateFile(Context mContext, string apkAddress)
|
||||
{
|
||||
var apkFileName = System.IO.Path.GetFileName(apkAddress);
|
||||
DownloadManager.Request request = new DownloadManager.Request(Android.Net.Uri.Parse(apkAddress));
|
||||
// request.SetAllowedNetworkTypes(DownloadNetwork.Wifi);//网络环境
|
||||
//request.SetDestinationInExternalPublicDir("download", "update1.apk");
|
||||
request.SetDestinationInExternalFilesDir(mContext, Android.OS.Environment.DirectoryDownloads, apkFileName);
|
||||
request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
|
||||
request.SetMimeType("application/vnd.android.package-archive");
|
||||
//设置通知信息
|
||||
request.SetTitle(apkFileName);
|
||||
request.SetDescription("软件更新");
|
||||
//设置为可见和可管理
|
||||
request.SetVisibleInDownloadsUi(true);
|
||||
//设置为可被媒体扫描器找到
|
||||
request.AllowScanningByMediaScanner();
|
||||
request.SetAllowedOverRoaming(false);
|
||||
|
||||
//下载管理
|
||||
DownloadManager downManager = (DownloadManager)mContext.GetSystemService(Context.DownloadService);
|
||||
//获取此次下载的ID,返回一个唯一编号(用于识别通知来源)
|
||||
var refrence = downManager.Enqueue(request);
|
||||
|
||||
// 注册广播监听系统的下载完成事件。
|
||||
IntentFilter intentFilter = new IntentFilter(DownloadManager.ActionDownloadComplete);
|
||||
var boradcastReceiver = new DownloadReceiver(refrence);
|
||||
mContext.RegisterReceiver(boradcastReceiver, intentFilter);
|
||||
|
||||
/*备注:服务器端apk文件mime类型为application/vnd.android.package-archive
|
||||
* 需要权限:android.permission.INTERNET和android.permission.WRITE_EXTERNAL_STORAGE
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义下载更新
|
||||
/// </summary>
|
||||
/// <param name="mContext"></param>
|
||||
/// <param name="apkAddress"></param>
|
||||
public void DownloadUpdateFile2(Context mContext, String apkAddress)
|
||||
{
|
||||
//权限检查
|
||||
if (mContext.CheckSelfPermission(Android.Manifest.Permission.WriteExternalStorage) != Android.Content.PM.Permission.Granted)
|
||||
{
|
||||
MainActivity.Instance.RequestPermissions(new string[] { Android.Manifest.Permission.WriteExternalStorage }, 1001);
|
||||
return;
|
||||
}
|
||||
|
||||
Java.IO.FileOutputStream outputStream = null;
|
||||
System.IO.Stream inputStream = null;
|
||||
Java.Net.HttpURLConnection connection = null;
|
||||
Java.IO.File installFile = null;
|
||||
try
|
||||
{
|
||||
var url = new Java.Net.URL(apkAddress);
|
||||
connection = (Java.Net.HttpURLConnection)url.OpenConnection();
|
||||
connection.ConnectTimeout = 60 * 1000;//1分钟
|
||||
connection.ReadTimeout = 60 * 10 * 1000;
|
||||
connection.Connect();
|
||||
if (connection.ResponseCode != Java.Net.HttpStatus.Ok)
|
||||
{
|
||||
var errorMessage = connection.ResponseCode.ToString() + " " + connection.ResponseMessage;
|
||||
return;
|
||||
}
|
||||
var contentLength = connection.ContentLength;
|
||||
inputStream = connection.InputStream;
|
||||
var downloadFile = Android.Net.Uri.FromFile(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads));
|
||||
installFile = new Java.IO.File(downloadFile.Path, System.IO.Path.GetFileName(apkAddress));
|
||||
outputStream = new Java.IO.FileOutputStream(installFile, false);//需要获取存储权限
|
||||
byte[] data = new byte[4096];
|
||||
long total = 0;
|
||||
int count;
|
||||
while ((count = inputStream.Read(data, 0, data.Length)) > 0)
|
||||
{
|
||||
total += count;
|
||||
outputStream.Write(data, 0, count);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Toast.MakeText(mContext, ex.Message, ToastLength.Long).Show();
|
||||
}
|
||||
|
||||
if (outputStream != null)
|
||||
outputStream.Close();
|
||||
if (inputStream != null)
|
||||
inputStream.Close();
|
||||
if (connection != null)
|
||||
connection.Disconnect();
|
||||
|
||||
if (installFile != null && installFile.Exists())
|
||||
{
|
||||
var installIntent = new Intent(Intent.ActionView);
|
||||
installIntent.SetDataAndType(Android.Net.Uri.FromFile(installFile), "application/vnd.android.package-archive");
|
||||
mContext.StartActivity(installIntent);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
169
XXCpzs.Android/MainActivity.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using Acr.UserDialogs;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Plugin.CurrentActivity;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
using ZXing.Mobile;
|
||||
|
||||
namespace XXCpzs.Droid
|
||||
{
|
||||
[Activity(Label = "XXCpzs", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||
{
|
||||
internal static Context mContext { get; private set; }
|
||||
internal static MainActivity Instance { get; private set; }
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
TabLayoutResource = Resource.Layout.Tabbar;
|
||||
ToolbarResource = Resource.Layout.Toolbar;
|
||||
|
||||
//var uiOpts = SystemUiFlags.LayoutStable | SystemUiFlags.LayoutFullscreen;
|
||||
//LayoutStable表示布局稳定,不随其他变动而变动
|
||||
//LayoutFullscreen表示把布局拓宽到全屏幕
|
||||
//Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOpts;
|
||||
//把标题栏设置为透明色
|
||||
// Window.SetStatusBarColor(Android.Graphics.Color.Argb(0, 0, 0, 0));
|
||||
|
||||
|
||||
base.OnCreate(savedInstanceState);
|
||||
Instance = this;
|
||||
mContext = this;
|
||||
|
||||
UserDialogs.Init(this);
|
||||
Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);
|
||||
|
||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
//初始化代码
|
||||
CrossCurrentActivity.Current.Init(this, savedInstanceState);
|
||||
MobileBarcodeScanner.Initialize(Application);
|
||||
LoadApplication(new App());
|
||||
DependencyService.Register<XXCpzs.Services.ITextToSpeechService, Services.TextToSpeechService>();
|
||||
}
|
||||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
||||
{
|
||||
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region --自动更新--
|
||||
|
||||
/// <summary>
|
||||
/// 使用DownloadManager下载安装文件
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="apkAddress"></param>
|
||||
public void DownloadUpdateFile(string apkAddress)
|
||||
{
|
||||
var apkFileName = System.IO.Path.GetFileName(apkAddress);
|
||||
DownloadManager.Request request = new DownloadManager.Request(Android.Net.Uri.Parse(apkAddress));
|
||||
// request.SetAllowedNetworkTypes(DownloadNetwork.Wifi);//网络环境
|
||||
//request.SetDestinationInExternalPublicDir("download", "update1.apk");
|
||||
request.SetDestinationInExternalFilesDir(this, Android.OS.Environment.DirectoryDownloads, apkFileName);
|
||||
request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
|
||||
request.SetMimeType("application/vnd.android.package-archive");
|
||||
//设置通知信息
|
||||
request.SetTitle(apkFileName);
|
||||
request.SetDescription("软件更新");
|
||||
//设置为可见和可管理
|
||||
request.SetVisibleInDownloadsUi(true);
|
||||
//设置为可被媒体扫描器找到
|
||||
request.AllowScanningByMediaScanner();
|
||||
request.SetAllowedOverRoaming(false);
|
||||
|
||||
//下载管理
|
||||
DownloadManager downManager = (DownloadManager)this.GetSystemService(Context.DownloadService);
|
||||
//获取此次下载的ID,返回一个唯一编号(用于识别通知来源)
|
||||
var refrence = downManager.Enqueue(request);
|
||||
|
||||
// 注册广播监听系统的下载完成事件。
|
||||
IntentFilter intentFilter = new IntentFilter(DownloadManager.ActionDownloadComplete);
|
||||
var boradcastReceiver = new DownloadReceiver(refrence);
|
||||
this.RegisterReceiver(boradcastReceiver, intentFilter);
|
||||
|
||||
/*备注:服务器端apk文件mime类型为application/vnd.android.package-archive
|
||||
* 需要权限:android.permission.INTERNET和android.permission.WRITE_EXTERNAL_STORAGE
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义下载更新
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="apkAddress"></param>
|
||||
public void DownloadUpdateFile2(Context context, String apkAddress)
|
||||
{
|
||||
//权限检查
|
||||
if (context.CheckSelfPermission(Android.Manifest.Permission.WriteExternalStorage) != Android.Content.PM.Permission.Granted)
|
||||
{
|
||||
this.RequestPermissions(new string[] { Android.Manifest.Permission.WriteExternalStorage }, 1001);
|
||||
return;
|
||||
}
|
||||
|
||||
Java.IO.FileOutputStream outputStream = null;
|
||||
System.IO.Stream inputStream = null;
|
||||
Java.Net.HttpURLConnection connection = null;
|
||||
Java.IO.File installFile = null;
|
||||
try
|
||||
{
|
||||
var url = new Java.Net.URL(apkAddress);
|
||||
connection = (Java.Net.HttpURLConnection)url.OpenConnection();
|
||||
connection.ConnectTimeout = 60 * 1000;//1分钟
|
||||
connection.ReadTimeout = 60 * 10 * 1000;
|
||||
connection.Connect();
|
||||
if (connection.ResponseCode != Java.Net.HttpStatus.Ok)
|
||||
{
|
||||
var errorMessage = connection.ResponseCode.ToString() + " " + connection.ResponseMessage;
|
||||
return;
|
||||
}
|
||||
var contentLength = connection.ContentLength;
|
||||
inputStream = connection.InputStream;
|
||||
var downloadFile = Android.Net.Uri.FromFile(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads));
|
||||
installFile = new Java.IO.File(downloadFile.Path, System.IO.Path.GetFileName(apkAddress));
|
||||
outputStream = new Java.IO.FileOutputStream(installFile, false);//需要获取存储权限
|
||||
byte[] data = new byte[4096];
|
||||
long total = 0;
|
||||
int count;
|
||||
while ((count = inputStream.Read(data, 0, data.Length)) > 0)
|
||||
{
|
||||
total += count;
|
||||
outputStream.Write(data, 0, count);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
|
||||
}
|
||||
|
||||
if (outputStream != null)
|
||||
outputStream.Close();
|
||||
if (inputStream != null)
|
||||
inputStream.Close();
|
||||
if (connection != null)
|
||||
connection.Disconnect();
|
||||
|
||||
if (installFile != null && installFile.Exists())
|
||||
{
|
||||
var installIntent = new Intent(Intent.ActionView);
|
||||
installIntent.SetDataAndType(Android.Net.Uri.FromFile(installFile), "application/vnd.android.package-archive");
|
||||
context.StartActivity(installIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
9
XXCpzs.Android/Properties/AndroidManifest.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.01" package="com.xixingwl.xxcpzs" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
|
||||
<application android:label="XXCpzs" android:icon="@drawable/icon"></application>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
</manifest>
|
||||
34
XXCpzs.Android/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("XXCpzs.Android")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("XXCpzs.Android")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
// Add some common permissions, these can be removed if not needed
|
||||
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
|
||||
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
|
||||
50
XXCpzs.Android/Resources/AboutResources.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||
in your application as resource files. Various Android APIs are designed to
|
||||
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||
directly.
|
||||
|
||||
For example, a sample Android app that contains a user interface layout (main.xml),
|
||||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||
would keep its resources in the "Resources" directory of the application:
|
||||
|
||||
Resources/
|
||||
drawable-hdpi/
|
||||
icon.png
|
||||
|
||||
drawable-ldpi/
|
||||
icon.png
|
||||
|
||||
drawable-mdpi/
|
||||
icon.png
|
||||
|
||||
layout/
|
||||
main.xml
|
||||
|
||||
values/
|
||||
strings.xml
|
||||
|
||||
In order to get the build system to recognize Android resources, set the build action to
|
||||
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||
the build system will package the resources for distribution and generate a class called
|
||||
"Resource" that contains the tokens for each one of the resources included. For example,
|
||||
for the above Resources layout, this is what the Resource class would expose:
|
||||
|
||||
public class Resource {
|
||||
public class drawable {
|
||||
public const int icon = 0x123;
|
||||
}
|
||||
|
||||
public class layout {
|
||||
public const int main = 0x456;
|
||||
}
|
||||
|
||||
public class strings {
|
||||
public const int first_string = 0xabc;
|
||||
public const int second_string = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
|
||||
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
|
||||
string in the dictionary file values/strings.xml.
|
||||
14215
XXCpzs.Android/Resources/Resource.designer.cs
generated
Normal file
BIN
XXCpzs.Android/Resources/drawable/ico.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_Quit.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_Register.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_cangku.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_chucang.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_customer.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_hh.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_login.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_order.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_pack.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_resale.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_sale.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_search.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_th.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
XXCpzs.Android/Resources/drawable/ico_weixiu.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
XXCpzs.Android/Resources/drawable/icon.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/drawable/loading.gif
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
XXCpzs.Android/Resources/drawable/xamarin_logo.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
11
XXCpzs.Android/Resources/layout/Tabbar.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/sliding_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabGravity="fill"
|
||||
app:tabMode="fixed" />
|
||||
9
XXCpzs.Android/Resources/layout/Toolbar.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<android.support.v7.widget.Toolbar
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
5
XXCpzs.Android/Resources/mipmap-anydpi-v26/icon.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/launcher_background" />
|
||||
<foreground android:drawable="@mipmap/launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/launcher_background" />
|
||||
<foreground android:drawable="@mipmap/launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
XXCpzs.Android/Resources/mipmap-hdpi/icon.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/mipmap-hdpi/launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
XXCpzs.Android/Resources/mipmap-mdpi/icon.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/mipmap-mdpi/launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
XXCpzs.Android/Resources/mipmap-xhdpi/icon.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/mipmap-xhdpi/launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
XXCpzs.Android/Resources/mipmap-xxhdpi/icon.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/mipmap-xxhdpi/launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
XXCpzs.Android/Resources/mipmap-xxxhdpi/icon.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
XXCpzs.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
7
XXCpzs.Android/Resources/values/colors.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="launcher_background">#FFFFFF</color>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
30
XXCpzs.Android/Resources/values/styles.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<resources>
|
||||
|
||||
<style name="MainTheme" parent="MainTheme.Base">
|
||||
</style>
|
||||
<!-- Base theme applied no matter what API -->
|
||||
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
|
||||
<item name="windowNoTitle">true</item>
|
||||
<!--We will be using the toolbar so no need to show ActionBar-->
|
||||
<item name="windowActionBar">false</item>
|
||||
<!-- Set theme colors from https://aka.ms/material-colors -->
|
||||
<!-- colorPrimary is used for the default action bar background -->
|
||||
<item name="colorPrimary">#2196F3</item>
|
||||
<!-- colorPrimaryDark is used for the status bar -->
|
||||
<item name="colorPrimaryDark">#1976D2</item>
|
||||
<!-- colorAccent is used as the default value for colorControlActivated
|
||||
which is used to tint widgets -->
|
||||
<item name="colorAccent">#FF4081</item>
|
||||
<!-- You can also set colorControlNormal, colorControlActivated
|
||||
colorControlHighlight and colorSwitchThumbNormal. -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
|
||||
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="colorAccent">#FF4081</item>
|
||||
</style>
|
||||
</resources>
|
||||
121
XXCpzs.Android/Services/CommonService.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.Content.Res;
|
||||
using Android.Media;
|
||||
using Android.OS;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
using XXCpzs.Droid.Services;
|
||||
using XXCpzs.Services;
|
||||
|
||||
[assembly: Dependency(typeof(CommonService))]
|
||||
namespace XXCpzs.Droid.Services
|
||||
{
|
||||
public class CommonService : ICommonService
|
||||
{
|
||||
public string GetVersion()
|
||||
{
|
||||
string version = "1.00";
|
||||
try
|
||||
{
|
||||
PackageManager packageManager = MainActivity.Instance.PackageManager;
|
||||
// getPackageName()是你当前类的包名,0代表是获取版本信息
|
||||
PackageInfo packInfo = packageManager.GetPackageInfo(MainActivity.Instance.PackageName, 0);
|
||||
|
||||
version = packInfo.VersionName;
|
||||
}
|
||||
catch (PackageManager.NameNotFoundException e)
|
||||
{
|
||||
// e.printStackTrace();
|
||||
}
|
||||
return version;
|
||||
}
|
||||
public void CloseApp()
|
||||
{
|
||||
//App.Current.Quit();
|
||||
Process.KillProcess(Process.MyPid());
|
||||
}
|
||||
public void UpdateApp(string DownloadUrl)
|
||||
{
|
||||
|
||||
var thread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
|
||||
{
|
||||
|
||||
//更新方式1
|
||||
FileDownload.DownloadUpdateFile(MainActivity.Instance, DownloadUrl);
|
||||
//更新方式2
|
||||
//DownloadUpdateFile2(context, upadtePackageAddress);
|
||||
}))
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
thread.Start();
|
||||
|
||||
}
|
||||
// Unique ID for our notification:
|
||||
static readonly int NOTIFICATION_ID = 1000;
|
||||
static readonly string CHANNEL_ID = "location_notification";
|
||||
internal static readonly string COUNT_KEY = "count";
|
||||
|
||||
// Number of times the button is tapped (starts with first tap):
|
||||
int count = 1;
|
||||
public void SendNotity(string title, string content)
|
||||
{
|
||||
// 将当前按钮按下计数值传递给下一个活动:
|
||||
var valuesForActivity = new Bundle();
|
||||
valuesForActivity.PutInt(COUNT_KEY, count);
|
||||
|
||||
//当用户单击通知时,将启动第二个活动。
|
||||
var resultIntent = new Intent(MainActivity.mContext, typeof(MainActivity));
|
||||
|
||||
// 将一些值传递给 Activity
|
||||
resultIntent.PutExtras(valuesForActivity);
|
||||
|
||||
// 构建跨任务导航的后堆栈:
|
||||
var stackBuilder = TaskStackBuilder.Create(MainActivity.mContext);
|
||||
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
|
||||
stackBuilder.AddNextIntent(resultIntent);
|
||||
|
||||
var resultPendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent);
|
||||
|
||||
// 使用后堆栈创建PendingEntent
|
||||
var builder = new Android.Support.V4.App.NotificationCompat.Builder(MainActivity.mContext, CHANNEL_ID)
|
||||
.SetAutoCancel(true) // 当用户单击通知时,从通知区域中取消通知
|
||||
.SetContentIntent(resultPendingIntent) // 当用户单击意图时启动此活动。
|
||||
.SetContentTitle("Button Clicked") // 设置标题
|
||||
.SetNumber(count) //在内容信息中显示计数
|
||||
.SetSmallIcon(Resource.Drawable.ico) // 这是要显示的图标
|
||||
.SetContentText($"The button has been clicked {count} times."); // 要显示的消息。
|
||||
|
||||
// 最后,发布通知
|
||||
var notificationManager = Android.Support.V4.App.NotificationManagerCompat.From(MainActivity.mContext);
|
||||
notificationManager.Notify(NOTIFICATION_ID, builder.Build());
|
||||
|
||||
// 增加按钮按下次数
|
||||
count++;
|
||||
}
|
||||
|
||||
void CreateNotificationChannel()
|
||||
{
|
||||
if (Build.VERSION.SdkInt < BuildVersionCodes.O)
|
||||
{
|
||||
//通知通道在API 26中是新的(不是 支持库)。不需要创建通知
|
||||
|
||||
//Android旧版本上的频道。
|
||||
return;
|
||||
}
|
||||
|
||||
//var name = Resources.GetString(Resource.String.channel_name);
|
||||
//var description =MainActivity.Instance. GetString("The count from MainActivity.");
|
||||
var channel = new NotificationChannel(CHANNEL_ID, "Local Notifications", NotificationImportance.Default)
|
||||
{
|
||||
Description = "The count from MainActivity."
|
||||
};
|
||||
var notificationManager = (NotificationManager)MainActivity.mContext. GetSystemService(Context. NotificationService);
|
||||
notificationManager.CreateNotificationChannel(channel);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
171
XXCpzs.Android/Services/NetworkConnection.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
using Android.Content.PM;
|
||||
using Android.OS;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
using XXCpzs.Droid.Services;
|
||||
using XXCpzs.Services;
|
||||
using XXCpzs.Droid;
|
||||
using Android.Net;
|
||||
using Android.Locations;
|
||||
using Android.Content;
|
||||
using Android.Telephony;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
[assembly: Dependency(typeof(NetworkConnection))] //的作用是将该类依赖于程序集,以便在可移植平台底下实例化接口。
|
||||
|
||||
namespace XXCpzs.Droid
|
||||
{
|
||||
public class NetworkConnection : INetworkConnection
|
||||
{
|
||||
//没有网络
|
||||
public const int NETWORKTYPE_INVALID = 0;
|
||||
//wap网络
|
||||
public const int NETWORKTYPE_WAP = 1;
|
||||
//2G网络
|
||||
public const int NETWORKTYPE_2G = 2;
|
||||
//3G和3G以上网络,或统称为快速网络
|
||||
public const int NETWORKTYPE_3G = 3;
|
||||
//wifi网络
|
||||
public const int NETWORKTYPE_WIFI = 4;
|
||||
public bool IsConnected { get; set; }
|
||||
//判断是否有网络连接
|
||||
public void CheckNetworkConnection()
|
||||
{
|
||||
var current = Connectivity.NetworkAccess;
|
||||
|
||||
if (current == NetworkAccess.Internet)
|
||||
{
|
||||
IsConnected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsConnected = false;
|
||||
}
|
||||
}
|
||||
//检查启用了网络位置提供商报告
|
||||
public bool isNetLocEnabled()
|
||||
{
|
||||
LocationManager locMgr = MainActivity.mContext.GetSystemService(Context.LocationService) as LocationManager;
|
||||
return locMgr.IsProviderEnabled(LocationManager.NetworkProvider);
|
||||
}
|
||||
//判断是否有WIFI连接
|
||||
public bool isWifiConnected(Context context)
|
||||
{
|
||||
if (context != null)
|
||||
{
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService);
|
||||
NetworkInfo mWiFiNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityType.Wifi);
|
||||
//NetworkInfo mWiFiNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if (mWiFiNetworkInfo != null)
|
||||
{
|
||||
return mWiFiNetworkInfo.IsAvailable;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//判断Mobile网络是否可用
|
||||
public bool isMobileConnected(Context context)
|
||||
{
|
||||
if (context != null)
|
||||
{
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService);
|
||||
NetworkInfo mMobileNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityType.Mobile);
|
||||
//NetworkInfo mMobileNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
if (mMobileNetworkInfo != null)
|
||||
{
|
||||
return mMobileNetworkInfo.IsAvailable;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//检查飞行模式 - 我们要关闭飞机模式
|
||||
//public bool confirmAirplaneModeOff(Context context)
|
||||
//{
|
||||
//int airplaneSetting = Settings.System.GetInt(context.ContentResolver, Settings.System.AirplaneModeOn, 0);
|
||||
//int airplaneSetting = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0);
|
||||
//return airplaneSetting == 0;
|
||||
//}
|
||||
//确定网络位置提供程序是否真的可用
|
||||
// public bool isNetlocUsable(Context context)
|
||||
// {
|
||||
// return isNetLocEnabled(context) && confirmAirplaneModeOff(context) && isWifiConnected(context) && isMobileConnected(context);
|
||||
// }
|
||||
//判断是否是FastMobileNetWork,将3G或者3G以上的网络称为快速网络
|
||||
private static bool isFastMobileNetwork(Context context)
|
||||
{
|
||||
TelephonyManager telephonyManager = (TelephonyManager)context.GetSystemService(Context.TelephonyService);
|
||||
switch (telephonyManager.NetworkType)
|
||||
{
|
||||
case NetworkType.OneXrtt:
|
||||
return false; // ~ 50-100 kbps
|
||||
case NetworkType.Cdma:
|
||||
return false; // ~ 14-64 kbps
|
||||
case NetworkType.Edge:
|
||||
return false; // ~ 50-100 kbps
|
||||
case NetworkType.Evdo0:
|
||||
return true; // ~ 400-1000 kbps
|
||||
case NetworkType.EvdoA:
|
||||
return true; // ~ 600-1400 kbps
|
||||
case NetworkType.Gprs:
|
||||
return false; // ~ 100 kbps
|
||||
case NetworkType.Hsdpa:
|
||||
return true; // ~ 2-14 Mbps
|
||||
case NetworkType.Hspa:
|
||||
return true; // ~ 700-1700 kbps
|
||||
case NetworkType.Hsupa:
|
||||
return true; // ~ 1-23 Mbps
|
||||
case NetworkType.Umts:
|
||||
return true; // ~ 400-7000 kbps
|
||||
case NetworkType.Ehrpd:
|
||||
return true; // ~ 1-2 Mbps
|
||||
case NetworkType.EvdoB:
|
||||
return true; // ~ 5 Mbps
|
||||
case NetworkType.Hspap:
|
||||
return true; // ~ 10-20 Mbps
|
||||
case NetworkType.Iden:
|
||||
return false; // ~25 kbps
|
||||
case NetworkType.Lte:
|
||||
return true; // ~ 10+ Mbps
|
||||
case NetworkType.Unknown:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//获取网络状态,wifi,wap,2g,3g.
|
||||
/// <summary>
|
||||
/// context 上下文
|
||||
/// return int 网络状态 {@link #NETWORKTYPE_2G},{@link #NETWORKTYPE_3G}
|
||||
/// {@link #NETWORKTYPE_INVALID},{@link #NETWORKTYPE_WAP}* <p>{@link #NETWORKTYPE_WIFI}
|
||||
/// </summary>
|
||||
public static int getNetWorkType(Context context)
|
||||
{
|
||||
int mNetWorkType = 0;
|
||||
ConnectivityManager manager = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService);
|
||||
NetworkInfo networkInfo = manager.ActiveNetworkInfo;
|
||||
|
||||
|
||||
if (networkInfo != null && networkInfo.IsConnected)
|
||||
{
|
||||
String type = networkInfo.TypeName;
|
||||
|
||||
|
||||
if (type.Equals("WIFI".ToUpper()))
|
||||
{
|
||||
mNetWorkType = NETWORKTYPE_WIFI;
|
||||
}
|
||||
else if (type.Equals("MOBILE".ToUpper()))
|
||||
{
|
||||
String proxyHost = Proxy.DefaultHost;
|
||||
//String proxyHost = android.net.Proxy.getDefaultHost();
|
||||
//mNetWorkType = TextUtils.IsEmpty(proxyHost) ? (isFastMobileNetwork(context) ? NETWORKTYPE_3G : NETWORKTYPE_2G) : NETWORKTYPE_WAP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetWorkType = NETWORKTYPE_INVALID;
|
||||
}
|
||||
return mNetWorkType;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
XXCpzs.Android/Services/NotifyService.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
|
||||
namespace XXCpzs.Droid.Services
|
||||
{
|
||||
class NotifyService
|
||||
{
|
||||
}
|
||||
}
|
||||
83
XXCpzs.Android/Services/TextToSpeechService.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Android.Speech.Tts;
|
||||
using XXCpzs.Services;
|
||||
|
||||
namespace XXCpzs.Droid.Services
|
||||
{
|
||||
public class TextToSpeechService : Java.Lang.Object, ITextToSpeechService, TextToSpeech.IOnInitListener,
|
||||
#pragma warning disable CS0618
|
||||
TextToSpeech.IOnUtteranceCompletedListener
|
||||
#pragma warning restore CS0618
|
||||
{
|
||||
TextToSpeech speaker;
|
||||
TaskCompletionSource<bool> tcsInitialize;
|
||||
TaskCompletionSource<bool> tcsUtterance;
|
||||
|
||||
Task<bool> Initialize()
|
||||
{
|
||||
if (tcsInitialize != null)
|
||||
return tcsInitialize.Task;
|
||||
|
||||
tcsInitialize = new TaskCompletionSource<bool>();
|
||||
try
|
||||
{
|
||||
speaker = new TextToSpeech(MainActivity.Instance, this);
|
||||
#pragma warning disable CS0618
|
||||
speaker.SetOnUtteranceCompletedListener(this);
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tcsInitialize.TrySetException(ex);
|
||||
}
|
||||
return tcsInitialize.Task;
|
||||
}
|
||||
|
||||
public async Task SpeakAsync(string text)
|
||||
{
|
||||
await Initialize();
|
||||
|
||||
if (tcsUtterance?.Task != null)
|
||||
await tcsUtterance.Task;
|
||||
|
||||
tcsUtterance = new TaskCompletionSource<bool>();
|
||||
|
||||
// Set the utterance id so the completed listener fires
|
||||
var parameters = new Dictionary<string, string>();
|
||||
parameters.Add(TextToSpeech.Engine.KeyParamUtteranceId, new Guid().ToString());
|
||||
|
||||
// Use an obsolete overload so it works on older API levels
|
||||
#pragma warning disable CS0618
|
||||
speaker.Speak(text, QueueMode.Flush, parameters);
|
||||
#pragma warning restore CS0618
|
||||
await tcsUtterance.Task;
|
||||
}
|
||||
|
||||
public void OnInit(OperationResult status)
|
||||
{
|
||||
if (status.Equals(OperationResult.Success))
|
||||
tcsInitialize.TrySetResult(true);
|
||||
else
|
||||
tcsInitialize.TrySetException(new ArgumentException("Failed to initialize TTS engine."));
|
||||
}
|
||||
|
||||
public void OnUtteranceCompleted(string utteranceId)
|
||||
{
|
||||
tcsUtterance.TrySetResult(true);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
speaker?.Stop();
|
||||
speaker?.Shutdown();
|
||||
speaker = null;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
171
XXCpzs.Android/XXCpzs.Android.csproj
Normal file
@@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C0C1A1B5-9459-42ED-96AA-632294020CFE}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TemplateGuid>{9AA2D3C6-3393-45F1-8E7C-5A9901728795}</TemplateGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>XXCpzs.Droid</RootNamespace>
|
||||
<AssemblyName>XXCpzs.Android</AssemblyName>
|
||||
<AndroidApplication>True</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
|
||||
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
|
||||
<AndroidUseAapt2>true</AndroidUseAapt2>
|
||||
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>portable</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<AotAssemblies>false</AotAssemblies>
|
||||
<EnableLLVM>false</EnableLLVM>
|
||||
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
|
||||
<BundleAssemblies>false</BundleAssemblies>
|
||||
<AndroidUseAapt2>true</AndroidUseAapt2>
|
||||
<AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
|
||||
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
|
||||
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>portable</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidManagedSymbols>true</AndroidManagedSymbols>
|
||||
<AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
|
||||
<AotAssemblies>false</AotAssemblies>
|
||||
<EnableLLVM>false</EnableLLVM>
|
||||
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
||||
<BundleAssemblies>false</BundleAssemblies>
|
||||
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
|
||||
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Xamarin.Forms" Version="4.3.0.908675" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DownloadReceiver.cs" />
|
||||
<Compile Include="FileDownload.cs" />
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\CommonService.cs" />
|
||||
<Compile Include="Services\NetworkConnection.cs" />
|
||||
<Compile Include="Services\NotifyService.cs" />
|
||||
<Compile Include="Services\TextToSpeechService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Assets\AboutAssets.txt" />
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Tabbar.xml" />
|
||||
<AndroidResource Include="Resources\layout\Toolbar.xml" />
|
||||
<AndroidResource Include="Resources\values\styles.xml" />
|
||||
<AndroidResource Include="Resources\values\colors.xml" />
|
||||
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon.xml" />
|
||||
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon_round.xml" />
|
||||
<AndroidResource Include="Resources\mipmap-hdpi\launcher_foreground.png" />
|
||||
<AndroidResource Include="Resources\mipmap-mdpi\launcher_foreground.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xhdpi\icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xhdpi\launcher_foreground.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxhdpi\icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxhdpi\launcher_foreground.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
|
||||
<AndroidResource Include="Resources\drawable\xamarin_logo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\XXCpzs\XXCpzs.csproj">
|
||||
<Project>{84264E36-B135-4ECF-9C36-4E298D158A2E}</Project>
|
||||
<Name>XXCpzs</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_cangku.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_chucang.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_customer.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_hh.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_login.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_order.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_pack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_Quit.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_Register.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_resale.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_sale.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_search.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_th.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico_weixiu.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\loading.gif" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\mipmap-hdpi\icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\ico.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\mipmap-mdpi\icon.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
||||
79
XXCpzs.MobileAppService/Controllers/ItemController.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using XXCpzs.Models;
|
||||
|
||||
namespace XXCpzs.Controllers
|
||||
{
|
||||
[Route("api/item")]
|
||||
[ApiController]
|
||||
public class ItemController : ControllerBase
|
||||
{
|
||||
private readonly IItemRepository ItemRepository;
|
||||
|
||||
public ItemController(IItemRepository itemRepository)
|
||||
{
|
||||
ItemRepository = itemRepository;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ActionResult<IEnumerable<Item>> List()
|
||||
{
|
||||
return ItemRepository.GetAll().ToList();
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public ActionResult<Item> GetItem(string id)
|
||||
{
|
||||
Item item = ItemRepository.Get(id);
|
||||
|
||||
if (item == null)
|
||||
return NotFound();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public ActionResult<Item> Create([FromBody]Item item)
|
||||
{
|
||||
ItemRepository.Add(item);
|
||||
return CreatedAtAction(nameof(GetItem), new { item.Id }, item);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public ActionResult Edit([FromBody] Item item)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemRepository.Update(item);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return BadRequest("Error while editing item");
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public ActionResult Delete(string id)
|
||||
{
|
||||
Item item = ItemRepository.Remove(id);
|
||||
|
||||
if (item == null)
|
||||
return NotFound();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
XXCpzs.MobileAppService/Models/IItemRepository.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XXCpzs.Models
|
||||
{
|
||||
public interface IItemRepository
|
||||
{
|
||||
void Add(Item item);
|
||||
void Update(Item item);
|
||||
Item Remove(string key);
|
||||
Item Get(string id);
|
||||
IEnumerable<Item> GetAll();
|
||||
}
|
||||
}
|
||||
16
XXCpzs.MobileAppService/Models/Item.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace XXCpzs.Models
|
||||
{
|
||||
public class Item
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Text { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
47
XXCpzs.MobileAppService/Models/ItemRepository.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace XXCpzs.Models
|
||||
{
|
||||
public class ItemRepository : IItemRepository
|
||||
{
|
||||
private static ConcurrentDictionary<string, Item> items =
|
||||
new ConcurrentDictionary<string, Item>();
|
||||
|
||||
public ItemRepository()
|
||||
{
|
||||
Add(new Item { Id = Guid.NewGuid().ToString(), Text = "Item 1", Description = "This is an item description." });
|
||||
Add(new Item { Id = Guid.NewGuid().ToString(), Text = "Item 2", Description = "This is an item description." });
|
||||
Add(new Item { Id = Guid.NewGuid().ToString(), Text = "Item 3", Description = "This is an item description." });
|
||||
}
|
||||
|
||||
public IEnumerable<Item> GetAll()
|
||||
{
|
||||
return items.Values;
|
||||
}
|
||||
|
||||
public void Add(Item item)
|
||||
{
|
||||
item.Id = Guid.NewGuid().ToString();
|
||||
items[item.Id] = item;
|
||||
}
|
||||
|
||||
public Item Get(string id)
|
||||
{
|
||||
items.TryGetValue(id, out Item item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public Item Remove(string id)
|
||||
{
|
||||
items.TryRemove(id, out Item item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void Update(Item item)
|
||||
{
|
||||
items[item.Id] = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
XXCpzs.MobileAppService/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace XXCpzs.MobileAppService
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
30
XXCpzs.MobileAppService/Properties/launchSettings.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:53100",
|
||||
"sslPort": 44300
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/item",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"XXCpzs.MobileAppService": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/item",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
XXCpzs.MobileAppService/Startup.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using XXCpzs.Models;
|
||||
|
||||
namespace XXCpzs.MobileAppService
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
services.AddSingleton<IItemRepository, ItemRepository>();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
7
XXCpzs.MobileAppService/XXCpzs.MobileAppService.csproj
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
9
XXCpzs.MobileAppService/appsettings.Development.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
XXCpzs.MobileAppService/appsettings.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
},
|
||||
"Console": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
31
XXCpzs.iOS/AppDelegate.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace XXCpzs.iOS
|
||||
{
|
||||
// The UIApplicationDelegate for the application. This class is responsible for launching the
|
||||
// User Interface of the application, as well as listening (and optionally responding) to
|
||||
// application events from iOS.
|
||||
[Register("AppDelegate")]
|
||||
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
|
||||
{
|
||||
//
|
||||
// This method is invoked when the application has loaded and is ready to run. In this
|
||||
// method you should instantiate the window, load the UI into it and then make the window
|
||||
// visible.
|
||||
//
|
||||
// You have 17 seconds to return from this method, or iOS will terminate your application.
|
||||
//
|
||||
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
||||
{
|
||||
global::Xamarin.Forms.Forms.Init();
|
||||
LoadApplication(new App());
|
||||
|
||||
return base.FinishedLaunching(app, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
117
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "20x20",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon40.png"
|
||||
},
|
||||
{
|
||||
"scale": "3x",
|
||||
"size": "20x20",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon60.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "29x29",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon58.png"
|
||||
},
|
||||
{
|
||||
"scale": "3x",
|
||||
"size": "29x29",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon87.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "40x40",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon80.png"
|
||||
},
|
||||
{
|
||||
"scale": "3x",
|
||||
"size": "40x40",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon120.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "60x60",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon120.png"
|
||||
},
|
||||
{
|
||||
"scale": "3x",
|
||||
"size": "60x60",
|
||||
"idiom": "iphone",
|
||||
"filename": "Icon180.png"
|
||||
},
|
||||
{
|
||||
"scale": "1x",
|
||||
"size": "20x20",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon20.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "20x20",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon40.png"
|
||||
},
|
||||
{
|
||||
"scale": "1x",
|
||||
"size": "29x29",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon29.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "29x29",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon58.png"
|
||||
},
|
||||
{
|
||||
"scale": "1x",
|
||||
"size": "40x40",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon40.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "40x40",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon80.png"
|
||||
},
|
||||
{
|
||||
"scale": "1x",
|
||||
"size": "76x76",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon76.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "76x76",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon152.png"
|
||||
},
|
||||
{
|
||||
"scale": "2x",
|
||||
"size": "83.5x83.5",
|
||||
"idiom": "ipad",
|
||||
"filename": "Icon167.png"
|
||||
},
|
||||
{
|
||||
"scale": "1x",
|
||||
"size": "1024x1024",
|
||||
"idiom": "ios-marketing",
|
||||
"filename": "Icon1024.png"
|
||||
}
|
||||
],
|
||||
"properties": {},
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
||||
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png
Normal file
|
After Width: | Height: | Size: 845 B |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
XXCpzs.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
7
XXCpzs.iOS/Entitlements.plist
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
38
XXCpzs.iOS/Info.plist
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>XXCpzs</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.companyname.XXCpzs</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>XXCpzs</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
</dict>
|
||||
</plist>
|
||||
20
XXCpzs.iOS/Main.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace XXCpzs.iOS
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
||||
140
XXCpzs.iOS/NetworkConnection.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using CoreFoundation;
|
||||
using System;
|
||||
using System.Net;
|
||||
using SystemConfiguration;
|
||||
using Xamarin.Forms;
|
||||
using XXCpzs.iOS;
|
||||
using XXCpzs.Services;
|
||||
|
||||
[assembly: Dependency(typeof(NetworkConnection))]
|
||||
namespace XXCpzs.iOS
|
||||
{
|
||||
public class NetworkConnection : INetworkConnection
|
||||
{
|
||||
//public NetworkConnection()
|
||||
//{
|
||||
// InternetConnectionStatus();
|
||||
//}
|
||||
public bool IsConnected { get; set; }
|
||||
public void CheckNetworkConnection()
|
||||
{
|
||||
InternetConnectionStatus();
|
||||
}
|
||||
|
||||
|
||||
private void UpdateNetworkStatus()
|
||||
{
|
||||
if (InternetConnectionStatus())
|
||||
{
|
||||
IsConnected = true;
|
||||
}
|
||||
else if (LocalWifiConnectionStatus())
|
||||
{
|
||||
IsConnected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private event EventHandler ReachabilityChanged;
|
||||
private void OnChange(NetworkReachabilityFlags flags)
|
||||
{
|
||||
var h = ReachabilityChanged;
|
||||
if (h != null)
|
||||
h(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
private NetworkReachability defaultRouteReachability;
|
||||
private bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
|
||||
{
|
||||
if (defaultRouteReachability == null)
|
||||
{
|
||||
defaultRouteReachability = new NetworkReachability(new IPAddress(0));
|
||||
defaultRouteReachability.SetNotification(OnChange);
|
||||
//defaultRouteReachability.SetCallback(OnChange);
|
||||
defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
|
||||
}
|
||||
if (!defaultRouteReachability.TryGetFlags(out flags))
|
||||
return false;
|
||||
return IsReachableWithoutRequiringConnection(flags);
|
||||
}
|
||||
|
||||
|
||||
private NetworkReachability adHocWiFiNetworkReachability;
|
||||
private bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
|
||||
{
|
||||
if (adHocWiFiNetworkReachability == null)
|
||||
{
|
||||
adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte[] { 169, 254, 0, 0 }));
|
||||
adHocWiFiNetworkReachability.SetNotification(OnChange);
|
||||
//adHocWiFiNetworkReachability.SetCallback(OnChange);
|
||||
adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
|
||||
}
|
||||
|
||||
|
||||
if (!adHocWiFiNetworkReachability.TryGetFlags(out flags))
|
||||
return false;
|
||||
|
||||
|
||||
return IsReachableWithoutRequiringConnection(flags);
|
||||
}
|
||||
|
||||
|
||||
public static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlags flags)
|
||||
{
|
||||
// 它是否可以与当前的网络配置联系在一起?
|
||||
bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;
|
||||
|
||||
|
||||
// 我们需要连接来达到它吗?
|
||||
bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;
|
||||
|
||||
|
||||
// 网络堆栈
|
||||
// 检查
|
||||
if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
|
||||
noConnectionRequired = true;
|
||||
|
||||
|
||||
return isReachable && noConnectionRequired;
|
||||
}
|
||||
|
||||
|
||||
private bool InternetConnectionStatus()
|
||||
{
|
||||
NetworkReachabilityFlags flags;
|
||||
bool defaultNetworkAvailable = IsNetworkAvailable(out flags);
|
||||
if (defaultNetworkAvailable && ((flags & NetworkReachabilityFlags.IsDirect) != 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (flags == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private bool LocalWifiConnectionStatus()
|
||||
{
|
||||
NetworkReachabilityFlags flags;
|
||||
if (IsAdHocWiFiNetworkAvailable(out flags))
|
||||
{
|
||||
if ((flags & NetworkReachabilityFlags.IsDirect) != 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
XXCpzs.iOS/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("XXCpzs.iOS")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("XXCpzs.iOS")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
BIN
XXCpzs.iOS/Resources/Default-568h@2x.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
XXCpzs.iOS/Resources/Default-Portrait.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
XXCpzs.iOS/Resources/Default-Portrait@2x.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
XXCpzs.iOS/Resources/Default.png
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
XXCpzs.iOS/Resources/Default@2x.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
39
XXCpzs.iOS/Resources/LaunchScreen.storyboard
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="X5k-f2-b5h">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="gAE-YM-kbH">
|
||||
<objects>
|
||||
<viewController id="X5k-f2-b5h" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Y8P-hJ-Z43"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="9ZL-r4-8FZ"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="yd7-JS-zBw">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" image="Icon-60.png" translatesAutoresizingMaskIntoConstraints="NO" id="23">
|
||||
<rect key="frame" x="270" y="270" width="60" height="60"/>
|
||||
<rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.20392156862745098" green="0.59607843137254901" blue="0.85882352941176465" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="23" firstAttribute="centerY" secondItem="yd7-JS-zBw" secondAttribute="centerY" priority="1" id="39"/>
|
||||
<constraint firstItem="23" firstAttribute="centerX" secondItem="yd7-JS-zBw" secondAttribute="centerX" priority="1" id="41"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="XAI-xm-WK6" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="349" y="339"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="Icon-60.png" width="180" height="180"/>
|
||||
</resources>
|
||||
</document>
|
||||
BIN
XXCpzs.iOS/Resources/tab_about.png
Normal file
|
After Width: | Height: | Size: 518 B |
BIN
XXCpzs.iOS/Resources/tab_about@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
XXCpzs.iOS/Resources/tab_about@3x.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
XXCpzs.iOS/Resources/tab_feed.png
Normal file
|
After Width: | Height: | Size: 415 B |
BIN
XXCpzs.iOS/Resources/tab_feed@2x.png
Normal file
|
After Width: | Height: | Size: 863 B |
BIN
XXCpzs.iOS/Resources/tab_feed@3x.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
XXCpzs.iOS/Resources/xamarin_logo.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
XXCpzs.iOS/Resources/xamarin_logo@2x.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
XXCpzs.iOS/Resources/xamarin_logo@3x.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
147
XXCpzs.iOS/XXCpzs.iOS.csproj
Normal file
@@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F9778D37-49CB-485A-A730-59249C48AA8C}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TemplateGuid>{65C0771A-452F-423B-995C-F0AE46E643BA}</TemplateGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>XXCpzs.iOS</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>XXCpzs.iOS</AssemblyName>
|
||||
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchInterpreter>-all</MtouchInterpreter>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<None Include="Entitlements.plist" />
|
||||
<None Include="Info.plist" />
|
||||
<Compile Include="NetworkConnection.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon1024.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon180.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon167.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon152.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon120.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon87.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon80.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon76.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon60.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon58.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon40.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon29.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon20.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<BundleResource Include="Resources\tab_about.png" />
|
||||
<BundleResource Include="Resources\tab_about%402x.png" />
|
||||
<BundleResource Include="Resources\tab_about%403x.png" />
|
||||
<BundleResource Include="Resources\tab_feed.png" />
|
||||
<BundleResource Include="Resources\tab_feed%402x.png" />
|
||||
<BundleResource Include="Resources\tab_feed%403x.png" />
|
||||
<BundleResource Include="Resources\xamarin_logo.png" />
|
||||
<BundleResource Include="Resources\xamarin_logo%402x.png" />
|
||||
<BundleResource Include="Resources\xamarin_logo%403x.png" />
|
||||
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Xamarin.Forms" Version="4.3.0.908675" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\XXCpzs\XXCpzs.csproj">
|
||||
<Project>{84264E36-B135-4ECF-9C36-4E298D158A2E}</Project>
|
||||
<Name>XXCpzs</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
103
XXCpzs.sln
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29905.134
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XXCpzs.Android", "XXCpzs.Android\XXCpzs.Android.csproj", "{C0C1A1B5-9459-42ED-96AA-632294020CFE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XXCpzs.iOS", "XXCpzs.iOS\XXCpzs.iOS.csproj", "{F9778D37-49CB-485A-A730-59249C48AA8C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XXCpzs", "XXCpzs\XXCpzs.csproj", "{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XXCPZSD", "..\XXCPZSD\XXCPZSD.csproj", "{E2776C97-D619-457A-9C48-1309BC69278D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|iPhone = Release|iPhone
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|iPhone.Deploy.0 = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|iPhone.Deploy.0 = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{C0C1A1B5-9459-42ED-96AA-632294020CFE}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|Any CPU.Deploy.0 = Debug|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|iPhone.Deploy.0 = Debug|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Debug|iPhoneSimulator.Deploy.0 = Debug|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|Any CPU.ActiveCfg = Release|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|Any CPU.Build.0 = Release|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|Any CPU.Deploy.0 = Release|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|iPhone.Deploy.0 = Release|iPhone
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
{F9778D37-49CB-485A-A730-59249C48AA8C}.Release|iPhoneSimulator.Deploy.0 = Release|iPhoneSimulator
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|iPhone.Deploy.0 = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|iPhone.Deploy.0 = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{3A95CF58-F38E-497C-BF39-CFBDFCCA7470}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|iPhone.Deploy.0 = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|iPhone.Deploy.0 = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{E2776C97-D619-457A-9C48-1309BC69278D}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BDF2FB8D-64C3-48ED-9DDD-7650818AC24F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
20
XXCpzs/App.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Application xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
x:Class="XXCpzs.App">
|
||||
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<!--Global Styles-->
|
||||
<Color x:Key="NavigationPrimary">#2196F3</Color>
|
||||
<Style TargetType="NavigationPage">
|
||||
<Setter Property="BarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
|
||||
<Setter Property="BarTextColor" Value="White" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
</Application>
|
||||
43
XXCpzs/App.xaml.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
using XXCpzs.IOInterface;
|
||||
using XXCpzs.Services;
|
||||
using XXCpzs.Views;
|
||||
|
||||
namespace XXCpzs
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
//TODO: Replace with *.azurewebsites.net url after deploying backend to Azure
|
||||
//To debug on Android emulators run the web backend against .NET Core not IIS
|
||||
//If using other emulators besides stock Google images you may need to adjust the IP address
|
||||
public static string AzureBackendUrl =
|
||||
DeviceInfo.Platform == DevicePlatform.Android ? "http://10.0.2.2:5000" : "http://localhost:5000";
|
||||
public static bool UseMockDataStore = true;
|
||||
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (UseMockDataStore)
|
||||
DependencyService.Register<MockDataStore>();
|
||||
else
|
||||
DependencyService.Register<AzureDataStore>();
|
||||
MainPage = new MainPage();
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnSleep()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnResume()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
3
XXCpzs/AssemblyInfo.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
132
XXCpzs/Helper/HttpHelper.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using XXCpzs.Models;
|
||||
|
||||
namespace XXCpzs.helper
|
||||
|
||||
{
|
||||
public class HttpHelper
|
||||
{
|
||||
public static async Task<ResultModel> RequestPost(int type, Dictionary<string, string> _body = null)
|
||||
{
|
||||
string _domain = string.Format(@"http://cpzs.xixingwl.cn/cpzs/Api/{0}.shtml", type);
|
||||
Console.WriteLine(">>>>" + _domain);
|
||||
var client = new RestClient
|
||||
{
|
||||
BaseUrl = new Uri(_domain),
|
||||
Timeout = 60000,
|
||||
//Authenticator = new HttpBasicAuthenticator("username", "password")
|
||||
};
|
||||
var request = new RestRequest
|
||||
{
|
||||
Timeout = 30000,
|
||||
Method = Method.POST
|
||||
};
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
request.AddHeader("Authorization", "Bearer123456");
|
||||
request.AddJsonBody(_body);
|
||||
var response = await client.ExecuteAsync<ResultModel>(request);
|
||||
Console.WriteLine(response.Content);
|
||||
if (response.IsSuccessful)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
return new ResultModel { Code = 500, Msg = "系统错误!" }; ;
|
||||
}
|
||||
|
||||
|
||||
/// send the get request based on HttpWebRequest
|
||||
/// </summary>
|
||||
/// <param name="requestUrl">the url you post</param>
|
||||
/// <param name="routeParameters">the parameters you post</param>
|
||||
/// <returns>return a response object</returns>
|
||||
public static List<T> RefreshData<T>(int type, Method method = Method.GET, Dictionary<string, string> _body = null)
|
||||
{
|
||||
string _domain = string.Format(@"http://cpzs.xixingwl.cn/cpzs/Api/{0}.shtml", type);
|
||||
Console.WriteLine(">>>>" + _domain);
|
||||
var client = new RestClient
|
||||
{
|
||||
BaseUrl = new Uri(_domain),
|
||||
Timeout = 60000,
|
||||
//Authenticator = new HttpBasicAuthenticator("username", "password")
|
||||
};
|
||||
var request = new RestRequest
|
||||
{
|
||||
Timeout = 30000,
|
||||
Method = method
|
||||
};
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
request.AddHeader("Authorization", "Bearer123456");
|
||||
request.AddJsonBody(_body);
|
||||
IRestResponse<ListModel<T>> response2 = client.Execute<ListModel<T>>(request);
|
||||
Console.WriteLine(response2.Content);
|
||||
if (response2.Data.Code == 200 && response2.Data.Data != null)
|
||||
{
|
||||
return response2.Data.Data;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static BaseModel<T> Refresh<T>(string type, Dictionary<string, string> _body = null)
|
||||
{
|
||||
string _domain = string.Format(@"http://cpzs.xixingwl.cn/addons/cpzs/Api/{0}.shtml", type);
|
||||
Console.WriteLine(">>>>" + _domain);
|
||||
var client = new RestClient
|
||||
{
|
||||
BaseUrl = new Uri(_domain),
|
||||
Timeout = 60000,
|
||||
//Authenticator = new HttpBasicAuthenticator("username", "password")
|
||||
};
|
||||
var request = new RestRequest
|
||||
{
|
||||
Timeout = 30000,
|
||||
Method = Method.POST
|
||||
};
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
request.AddHeader("Authorization", "Bearer123456");
|
||||
request.AddJsonBody(_body);
|
||||
IRestResponse<BaseModel<T>> response2 = client.Execute<BaseModel<T>>(request);
|
||||
if (response2.IsSuccessful)
|
||||
{
|
||||
Console.Write(">>>" + response2.Content);
|
||||
return response2.Data;
|
||||
}
|
||||
return new BaseModel<T>() { Code = 500, Msg = "系统错误!" };
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public enum RequestType {
|
||||
/// <summary>
|
||||
/// 授权验证
|
||||
/// </summary>
|
||||
noun,
|
||||
/// <summary>
|
||||
/// 设备软件验证
|
||||
/// </summary>
|
||||
verb,
|
||||
/// <summary>
|
||||
/// 注册接口
|
||||
/// </summary>
|
||||
reg ,//= "reg",
|
||||
/// <summary>
|
||||
/// 获取部门
|
||||
/// </summary>
|
||||
getdepartment
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
35
XXCpzs/Helper/Verification.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace XXCpzs.helper
|
||||
{
|
||||
public class Verification
|
||||
{
|
||||
// 验证电话号码的主要代码如下:
|
||||
public static bool IsTelephone(string str_telephone)
|
||||
{
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(str_telephone, @"^(\d{3,4}-)?\d{6,8}$");
|
||||
}
|
||||
//验证手机号码的主要代码如下:
|
||||
public static bool IsHandset(string str_handset)
|
||||
{
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^[1]+[3,5]+\d{9}");
|
||||
}
|
||||
// 验证身份证号的主要代码如下:
|
||||
public static bool IsIDcard(string str_idcard)
|
||||
{
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(str_idcard, @"(^\d{18}$)|(^\d{15}$)");
|
||||
}
|
||||
// 验证输入为数字的主要代码如下:
|
||||
public static bool IsNumber(string str_number)
|
||||
{
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(str_number, @"^[0-9]*$");
|
||||
}
|
||||
// 验证邮编的主要代码如下:
|
||||
public static bool IsPostalcode(string str_postalcode)
|
||||
{
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(str_postalcode, @"^\d{6}$");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
XXCpzs/Helper/com.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace XXCpzs.helper
|
||||
{
|
||||
class com
|
||||
{
|
||||
}
|
||||
}
|
||||