Android Open Source - yapea Yapea Auth Activity






From Project

Back to project page yapea.

License

The source code is released under:

GNU General Public License

If you think the Android project yapea 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 org.jdamico.yapea;
/*  w  w  w .  j  a v  a2 s .co m*/
/*
 * This file is part of YAPEA.
 * 
 *    YAPEA is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License (version 2) 
 *    as published by the Free Software Foundation.
 *
 *    YAPEA is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with YAPEA.  If not, see <http://www.gnu.org/licenses/>.
 */

import org.jdamico.yapea.commons.AppMessages;
import org.jdamico.yapea.commons.StaticObj;
import org.jdamico.yapea.commons.Utils;
import org.jdamico.yapea.commons.YapeaException;
import org.jdamico.yapea.crypto.CryptoUtils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class YapeaAuthActivity extends Activity {

  Button authButton = null;
  EditText keyEt = null;
  TextView key_textView = null;
  int countPanic = 0;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_yapea_auth);

    authButton = (Button) findViewById(R.id.auth_button);
    authButton.setText(AppMessages.getInstance().getMessage("GLOBAL.authButton"));
    
    key_textView = (TextView) findViewById(R.id.key_textView);
    key_textView.setText(AppMessages.getInstance().getMessage("GLOBAL.key_textView"));

    keyEt = (EditText) findViewById(R.id.key_text);

    authButton.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {

        if(Utils.getInstance().isAuthenticated(v.getContext(), keyEt.getText().toString())){
          
          
          try {
            CryptoUtils.getInstance().storeKeyInCache(keyEt.getText().toString(), v.getContext());
          } catch (YapeaException e) {
            Toast.makeText(getApplicationContext(), AppMessages.getInstance().getMessage("YapeaAuthActivity.onCreate.failToStoreKeyInCache"), Toast.LENGTH_LONG).show();
          }
          
          
          Intent intent = new Intent(v.getContext(), YapeaMainActivity.class);
          startActivityForResult(intent, 0);
        }else{
          countPanic = countPanic + Utils.getInstance().isPanicAuthenticated(v.getContext(), keyEt.getText().toString(), countPanic);
          //System.out.println("============== countPanic"+countPanic);
          Toast.makeText(getApplicationContext(), AppMessages.getInstance().getMessage("YapeaAuthActivity.onCreate.WrongKey"), Toast.LENGTH_LONG).show();
        }
        keyEt.setText("");
      }
    });
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(AppMessages.getInstance().getMessage("GLOBAL.about"));

    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item)
  {
    switch(item.getItemId())
    {
    case 0:
      Intent intent = new Intent(getApplicationContext(), YapeaAboutActivity.class);
      startActivityForResult(intent, 0);
      return true;
    default:
      return super.onOptionsItemSelected(item);
    }
  }
}




Java Source Code List

org.jdamico.yapea.ImageDetailActivity.java
org.jdamico.yapea.ImageDetailFragment.java
org.jdamico.yapea.ImageListActivity.java
org.jdamico.yapea.ImageListFragment.java
org.jdamico.yapea.YapeaAboutActivity.java
org.jdamico.yapea.YapeaAuthActivity.java
org.jdamico.yapea.YapeaConfigActivity.java
org.jdamico.yapea.YapeaMainActivity.java
org.jdamico.yapea.commons.ActivityHelper.java
org.jdamico.yapea.commons.AppMessages.java
org.jdamico.yapea.commons.Constants.java
org.jdamico.yapea.commons.StaticObj.java
org.jdamico.yapea.commons.Utils.java
org.jdamico.yapea.commons.YapeaException.java
org.jdamico.yapea.crypto.CryptoUtils.java
org.jdamico.yapea.dataobjects.ConfigObj.java
org.jdamico.yapea.dataobjects.CryptoAlgoObj.java
org.jdamico.yapea.dataobjects.ImageItemObj.java