forked from dl6655/StudyDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
2,075 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>PrintDemo</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.loveplusplus.demo.print" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="11" | ||
android:targetSdkVersion="17" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.BLUETOOTH"/> | ||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
|
||
<service android:name="PrintService"/> | ||
</application> | ||
|
||
</manifest> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To enable ProGuard in your project, edit project.properties | ||
# to define the proguard.config property as described in that file. | ||
# | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in ${sdk.dir}/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system edit | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
# | ||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||
|
||
# Project target. | ||
target=android-17 | ||
android.library=true |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
tools:context=".MainActivity" > | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/hello_world" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<item | ||
android:id="@+id/action_table1" | ||
android:orderInCategory="100" | ||
android:showAsAction="always" | ||
android:title="@string/action_table1"/> | ||
<item | ||
android:id="@+id/action_table2" | ||
android:orderInCategory="100" | ||
android:showAsAction="always" | ||
android:title="@string/action_table2"/> | ||
|
||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<resources> | ||
|
||
<!-- | ||
Customize dimensions originally defined in res/values/dimens.xml (such as | ||
screen margins) for sw600dp devices (e.g. 7" tablets) here. | ||
--> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<resources> | ||
|
||
<!-- | ||
Customize dimensions originally defined in res/values/dimens.xml (such as | ||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. | ||
--> | ||
<dimen name="activity_horizontal_margin">128dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme for API 11+. This theme completely replaces | ||
AppBaseTheme from res/values/styles.xml on API 11+ devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"> | ||
<!-- API 11 theme customizations can go here. --> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme for API 14+. This theme completely replaces | ||
AppBaseTheme from BOTH res/values/styles.xml and | ||
res/values-v11/styles.xml on API 14+ devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> | ||
<!-- API 14 theme customizations can go here. --> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<resources> | ||
|
||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">PrintDemo</string> | ||
<string name="action_table1">打印表1</string> | ||
<string name="action_table2">打印表2</string> | ||
<string name="hello_world">Hello world!</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<resources> | ||
|
||
<!-- | ||
Base application theme, dependent on API level. This theme is replaced | ||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Light"> | ||
<!-- | ||
Theme customizations available in newer API levels can go in | ||
res/values-vXX/styles.xml, while customizations related to | ||
backward-compatibility can go here. | ||
--> | ||
</style> | ||
|
||
<!-- Application theme. --> | ||
<style name="AppTheme" parent="AppBaseTheme"> | ||
<!-- All customizations that are NOT specific to a particular API-level can go here. --> | ||
</style> | ||
|
||
</resources> |
42 changes: 42 additions & 0 deletions
42
PrintDemo/src/com/loveplusplus/demo/print/PrintService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.loveplusplus.demo.print; | ||
|
||
import java.io.File; | ||
|
||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
|
||
import com.loveplusplus.demo.print.util.AppUtil; | ||
import com.loveplusplus.demo.print.util.FileUtils; | ||
import com.loveplusplus.demo.print.util.PrinterUtil; | ||
|
||
public class PrintService extends IntentService { | ||
|
||
public PrintService() { | ||
super("PrintService"); | ||
} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent intent) { | ||
// 判断插件是否安装 | ||
boolean appIsInstalled = AppUtil.appIsInstalled(this, | ||
PrinterUtil.packageName); | ||
|
||
if (!appIsInstalled) { | ||
Intent installIntent = new Intent(Intent.ACTION_VIEW); | ||
String dirPath = FileUtils.getCacheDir(this); | ||
File file = FileUtils.copyAssetFileToSDCard(this, "printer.apk", | ||
dirPath); | ||
installIntent.setDataAndType(Uri.fromFile(file), | ||
"application/vnd.android.package-archive"); | ||
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(installIntent); | ||
} else { | ||
Uri uri = intent.getData(); | ||
Intent intent3 = PrinterUtil.getPrintIntent(uri, PrinterUtil.PDF1); | ||
startActivity(intent3); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.loveplusplus.demo.print; | ||
|
||
public class Sampling { | ||
|
||
public static final String SNO = "sno"; | ||
public static final String NAME = "name"; | ||
public static final String ADDRESS = "address"; | ||
public static final String PEOPLE = "people"; | ||
public static final String PRODUCT_NAME = "product_name"; | ||
public static final String PRODUCT_TYPE = "product_type"; | ||
public static final String PRODUCT_LEVEL = "product_level"; | ||
public static final String PRODUCT_BRAND = "product_brand"; | ||
public static final String PRODUCT_STANDARD = "product_standard"; | ||
public static final String PRODUCT_SNO = "product_sno"; | ||
public static final String PRODUCT_DATE = " product_date"; | ||
public static final String PRODUCT_EXPIRED = " product_expired"; | ||
public static final String NUMBER = " number"; | ||
public static final String DATE = " date"; | ||
public static final String COMPANY_NAME = " company_name"; | ||
public static final String COMPANY_ADDRESS = " company_address"; | ||
public static final String COMPANY_PHONE = " company_phone"; | ||
public static final String DEPART_NAME = " depart_name"; | ||
public static final String DEPART_PEOPLE = " depart_people"; | ||
public static final String DEPART_PHONE = " depart_phone"; | ||
public static final String DEPART_EMAIL = " depart_email"; | ||
public static final String REMARK = " remark"; | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
PrintDemo/src/com/loveplusplus/demo/print/util/AppUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.loveplusplus.demo.print.util; | ||
|
||
import android.content.Context; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
|
||
public class AppUtil { | ||
|
||
/** | ||
* 获取app的版本号 | ||
* | ||
* @param context | ||
* @return | ||
*/ | ||
public static int getVersionCode(Context context) { | ||
int v = -1; | ||
try { | ||
v = context.getPackageManager().getPackageInfo( | ||
context.getPackageName(), 0).versionCode; | ||
} catch (NameNotFoundException e) { | ||
// 不用理会 | ||
} | ||
return v; | ||
} | ||
|
||
/** | ||
* | ||
* 判断app 是否安装 com.dynamixsoftware.printershare | ||
* | ||
* @param context | ||
* @param pageName | ||
* @return | ||
*/ | ||
public static boolean appIsInstalled(Context context, String pageName) { | ||
try { | ||
context.getPackageManager().getPackageInfo(pageName, 0); | ||
return true; | ||
} catch (NameNotFoundException e) { | ||
return false; | ||
} | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
PrintDemo/src/com/loveplusplus/demo/print/util/BundleUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.loveplusplus.demo.print.util; | ||
|
||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import android.os.Bundle; | ||
|
||
public class BundleUtils { | ||
|
||
public static Bundle mapToBundle(Map<String, String> map) { | ||
Bundle bundle = new Bundle(); | ||
for (String key : map.keySet()) { | ||
bundle.putString(key, map.get(key)); | ||
} | ||
return bundle; | ||
} | ||
|
||
public static Map<String, String> bundleToMap(Bundle extras) { | ||
Map<String, String> map = new HashMap<String, String>(); | ||
|
||
Set<String> ks = extras.keySet(); | ||
Iterator<String> iterator = ks.iterator(); | ||
while (iterator.hasNext()) { | ||
String key = iterator.next(); | ||
map.put(key, extras.getString(key)); | ||
} | ||
return map; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
PrintDemo/src/com/loveplusplus/demo/print/util/DateUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.loveplusplus.demo.print.util; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
public class DateUtil { | ||
|
||
public static String formatToString(Date time) { | ||
return formatToString(time, "yyyy-MM-hh HH:mm:ss"); | ||
} | ||
|
||
public static String formatToString(Date time, String pattern) { | ||
SimpleDateFormat format = new SimpleDateFormat(pattern,Locale.getDefault()); | ||
return format.format(new Date()); | ||
} | ||
|
||
} |
Oops, something went wrong.