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 9695b11
Showing
57 changed files
with
980 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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Binary file added
BIN
+7.33 KB
AndroidAppsForAbsoluteBeginners/Assets_Images/MindTaffyLogoAndroidGreen.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.27 KB
AndroidAppsForAbsoluteBeginners/Assets_Images/MindTaffyLogoAndroidGreen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
AndroidAppsForAbsoluteBeginners/Content Providers/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,28 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="sixth.example.contentproviders" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:targetSdkVersion="15" /> | ||
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> | ||
<uses-permission android:name="android.permission.READ_CONTACTS" /> | ||
|
||
|
||
<application | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/title_activity_main" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
46 changes: 46 additions & 0 deletions
46
AndroidAppsForAbsoluteBeginners/Content Providers/res/layout/activity_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,46 @@ | ||
<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" > | ||
<TextView | ||
android:id="@+id/textView1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentTop="true" | ||
android:layout_centerHorizontal="true" | ||
android:text="@string/display_data" | ||
tools:context=".MainActivity" /> | ||
<Button | ||
android:id="@+id/button1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/textView1" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="50dp" | ||
android:text="@string/button_title" /> | ||
<Button | ||
android:id="@+id/button2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button1" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="20dp" | ||
android:text="@string/append_data" /> | ||
<Button | ||
android:id="@+id/button3" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button2" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="20dp" | ||
android:text="@string/modify_data" /> | ||
|
||
<Button | ||
android:id="@+id/button4" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button3" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="20dp" | ||
android:text="@string/delete_data" /> | ||
</RelativeLayout> |
10 changes: 10 additions & 0 deletions
10
AndroidAppsForAbsoluteBeginners/Content Providers/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,10 @@ | ||
<resources> | ||
<string name="app_name">ContentProviders</string> | ||
<string name="display_data">Click Buttons Below to Query, Add, Modify or Delete</string> | ||
<string name="button_title">Click to Query Contacts Database</string> | ||
<string name="append_data">Click to Add to Contacts Database</string> | ||
<string name="modify_data">Click to Modify Contacts Database</string> | ||
<string name="delete_data">Click to Delete Contact in Database</string> | ||
<string name="menu_settings">Settings</string> | ||
<string name="title_activity_main">MainActivity</string> | ||
</resources> |
98 changes: 98 additions & 0 deletions
98
AndroidAppsForAbsoluteBeginners/Content Providers/src/MainActivity.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,98 @@ | ||
package sixth.example.contentproviders; | ||
import android.os.Bundle; | ||
import android.app.Activity; | ||
import android.net.Uri; | ||
import android.provider.ContactsContract; | ||
import android.provider.ContactsContract.CommonDataKinds.StructuredName; | ||
import android.provider.ContactsContract.Data; | ||
import android.provider.ContactsContract.RawContacts; | ||
import android.content.ContentResolver; | ||
import android.content.ContentUris; | ||
import android.content.ContentValues; | ||
import android.database.Cursor; | ||
import android.view.Menu; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.Button; | ||
import android.widget.Toast; | ||
public class MainActivity extends Activity { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Button queryButton = (Button)findViewById(R.id.button1); | ||
queryButton.setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View arg0) { queryContact(); } | ||
}); | ||
Button addButton = (Button)findViewById(R.id.button2); | ||
addButton.setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View arg0) { addContact("Steve Wozniak"); } | ||
}); | ||
Button modifyButton = (Button)findViewById(R.id.button3); | ||
modifyButton.setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View arg0) { modContact("The Woz"); } | ||
}); | ||
Button delButton = (Button)findViewById(R.id.button4); | ||
delButton.setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View arg0) { delContact("The Woz"); } | ||
}); | ||
} | ||
private void queryContact() { | ||
Cursor nameCursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); | ||
while (nameCursor.moveToNext()) { | ||
String contactName = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME_PRIMARY)); | ||
Toast.makeText(this, contactName, Toast.LENGTH_SHORT).show(); | ||
} | ||
nameCursor.close(); | ||
} | ||
private void addContact(String newName) { | ||
ContentValues myContact = new ContentValues(); | ||
myContact.put(RawContacts.ACCOUNT_NAME, newName); | ||
myContact.put(RawContacts.ACCOUNT_TYPE, newName); | ||
Uri addUri = getContentResolver().insert(RawContacts.CONTENT_URI, myContact); | ||
long rawContactId = ContentUris.parseId(addUri); | ||
myContact.clear(); | ||
myContact.put(Data.RAW_CONTACT_ID, rawContactId); | ||
myContact.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); | ||
myContact.put(StructuredName.DISPLAY_NAME, newName); | ||
getContentResolver().insert(Data.CONTENT_URI, myContact); | ||
Toast.makeText(this, "New Contact: " + newName, Toast.LENGTH_SHORT).show(); | ||
} | ||
private void modContact(String modName) { | ||
ContentValues myContact = new ContentValues(); | ||
myContact.put(RawContacts.ACCOUNT_NAME, modName); | ||
myContact.put(RawContacts.ACCOUNT_TYPE, modName); | ||
Uri addUri = getContentResolver().insert(RawContacts.CONTENT_URI, myContact); | ||
long rawContactId = ContentUris.parseId(addUri); | ||
myContact.clear(); | ||
myContact.put(Data.RAW_CONTACT_ID, rawContactId); | ||
myContact.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); | ||
myContact.put(StructuredName.DISPLAY_NAME, modName); | ||
getContentResolver().update(Data.CONTENT_URI, myContact, null, null); | ||
Toast.makeText(this, "Modified Contact: " + modName, Toast.LENGTH_SHORT).show(); | ||
} | ||
private void delContact(String delName) { | ||
ContentResolver cresolver = getContentResolver(); | ||
Cursor cur = cresolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); | ||
while (cur.moveToNext()) { | ||
try { | ||
String lookupKey = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); | ||
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey); | ||
Toast.makeText(this, "Deleted Contact URI: " + uri.toString(), Toast.LENGTH_SHORT).show(); | ||
cresolver.delete(uri, null, null); | ||
} | ||
catch(Exception e) | ||
{ | ||
System.out.println(e.getStackTrace()); | ||
} | ||
} | ||
} | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.activity_main, menu); | ||
return true; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
AndroidAppsForAbsoluteBeginners/EventHandling/res/layout/activity_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,53 @@ | ||
<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" > | ||
<Button | ||
android:id="@+id/button1" | ||
android:nextFocusUp="@+id/button4" | ||
android:nextFocusDown="@+id/button2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentTop="true" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="50dp" | ||
android:text="@string/button_caption" /> | ||
<TextView | ||
android:id="@+id/textmessage" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" | ||
android:text="@string/text_message" | ||
tools:context=".MainActivity" /> | ||
<Button | ||
android:id="@+id/button2" | ||
android:nextFocusUp="@+id/button1" | ||
android:nextFocusDown="@+id/button3" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/textmessage" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="50dp" | ||
android:text="@string/context_button_caption" /> | ||
<Button | ||
android:id="@+id/button3" | ||
android:nextFocusUp="@+id/button2" | ||
android:nextFocusDown="@+id/button4" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button2" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="10dp" | ||
android:text="@string/third_button_caption" /> | ||
<Button | ||
android:id="@+id/button4" | ||
android:nextFocusUp="@+id/button3" | ||
android:nextFocusDown="@+id/button1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button3" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="10dp" | ||
android:text="@string/fourth_button_caption" /> | ||
</RelativeLayout> |
10 changes: 10 additions & 0 deletions
10
AndroidAppsForAbsoluteBeginners/EventHandling/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,10 @@ | ||
<resources> | ||
<string name="app_name">EventHandling</string> | ||
<string name="button_caption">CLICK TO GENERATE EVENT</string> | ||
<string name="context_button_caption">LONG-CLICK FOR CONTEXT MENU</string> | ||
<string name="third_button_caption">THIRD BUTTON</string> | ||
<string name="fourth_button_caption">FOURTH BUTTON</string> | ||
<string name="menu_settings">Settings</string> | ||
<string name="title_activity_main">MainActivity</string> | ||
<string name="text_message">NO EVENT RECEIVED YET</string> | ||
</resources> |
79 changes: 79 additions & 0 deletions
79
AndroidAppsForAbsoluteBeginners/EventHandling/src/MainActivity.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,79 @@ | ||
package fifth.example.eventhandling; | ||
import android.os.Bundle; | ||
import android.app.Activity; | ||
import android.view.ContextMenu; | ||
import android.view.ContextMenu.ContextMenuInfo; | ||
import android.view.KeyEvent; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.view.View.OnLongClickListener; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
public class MainActivity extends Activity implements OnClickListener, OnLongClickListener { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Button button = (Button) findViewById(R.id.button1); | ||
button.setOnClickListener(this); | ||
button.setOnLongClickListener(this); | ||
Button button2 = (Button) findViewById(R.id.button2); | ||
registerForContextMenu(button2); | ||
Button button3 = (Button) findViewById(R.id.button3); | ||
registerForContextMenu(button3); | ||
Button button4 = (Button) findViewById(R.id.button4); | ||
registerForContextMenu(button4); | ||
} | ||
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { | ||
super.onCreateContextMenu(menu, view, menuInfo); | ||
menu.setHeaderTitle("Android Context Menu"); | ||
menu.add(0, view.getId(), 0, "Invoke Context Function 1"); | ||
menu.add(0, view.getId(), 0, "Invoke Context Function 2"); | ||
} | ||
public boolean onContextItemSelected(MenuItem item) { | ||
if(item.getTitle().equals("Invoke Context Function 1")) { | ||
contextFunction1(item.getItemId()); | ||
} | ||
else if(item.getTitle().equals("Invoke Context Function 2")){ | ||
contextFunction2(item.getItemId()); | ||
} | ||
else { | ||
return false; | ||
} | ||
return true; | ||
} | ||
public void contextFunction1(int id){ | ||
Toast.makeText(this, "function 1 invoked!", Toast.LENGTH_SHORT).show(); | ||
} | ||
public void contextFunction2(int id){ | ||
Toast.makeText(this, "function 2 invoked!", Toast.LENGTH_SHORT).show(); | ||
} | ||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.activity_main, menu); | ||
return true; | ||
} | ||
public void onClick(View arg0) { | ||
TextView text = (TextView) findViewById(R.id.textmessage); | ||
text.setText("BUTTON HAS BEEN CLICKED. EVENT PROCESSED."); | ||
} | ||
public boolean onLongClick(View arg0) { | ||
TextView text = (TextView) findViewById(R.id.textmessage); | ||
text.setText("BUTTON HAS BEEN HELD. onLongClick EVENT PROCESSED."); | ||
return true; | ||
} | ||
public boolean onKeyDown(int keyCode, KeyEvent event) { | ||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { | ||
textUpdate(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
public void textUpdate() { | ||
TextView text = (TextView)findViewById(R.id.textmessage); | ||
text.setText("CENTER KEYPAD KEY PRESSED."); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
AndroidAppsForAbsoluteBeginners/GraphicDesign/res/anim/text_animation.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,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shareInterpolator="false"> | ||
<scale android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:fromXScale="1.0" | ||
android:toXScale="1.4" | ||
android:fromYScale="1.0" | ||
android:toYScale="0.6" | ||
android:pivotX="50%" | ||
android:pivotY="50%" | ||
android:fillAfter="false" | ||
android:duration="700" /> | ||
<set android:interpolator="@android:anim/decelerate_interpolator"> | ||
<scale android:fromXScale="1.4" | ||
android:toXScale="0.0" | ||
android:fromYScale="0.6" | ||
android:toYScale="0.0" | ||
android:pivotX="50%" | ||
android:pivotY="50%" | ||
android:startOffset="700" | ||
android:duration="400" | ||
android:fillBefore="false" /> | ||
<rotate android:fromDegrees="0" | ||
android:toDegrees="-45" | ||
android:toYScale="0.0" | ||
android:pivotX="50%" | ||
android:pivotY="50%" | ||
android:startOffset="700" | ||
android:duration="400" /> | ||
</set> | ||
</set> |
15 changes: 15 additions & 0 deletions
15
AndroidAppsForAbsoluteBeginners/GraphicDesign/res/drawable/logo_animation.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 @@ | ||
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:oneshot="false"> | ||
|
||
<item android:drawable="@drawable/logoanim0" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim1" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim2" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim3" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim4" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim5" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim6" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim7" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim8" android:duration="200" /> | ||
<item android:drawable="@drawable/logoanim9" android:duration="200" /> | ||
|
||
</animation-list> |
Oops, something went wrong.