Android Open Source - dCache-Cloud Profile Activity






From Project

Back to project page dCache-Cloud.

License

The source code is released under:

Copyright ? 2013, Michael Stapelberg and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following ...

If you think the Android project dCache-Cloud listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.desy.dCacheCloud.Activities;
/*from  ww w  .j  av  a2  s .  co m*/
import External.Contents;
import External.QRCodeEncoder;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;

import de.desy.dCacheCloud.CryptoHelper;
import de.desy.dCacheCloud.KeyStoreHelper;
import de.desy.dCacheCloud.R;

public class ProfileActivity extends Activity {

  private ImageView ivQR;
  private TextView tvFingerPrint;

  
  public ProfileActivity(){}
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile);
    
    ivQR = (ImageView)findViewById(R.id.imageViewQR);
    tvFingerPrint = (TextView)findViewById(R.id.textViewFingerPrint);
         
     //Find screen size
     WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
     Display display = manager.getDefaultDisplay();
     Point point = new Point();
     display.getSize(point);
     int width = point.x;
     int height = point.y;
     int smallerDimension = width < height ? width : height;
     
     // can scale the size of the QR-Code, if needed
     // smallerDimension = smallerDimension * 3/4;
   
     //DatabaseHelper oh = new DatabaseHelper(this);
     //String content = oh.getOwnPublic().toString();
     //String hashContent = oh.getOwnHashKey();
     String content = CryptoHelper.PublicKeyToString(KeyStoreHelper.getOwnPub());
     String hashContent = CryptoHelper.hash(content);

     //Encode with a QR Code image
     QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(content, 
               null, 
               Contents.Type.TEXT,  
               BarcodeFormat.QR_CODE.toString(), 
               smallerDimension);
     try {
      Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
      ivQR.setImageBitmap(bitmap);
      tvFingerPrint.setText("Fingerprint: " + hashContent);
   
     } catch (WriterException e) {
      e.printStackTrace();
     }
  }

  @Override
  protected void onPause() {
    super.onPause();
  }

  @Override
  protected void onResume() {
    super.onResume();
  }
}




Java Source Code List

External.Contents.java
External.IntentIntegrator.java
External.IntentResult.java
External.QRCodeEncoder.java
de.desy.dCacheCloud.CountingInputStreamEntity.java
de.desy.dCacheCloud.CryptoHelper.java
de.desy.dCacheCloud.DatabaseHelper.java
de.desy.dCacheCloud.DownloadService.java
de.desy.dCacheCloud.KeyStoreHelper.java
de.desy.dCacheCloud.MySSLSocketFactory.java
de.desy.dCacheCloud.ServerHelper.java
de.desy.dCacheCloud.UploadService.java
de.desy.dCacheCloud.Activities.FriendFoundActivity.java
de.desy.dCacheCloud.Activities.ImportDataActivity.java
de.desy.dCacheCloud.Activities.MainActivity.java
de.desy.dCacheCloud.Activities.ProfileActivity.java
de.desy.dCacheCloud.Activities.ServerViewActivity.java
de.desy.dCacheCloud.Activities.SettingsActivity.java
de.desy.dCacheCloud.Activities.ShareDataActivity.java
de.desy.dCacheCloud.Activities.ShareWithFriendActivity.java
de.desy.dCacheCloud.Activities.UploadActivity.java
de.desy.dCacheCloud.Activities.UserPasswordActivity.java
de.desy.dCacheCloud.BCReceiver.NetworkReceiver.java
de.desy.dCacheCloud.BCReceiver.NewMediaReceiver.java