From f5efd73d33e80657b1d4af300f0916ea756e5753 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Fri, 16 Jul 2010 20:13:12 +0000 Subject: set svn:eol-style to LF for all code/resource files --- .../thialfihar/android/apg/GeneralActivity.java | 354 ++++++++++----------- 1 file changed, 177 insertions(+), 177 deletions(-) (limited to 'src/org/thialfihar/android/apg/GeneralActivity.java') diff --git a/src/org/thialfihar/android/apg/GeneralActivity.java b/src/org/thialfihar/android/apg/GeneralActivity.java index 49cbdcf2a..01bd93f92 100644 --- a/src/org/thialfihar/android/apg/GeneralActivity.java +++ b/src/org/thialfihar/android/apg/GeneralActivity.java @@ -1,177 +1,177 @@ -package org.thialfihar.android.apg; - -import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Vector; - -import org.thialfihar.android.apg.utils.Choice; - -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.ListView; -import android.widget.Toast; - -public class GeneralActivity extends BaseActivity { - private Intent mIntent; - private ArrayAdapter mAdapter; - private ListView mList; - private Button mCancelButton; - private String mDataString; - private Uri mDataUri; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.general); - - mIntent = getIntent(); - - InputStream inStream = null; - { - String data = mIntent.getStringExtra(Intent.EXTRA_TEXT); - if (data != null) { - mDataString = data; - inStream = new ByteArrayInputStream(data.getBytes()); - } - } - - if (inStream == null) { - Uri data = mIntent.getData(); - if (data != null) { - mDataUri = data; - try { - inStream = getContentResolver().openInputStream(data); - } catch (FileNotFoundException e) { - // didn't work - Toast.makeText(this, "failed to open stream", Toast.LENGTH_SHORT).show(); - } - } - } - - if (inStream == null) { - Toast.makeText(this, "no data found", Toast.LENGTH_SHORT).show(); - finish(); - return; - } - - int contentType = Id.content.unknown; - try { - contentType = Apg.getStreamContent(this, inStream); - inStream.close(); - } catch (IOException e) { - // just means that there's no PGP data in there - } - - mList = (ListView) findViewById(R.id.options); - Vector choices = new Vector(); - - if (contentType == Id.content.keys) { - choices.add(new Choice(Id.choice.action.import_public, - getString(R.string.action_importPublic))); - choices.add(new Choice(Id.choice.action.import_secret, - getString(R.string.action_importSecret))); - } - - if (contentType == Id.content.encrypted_data) { - choices.add(new Choice(Id.choice.action.decrypt, getString(R.string.action_decrypt))); - } - - if (contentType == Id.content.unknown) { - choices.add(new Choice(Id.choice.action.encrypt, getString(R.string.action_encrypt))); - } - - mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, choices); - mList.setAdapter(mAdapter); - - mList.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - clicked(mAdapter.getItem(arg2).getId()); - } - }); - - mCancelButton = (Button) findViewById(R.id.btn_cancel); - mCancelButton.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - GeneralActivity.this.finish(); - } - }); - - if (choices.size() == 1) { - clicked(choices.get(0).getId()); - } - } - - private void clicked(int id) { - Intent intent = new Intent(); - switch (id) { - case Id.choice.action.encrypt: { - intent.setClass(this, EncryptActivity.class); - if (mDataString != null) { - intent.setAction(Apg.Intent.ENCRYPT); - intent.putExtra(Apg.EXTRA_TEXT, mDataString); - } else if (mDataUri != null) { - intent.setAction(Apg.Intent.ENCRYPT_FILE); - intent.setDataAndType(mDataUri, mIntent.getType()); - } - - break; - } - - case Id.choice.action.decrypt: { - intent.setClass(this, DecryptActivity.class); - if (mDataString != null) { - intent.setAction(Apg.Intent.DECRYPT); - intent.putExtra(Apg.EXTRA_TEXT, mDataString); - } else if (mDataUri != null) { - intent.setAction(Apg.Intent.DECRYPT_FILE); - intent.setDataAndType(mDataUri, mIntent.getType()); - } - - break; - } - - case Id.choice.action.import_public: { - intent.setClass(this, PublicKeyListActivity.class); - intent.setAction(Apg.Intent.IMPORT); - if (mDataString != null) { - intent.putExtra(Apg.EXTRA_TEXT, mDataString); - } else if (mDataUri != null) { - intent.setDataAndType(mDataUri, mIntent.getType()); - } - break; - } - - case Id.choice.action.import_secret: { - intent.setClass(this, SecretKeyListActivity.class); - intent.setAction(Apg.Intent.IMPORT); - if (mDataString != null) { - intent.putExtra(Apg.EXTRA_TEXT, mDataString); - } else if (mDataUri != null) { - intent.setDataAndType(mDataUri, mIntent.getType()); - } - break; - } - - default: { - // shouldn't happen - return; - } - } - - startActivity(intent); - finish(); - } -} +package org.thialfihar.android.apg; + +import java.io.ByteArrayInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Vector; + +import org.thialfihar.android.apg.utils.Choice; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; +import android.widget.Toast; + +public class GeneralActivity extends BaseActivity { + private Intent mIntent; + private ArrayAdapter mAdapter; + private ListView mList; + private Button mCancelButton; + private String mDataString; + private Uri mDataUri; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.general); + + mIntent = getIntent(); + + InputStream inStream = null; + { + String data = mIntent.getStringExtra(Intent.EXTRA_TEXT); + if (data != null) { + mDataString = data; + inStream = new ByteArrayInputStream(data.getBytes()); + } + } + + if (inStream == null) { + Uri data = mIntent.getData(); + if (data != null) { + mDataUri = data; + try { + inStream = getContentResolver().openInputStream(data); + } catch (FileNotFoundException e) { + // didn't work + Toast.makeText(this, "failed to open stream", Toast.LENGTH_SHORT).show(); + } + } + } + + if (inStream == null) { + Toast.makeText(this, "no data found", Toast.LENGTH_SHORT).show(); + finish(); + return; + } + + int contentType = Id.content.unknown; + try { + contentType = Apg.getStreamContent(this, inStream); + inStream.close(); + } catch (IOException e) { + // just means that there's no PGP data in there + } + + mList = (ListView) findViewById(R.id.options); + Vector choices = new Vector(); + + if (contentType == Id.content.keys) { + choices.add(new Choice(Id.choice.action.import_public, + getString(R.string.action_importPublic))); + choices.add(new Choice(Id.choice.action.import_secret, + getString(R.string.action_importSecret))); + } + + if (contentType == Id.content.encrypted_data) { + choices.add(new Choice(Id.choice.action.decrypt, getString(R.string.action_decrypt))); + } + + if (contentType == Id.content.unknown) { + choices.add(new Choice(Id.choice.action.encrypt, getString(R.string.action_encrypt))); + } + + mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, choices); + mList.setAdapter(mAdapter); + + mList.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { + clicked(mAdapter.getItem(arg2).getId()); + } + }); + + mCancelButton = (Button) findViewById(R.id.btn_cancel); + mCancelButton.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + GeneralActivity.this.finish(); + } + }); + + if (choices.size() == 1) { + clicked(choices.get(0).getId()); + } + } + + private void clicked(int id) { + Intent intent = new Intent(); + switch (id) { + case Id.choice.action.encrypt: { + intent.setClass(this, EncryptActivity.class); + if (mDataString != null) { + intent.setAction(Apg.Intent.ENCRYPT); + intent.putExtra(Apg.EXTRA_TEXT, mDataString); + } else if (mDataUri != null) { + intent.setAction(Apg.Intent.ENCRYPT_FILE); + intent.setDataAndType(mDataUri, mIntent.getType()); + } + + break; + } + + case Id.choice.action.decrypt: { + intent.setClass(this, DecryptActivity.class); + if (mDataString != null) { + intent.setAction(Apg.Intent.DECRYPT); + intent.putExtra(Apg.EXTRA_TEXT, mDataString); + } else if (mDataUri != null) { + intent.setAction(Apg.Intent.DECRYPT_FILE); + intent.setDataAndType(mDataUri, mIntent.getType()); + } + + break; + } + + case Id.choice.action.import_public: { + intent.setClass(this, PublicKeyListActivity.class); + intent.setAction(Apg.Intent.IMPORT); + if (mDataString != null) { + intent.putExtra(Apg.EXTRA_TEXT, mDataString); + } else if (mDataUri != null) { + intent.setDataAndType(mDataUri, mIntent.getType()); + } + break; + } + + case Id.choice.action.import_secret: { + intent.setClass(this, SecretKeyListActivity.class); + intent.setAction(Apg.Intent.IMPORT); + if (mDataString != null) { + intent.putExtra(Apg.EXTRA_TEXT, mDataString); + } else if (mDataUri != null) { + intent.setDataAndType(mDataUri, mIntent.getType()); + } + break; + } + + default: { + // shouldn't happen + return; + } + } + + startActivity(intent); + finish(); + } +} -- cgit v1.2.3