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
Apress
committed
Oct 16, 2016
0 parents
commit 616954d
Showing
1,259 changed files
with
31,370 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
BeginningAndroid3/APIVersions/ReadWriteStrict/AndroidManifest.xml
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,13 @@ | ||
<?xml version="1.0"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.commonsware.android.readwrite"> | ||
<application android:icon="@drawable/cw"> | ||
<activity android:name=".ReadWriteFileDemo" android:label="ReadWriteFileDemo"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9" /> | ||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/> | ||
</manifest> |
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,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="ReadWriteFileDemo" default="help"> | ||
|
||
<!-- The local.properties file is created and updated by the 'android' tool. | ||
It contains the path to the SDK. It should *NOT* be checked in in Version | ||
Control Systems. --> | ||
<property file="local.properties" /> | ||
|
||
<!-- The build.properties file can be created by you and is never touched | ||
by the 'android' tool. This is the place to change some of the default property values | ||
used by the Ant rules. | ||
Here are some properties you may want to change/update: | ||
application.package | ||
the name of your application package as defined in the manifest. Used by the | ||
'uninstall' rule. | ||
source.dir | ||
the name of the source directory. Default is 'src'. | ||
out.dir | ||
the name of the output directory. Default is 'bin'. | ||
Properties related to the SDK location or the project target should be updated | ||
using the 'android' tool with the 'update' action. | ||
This file is an integral part of the build system for your application and | ||
should be checked in in Version Control Systems. | ||
--> | ||
<property file="build.properties" /> | ||
|
||
<!-- The default.properties file is created and updated by the 'android' tool, as well | ||
as ADT. | ||
This file is an integral part of the build system for your application and | ||
should be checked in in Version Control Systems. --> | ||
<property file="default.properties" /> | ||
|
||
<!-- Custom Android task to deal with the project target, and import the proper rules. | ||
This requires ant 1.6.0 or above. --> | ||
<path id="android.antlibs"> | ||
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" /> | ||
</path> | ||
|
||
<taskdef name="setup" | ||
classname="com.android.ant.SetupTask" | ||
classpathref="android.antlibs" /> | ||
|
||
<!-- Execute the Android Setup task that will setup some properties specific to the target, | ||
and import the build rules files. | ||
The rules file is imported from | ||
<SDK>/platforms/<target_platform>/templates/android_rules.xml | ||
To customize some build steps for your project: | ||
- copy the content of the main node <project> from android_rules.xml | ||
- paste it in this build.xml below the <setup /> task. | ||
- disable the import by changing the setup task below to <setup import="false" /> | ||
This will ensure that the properties are setup correctly but that your customized | ||
build steps are used. | ||
--> | ||
<setup /> | ||
|
||
</project> |
11 changes: 11 additions & 0 deletions
11
BeginningAndroid3/APIVersions/ReadWriteStrict/default.properties
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 @@ | ||
# 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 use, | ||
# "build.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-9 |
36 changes: 36 additions & 0 deletions
36
BeginningAndroid3/APIVersions/ReadWriteStrict/proguard.cfg
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,36 @@ | ||
-optimizationpasses 5 | ||
-dontusemixedcaseclassnames | ||
-dontskipnonpubliclibraryclasses | ||
-dontpreverify | ||
-verbose | ||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||
|
||
-keep public class * extends android.app.Activity | ||
-keep public class * extends android.app.Application | ||
-keep public class * extends android.app.Service | ||
-keep public class * extends android.content.BroadcastReceiver | ||
-keep public class * extends android.content.ContentProvider | ||
-keep public class * extends android.app.backup.BackupAgentHelper | ||
-keep public class * extends android.preference.Preference | ||
-keep public class com.android.vending.licensing.ILicensingService | ||
|
||
-keepclasseswithmembernames class * { | ||
native <methods>; | ||
} | ||
|
||
-keepclasseswithmembernames class * { | ||
public <init>(android.content.Context, android.util.AttributeSet); | ||
} | ||
|
||
-keepclasseswithmembernames class * { | ||
public <init>(android.content.Context, android.util.AttributeSet, int); | ||
} | ||
|
||
-keepclassmembers enum * { | ||
public static **[] values(); | ||
public static ** valueOf(java.lang.String); | ||
} | ||
|
||
-keep class * implements android.os.Parcelable { | ||
public static final android.os.Parcelable$Creator *; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions
8
BeginningAndroid3/APIVersions/ReadWriteStrict/res/layout/main.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<EditText xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/editor" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:singleLine="false" | ||
android:gravity="top" | ||
/> |
4 changes: 4 additions & 0 deletions
4
BeginningAndroid3/APIVersions/ReadWriteStrict/res/values/strings.xml
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">ReadWriteFileDemo</string> | ||
</resources> |
90 changes: 90 additions & 0 deletions
90
.../APIVersions/ReadWriteStrict/src/com/commonsware/android/readwrite/ReadWriteFileDemo.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,90 @@ | ||
/*** | ||
Copyright (c) 2008-2011 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
not use this file except in compliance with the License. You may obtain | ||
a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package com.commonsware.android.readwrite; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStream; | ||
import java.io.OutputStreamWriter; | ||
|
||
public class ReadWriteFileDemo extends Activity { | ||
private final static String NOTES="notes.txt"; | ||
private EditText editor; | ||
|
||
@Override | ||
public void onCreate(Bundle icicle) { | ||
super.onCreate(icicle); | ||
setContentView(R.layout.main); | ||
|
||
StrictWrapper.init(); | ||
|
||
editor=(EditText)findViewById(R.id.editor); | ||
} | ||
|
||
public void onResume() { | ||
super.onResume(); | ||
|
||
try { | ||
InputStream in=openFileInput(NOTES); | ||
|
||
if (in!=null) { | ||
InputStreamReader tmp=new InputStreamReader(in); | ||
BufferedReader reader=new BufferedReader(tmp); | ||
String str; | ||
StringBuilder buf=new StringBuilder(); | ||
|
||
while ((str = reader.readLine()) != null) { | ||
buf.append(str+"\n"); | ||
} | ||
|
||
in.close(); | ||
editor.setText(buf.toString()); | ||
} | ||
} | ||
catch (java.io.FileNotFoundException e) { | ||
// that's OK, we probably haven't created it yet | ||
} | ||
catch (Throwable t) { | ||
Toast | ||
.makeText(this, "Exception: "+t.toString(), Toast.LENGTH_LONG) | ||
.show(); | ||
} | ||
} | ||
|
||
public void onPause() { | ||
super.onPause(); | ||
|
||
try { | ||
OutputStreamWriter out= | ||
new OutputStreamWriter(openFileOutput(NOTES, 0)); | ||
|
||
out.write(editor.getText().toString()); | ||
out.close(); | ||
} | ||
catch (Throwable t) { | ||
Toast | ||
.makeText(this, "Exception: "+t.toString(), Toast.LENGTH_LONG) | ||
.show(); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...id3/APIVersions/ReadWriteStrict/src/com/commonsware/android/readwrite/StrictForRealz.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,26 @@ | ||
/*** | ||
Copyright (c) 2011 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
not use this file except in compliance with the License. You may obtain | ||
a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package com.commonsware.android.readwrite; | ||
|
||
import android.os.StrictMode; | ||
|
||
class StrictForRealz extends StrictWrapper { | ||
StrictForRealz() { | ||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() | ||
.detectAll() | ||
.penaltyLog() | ||
.build()); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...oid3/APIVersions/ReadWriteStrict/src/com/commonsware/android/readwrite/StrictWrapper.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,34 @@ | ||
/*** | ||
Copyright (c) 2011 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
not use this file except in compliance with the License. You may obtain | ||
a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package com.commonsware.android.readwrite; | ||
|
||
import android.os.Build; | ||
|
||
abstract class StrictWrapper { | ||
static private StrictWrapper INSTANCE=null; | ||
|
||
static public void init() { | ||
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.GINGERBREAD) { | ||
INSTANCE=new StrictForRealz(); | ||
} | ||
else { | ||
INSTANCE=new NotAllThatStrict(); | ||
} | ||
} | ||
|
||
static class NotAllThatStrict extends StrictWrapper { | ||
// no methods needed | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
BeginningAndroid3/Activities/IntentTab/AndroidManifest.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.commonsware.android.intenttab" android:versionCode="1" android:versionName="1.0.0"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<application android:label="@string/app_name" android:icon="@drawable/cw"> | ||
<activity android:name=".IntentTabDemo" android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".CWBrowser"/> | ||
<activity android:name=".AndroidBrowser"/> | ||
</application> | ||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/> | ||
</manifest> |
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,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="IntentTabDemo" default="help"> | ||
|
||
<!-- The local.properties file is created and updated by the 'android' tool. | ||
It contains the path to the SDK. It should *NOT* be checked in in Version | ||
Control Systems. --> | ||
<property file="local.properties" /> | ||
|
||
<!-- The build.properties file can be created by you and is never touched | ||
by the 'android' tool. This is the place to change some of the default property values | ||
used by the Ant rules. | ||
Here are some properties you may want to change/update: | ||
application.package | ||
the name of your application package as defined in the manifest. Used by the | ||
'uninstall' rule. | ||
source.dir | ||
the name of the source directory. Default is 'src'. | ||
out.dir | ||
the name of the output directory. Default is 'bin'. | ||
Properties related to the SDK location or the project target should be updated | ||
using the 'android' tool with the 'update' action. | ||
This file is an integral part of the build system for your application and | ||
should be checked in in Version Control Systems. | ||
--> | ||
<property file="build.properties" /> | ||
|
||
<!-- The default.properties file is created and updated by the 'android' tool, as well | ||
as ADT. | ||
This file is an integral part of the build system for your application and | ||
should be checked in in Version Control Systems. --> | ||
<property file="default.properties" /> | ||
|
||
<!-- Custom Android task to deal with the project target, and import the proper rules. | ||
This requires ant 1.6.0 or above. --> | ||
<path id="android.antlibs"> | ||
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" /> | ||
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" /> | ||
</path> | ||
|
||
<taskdef name="setup" | ||
classname="com.android.ant.SetupTask" | ||
classpathref="android.antlibs" /> | ||
|
||
<!-- Execute the Android Setup task that will setup some properties specific to the target, | ||
and import the build rules files. | ||
The rules file is imported from | ||
<SDK>/platforms/<target_platform>/templates/android_rules.xml | ||
To customize some build steps for your project: | ||
- copy the content of the main node <project> from android_rules.xml | ||
- paste it in this build.xml below the <setup /> task. | ||
- disable the import by changing the setup task below to <setup import="false" /> | ||
This will ensure that the properties are setup correctly but that your customized | ||
build steps are used. | ||
--> | ||
<setup /> | ||
|
||
</project> |
Oops, something went wrong.