Android Open Source - PassPlus pass View






From Project

Back to project page PassPlus.

License

The source code is released under:

Apache License

If you think the Android project PassPlus 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 com.diragi.passplus;
// w w w .  j  a v  a2 s. com
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.diragi.passplus.Encrypt2;

import com.diragi.passplus.R;

public class passView extends themeCheck {
    SharedPreferences mPrefs;
    String masterPass = "";
    String passedPassword = "";
    String passBoxContent = "";
    EditText textPreview;
    EditText masterPassBox;

    @Override
    public void finOnCreate() {
        mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        String theme = mPrefs.getString("pref_themeColor", "0");
        setContentView(R.layout.activity_pass_view);

        makefontsnotshit();

        mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

        SharedPreferences.Editor editor = mPrefs.edit();



        String passedTitle = mPrefs.getString("listClickTitle", null);
        Log.d("passView", "The clicked title is: " +passedTitle);

        passedPassword = mPrefs.getString(passedTitle, null);
        Log.d("passView", "The clicked password is: " +passedPassword);

         masterPass = mPrefs.getString("mastPass", "");

        getActionBar().setTitle(passedTitle);

        masterPassBox = (EditText)findViewById(R.id.mastPassView);

        textPreview = (EditText)findViewById(R.id.passPreview);

    }

    public void onClick(View v) {

        passBoxContent = masterPassBox.getText().toString();
        Encrypt2 encrypt = new Encrypt2();
        String key = "SUPER SECRET ENCRYPTION KEY GOES HERE";

        String masterPassDec = encrypt.decrypt(key, masterPass);
        Log.d("Decrypt: ", masterPassDec);

        if (passBoxContent.equals(masterPassDec)) {
            Log.d("passView", "The passwords match");

            String decrypt = "";
            Log.d(masterPass, passedPassword);


            Encrypt2 encrypt2 = new Encrypt2();

            String mastPassData = passBoxContent;

            String masterPassDecrypt = encrypt2.decrypt(key, masterPass);

            if (masterPassDecrypt.equals(mastPassData)) {

                try {
                    decrypt = encrypt2.decrypt(key, passedPassword);
                    Log.d("Decryption: ", "Succeded: " + decrypt);
                } catch (Exception e) {
                    Log.d("Decryption", "failed");
                }
                textPreview.setText(decrypt);
                //TODO: Only show password for a set amount of time, then hide it
            } else {
                Toast.makeText(getApplicationContext(), "That is not your master password", Toast.LENGTH_SHORT).show();
            }
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.pass_view, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void makefontsnotshit(){
        EditText text1 = (EditText)findViewById(R.id.mastPassView);

        text1.setTypeface(Typeface.DEFAULT);
    }


    @Override
    public void onPause(){

        //clear the textviews/edittexts so people can't go back and find your passwords
        textPreview.setText("");
        masterPassBox.setText("");
        super.onPause();

    }

}




Java Source Code List

com.diragi.passplus.AboutActivity.java
com.diragi.passplus.ApplicationTest.java
com.diragi.passplus.BackupAgent.java
com.diragi.passplus.Backup.java
com.diragi.passplus.DriveBackup.java
com.diragi.passplus.Encrypt2.java
com.diragi.passplus.SettingsActivity.java
com.diragi.passplus.Upgrade.java
com.diragi.passplus.util.Base64DecoderException.java
com.diragi.passplus.util.Base64.java
com.diragi.passplus.util.IabException.java
com.diragi.passplus.util.IabHelper.java
com.diragi.passplus.util.IabResult.java
com.diragi.passplus.util.Inventory.java
com.diragi.passplus.util.Purchase.java
com.diragi.passplus.util.Security.java
com.diragi.passplus.util.SkuDetails.java
com.diragi.passplus.add.java
com.diragi.passplus.first.java
com.diragi.passplus.forgot.java
com.diragi.passplus.lock.java
com.diragi.passplus.main.java
com.diragi.passplus.passGen.java
com.diragi.passplus.passView.java
com.diragi.passplus.themeCheckPref.java
com.diragi.passplus.themeCheck.java