Monday, 31 August 2015

KESCO APP







LOGIN LAYOUT

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/bg_login"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="10dp" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:paddingLeft="20dp"
        android:paddingRight="20dp" >

        <EditText
            android:id="@+id/email"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:background="@color/white"
            android:hint="@string/hint_email"
            android:inputType="textEmailAddress"
            android:padding="10dp"
            android:singleLine="true"
            android:textColor="@color/input_login"
            android:textColorHint="@color/input_login_hint" />

        <EditText
            android:id="@+id/password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:background="@color/white"
            android:hint="@string/hint_password"
            android:inputType="textPassword"
            android:padding="10dp"
            android:singleLine="true"
            android:textColor="@color/input_login"
            android:textColorHint="@color/input_login_hint" />

        <!-- Login Button -->

        <Button
            android:id="@+id/btnLogin"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dip"
            android:background="@color/btn_login_bg"
            android:text="@string/btn_login"
            android:textColor="@color/btn_login" />

        <!-- Link to Login Screen -->

        <Button
            android:id="@+id/btnLinkToRegisterScreen"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dip"
            android:background="@null"
            android:text="@string/btn_link_to_register"
            android:textAllCaps="false"
            android:textColor="@color/white"
            android:textSize="15dp" />
    </LinearLayout>

</LinearLayout>

Saturday, 22 August 2015

Android Image capture

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.camera);
        Button txt1=(Button)findViewById(R.id.dissum);
        Button txt2=(Button)findViewById(R.id.dup);
        txt1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                   
                //Toast.makeText(getApplicationContext(), "Under construction....  " , Toast.LENGTH_LONG).show();

                   
 //                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//                     File f = new File(android.os.Environment.getExternalStorageDirectory(), "subtemp.jpg");
//                     intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
//                     startActivityForResult(intent, 1);
                   
                    String fileName = "subimage.jpg";
                       //create parameters for Intent with filename
                       ContentValues values = new ContentValues();
                       values.put(MediaStore.Images.Media.TITLE, fileName);
                       values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");
                       //imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)
                       imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
                       //create new Intent
                       Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                       intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                       intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
                       startActivityForResult(intent, 1);
                }
               
               
            });
        txt2.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                   
                    gps = new GPSTracker(camera.this);
                   
                    // check if GPS enabled   
                    if(gps.canGetLocation()){
                        
                        latitude = gps.getLatitude();
                       longitude = gps.getLongitude();
                         if(latitude!=0 && longitude!=0)
                         {
                             if (bitmap == null) {
                                 Toast.makeText(getApplicationContext(),
                                         "Please Select Image ..", Toast.LENGTH_SHORT).show();
                             } else {
//                                 dialog = ProgressDialog.show(SellMyProperty.this, "Uploading",
//                                         "Please wait...", true);
                            
                         new ImageUploadTask().execute();
                             }
                         }
                         else{
                                Toast.makeText(getApplicationContext(), "Please Wait Gps fetch the value....  " , Toast.LENGTH_LONG).show();
                            }
                        // \n is for new line
                       Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();  
                   //latlong="Lat:-"+latitude+"Long:-"+longitude+" ";
                  
                   
                   
                 
                    }else{
                        // can't get location
                        // GPS or Network is not enabled
                        // Ask user to enable GPS/network in settings
                         buildAlertMessageNoGps();
                      
                     //  Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();  
                       // latlong="Lat:-"+latitude+"Long:-"+longitude+" ";
                       
                    }
                   
               
                }
                });
       
    }

   

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
       
        String filePath = null;
        if (resultCode == RESULT_OK) {
            if (requestCode == 1) {

                 selectedImageUri = imageUri;
            } else if (requestCode == 2) {
               
                selectedImageUri = data.getData();
//                Uri selectedImageUri = data.getData();
//                String p=selectedImageUri.getPath();
//
//                String tempPath = data.getDataString();
//                Log.i("path of image from gallery......******************.........", p);
//                Bitmap bitmap;
//                BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
//                bitmap = BitmapFactory.decodeFile(tempPath, bitmapOptions);
//                imgView.setImageBitmap(bitmap);

//                Uri selectedImage = data.getData();
//                String[] filePath = { MediaStore.Images.Media.DATA };
//                Cursor c = getContentResolver().query(selectedImage,filePath, null, null, null);
//                c.moveToFirst();
//                int columnIndex = c.getColumnIndex(filePath[0]);
//                String picturePath = c.getString(columnIndex);
//                c.close();
//                Bitmap bitmap = (BitmapFactory.decodeFile(picturePath));
//                Log.w("path of image from gallery......******************.........", picturePath+"");
//                imgView.setImageBitmap(bitmap);
            }
           
            if(selectedImageUri != null){
             try {
                 // OI FILE Manager
                 String filemanagerstring = selectedImageUri.getPath();

                 // MEDIA GALLERY
                 String selectedImagePath = getPath(selectedImageUri);
//                 txt9.setText(selectedImagePath);
                 if (selectedImagePath != null) {
                     filePath = selectedImagePath;
                 } else if (filemanagerstring != null) {
                     filePath = filemanagerstring;
                 } else {
                     Toast.makeText(getApplicationContext(), "Unknown path",
                             Toast.LENGTH_LONG).show();
                     Log.e("Bitmap", "Unknown path");
                 }

                 if (filePath != null) {
                     decodeFile(filePath);
                 } else {
                     bitmap = null;
                 }
             } catch (Exception e) {
                 Toast.makeText(getApplicationContext(), "Internal error",
                         Toast.LENGTH_LONG).show();
                 Log.e(e.getClass().getName(), e.getMessage(), e);
             }
     }
        }



}