Documente Academic
Documente Profesional
Documente Cultură
Java
XML
Drawable XML
Mainifest XML
JAVA:-
AddCustomItem.java:-
}
intOld = savedInstanceState!=null ? savedInstanceState.getInt(subfolder.intOld): null;
if(intOld == null)
{
intOld = extras !=null? extras.getInt(subfolder.intOld) : 0;
}
setContentView(R.layout.custom_item_layout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
final TextView centertext = (TextView) findViewById(R.id.center_text);
centertext.setText("Add Custom Item");
CustomItem = (EditText)findViewById(R.id.CustomItem);
final Spinner s1 = (Spinner)findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.CustomItemType, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
s1.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View v,
int position, long id)
{
String selectedItemString = (String)s1.getSelectedItem();
mItemType = selectedItemString;
if(mItemType.equals("Numeric"))
{
mItemDataType = information.ITEM_NUMERIC;
}
else if(mItemType.equals("Text"))
{
mItemDataType = information.ITEM_TEXT;
}
else if(mItemType.equals("Text Box"))
{
mItemDataType = information.ITEM_MULTITEXT;
}
else if(mItemType.equals("Date Format"))
{
mItemDataType = information.ITEM_DATE;
}
else
{
mItemDataType = information.ITEM_TEXT;
}
}
});
saveCustomItem = (Button)findViewById(R.id.saveCustomItem);
saveCustomItem.setOnClickListener(this);
}
@Override
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
outState.putLong(information.SubFolderID, mSubFolderId);
outState.putInt(subfolder.intOld, intOld);
}
@Override
public void onClick(View v)
{
mItemName = CustomItem.getText().toString();
if(v.getId()==R.id.saveCustomItem)
{
if(mItemName.length()>0)
{
if(mItemID==null)
{
long id;
if(intOld==1)
{
id = mDbHelper.CreateInformation(mItemDataType, mItemName, mSubFolderId);
}
else
{
id = mDbHelper.CreateInformation(mItemDataType, mItemName, 0);
}
if(id > 0)
{
mItemID = id;
}
}
Intent intent = new Intent();
intent.putExtra(information.SubFolderID , mSubFolderId);
intent.putExtra("mItemID", mItemID);
setResult(RESULT_OK, intent);
finish();
return;
}
else
{
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Item Name");
alertDialog.setMessage("Please enter Item Name.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
return;
}
});
alertDialog.show();
}
}
}
Pocketdiary.java:-
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
RelativeLayout r = (RelativeLayout)findViewById(R.id.pocketwelcome);
startnew();
r.setOnTouchListener(this);
}
public boolean onTouch (View v, MotionEvent event )
{
startnew();
return true;
}
if(correctMd5 != null)
{
//Bundle bundle= new Bundle();
//bundle.putString("correctMd5", correctMd5);
loginIntent= new Intent(aPocketDiary.this,Authentication.class);
//loginIntent.putExtras(bundle);
}
else
{
loginIntent= new Intent(aPocketDiary.this,LoginView.class);
}
startActivityForResult(loginIntent,ACTIVITY_START);
}
catch (Throwable er)
{
Toast.makeText(aPocketDiary.this, "Error "+er.getMessage(),
Toast.LENGTH_LONG).show();
}
}
}, 3000);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
startnew();
Login.java:-
public class LoginView extends Activity implements
OnClickListener
{
public static final String PASSWORD_PREF_KEY = "passwd";
Button btnSavePassword;
private EditText pass1;
private EditText pass2;
private AlertDialog alertDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.setpassword);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title);
final TextView centertext = (TextView)
findViewById(R.id.center_text);
centertext.setText("Set Password");
pass1 = (EditText) findViewById(R.id.password);
pass2 = (EditText) findViewById(R.id.password_confirm);
btnSavePassword = (Button)findViewById(R.id.ok);
btnSavePassword.setOnClickListener(this);
}
public void onClick(View v)
{
String p1 = pass1.getText().toString();
String p2 = pass2.getText().toString();
if (p1.equals(p2))
{
}
else
{
if(p1.length()==0)
{
alertDialog = new
AlertDialog.Builder(this).create();
alertDialog.setTitle("Password");
alertDialog.setMessage("Please enter
password.");
alertDialog.setButton("OK", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int which)
{
return;
}
});
}
else
{
alertDialog = new
AlertDialog.Builder(this).create();
alertDialog.setTitle("Password");
alertDialog.setMessage("Passwords must be at
least 6 characters.");
alertDialog.setButton("OK", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int which) {
return;
}
});
}
}
else
{
pass1.setText("");
pass2.setText("");
alertDialog = new AlertDialog.Builder(this).create();
//.setTitle("Passwords do not match")
alertDialog.setMessage("Passwords do not match");
alertDialog.setButton("OK", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
which)
{
return;
}
});
alertDialog.show();
}
public static String getMd5Hash(String input) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(input.getBytes());
BigInteger number = new BigInteger(1,messageDigest);
String md5 = number.toString(16);
return md5;
} catch(NoSuchAlgorithmException e) {
Log.e("MD5", e.getMessage());
return null;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent msg)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
Intent intent = new Intent();
setResult(RESULT_OK,intent);
finish();
}
return true;
}
ItemList.java:-
if(v.getId()==R.id.menu_help)
{
Intent changePassIntent= new Intent(this,Help.class);
startActivity(changePassIntent);
}
else if(v.getId()==R.id.btnAddNewFolder)
{
Intent folderEditorIntent= new
Intent(this,FolderEditor.class);
startActivityForResult(folderEditorIntent,ACTIVITY_CREATE);
}
}
private void fillData()
{
try
{
folderCursor = mDbHelper.FetchAllFolders();
startManagingCursor(folderCursor);
lv.setAdapter(new EfficientAdapter(this,folderCursor));
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View
v, int position, long id)
{
Intent SubFolderListIntent = new
Intent(ItemList.this, SubItemList.class);
SubFolderListIntent.putExtra(subfolder.FolderID,
id);
startActivityForResult(SubFolderListIntent,ACTIVITY_CREATE_SUBFO
LDER);
}
});
}
catch (Throwable er)
{
Toast.makeText(this, "Error "+er.getMessage(),
Toast.LENGTH_LONG).show();
}
private class EfficientAdapter extends CursorAdapter
{
private final LayoutInflater mInflater;
public EfficientAdapter(Context context, Cursor cursor)
{
super(context,cursor,true);
mInflater = LayoutInflater.from(context);
}
@Override
public void bindView(View view, Context context, Cursor
cursor)
{
int resID =
getResources().getIdentifier(cursor.getString(cursor.getColumnIn
dex(folder.FolderImage)), "drawable",
"com.softwaredepotonline.iPocketDiary");
ImageView s = (ImageView)
view.findViewById(R.id.FolderIcon);
s.setImageResource(resID);
TextView t = (TextView)
view.findViewById(R.id.sFolderName);
t.setText(cursor.getString(cursor.getColumnIndex(folder.FolderNa
me)));
@Override
public View newView(Context context, Cursor cursor,
ViewGroup parent)
{
// TODO Auto-generated method stub
final View view =
mInflater.inflate(R.layout.folderlist_item, parent, false);
return view;
@Override
protected void onActivityResult(int requestCode, int
resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
fillData();
}
XML:-
Authlayout.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:background="@drawable/password"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="20dip"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="40dip">
<TextView android:layout_height="wrap_content"
android:text="@string/enter_password"
android:id="@+id/label"
android:layout_width="150px"
style="@style/textview_style"/>
<EditText android:id="@+id/password"
android:maxLines="1"
android:singleLine="true"
android:layout_height="wrap_content"
android:password="true"
android:inputType="textPassword"
android:layout_marginTop="5dip"
android:background="@android:drawable/editbox_background"
android:layout_width="160dip"
android:layout_below="@id/label"
/>
<Button
android:id="@+id/ok"
android:layout_width="150dip"
android:text="@string/button_ok"
android:layout_gravity="left"
android:layout_marginTop="10dip"
android:layout_below="@id/password"
android:layout_height="40dip" android:soundEffectsEnabled="true"/>
<Button android:id="@+id/btnChangePassword"
style="@style/textview_btnstyle"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:text="@string/button_ChangePassword"
android:background="@drawable/textviewbutton"
android:layout_width="140dip"
android:layout_height="35dip"
android:layout_below="@+id/ok"/>
</RelativeLayout>
</LinearLayout>
Setpassword.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:background="@drawable/password"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="20dip"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="40dip">
<TextView android:layout_height="wrap_content"
android:text="@string/enter_password"
android:id="@+id/label"
android:layout_width="150px"
style="@style/textview_style"/>
<EditText android:id="@+id/password"
android:maxLines="1"
android:singleLine="true"
android:layout_height="wrap_content"
android:password="true"
android:inputType="textPassword"
android:layout_marginTop="5dip"
android:background="@android:drawable/editbox_background"
android:layout_width="160dip"
android:layout_below="@id/label"
/>
<Button
android:id="@+id/ok"
android:layout_width="150dip"
android:text="@string/button_ok"
android:layout_gravity="left"
android:layout_marginTop="10dip"
android:layout_below="@id/password"
android:layout_height="40dip" android:soundEffectsEnabled="true"/>
<Button android:id="@+id/btnChangePassword"
style="@style/textview_btnstyle"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:text="@string/button_ChangePassword"
android:background="@drawable/textviewbutton"
android:layout_width="140dip"
android:layout_height="35dip"
android:layout_below="@+id/ok"/>
</RelativeLayout>
</LinearLayout>
Categorylist.xml
<ImageView android:id="@+id/FolderIcon"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content" />
<TextView android:id="@+id/sFolderName"
android:layout_gravity="center_vertical"
android:paddingLeft="10dip"
android:layout_width="0dip"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<ImageView android:id="@+id/ArrowIcon"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:background="@drawable/forward_32"/>
</LinearLayout>
Infomain.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/help"
android:layout_height="fill_parent"
>
<LinearLayout
android:background="@drawable/border"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/subFolderImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/bank"
/>
<TextView
android:id="@+id/subFolderName"
android:layout_gravity="center_vertical"
android:paddingLeft="10dip"
android:layout_width="0dip"
android:layout_weight="1.0"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/btnEditSubFolder"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:background="@drawable/btn_expand" />
</LinearLayout>
<ListView android:id="@+id/ListView01"
android:layout_width="fill_parent"
android:layout_marginTop="15dp"
android:paddingLeft="20dip"
android:layout_weight="1.0"
android:layout_height="fill_parent"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnAddNewItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:drawable/ic_menu_add"
android:soundEffectsEnabled="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="50dip"/>
<Button
android:id="@+id/btnDeleteSubFolder"
android:background="@android:drawable/ic_menu_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:soundEffectsEnabled="true"
android:layout_marginRight="50dip"/>
</RelativeLayout>
</LinearLayout>
DRAWABLE XML:-
Border.xml:-
Checkmark.xml:-
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@drawable/ic_text_dot_c_invert" />
<item android:drawable="@drawable/ic_text_dot_c" />
</selector>
Textviewbutton.xml:-
AndroidManifest.xml:-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.softwaredepotonline.iPocketDiary"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" android:resizeable="true"/>
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:name=".aPocketDiary"
android:screenOrientation="portrait" android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" android:maxSdkVersion="7"/>
</manifest>