Add original project.
This commit is contained in:
1
app/.gitignore
vendored
Executable file
1
app/.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
||||
/build
|
26
app/build.gradle
Executable file
26
app/build.gradle
Executable file
@ -0,0 +1,26 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.hyperling.apps.example_sqlite_addressbook"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
}
|
17
app/proguard-rules.pro
vendored
Executable file
17
app/proguard-rules.pro
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/ling/WDBlue/Programming/Java/Android/android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# 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 *;
|
||||
#}
|
@ -0,0 +1,13 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
20
app/src/main/AndroidManifest.xml
Executable file
20
app/src/main/AndroidManifest.xml
Executable file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hyperling.apps.example_sqlite_addressbook">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,154 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/13/15.
|
||||
*/
|
||||
public class AddEditFragment extends Fragment {
|
||||
public interface AddEditFragmentListener {
|
||||
public void onAddEditCompleted(long rowID);
|
||||
}
|
||||
|
||||
private AddEditFragmentListener listener;
|
||||
|
||||
private long rowID;
|
||||
|
||||
private Bundle contactInfoBundle;
|
||||
|
||||
private EditText etName;
|
||||
private EditText etPhone;
|
||||
private EditText etEmail;
|
||||
private EditText etStreet;
|
||||
private EditText etCity;
|
||||
private EditText etState;
|
||||
private EditText etZip;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity){
|
||||
super.onAttach(activity);
|
||||
listener = (AddEditFragmentListener) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach(){
|
||||
super.onDetach();
|
||||
listener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_add_edit, container, false);
|
||||
etName = (EditText) view.findViewById(R.id.et_name);
|
||||
etPhone = (EditText) view.findViewById(R.id.et_phone);
|
||||
etEmail = (EditText) view.findViewById(R.id.et_email);
|
||||
etStreet = (EditText) view.findViewById(R.id.et_street);
|
||||
etCity = (EditText) view.findViewById(R.id.et_city);
|
||||
etState = (EditText) view.findViewById(R.id.et_state);
|
||||
etZip = (EditText) view.findViewById(R.id.et_zip);
|
||||
|
||||
contactInfoBundle = getArguments();
|
||||
|
||||
if (contactInfoBundle != null){
|
||||
rowID = contactInfoBundle.getLong(MainActivity.ROW_ID);
|
||||
etName.setText(contactInfoBundle.getString("name"));
|
||||
etPhone.setText(contactInfoBundle.getString("phone"));
|
||||
etEmail.setText(contactInfoBundle.getString("email"));
|
||||
etStreet.setText(contactInfoBundle.getString("street"));
|
||||
etCity.setText(contactInfoBundle.getString("city"));
|
||||
etState.setText(contactInfoBundle.getString("state"));
|
||||
etZip.setText(contactInfoBundle.getString("zip"));
|
||||
}
|
||||
|
||||
Button btnSave = (Button) view.findViewById(R.id.btn_save);
|
||||
btnSave.setOnClickListener(saveButtonClicked);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
View.OnClickListener saveButtonClicked = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (etName.getText().toString().trim().length() > 0){
|
||||
AsyncTask<Object, Object, Object> saveContactTask = new AsyncTask<Object, Object, Object>() {
|
||||
@Override
|
||||
protected Object doInBackground(Object... params) {
|
||||
saveContact();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object results){
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
|
||||
|
||||
listener.onAddEditCompleted(rowID);
|
||||
}
|
||||
};
|
||||
|
||||
saveContactTask.execute((Object[]) null);
|
||||
}
|
||||
else{
|
||||
DialogFragment errorSaving = new DialogFragment(){
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
builder.setMessage(R.string.error_create_contact);
|
||||
builder.setPositiveButton(R.string.msg_confirm_ok_button, null);
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
};
|
||||
|
||||
errorSaving.show(getFragmentManager(), "Error saving contact");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void saveContact(){
|
||||
DatabaseConnector databaseConnector = new DatabaseConnector(getActivity());
|
||||
|
||||
if (contactInfoBundle == null) {
|
||||
rowID = databaseConnector.insertContact(
|
||||
etName.getText().toString(),
|
||||
etPhone.getText().toString(),
|
||||
etEmail.getText().toString(),
|
||||
etStreet.getText().toString(),
|
||||
etCity.getText().toString(),
|
||||
etState.getText().toString(),
|
||||
etZip.getText().toString()
|
||||
);
|
||||
}
|
||||
else{
|
||||
databaseConnector.updateContact(
|
||||
rowID,
|
||||
etName.getText().toString(),
|
||||
etPhone.getText().toString(),
|
||||
etEmail.getText().toString(),
|
||||
etStreet.getText().toString(),
|
||||
etCity.getText().toString(),
|
||||
etState.getText().toString(),
|
||||
etZip.getText().toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListFragment;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.CursorAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/13/15.
|
||||
*/
|
||||
public class ContactListFragment extends ListFragment {
|
||||
public interface ContactListFragmentListener{
|
||||
public void onContactSelected(long rowID);
|
||||
public void onAddContact();
|
||||
}
|
||||
|
||||
private ContactListFragmentListener listener;
|
||||
|
||||
private ListView contactListView;
|
||||
|
||||
private CursorAdapter contactAdapter;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity){
|
||||
super.onAttach(activity);
|
||||
listener = (ContactListFragmentListener) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach(){
|
||||
super.onDetach();
|
||||
listener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceBundle){
|
||||
super.onViewCreated(view, savedInstanceBundle);
|
||||
setRetainInstance(true);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
setEmptyText(getResources().getString(R.string.no_contacts));
|
||||
|
||||
contactListView = getListView();
|
||||
contactListView.setOnItemClickListener(viewContactListener);
|
||||
contactListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
|
||||
String[] from = new String[] {"name"};
|
||||
int[] to = new int[] {android.R.id.text1};
|
||||
contactAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, from, to, 0);
|
||||
setListAdapter(contactAdapter);
|
||||
}
|
||||
|
||||
AdapterView.OnItemClickListener viewContactListener = new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
listener.onContactSelected(id);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
new GetContactsTask().execute((Object[]) null);
|
||||
}
|
||||
|
||||
private class GetContactsTask extends AsyncTask<Object, Object, Cursor>{
|
||||
DatabaseConnector databaseConnector = new DatabaseConnector(getActivity());
|
||||
|
||||
@Override
|
||||
protected Cursor doInBackground(Object... params){
|
||||
databaseConnector.open();
|
||||
return databaseConnector.getAllContacts();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Cursor result){
|
||||
contactAdapter.changeCursor(result);
|
||||
databaseConnector.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(){
|
||||
Cursor cursor = contactAdapter.getCursor();
|
||||
contactAdapter.changeCursor(null);
|
||||
|
||||
if (cursor != null){
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.fragment_contact_list_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item){
|
||||
switch(item.getItemId()){
|
||||
case R.id.action_add:
|
||||
listener.onAddContact();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void updateContactList(){
|
||||
new GetContactsTask().execute((Object[]) null);
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/13/15.
|
||||
*/
|
||||
public class DatabaseConnector extends Object {
|
||||
private static final String DATABASE_NAME = "user_contacts";
|
||||
|
||||
private SQLiteDatabase database;
|
||||
private DatabaseOpenHelper databaseOpenHelper;
|
||||
|
||||
public DatabaseConnector(Context context){
|
||||
databaseOpenHelper = new DatabaseOpenHelper(context, DATABASE_NAME, null, 1);
|
||||
}
|
||||
|
||||
public void open() throws SQLException{
|
||||
database = databaseOpenHelper.getWritableDatabase();
|
||||
}
|
||||
|
||||
public void close(){
|
||||
if (database != null){
|
||||
database.close();
|
||||
}
|
||||
}
|
||||
|
||||
public long insertContact(String name, String phone, String email, String street, String city, String state, String zip){
|
||||
ContentValues newContact = new ContentValues();
|
||||
newContact.put("name", name);
|
||||
newContact.put("phone", phone);
|
||||
newContact.put("email", email);
|
||||
newContact.put("street", street);
|
||||
newContact.put("city", city);
|
||||
newContact.put("state", state);
|
||||
newContact.put("zip", zip);
|
||||
|
||||
open();
|
||||
long rowID = database.insert("contacts", null, newContact);
|
||||
close();
|
||||
return rowID;
|
||||
}
|
||||
|
||||
public void updateContact(long id, String name, String phone, String email, String street, String city, String state, String zip){
|
||||
ContentValues editContact = new ContentValues();
|
||||
editContact.put("name", name);
|
||||
editContact.put("phone", phone);
|
||||
editContact.put("email", email);
|
||||
editContact.put("street", street);
|
||||
editContact.put("city", city);
|
||||
editContact.put("state", state);
|
||||
editContact.put("zip", zip);
|
||||
|
||||
open();
|
||||
database.update("contacts", editContact, "_id=" + id, null);
|
||||
close();
|
||||
}
|
||||
|
||||
public Cursor getAllContacts(){
|
||||
return database.query("contacts", new String[] {"_id"}, null, null, null, null, "name");
|
||||
}
|
||||
|
||||
public Cursor getOneContact(long id){
|
||||
return database.query("contacts", null, "_id=" + id, null, null, null, null);
|
||||
}
|
||||
|
||||
public void deleteContact(long id){
|
||||
open();
|
||||
database.delete("contacts", "_id=" + id, null);
|
||||
close();
|
||||
}
|
||||
|
||||
private class DatabaseOpenHelper extends SQLiteOpenHelper{
|
||||
public DatabaseOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
|
||||
super(context, name, factory, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db){
|
||||
String createQuery =
|
||||
"CREATE TABLE contacts" +
|
||||
"(" +
|
||||
"_id integer primary key autoincrement," +
|
||||
"name TEXT," +
|
||||
"phone TEXT," +
|
||||
"email TEXT," +
|
||||
"street TEXT," +
|
||||
"city TEXT," +
|
||||
"state TEXT," +
|
||||
"zip TEXT" +
|
||||
");";
|
||||
|
||||
db.execSQL(createQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
|
||||
// Do nothing
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/13/15.
|
||||
*/
|
||||
public class DetailsFragment extends Fragment {
|
||||
|
||||
public interface DetailsFragmentListener{
|
||||
public void onContactDeleted();
|
||||
public void onEditContact(Bundle arguments);
|
||||
}
|
||||
|
||||
private DetailsFragmentListener listener;
|
||||
|
||||
private long rowID = -1;
|
||||
|
||||
private TextView tvName;
|
||||
private TextView tvPhone;
|
||||
private TextView tvEmail;
|
||||
private TextView tvStreet;
|
||||
private TextView tvCity;
|
||||
private TextView tvState;
|
||||
private TextView tvZip;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity){
|
||||
super.onAttach(activity);
|
||||
listener = (DetailsFragmentListener) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach(){
|
||||
super.onDetach();
|
||||
listener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
|
||||
if (savedInstanceState != null){
|
||||
rowID = savedInstanceState.getLong(MainActivity.ROW_ID);
|
||||
}
|
||||
else{
|
||||
Bundle arguments = getArguments();
|
||||
|
||||
if (arguments != null){
|
||||
rowID = arguments.getLong(MainActivity.ROW_ID);
|
||||
}
|
||||
}
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_details, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
tvName = (TextView) view.findViewById(R.id.tv_name);
|
||||
tvPhone = (TextView) view.findViewById(R.id.tv_phone);
|
||||
tvEmail = (TextView) view.findViewById(R.id.tv_email);
|
||||
tvStreet = (TextView) view.findViewById(R.id.tv_street);
|
||||
tvCity = (TextView) view.findViewById(R.id.tv_city);
|
||||
tvState = (TextView) view.findViewById(R.id.tv_state);
|
||||
tvZip = (TextView) view.findViewById(R.id.tv_zip);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
new LoadContactTask().execute(rowID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState){
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putLong(MainActivity.ROW_ID, rowID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.fragment_details_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item){
|
||||
switch(item.getItemId()){
|
||||
case R.id.action_edit:
|
||||
Bundle arguments = new Bundle();
|
||||
|
||||
arguments.putLong(MainActivity.ROW_ID, rowID);
|
||||
arguments.putCharSequence("name", tvName.getText());
|
||||
arguments.putCharSequence("phone", tvPhone.getText());
|
||||
arguments.putCharSequence("email", tvEmail.getText());
|
||||
arguments.putCharSequence("street", tvStreet.getText());
|
||||
arguments.putCharSequence("city", tvCity.getText());
|
||||
arguments.putCharSequence("state", tvState.getText());
|
||||
arguments.putCharSequence("zip", tvZip.getText());
|
||||
return true;
|
||||
case R.id.action_delete:
|
||||
deleteContact();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private class LoadContactTask extends AsyncTask<Long, Object, Cursor>{
|
||||
DatabaseConnector databaseConnector = new DatabaseConnector(getActivity());
|
||||
|
||||
@Override
|
||||
protected Cursor doInBackground(Long... params){
|
||||
databaseConnector.open();
|
||||
return databaseConnector.getOneContact(params[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Cursor result){
|
||||
super.onPostExecute(result);
|
||||
|
||||
result.moveToFirst();
|
||||
|
||||
int iName = result.getColumnIndex("name");
|
||||
int iPhone = result.getColumnIndex("phone");
|
||||
int iEmail = result.getColumnIndex("email");
|
||||
int iStreet = result.getColumnIndex("street");
|
||||
int iCity = result.getColumnIndex("city");
|
||||
int iState = result.getColumnIndex("state");
|
||||
int iZip = result.getColumnIndex("zip");
|
||||
|
||||
tvName.setText(result.getString(iName));
|
||||
tvPhone.setText(result.getString(iPhone));
|
||||
tvEmail.setText(result.getString(iEmail));
|
||||
tvStreet.setText(result.getString(iStreet));
|
||||
tvCity.setText(result.getString(iCity));
|
||||
tvState.setText(result.getString(iState));
|
||||
tvZip.setText(result.getString(iZip));
|
||||
|
||||
result.close();
|
||||
databaseConnector.close();
|
||||
}
|
||||
|
||||
private void deleteContact(){
|
||||
confirmDelete.show(getFragmentManager(), "confirm delete");
|
||||
}
|
||||
|
||||
private DialogFragment confirmDelete = new DialogFragment(){
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle bundle){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
builder.setTitle(R.string.msg_confirm_title);
|
||||
builder.setMessage(R.string.msg_confirm_text);
|
||||
|
||||
builder.setPositiveButton(R.string.msg_confirm_ok_button, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final DatabaseConnector databaseConnector = new DatabaseConnector(getActivity());
|
||||
|
||||
AsyncTask<Long, Object, Cursor> deleteTask = new AsyncTask<Long, Object, Cursor>() {
|
||||
@Override
|
||||
protected Cursor doInBackground(Long... params) {
|
||||
databaseConnector.deleteContact(params[0]);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object result) {
|
||||
listener.onContactDeleted();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
deleteTask.execute(new Long[]{rowID});
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.msg_confirm_cancel_button, null);
|
||||
return builder.create();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import android.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements ContactListFragment.ContactListFragmentListener,
|
||||
DetailsFragment.DetailsFragmentListener,
|
||||
AddEditFragment.AddEditFragmentListener{
|
||||
|
||||
public static final String ROW_ID = "row_id";
|
||||
|
||||
ContactListFragment contactListFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
if (savedInstanceState != null){
|
||||
return;
|
||||
}
|
||||
|
||||
if (findViewById(R.id.fragmentContainer) != null){
|
||||
contactListFragment = new ContactListFragment();
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.fragmentContainer, contactListFragment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
|
||||
if (contactListFragment == null){
|
||||
contactListFragment = (ContactListFragment) getFragmentManager().findFragmentById(R.id.contactListFragment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactSelected(long rowID){
|
||||
if (findViewById(R.id.fragmentContainer) != null){
|
||||
displayContact(rowID, R.id.fragmentContainer);
|
||||
}
|
||||
else{
|
||||
getFragmentManager().popBackStack();
|
||||
displayContact(rowID, R.id.rightPaneContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayContact(long rowID, int viewID){
|
||||
DetailsFragment detailsFragment = new DetailsFragment();
|
||||
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putLong(ROW_ID, rowID);
|
||||
|
||||
detailsFragment.setArguments(arguments);
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(viewID, detailsFragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddContact(){
|
||||
if (findViewById(R.id.fragmentContainer) != null){
|
||||
displayAddEditFragment(R.id.fragmentContainer, null);
|
||||
}
|
||||
else{
|
||||
displayAddEditFragment(R.id.rightPaneContainer, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayAddEditFragment(int viewID, Bundle arguments){
|
||||
AddEditFragment addEditFragment = new AddEditFragment();
|
||||
|
||||
if (arguments != null){
|
||||
addEditFragment.setArguments(arguments);
|
||||
}
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(viewID, addEditFragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactDeleted(){
|
||||
getFragmentManager().popBackStack();
|
||||
|
||||
if (findViewById(R.id.fragmentContainer) == null){
|
||||
contactListFragment.updateContactList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEditContact(Bundle arguments){
|
||||
if (findViewById(R.id.fragmentContainer) != null){
|
||||
displayAddEditFragment(R.id.fragmentContainer, arguments);
|
||||
}
|
||||
else{
|
||||
displayAddEditFragment(R.id.rightPaneContainer, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddEditCompleted(long rowID){
|
||||
getFragmentManager().popBackStack();
|
||||
|
||||
if (findViewById(R.id.fragmentContainer) == null){
|
||||
getFragmentManager().popBackStack();
|
||||
|
||||
contactListFragment.updateContactList();
|
||||
|
||||
displayContact(rowID, R.id.rightPaneContainer);
|
||||
}
|
||||
}
|
||||
}
|
7
app/src/main/res/drawable/textview_border.xml
Executable file
7
app/src/main/res/drawable/textview_border.xml
Executable file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="5dp"/>
|
||||
<stroke android:width="1dp" android:color="#555"/>
|
||||
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/>
|
||||
</shape>
|
20
app/src/main/res/layout-large/activity_main.xml
Executable file
20
app/src/main/res/layout-large/activity_main.xml
Executable file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="3">
|
||||
|
||||
<fragment
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:name="com.hyperling.apps.example_sqlite_addressbook.ContactListFragment"
|
||||
android:id="@+id/contactListFragment"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:id="@+id/rightPaneContainer"></FrameLayout>
|
||||
</LinearLayout>
|
16
app/src/main/res/layout/activity_main.xml
Executable file
16
app/src/main/res/layout/activity_main.xml
Executable file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="com.hyperling.apps.example_sqlite_addressbook.MainActivity">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/fragmentContainer"></FrameLayout>
|
||||
</RelativeLayout>
|
116
app/src/main/res/layout/fragment_add_edit.xml
Executable file
116
app/src/main/res/layout/fragment_add_edit.xml
Executable file
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/addEditScrollView">
|
||||
|
||||
<GridLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:columnCount="1"
|
||||
android:useDefaultMargins="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPersonName|textCapWords"
|
||||
android:id="@+id/et_name"
|
||||
android:hint="Name (required)"
|
||||
android:layout_column="0"
|
||||
android:layout_row="1"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionNext"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="phone"
|
||||
android:id="@+id/et_phone"
|
||||
android:layout_column="0"
|
||||
android:layout_row="2"
|
||||
android:hint="Phone Number"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionNext"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textEmailAddress"
|
||||
android:id="@+id/et_email"
|
||||
android:hint="E-Mail Address"
|
||||
android:layout_column="0"
|
||||
android:layout_row="3"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionNext"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPostalAddress|textCapWords"
|
||||
android:id="@+id/et_street"
|
||||
android:hint="Street Name"
|
||||
android:layout_row="4"
|
||||
android:layout_column="0"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionNext"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPostalAddress|textCapWords"
|
||||
android:id="@+id/et_city"
|
||||
android:layout_column="0"
|
||||
android:layout_row="5"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionNext"
|
||||
android:hint="City Name"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPostalAddress|textCapCharacters"
|
||||
android:id="@+id/et_state"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionNext"
|
||||
android:hint="State Initials"
|
||||
android:layout_column="0"
|
||||
android:layout_row="6"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:id="@+id/et_zip"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:imeOptions="actionDone"
|
||||
android:layout_column="0"
|
||||
android:layout_row="7"
|
||||
android:hint="Zip Code"
|
||||
android:enabled="false"
|
||||
android:ems="10" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Save Contact"
|
||||
android:id="@+id/btn_save"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_column="0"
|
||||
android:layout_row="8" />
|
||||
|
||||
</GridLayout>
|
||||
</ScrollView>
|
140
app/src/main/res/layout/fragment_details.xml
Executable file
140
app/src/main/res/layout/fragment_details.xml
Executable file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:id="@+id/detailsScrollView">
|
||||
|
||||
<GridLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:columnCount="2"
|
||||
android:useDefaultMargins="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Name:"
|
||||
android:id="@+id/tvl_name"
|
||||
android:layout_column="0"
|
||||
android:layout_row="1"
|
||||
style="@style/ContactLabelTextView" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Phone:"
|
||||
android:id="@+id/tvl_phone"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:layout_column="0"
|
||||
android:layout_row="2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="E-Mail:"
|
||||
android:id="@+id/tvl_email"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:layout_column="0"
|
||||
android:layout_row="3" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Street:"
|
||||
android:id="@+id/tvl_street"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:layout_column="0"
|
||||
android:layout_row="4" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="City:"
|
||||
android:id="@+id/tvl_city"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:layout_column="0"
|
||||
android:layout_row="5" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="State:"
|
||||
android:id="@+id/tvl_state"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:layout_column="0"
|
||||
android:layout_row="6" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Zip:"
|
||||
android:id="@+id/tvl_zip"
|
||||
style="@style/ContactLabelTextView"
|
||||
android:layout_row="7"
|
||||
android:layout_column="0" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_column="1"
|
||||
android:layout_row="1"
|
||||
style="@style/ContactTextView" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_phone"
|
||||
android:layout_column="1"
|
||||
android:layout_row="2"
|
||||
style="@style/ContactTextView" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_email"
|
||||
android:layout_column="1"
|
||||
android:layout_row="3"
|
||||
style="@style/ContactTextView" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_street"
|
||||
android:layout_row="4"
|
||||
android:layout_column="1"
|
||||
style="@style/ContactTextView" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_city"
|
||||
android:layout_column="1"
|
||||
android:layout_row="5"
|
||||
style="@style/ContactTextView" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_state"
|
||||
style="@style/ContactTextView"
|
||||
android:layout_column="1"
|
||||
android:layout_row="6" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/tv_zip"
|
||||
style="@style/ContactTextView"
|
||||
android:layout_column="1"
|
||||
android:layout_row="7" />
|
||||
|
||||
</GridLayout>
|
||||
</ScrollView>
|
9
app/src/main/res/menu/fragment_contact_list_menu.xml
Executable file
9
app/src/main/res/menu/fragment_contact_list_menu.xml
Executable file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:id="@+id/action_add"
|
||||
android:orderInCategory="0"
|
||||
android:title="Add Contact"
|
||||
android:icon="@android:drawable/ic_menu_add"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
</menu>
|
14
app/src/main/res/menu/fragment_details_menu.xml
Executable file
14
app/src/main/res/menu/fragment_details_menu.xml
Executable file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:id="@+id/action_edit"
|
||||
android:orderInCategory="0"
|
||||
android:title="Edit Contact"
|
||||
android:icon="@android:drawable/ic_menu_edit"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
<item android:id="@+id/action_delete"
|
||||
android:orderInCategory="0"
|
||||
android:title="Delete Contact"
|
||||
android:icon="@android:drawable/ic_delete"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
</menu>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Executable file
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Executable file
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Executable file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Executable file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Executable file
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
6
app/src/main/res/values-w820dp/dimens.xml
Executable file
6
app/src/main/res/values-w820dp/dimens.xml
Executable file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
6
app/src/main/res/values/colors.xml
Executable file
6
app/src/main/res/values/colors.xml
Executable file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
5
app/src/main/res/values/dimens.xml
Executable file
5
app/src/main/res/values/dimens.xml
Executable file
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
9
app/src/main/res/values/strings.xml
Executable file
9
app/src/main/res/values/strings.xml
Executable file
@ -0,0 +1,9 @@
|
||||
<resources>
|
||||
<string name="app_name">Address Book</string>
|
||||
<string name="no_contacts">No contacts have been added yet.</string>
|
||||
<string name="msg_confirm_title">Are You Sure?</string>
|
||||
<string name="msg_confirm_text">This will permanently delete the contact</string>
|
||||
<string name="msg_confirm_ok_button">OK</string>
|
||||
<string name="msg_confirm_cancel_button">Cancel</string>
|
||||
<string name="error_create_contact">You must enter a contact name</string>
|
||||
</resources>
|
27
app/src/main/res/values/styles.xml
Executable file
27
app/src/main/res/values/styles.xml
Executable file
@ -0,0 +1,27 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="ContactLabelTextView">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_gravity">right|center_vertical</item>
|
||||
</style>
|
||||
|
||||
<style name="ContactTextView">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_gravity">fill_horizontal</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:background">@drawable/textview_border</item>
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
@ -0,0 +1,15 @@
|
||||
package com.hyperling.apps.example_sqlite_addressbook;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view.
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user