From c7f6af1635f592927235a71b1bd9bde61bb82ec2 Mon Sep 17 00:00:00 2001 From: YuichiSawada Date: Thu, 20 Aug 2015 14:34:59 +0900 Subject: [PATCH] make grid show --- JoinEvents/.gitignore => .gitignore | 0 {JoinEvents/.idea => .idea}/.name | 0 {JoinEvents/.idea => .idea}/compiler.xml | 0 .../copyright/profiles_settings.xml | 0 {JoinEvents/.idea => .idea}/gradle.xml | 0 {JoinEvents/.idea => .idea}/misc.xml | 27 ++++ {JoinEvents/.idea => .idea}/modules.xml | 0 .../.idea => .idea}/runConfigurations.xml | 0 {JoinEvents/.idea => .idea}/vcs.xml | 0 JoinEvents/JoinEvents.iml => JoinEvents.iml | 0 .../yuichi10/github/com/joinevents/Home.java | 37 ------ .../app/src/main/res/layout/activity_home.xml | 11 -- .../app/src/main/res/values/strings.xml | 6 - {JoinEvents/app => app}/.gitignore | 0 {JoinEvents/app => app}/app.iml | 1 + {JoinEvents/app => app}/build.gradle | 0 {JoinEvents/app => app}/proguard-rules.pro | 0 .../com/joinevents/ApplicationTest.java | 0 .../app => app}/src/main/AndroidManifest.xml | 6 +- .../github/com/joinevents/BitmapAdapter.java | 44 +++++++ .../yuichi10/github/com/joinevents/Home.java | 22 ++++ .../github/com/joinevents/SignIn.java | 110 +++++++++++++++++ .../github/com/joinevents/SignUP.java | 47 +++++++ .../github/com/joinevents/ThumbnailImage.java | 73 +++++++++++ app/src/main/res/layout/activity_sign_in.xml | 43 +++++++ app/src/main/res/layout/home.xml | 12 ++ app/src/main/res/layout/image_list_item | 6 + app/src/main/res/layout/sign_up.xml | 116 ++++++++++++++++++ app/src/main/res/layout/thumbnail_image.xml | 15 +++ .../src/main/res/menu/menu_sign_in.xml | 2 +- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/dimens.xml | 0 app/src/main/res/values/strings.xml | 18 +++ .../src/main/res/values/styles.xml | 0 JoinEvents/build.gradle => build.gradle | 0 .../gradle.properties => gradle.properties | 0 .../wrapper/gradle-wrapper.jar | Bin .../wrapper/gradle-wrapper.properties | 2 +- JoinEvents/gradlew => gradlew | 0 JoinEvents/gradlew.bat => gradlew.bat | 0 JoinEvents/settings.gradle => settings.gradle | 0 45 files changed, 540 insertions(+), 58 deletions(-) rename JoinEvents/.gitignore => .gitignore (100%) rename {JoinEvents/.idea => .idea}/.name (100%) rename {JoinEvents/.idea => .idea}/compiler.xml (100%) rename {JoinEvents/.idea => .idea}/copyright/profiles_settings.xml (100%) rename {JoinEvents/.idea => .idea}/gradle.xml (100%) rename {JoinEvents/.idea => .idea}/misc.xml (58%) rename {JoinEvents/.idea => .idea}/modules.xml (100%) rename {JoinEvents/.idea => .idea}/runConfigurations.xml (100%) rename {JoinEvents/.idea => .idea}/vcs.xml (100%) rename JoinEvents/JoinEvents.iml => JoinEvents.iml (100%) delete mode 100644 JoinEvents/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java delete mode 100644 JoinEvents/app/src/main/res/layout/activity_home.xml delete mode 100644 JoinEvents/app/src/main/res/values/strings.xml rename {JoinEvents/app => app}/.gitignore (100%) rename {JoinEvents/app => app}/app.iml (99%) rename {JoinEvents/app => app}/build.gradle (100%) rename {JoinEvents/app => app}/proguard-rules.pro (100%) rename {JoinEvents/app => app}/src/androidTest/java/pmv02/ppr/yuichi10/github/com/joinevents/ApplicationTest.java (100%) rename {JoinEvents/app => app}/src/main/AndroidManifest.xml (72%) create mode 100644 app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/BitmapAdapter.java create mode 100644 app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java create mode 100644 app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignIn.java create mode 100644 app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignUP.java create mode 100644 app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/ThumbnailImage.java create mode 100644 app/src/main/res/layout/activity_sign_in.xml create mode 100644 app/src/main/res/layout/home.xml create mode 100644 app/src/main/res/layout/image_list_item create mode 100644 app/src/main/res/layout/sign_up.xml create mode 100644 app/src/main/res/layout/thumbnail_image.xml rename JoinEvents/app/src/main/res/menu/menu_home.xml => app/src/main/res/menu/menu_sign_in.xml (96%) rename {JoinEvents/app => app}/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {JoinEvents/app => app}/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {JoinEvents/app => app}/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {JoinEvents/app => app}/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {JoinEvents/app => app}/src/main/res/values-w820dp/dimens.xml (100%) rename {JoinEvents/app => app}/src/main/res/values/dimens.xml (100%) create mode 100644 app/src/main/res/values/strings.xml rename {JoinEvents/app => app}/src/main/res/values/styles.xml (100%) rename JoinEvents/build.gradle => build.gradle (100%) rename JoinEvents/gradle.properties => gradle.properties (100%) rename {JoinEvents/gradle => gradle}/wrapper/gradle-wrapper.jar (100%) rename {JoinEvents/gradle => gradle}/wrapper/gradle-wrapper.properties (86%) rename JoinEvents/gradlew => gradlew (100%) rename JoinEvents/gradlew.bat => gradlew.bat (100%) rename JoinEvents/settings.gradle => settings.gradle (100%) diff --git a/JoinEvents/.gitignore b/.gitignore similarity index 100% rename from JoinEvents/.gitignore rename to .gitignore diff --git a/JoinEvents/.idea/.name b/.idea/.name similarity index 100% rename from JoinEvents/.idea/.name rename to .idea/.name diff --git a/JoinEvents/.idea/compiler.xml b/.idea/compiler.xml similarity index 100% rename from JoinEvents/.idea/compiler.xml rename to .idea/compiler.xml diff --git a/JoinEvents/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml similarity index 100% rename from JoinEvents/.idea/copyright/profiles_settings.xml rename to .idea/copyright/profiles_settings.xml diff --git a/JoinEvents/.idea/gradle.xml b/.idea/gradle.xml similarity index 100% rename from JoinEvents/.idea/gradle.xml rename to .idea/gradle.xml diff --git a/JoinEvents/.idea/misc.xml b/.idea/misc.xml similarity index 58% rename from JoinEvents/.idea/misc.xml rename to .idea/misc.xml index d92476c..b8f88c0 100644 --- a/JoinEvents/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,32 @@ + + + + + + + diff --git a/JoinEvents/.idea/modules.xml b/.idea/modules.xml similarity index 100% rename from JoinEvents/.idea/modules.xml rename to .idea/modules.xml diff --git a/JoinEvents/.idea/runConfigurations.xml b/.idea/runConfigurations.xml similarity index 100% rename from JoinEvents/.idea/runConfigurations.xml rename to .idea/runConfigurations.xml diff --git a/JoinEvents/.idea/vcs.xml b/.idea/vcs.xml similarity index 100% rename from JoinEvents/.idea/vcs.xml rename to .idea/vcs.xml diff --git a/JoinEvents/JoinEvents.iml b/JoinEvents.iml similarity index 100% rename from JoinEvents/JoinEvents.iml rename to JoinEvents.iml diff --git a/JoinEvents/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java b/JoinEvents/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java deleted file mode 100644 index 45a7ede..0000000 --- a/JoinEvents/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java +++ /dev/null @@ -1,37 +0,0 @@ -package pmv02.ppr.yuichi10.github.com.joinevents; - -import android.support.v7.app.ActionBarActivity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - -public class Home extends ActionBarActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_home); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_home, 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(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } - - return super.onOptionsItemSelected(item); - } -} diff --git a/JoinEvents/app/src/main/res/layout/activity_home.xml b/JoinEvents/app/src/main/res/layout/activity_home.xml deleted file mode 100644 index 41e4d47..0000000 --- a/JoinEvents/app/src/main/res/layout/activity_home.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/JoinEvents/app/src/main/res/values/strings.xml b/JoinEvents/app/src/main/res/values/strings.xml deleted file mode 100644 index 4b0e69d..0000000 --- a/JoinEvents/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - JoinEvents - - Hello world! - Settings - diff --git a/JoinEvents/app/.gitignore b/app/.gitignore similarity index 100% rename from JoinEvents/app/.gitignore rename to app/.gitignore diff --git a/JoinEvents/app/app.iml b/app/app.iml similarity index 99% rename from JoinEvents/app/app.iml rename to app/app.iml index 163141e..5a80f20 100644 --- a/JoinEvents/app/app.iml +++ b/app/app.iml @@ -86,6 +86,7 @@ + diff --git a/JoinEvents/app/build.gradle b/app/build.gradle similarity index 100% rename from JoinEvents/app/build.gradle rename to app/build.gradle diff --git a/JoinEvents/app/proguard-rules.pro b/app/proguard-rules.pro similarity index 100% rename from JoinEvents/app/proguard-rules.pro rename to app/proguard-rules.pro diff --git a/JoinEvents/app/src/androidTest/java/pmv02/ppr/yuichi10/github/com/joinevents/ApplicationTest.java b/app/src/androidTest/java/pmv02/ppr/yuichi10/github/com/joinevents/ApplicationTest.java similarity index 100% rename from JoinEvents/app/src/androidTest/java/pmv02/ppr/yuichi10/github/com/joinevents/ApplicationTest.java rename to app/src/androidTest/java/pmv02/ppr/yuichi10/github/com/joinevents/ApplicationTest.java diff --git a/JoinEvents/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml similarity index 72% rename from JoinEvents/app/src/main/AndroidManifest.xml rename to app/src/main/AndroidManifest.xml index dccd99a..f7ad980 100644 --- a/JoinEvents/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,14 +8,16 @@ android:label="@string/app_name" android:theme="@style/AppTheme" > - + + + diff --git a/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/BitmapAdapter.java b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/BitmapAdapter.java new file mode 100644 index 0000000..167f6aa --- /dev/null +++ b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/BitmapAdapter.java @@ -0,0 +1,44 @@ +package pmv02.ppr.yuichi10.github.com.joinevents; + +import android.content.Context; +import android.graphics.Bitmap; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ImageView; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yuichi on 8/20/15. + */ +public class BitmapAdapter extends ArrayAdapter { + + private int resourceId; + + public BitmapAdapter(Context context, int resource, int textViewResourceId, List objects) { + super(context, resource, textViewResourceId, objects); + this.resourceId = resource; + } + + public BitmapAdapter(Context context, int resource, List objects) { + super(context, resource, objects); + resourceId = resource; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + if (convertView == null) { + LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = inflater.inflate(resourceId, null); + } + + ImageView view = (ImageView) convertView; + view.setImageBitmap(getItem(position)); + + return view; + } +} diff --git a/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java new file mode 100644 index 0000000..6098bcd --- /dev/null +++ b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/Home.java @@ -0,0 +1,22 @@ +package pmv02.ppr.yuichi10.github.com.joinevents; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.widget.TextView; + +/** + * Created by yuichi on 8/20/15. + */ +public class Home extends Activity{ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.home); + Log.d("Intent", "success"); + Intent intent = getIntent(); + + TextView tv = (TextView)findViewById(R.id.homeText); + } +} diff --git a/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignIn.java b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignIn.java new file mode 100644 index 0000000..7948709 --- /dev/null +++ b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignIn.java @@ -0,0 +1,110 @@ +package pmv02.ppr.yuichi10.github.com.joinevents; + +import android.content.Intent; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class SignIn extends ActionBarActivity implements View.OnClickListener{ + EditText idSignIn; + EditText passwordSignIn; + static String packageName = "pmv02.ppr.yuichi10.github.com.joinevents"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sign_in); + //get the edit text for sign in + idSignIn = (EditText)findViewById(R.id.idSignIn); + passwordSignIn = (EditText)findViewById(R.id.passwordSignIn); + //button for sign in + Button doSignIn = (Button)findViewById(R.id.doSignIn); + doSignIn.setOnClickListener(this); + //button for sign up + Button doSignUp = (Button)findViewById(R.id.doSignUp); + doSignUp.setOnClickListener(this); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_sign_in, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public void onClick(View v) { + + Intent intent = new Intent(); + switch (v.getId()){ + case R.id.doSignIn: + String strID = idSignIn.getText().toString(); + String strPass = passwordSignIn.getText().toString(); + strPass = encodePassdigiest(strPass); + Log.d("Intent","push button"); + intent.setClassName(packageName, packageName + ".Home"); + startActivity(intent); + break; + case R.id.doSignUp: + intent.setClassName(packageName, packageName + ".SignUP"); + startActivity(intent); + break; + } + } + + + + public String encodePassdigiest(String password){ + byte[] enclyptedHash=null; + // MD5で暗号化したByte型配列を取得する + MessageDigest md5; + try { + md5 = MessageDigest.getInstance("MD5"); + md5.update(password.getBytes()); + enclyptedHash = md5.digest(); + + // 暗号化されたByte型配列を、16進数表記文字列に変換する + } catch (NoSuchAlgorithmException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return bytesToHexString(enclyptedHash); + } + + private String bytesToHexString(byte[] fromByte) { + + StringBuilder hexStrBuilder = new StringBuilder(); + for (int i = 0; i < fromByte.length; i++) { + + // 16進数表記で1桁数値だった場合、2桁目を0で埋める + if ((fromByte[i] & 0xff) < 0x10) { + hexStrBuilder.append("0"); + } + hexStrBuilder.append(Integer.toHexString(0xff & fromByte[i])); + } + return hexStrBuilder.toString(); + } +} diff --git a/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignUP.java b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignUP.java new file mode 100644 index 0000000..043b420 --- /dev/null +++ b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/SignUP.java @@ -0,0 +1,47 @@ +package pmv02.ppr.yuichi10.github.com.joinevents; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Created by yuichi on 8/20/15. + */ +public class SignUP extends Activity implements View.OnClickListener{ + static int mRequestCode = 1001; + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.sign_up); + Log.d("Intent", "success"); + Intent intent = getIntent(); + + Button thumbnail = (Button)findViewById(R.id.signUpGetImage); + thumbnail.setOnClickListener(this); + } + + public void onActivityResult( int requestCode, int resultCode, Intent intent ){ + if(requestCode == this.mRequestCode){ + if(resultCode == Activity.RESULT_OK){ + // 返却されてきたintentから値を取り出す + String str = intent.getStringExtra( "key" ); + Log.d("aa",str); + } + } + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.signUpGetImage: + Intent intent = new Intent(); + intent.setClassName(SignIn.packageName, SignIn.packageName + ".ThumbnailImage"); + startActivityForResult(intent,this.mRequestCode); + break; + } + } +} diff --git a/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/ThumbnailImage.java b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/ThumbnailImage.java new file mode 100644 index 0000000..d4ba739 --- /dev/null +++ b/app/src/main/java/pmv02/ppr/yuichi10/github/com/joinevents/ThumbnailImage.java @@ -0,0 +1,73 @@ +package pmv02.ppr.yuichi10.github.com.joinevents; + +import android.app.Activity; +import android.content.ContentResolver; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.os.Bundle; +import android.provider.MediaStore; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.GridView; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yuichi on 8/20/15. + */ +public class ThumbnailImage extends Activity implements AdapterView.OnItemClickListener{ + MapimageMap = new HashMap(); + ArrayListimageList = new ArrayList(); + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.thumbnail_image); + + ContentResolver resolver = getContentResolver(); + Cursor cursor = resolver.query( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + null, + null, + null, + null + ); + Log.v("MEDIA", Arrays.toString(cursor.getColumnNames())); // 項目名一覧 + Log.v("MEDIA", "Image files = " + cursor.getCount()); // 取得件数 + int i = 0; + if(cursor.moveToFirst()){ + do{ + long idImage = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID)); + String pathImage = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)); + imageMap.put(idImage, pathImage); + Bitmap bmp = MediaStore.Images.Thumbnails.getThumbnail(resolver,idImage,MediaStore.Images.Thumbnails.MINI_KIND,null); + + imageList.add(bmp); + ++i; + if(i == 20){ + break; + } + }while(cursor.moveToNext()); + } + BitmapAdapter adapter = new BitmapAdapter( + getApplicationContext(), R.layout.image_list_item, imageList); + GridView gridView = (GridView)findViewById(R.id.imageGrid); + gridView.setOnItemClickListener(this); + gridView.setAdapter(adapter); + } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + + Intent intent = new Intent(); + intent.putExtra("key", "success"); + setResult(Activity.RESULT_OK, intent); + finish(); + } +} diff --git a/app/src/main/res/layout/activity_sign_in.xml b/app/src/main/res/layout/activity_sign_in.xml new file mode 100644 index 0000000..7204b8f --- /dev/null +++ b/app/src/main/res/layout/activity_sign_in.xml @@ -0,0 +1,43 @@ + + + + + + +