LISTING PROGRAM
1.
Search.java
package id.mego;import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
public class Search {
public static List<Integer> match(String pattern, String text) { List<Integer> matches = new ArrayList<Integer>();
// pecocokan panjang pattern (n) dengan panjang text (m) int m = text.length();
int n = pattern.length();
//proses pencocokan pattern dari kanan ke kiri dan proses sebelum Bad Character
//dengan mencari posisi paling kanan dari semua karakter dalam pattern:
Map<Character, Integer> rightMostIndexes =
preprocessForBadCharacterShift(pattern);
//mensejajarkan p dan t mulai dari indek 0 yaitu : awal teks = awal pattern
//posisi 0 di cocokan dari awal pattern //pencocokan karakter akhir sampai awal int alignedAt = 0;
while (alignedAt + (n - 1) < m) {
//Pada setiap posisi sejajar, kita memindai pattern dari kanan ke kiri, membandingkan karakter
//sejajar pada posisi saat ini dalam teks (t) dan pada posisi saat ini dalam pattern (p)
for (int indexInPattern = n - 1; indexInPattern >= 0; indexInPattern--) {
int indexInText = alignedAt + indexInPattern; char x = text.charAt(indexInText);
char y = pattern.charAt(indexInPattern); if (indexInText >= m) break;
//kasus ketidakcocokan, kita melakukan pergeseran: if (x != y) {
//Pertama-tama kita mengambil paling kanan indeks ketidakcocokan teks-karakter dalam pattern
Integer r = rightMostIndexes.get(x); //Jika karakter ketidakcocokan dalam teks tidak dalam pattern kita bisa menggeser sampai
//kita sejajar di belakang mismatch-posisi,
//hal ini akan mengakibatkan beberapa karakter pernah diperiksa:
if (r == null) {
alignedAt = indexInText + 1; }
//kita menggeser pattern ke kanan sampai paling kanan dari x dalam pattern posisi mismatch dalam teks
//(pergeseran ini adalah pergeseran ke depan, yaitu ke kanan),
else {
int shift = indexInText - (alignedAt + r);
alignedAt += shift > 0 ? shift : 1; }
break; }
//Jika karakter macth gerer pencocokan dari kanan ke kiri,
//kita mencocokan karakter berikutnya dalam teks. else if (indexInPattern == 0) {
matches.add(alignedAt); alignedAt++;
} } }
return matches; }
//Untuk masing-masing karakter dalam pattern kita menyimpan hasil pencocokan yang paling kanan
private static Map<Character, Integer> preprocessForBadCharacterShift(
String pattern) {
Map<Character, Integer> map = new HashMap<Character, Integer>();
for (int i = pattern.length() - 1; i >= 0; i--) { char c = pattern.charAt(i);
if (!map.containsKey(c)) map.put(c, i); }
return map; }
}
2.
MainActivity.java
package id.mego;import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class MainActivity extends
android.support.v4.app.FragmentActivity implements OnClickListener {
private boolean draweropened = false;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.navigationdrawer);
if(getSupportFragmentManager().findFragmentByTag(ContactFragment.TAG) == null)
getSupportFragmentManager().beginTransaction().add(R.id.container,
new ContactFragment(), ContactFragment.TAG).commit(); }
public void onClick(View v) {
// TODO Auto-generated method stub
DrawerLayout drawer = (DrawerLayout)findViewById(R.id.list); if(draweropened)
drawer.closeDrawer(findViewById(R.id.navigationdrawer)); else
drawer.openDrawer(findViewById(R.id.navigationdrawer));
draweropened = !draweropened;
} }
3.
NavigationDrawerFragment.java
package id.mego;import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class NavigationDrawerFragment extends
android.support.v4.app.ListFragment {
public void onViewCreated(View view, Bundle bundle) { super.onViewCreated(view, bundle);
getListView().setBackgroundColor(getResources().getColor(R.color.whit e));
setListAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, new String[] { "Help", "About" }) {
private int[] imgResource = { R.drawable.ic_help, R.drawable.ic_about };
public View getView(int position, View convertView, android.view.ViewGroup root) {
if(convertView == null)
convertView =
LayoutInflater.from(getActivity()).inflate(R.layout.item_navdrawer, root, false);
((TextView)
convertView.findViewById(R.id.text_list)).setText(getItem(position));
((ImageView)
convertView.findViewById(R.id.ic_list)).setImageResource(imgResource[p osition]);
return convertView;
}
}); }
public void onListItemClick(android.widget.ListView listView, View v,
int position, long id) { switch(position) { case 0:
startActivity(new Intent(getActivity(), Help.class));
case 1:
startActivity(new Intent(getActivity(), About.class));
break;
} }
}
4.
ContactFragment.java
import java.util.ArrayList;import java.util.List;
import id.mego.adapter.Adapter;
import id.mego.database.ContactDB;
import id.mego.entity.Contact;
import android.content.Intent;
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.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Toast;
public class ContactFragment extends android.support.v4.app.Fragment
implements OnItemClickListener {
public static String TAG = "ContactFragment";
private ListView lv;
private ContactDB db;
private Adapter adapter;
public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_main, root,
false);
db = ContactDB.getInstance(getActivity());
lv = (ListView) view.findViewById(R.id.listview_contact); lv.setEmptyView(view.findViewById(R.id.empty));
if (db.isContactHasData()) {
List<Contact> contacts = db.getAllContact(); adapter = new Adapter(getActivity(), contacts); lv.setAdapter(adapter);
}
lv.setOnItemClickListener(this); setHasOptionsMenu(true);
return view; }
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
SearchView search = (SearchView)
menu.findItem(R.id.action_search).getActionView(); search.setOnQueryTextListener(new
SearchView.OnQueryTextListener() {
public boolean onQueryTextSubmit(String query) {
return false;
}
public boolean onQueryTextChange(String newText) { if(newText.equals(""))
lv.setAdapter(new Adapter(getActivity(), db.getAllContact()));
else {
ArrayList<Contact> found = new
ArrayList<Contact>();
for(int i = 0; i < adapter.getCount(); i++) {
Contact data = (Contact)
adapter.getItem(i);
if(!Search.match(newText.toUpperCase(),
data.getNama().toUpperCase()).isEmpty())
found.add(data);
}
lv.setAdapter(new Adapter(getActivity(), found));
}
return false;
}
}); }
@Override
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) {
case R.id.add:
Toast.makeText(getActivity(), "add contact", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getActivity(), Add.class));
return true;
default:
return super.onOptionsItemSelected(item); }
}
@Override
public void onItemClick(AdapterView<?> adapterView, View arg1, int
position, long arg3) {
Bundle b = new Bundle();
ListAdapter adapter = lv.getAdapter();
b.putInt("id", ((Contact) adapter.getItem(position)).getId()); b.putString("nama", ((Contact)
b.putString("pict", ((Contact) adapter.getItem(position)).getPict());
Intent i = new Intent(getActivity(), Detail.class); i.putExtras(b);
startActivity(i); }
}
5.
Add.java
package id.mego;import id.mego.database.ContactDB;
import id.mego.entity.Contact;
import id.mego.MainActivity;
import id.mego.R;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
public class Add extends ActionBarActivity implements OnClickListener {
private EditText nama, email, phone, address, note;
private Button cancel, done;
private ContactDB db;
private ImageView pict;
private String imgPath = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_add);
db = ContactDB.getInstance(this);
nama = (EditText) findViewById(R.id.input_name); email = (EditText) findViewById(R.id.input_email); phone = (EditText) findViewById(R.id.input_phone); address = (EditText) findViewById(R.id.input_alamat); note = (EditText) findViewById(R.id.input_catatan); cancel = (Button) findViewById(R.id.btn_cancel); done = (Button) findViewById(R.id.btn_done);
pict = (ImageView) findViewById(R.id.input_image); pict.setOnClickListener(this);
cancel.setOnClickListener(this); done.setOnClickListener(this); }
@Override
if (v == done) {
if (!TextUtils.isEmpty(nama.getText().toString()) && !TextUtils.isEmpty(phone.getText().toString())
&& !TextUtils.isEmpty(email.getText().toString()) && !TextUtils.isEmpty(address.getText().toString())
&& !TextUtils.isEmpty(note.getText().toString())) {
String name =
nama.getText().toString().toLowerCase();
name = String.valueOf(name.charAt(0)).toUpperCase() + name.substring(1, name.length());
db.addContact(new Contact(
name,
phone.getText().toString(),
email.getText().toString(),
address.getText().toString(),
note.getText().toString(),
imgPath));
startActivity(new Intent(this, MainActivity.class));
finish();
} else
{
Toast.makeText(this, "Lengkapi Data", Toast.LENGTH_SHORT)
.show();
} }
else if (v == cancel) {
startActivity(new Intent(this, MainActivity.class)); finish();
}
else if(v == pict) {
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 1);
} }
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed(); finish();
startActivity(new Intent(this, MainActivity.class)); }
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 1 && resultCode == RESULT_OK) { String[] projection = {
android.provider.MediaStore.Images.Media.DATA }; android.database.Cursor c =
getContentResolver().query(data.getData(), projection, "", null, ""); if(c.moveToFirst()) {
imgPath =
c.getString(c.getColumnIndex(projection[0]));
pict.setImageURI(Uri.parse(imgPath));
}
} }
6.
Edit.java
import id.mego.database.ContactDB;
import id.mego.entity.Contact;
import android.net.Uri;
import android.os.Bundle;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
public class Edit extends ActionBarActivity implements OnClickListener {
private EditText nama, email, phone, address, note;
private Button cancel, done;
private ContactDB db;
private ImageView pict;
private String imgPath = "";
private int id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit);
getSupportActionBar().setTitle("Edit Contact");
db = ContactDB.getInstance(this);
nama = (EditText) findViewById(R.id.edit_name); email = (EditText) findViewById(R.id.edit_email); phone = (EditText) findViewById(R.id.edit_phone); address = (EditText) findViewById(R.id.edit_alamat); note = (EditText) findViewById(R.id.edit_catatan); cancel = (Button) findViewById(R.id.btn_cancel); done = (Button) findViewById(R.id.btn_done); pict = (ImageView)findViewById(R.id.edit_image);
Bundle b = getIntent().getExtras(); if (b != null)
{
id = b.getInt("id");
nama.setText(b.getString("name")); phone.setText(b.getString("phone")); email.setText(b.getString("email")); address.setText(b.getString("address")); note.setText(b.getString("note"));
if((imgPath = b.getString("pict")).equals("")) pict.setImageResource(R.drawable.icon_user);
else
pict.setImageURI(Uri.parse(imgPath));
}}
@Override
public void onClick(View v) {
if (v == done) {
String name = nama.getText().toString().toLowerCase(); name = String.valueOf(name.charAt(0)).toUpperCase() + name.substring(1, name.length());
Contact contact = new Contact(
name,
phone .getText().toString(),
email.getText().toString(),
address.getText().toString(),
note.getText().toString(),
imgPath);
contact.setId(id);
db.editContact(contact);
startActivity(new Intent(this, MainActivity.class));
finish();
} else if (v == cancel) {
startActivity(new Intent(this, MainActivity.class));
finish();
}
else if(v == pict) {
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 1);
} }
@Override
public void onBackPressed() {
// TODO Auto-generated method stub super.onBackPressed();
startActivity(new Intent(this, MainActivity.class)); finish();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 1 && resultCode == RESULT_OK) { String[] projection = {
android.provider.MediaStore.Images.Media.DATA }; android.database.Cursor c =
getContentResolver().query(data.getData(), projection, "", null, ""); if(c.moveToFirst()) {
imgPath =
c.getString(c.getColumnIndex(projection[0]));
pict.setImageURI(Uri.parse(imgPath));
}
} }
}
import id.mego.database.ContactDB;
import android.R.drawable;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
public class Detail extends ActionBarActivity implements
OnClickListener {
private TextView phone, email, address, note; private int id;
private ImageView call, btnEmail, pict,btnmessage; private String imgPath = "";
private ContactDB db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
db = ContactDB.getInstance(this);
phone = (TextView) findViewById(R.id.txt_phone_number); email = (TextView) findViewById(R.id.txt_email);
address = (TextView) findViewById(R.id.txt_alamat); note = (TextView) findViewById(R.id.txt_catatan); pict = (ImageView) findViewById(R.id.thumb_detail); call = (ImageView) findViewById(R.id.btn_call); btnEmail = (ImageView) findViewById(R.id.btn_email); btnmessage = (ImageView) findViewById(R.id.btn_message);
Bundle b = getIntent().getExtras(); if (b != null)
{
id = b.getInt("id");
phone.setText(b.getString("phone")); address.setText(b.getString("address")); note.setText(b.getString("note"));
if((imgPath = b.getString("pict")).equals("")) pict.setImageResource(R.drawable.icon_user); else
pict.setImageURI(Uri.parse(imgPath));
getSupportActionBar().setTitle(b.getString("nama")); if (!b.getString("email").equals("null"))
{
email.setText(b.getString("email")); } else
{
}
}
call.setOnClickListener(this);
btnmessage.setOnClickListener(this); btnEmail.setOnClickListener(this); }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.detail_contact, menu); return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit:
Bundle b = new Bundle(); b.putInt("id", id); b.putString("name",
getSupportActionBar().getTitle().toString());
b.putString("email", email.getText().toString()); b.putString("phone", phone.getText().toString()); b.putString("address", address.getText().toString()); b.putString("note", note.getText().toString());
b.putString("pict", imgPath);
Intent i = new Intent(this, Edit.class);
i.putExtras(b);
startActivity(i);
finish();
return true;
case R.id.action_delete: showSettingsAlert(); return true;
default:
return super.onOptionsItemSelected(item);
} }
@Override
public void onClick(View v) {
if (v == btnEmail) {
if (!email.getText().toString().equals("")) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
Uri.fromParts("mailto",
email.getText().toString(),
null));
.createChooser(emailIntent, "Send email..."));
}
}
else if (v == call) {
Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" +
phone.getText().toString())); startActivity(callIntent);
}
else if (v == btnmessage ) {
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", phone.getText().toString(),
null));
startActivity(Intent
.createChooser(smsIntent, "Send Message..."));
} }
private void showSettingsAlert() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setIcon(drawable.ic_menu_help); alert.setTitle("Delete");
alert.setMessage("Delete Contact");
alert.setPositiveButton("Yes", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
db.deleteContact(id);
startActivity(new Intent(Detail.this,
MainActivity.class));
finish();
} });
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel(); }
});
alert.show();
}
public void onBackPressed() {
super.onBackPressed();
startActivity(new Intent(Detail.this, MainActivity.class)); finish();
} }
8.
About.java
package id.mego;import android.app.Activity;
import android.os.Bundle;
public class About extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about); }
}
9.
Help.java
package id.mego;import android.app.Activity;
import android.os.Bundle;
public class Help extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help); }}
10.
Actionnavigation.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="horizontal" > <ImageButton
android:id="@+id/navi"
style="?android:attr/borderlessButtonStyle" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:src="@drawable/ic_drawer"/> <TextView
android:id="@+id/teksnav"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Contact Manager" android:textColor="@color/white" android:textSize="17sp"
</LinearLayout>
11.
Activity_about.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:layout_marginTop="5dp"
android:text="IMPLEMENTASI ALGORITMA PENCOCOKAN STRING BOYER-MOORE DALAM PEMBUATAN CONTACT MANAGER PADA PLATFORM ANDROID" /> <TextView
android:id="@+id/textView2"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:layout_marginTop="5dp" android:text="SKRIPSI"/>
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:layout_marginTop="5dp" android:text="MEGO SUNTORO"/> <TextView
android:id="@+id/textView4"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:layout_marginTop="5dp" android:text="101401004"/> <ImageView
android:id="@+id/iconusu"
android:layout_marginTop="20dp" android:layout_width="150dp" android:layout_height="150dp" android:layout_gravity="center" android:src="@drawable/ic_usu"/> <TextView
android:id="@+id/textView5"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:layout_marginTop="80dp"
android:text="PROGRAM STUDI S1 ILMU KOMPUTER\nFAKULTAS ILMU KOMPUTER DAN TEKNOLOGI INFORMASI UNIVERSITAS SUMATERA UTARA\n2014"/>
12.
Activity_add.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical" >
<LinearLayout
android:id="@+id/input_content" android:layout_width="match_parent" android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="@+id/input_image"
android:layout_width="match_parent" android:layout_height="150dp"
android:src="@drawable/icon_user" />
<EditText
android:id="@+id/input_name"
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Nama"
android:inputType="textPersonName" />
<EditText
android:id="@+id/input_phone"
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Handphone"
android:inputType="number" />
<EditText
android:id="@+id/input_email"
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/input_alamat" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Address"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/input_catatan" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Note"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content" android:orientation="horizontal" >
<Button
android:id="@+id/btn_cancel" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:textColor="@color/white" android:background="#444069" android:text="Cancel" />
<Button
android:id="@+id/btn_done" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:textColor="@color/white" android:background="#444069" android:text="Done" />
</LinearLayout> </LinearLayout>
13.
Activity_edit.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical" >
<LinearLayout
android:id="@+id/input_content" android:layout_width="match_parent" android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="@+id/edit_image"
android:layout_width="match_parent" android:layout_height="150dp"
android:src="@drawable/icon_user" />
<EditText
android:id="@+id/edit_name"
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/edit_phone"
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Handphone"
android:inputType="number" />
<EditText
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/edit_alamat"
android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Address"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/edit_catatan" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Note"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<Button
android:id="@+id/btn_cancel" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:background="#444069" android:textColor="@color/white" android:text="Cancel" />
<Button
android:id="@+id/btn_done" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:background="#444069" android:textColor="@color/white" android:text="Done" />
</LinearLayout>
</LinearLayout>
14.
Activity_help.xml
<?xml version="1.0" encoding="utf-8"?> <ScrollView
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content"> <LinearLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" >
<TextView
android:gravity="center"
android:background="@color/redpa" android:textColor="@color/white" android:textSize="16dp"
android:text="Petunjuk Penggunaan Contact Manager" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="1.Gunakan actionbar tambah " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_add" android:background="@color/black" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk menambah contact baru" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="2.Gunakan actionbar Search " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_search" android:background="@color/black" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk mencari contact" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="3.Gunakan actionbar edit " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_edit" android:background="@color/black" /> <TextView
android:layout_marginLeft="10dp"
android:text="untuk mengedit contact" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="4.Gunakan actionbar delete " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_delete" android:background="@color/black" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk menghapus contact" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="5.Gunakan actionbar navigasi " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:background="@color/black" android:src="@drawable/ic_drawer" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk melihat menu navigasi" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="6.Gunakan navigasi help " /> <ImageView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk melihat bantuan" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="7.Gunakan navigasi about " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_about" android:background="@color/white" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk melihat tentang pembuat dan aplikasi" />
<View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="8.Gunakan button call " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_call" android:background="@color/white" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk memanggil contact" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="9.Gunakan button message " /> <ImageView
android:src="@drawable/ic_message" android:background="@color/white" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk mengirim pesan teks" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"
android:text="10.Gunakan button email " /> <ImageView
android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_email" android:background="@color/white" /> <TextView
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp"
android:text="untuk mengirim pesan email" /> <View
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_marginTop="8dp" android:background="#ddd" />
</LinearLayout> </ScrollView>
15.
Activity_detail.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical" > <View
android:layout_width="match_parent" android:layout_height="10dp"
android:background="#ddd" /> <ImageView
android:id="@+id/thumb_detail" android:layout_width="match_parent" android:layout_height="150dp"
android:scaleType="fitCenter"
android:src="@drawable/icon_user" /> <View
android:layout_width="match_parent" android:layout_height="10dp"
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" >
<TextView
android:id="@+id/txtMobile"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:textColor="#000"
android:textSize="16sp" android:text="Handphone" /> <View
android:id="@+id/garis"
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_below="@id/txtMobile" android:layout_marginTop="3dp"
android:layout_marginLeft="10dp" android:layout_marginRight="225dp" android:background="#ddd" />
<TextView
android:id="@+id/txt_phone_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/garis" android:layout_marginLeft="10dp" android:textSize="16sp"
android:textColor="#888"
android:text="097871647812648"/>
<ImageView
android:id="@+id/btn_call"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:src="@drawable/ic_call" />
<ImageView
android:id="@+id/btn_message"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginRight="17dp"
android:layout_toLeftOf="@+id/btn_call" android:src="@drawable/ic_message" /> </RelativeLayout>
<View
android:layout_width="match_parent" android:layout_height="10dp"
android:layout_marginTop="8dp" android:background="#ddd" />
<RelativeLayout
android:layout_marginTop="10dp" >
<TextView
android:id="@+id/txtEmail"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="Email"
android:textColor="#000" android:textSize="16sp" /> <View
android:id="@+id/garis2"
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_below="@id/txtEmail" android:layout_marginTop="3dp" android:layout_marginLeft="10dp" android:layout_marginRight="270dp" android:background="#ddd" />
<TextView
android:id="@+id/txt_email"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_below="@id/garis2" android:text="safasf"
android:textSize="16sp" android:textColor="#888" />
<ImageView
android:id="@+id/btn_email"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:src="@drawable/ic_email" /> </RelativeLayout>
<View
android:layout_width="match_parent" android:layout_height="10dp"
android:layout_marginTop="8dp" android:background="#ddd" />
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" >
<TextView
android:id="@+id/txtAlamat" android:layout_marginLeft="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Address"
android:textSize="16sp" android:textColor="#000" /> <View
android:id="@+id/garis3"
android:layout_height="1dp"
android:layout_below="@id/txtAlamat" android:layout_marginTop="3dp"
android:layout_marginLeft="10dp" android:layout_marginRight="251dp" android:background="#ddd" />
<TextView
android:id="@+id/txt_alamat" android:layout_marginLeft="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/garis3" android:text="safasf"
android:textSize="16sp" android:textColor="#888" />
<ImageView
android:id="@+id/btn_alamat"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:layout_alignParentRight="true" android:src="@drawable/ic_home" /> </RelativeLayout>
<View
android:layout_width="match_parent" android:layout_height="10dp"
android:layout_marginTop="8dp" android:background="#ddd" />
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" >
<TextView
android:id="@+id/txtCatatan"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="Note"
android:textSize="16sp" android:textColor="#000" /> <View
android:id="@+id/garis4"
android:layout_width="match_parent" android:layout_height="1dp"
android:layout_below="@id/txtCatatan" android:layout_marginTop="3dp"
android:layout_marginLeft="10dp" android:layout_marginRight="275dp" android:background="#ddd" />
<TextView
android:id="@+id/txt_catatan"
android:textSize="16sp" android:textColor="#888" />
<ImageView
android:id="@+id/btn_catatan"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" android:src="@drawable/ic_catatan" /> </RelativeLayout>
<View
android:layout_width="match_parent" android:layout_height="100dp"
android:layout_marginTop="3dp" android:background="#ddd" />
</LinearLayout>
16.
Activity_main.xml
<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="id.mego.MainActivity" >
<ListView
android:id="@+id/listview_contact" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@color/list_divider" android:dividerHeight="0.5dp">
</ListView>
<TextView
android:id="@+id/empty"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/listview_contact" android:text="Contact Empty" />
</RelativeLayout>
17.
Item_navdrawer.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="horizontal"> <ImageView
android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView
android:id="@+id/text_list" android:padding="8dp"
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" android:textSize="16sp" /> </LinearLayout>
18.
Navigationdrawer.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:id="@+id/list"
android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout
android:id= "@+id/container"
android:layout_height="match_parent" android:layout_width="match_parent" /> <fragment
android:id="@+id/navigationdrawer"
android:name="id.mego.NavigationDrawerFragment" android:layout_width="240dp"
android:layout_height="match_parent" android:layout_gravity="start" />
</android.support.v4.widget.DrawerLayout>
19.
Single_contact.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical" >
<ImageView
android:id="@+id/thumb_contact" android:layout_width="50dp" android:layout_height="50dp" android:layout_marginTop="12px" android:layout_marginBottom="12px" android:layout_marginRight="12px"/>
<TextView
android:id="@+id/name_contact" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black"
android:layout_below="@+id/thumb_contact" android:layout_alignTop="@+id/thumb_contact" android:layout_toRightOf="@+id/thumb_contact" android:textSize="18dp"
/> <TextView
android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@color/genre"
android:layout_below="@+id/name_contact"
android:layout_toRightOf="@+id/thumb_contact"/>