Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 504bcaf52c689d33a212d7f805a2ae6213725d1e @Danesh Danesh committed May 3, 2012
Showing with 146 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +22 −0 AndroidManifest.xml
  3. BIN res/drawable-hdpi/ic_launcher.png
  4. BIN res/drawable-hdpi/ic_lockscreen_alarm_activated.png
  5. BIN res/drawable-hdpi/ic_lockscreen_alarm_normal.png
  6. BIN res/drawable-hdpi/ic_lockscreen_browser_activated.png
  7. BIN res/drawable-hdpi/ic_lockscreen_browser_normal.png
  8. BIN res/drawable-hdpi/ic_lockscreen_calendar_activated.png
  9. BIN res/drawable-hdpi/ic_lockscreen_calendar_normal.png
  10. BIN res/drawable-hdpi/ic_lockscreen_camera_activated.png
  11. BIN res/drawable-hdpi/ic_lockscreen_camera_normal.png
  12. BIN res/drawable-hdpi/ic_lockscreen_chrome_activated.png
  13. BIN res/drawable-hdpi/ic_lockscreen_chrome_normal.png
  14. BIN res/drawable-hdpi/ic_lockscreen_email_activated.png
  15. BIN res/drawable-hdpi/ic_lockscreen_email_normal.png
  16. BIN res/drawable-hdpi/ic_lockscreen_facebook_activated.png
  17. BIN res/drawable-hdpi/ic_lockscreen_facebook_normal.png
  18. BIN res/drawable-hdpi/ic_lockscreen_gallery_activated.png
  19. BIN res/drawable-hdpi/ic_lockscreen_gallery_normal.png
  20. BIN res/drawable-hdpi/ic_lockscreen_gplus_activated.png
  21. BIN res/drawable-hdpi/ic_lockscreen_gplus_normal.png
  22. BIN res/drawable-hdpi/ic_lockscreen_gtalk_activated.png
  23. BIN res/drawable-hdpi/ic_lockscreen_gtalk_normal.png
  24. BIN res/drawable-hdpi/ic_lockscreen_maps_activated.png
  25. BIN res/drawable-hdpi/ic_lockscreen_maps_normal.png
  26. BIN res/drawable-hdpi/ic_lockscreen_movie_activated.png
  27. BIN res/drawable-hdpi/ic_lockscreen_movie_normal.png
  28. BIN res/drawable-hdpi/ic_lockscreen_music_activated.png
  29. BIN res/drawable-hdpi/ic_lockscreen_music_normal.png
  30. BIN res/drawable-hdpi/ic_lockscreen_nav_activated.png
  31. BIN res/drawable-hdpi/ic_lockscreen_nav_normal.png
  32. BIN res/drawable-hdpi/ic_lockscreen_phone_activated.png
  33. BIN res/drawable-hdpi/ic_lockscreen_phone_normal.png
  34. BIN res/drawable-hdpi/ic_lockscreen_podcast_activted.png
  35. BIN res/drawable-hdpi/ic_lockscreen_podcast_normal.png
  36. BIN res/drawable-hdpi/ic_lockscreen_rss_activated.png
  37. BIN res/drawable-hdpi/ic_lockscreen_rss_normal.png
  38. BIN res/drawable-hdpi/ic_lockscreen_sms_activated.png
  39. BIN res/drawable-hdpi/ic_lockscreen_sms_normal.png
  40. BIN res/drawable-hdpi/ic_lockscreen_spotify_activated.png
  41. BIN res/drawable-hdpi/ic_lockscreen_spotify_normal.png
  42. BIN res/drawable-hdpi/ic_lockscreen_train_activated.png
  43. BIN res/drawable-hdpi/ic_lockscreen_train_normal.png
  44. BIN res/drawable-hdpi/ic_lockscreen_twitter_activated.png
  45. BIN res/drawable-hdpi/ic_lockscreen_twitter_normal.png
  46. BIN res/drawable-ldpi/ic_launcher.png
  47. BIN res/drawable-mdpi/ic_launcher.png
  48. BIN res/drawable-mdpi/ic_lockscreen_alarm_activated.png
  49. BIN res/drawable-mdpi/ic_lockscreen_alarm_normal.png
  50. BIN res/drawable-mdpi/ic_lockscreen_browser_activated.png
  51. BIN res/drawable-mdpi/ic_lockscreen_browser_normal.png
  52. BIN res/drawable-mdpi/ic_lockscreen_calendar_activated.png
  53. BIN res/drawable-mdpi/ic_lockscreen_calendar_normal.png
  54. BIN res/drawable-mdpi/ic_lockscreen_camera_activated.png
  55. BIN res/drawable-mdpi/ic_lockscreen_camera_normal.png
  56. BIN res/drawable-mdpi/ic_lockscreen_chrome_activated.png
  57. BIN res/drawable-mdpi/ic_lockscreen_chrome_normal.png
  58. BIN res/drawable-mdpi/ic_lockscreen_email_acticated.png
  59. BIN res/drawable-mdpi/ic_lockscreen_email_normal.png
  60. BIN res/drawable-mdpi/ic_lockscreen_facebook_activated.png
  61. BIN res/drawable-mdpi/ic_lockscreen_facebook_normal.png
  62. BIN res/drawable-mdpi/ic_lockscreen_gallery_activated.png
  63. BIN res/drawable-mdpi/ic_lockscreen_gallery_normal.png
  64. BIN res/drawable-mdpi/ic_lockscreen_gplus_activated.png
  65. BIN res/drawable-mdpi/ic_lockscreen_gplus_normal.png
  66. BIN res/drawable-mdpi/ic_lockscreen_gtalk_activated.png
  67. BIN res/drawable-mdpi/ic_lockscreen_gtalk_normal.png
  68. BIN res/drawable-mdpi/ic_lockscreen_maps_activated.png
  69. BIN res/drawable-mdpi/ic_lockscreen_maps_normal.png
  70. BIN res/drawable-mdpi/ic_lockscreen_movie_activated.png
  71. BIN res/drawable-mdpi/ic_lockscreen_movie_normal.png
  72. BIN res/drawable-mdpi/ic_lockscreen_music_activated.png
  73. BIN res/drawable-mdpi/ic_lockscreen_music_normal.png
  74. BIN res/drawable-mdpi/ic_lockscreen_nav_activated.png
  75. BIN res/drawable-mdpi/ic_lockscreen_nav_normal.png
  76. BIN res/drawable-mdpi/ic_lockscreen_phone_activated.png
  77. BIN res/drawable-mdpi/ic_lockscreen_phone_normal.png
  78. BIN res/drawable-mdpi/ic_lockscreen_podcast_activated.png
  79. BIN res/drawable-mdpi/ic_lockscreen_podcast_normal.png
  80. BIN res/drawable-mdpi/ic_lockscreen_rss_activated.png
  81. BIN res/drawable-mdpi/ic_lockscreen_rss_normal.png
  82. BIN res/drawable-mdpi/ic_lockscreen_sms_activated.png
  83. BIN res/drawable-mdpi/ic_lockscreen_sms_normal.png
  84. BIN res/drawable-mdpi/ic_lockscreen_spotify_activated.png
  85. BIN res/drawable-mdpi/ic_lockscreen_spotify_normal.png
  86. BIN res/drawable-mdpi/ic_lockscreen_train_activated.png
  87. BIN res/drawable-mdpi/ic_lockscreen_train_normal.png
  88. BIN res/drawable-mdpi/ic_lockscreen_twitter_activated.png
  89. BIN res/drawable-mdpi/ic_lockscreen_twitter_normal.png
  90. BIN res/drawable-xhdpi/ic_launcher.png
  91. BIN res/drawable-xhdpi/ic_lockscreen_alarm_activated.png
  92. BIN res/drawable-xhdpi/ic_lockscreen_alarm_normal.png
  93. BIN res/drawable-xhdpi/ic_lockscreen_browser_activated.png
  94. BIN res/drawable-xhdpi/ic_lockscreen_browser_normal.png
  95. BIN res/drawable-xhdpi/ic_lockscreen_calendar_activated.png
  96. BIN res/drawable-xhdpi/ic_lockscreen_calendar_normal.png
  97. BIN res/drawable-xhdpi/ic_lockscreen_camera_activated.png
  98. BIN res/drawable-xhdpi/ic_lockscreen_camera_normal.png
  99. BIN res/drawable-xhdpi/ic_lockscreen_chrome_activated.png
  100. BIN res/drawable-xhdpi/ic_lockscreen_chrome_normal.png
  101. BIN res/drawable-xhdpi/ic_lockscreen_email_activated.png
  102. BIN res/drawable-xhdpi/ic_lockscreen_email_normal.png
  103. BIN res/drawable-xhdpi/ic_lockscreen_facebook_activated.png
  104. BIN res/drawable-xhdpi/ic_lockscreen_facebook_normal.png
  105. BIN res/drawable-xhdpi/ic_lockscreen_gallery_activated.png
  106. BIN res/drawable-xhdpi/ic_lockscreen_gallery_normal.png
  107. BIN res/drawable-xhdpi/ic_lockscreen_gplus_activated.png
  108. BIN res/drawable-xhdpi/ic_lockscreen_gplus_normal.png
  109. BIN res/drawable-xhdpi/ic_lockscreen_gtalk_activated.png
  110. BIN res/drawable-xhdpi/ic_lockscreen_gtalk_normal.png
  111. BIN res/drawable-xhdpi/ic_lockscreen_maps_activated.png
  112. BIN res/drawable-xhdpi/ic_lockscreen_maps_normal.png
  113. BIN res/drawable-xhdpi/ic_lockscreen_movie_activated.png
  114. BIN res/drawable-xhdpi/ic_lockscreen_movie_normal.png
  115. BIN res/drawable-xhdpi/ic_lockscreen_music_activated.png
  116. BIN res/drawable-xhdpi/ic_lockscreen_music_normal.png
  117. BIN res/drawable-xhdpi/ic_lockscreen_nav_activated.png
  118. BIN res/drawable-xhdpi/ic_lockscreen_nav_normal.png
  119. BIN res/drawable-xhdpi/ic_lockscreen_phone_activated.png
  120. BIN res/drawable-xhdpi/ic_lockscreen_phone_normal.png
  121. BIN res/drawable-xhdpi/ic_lockscreen_podcast_activated.png
  122. BIN res/drawable-xhdpi/ic_lockscreen_podcast_normal.png
  123. BIN res/drawable-xhdpi/ic_lockscreen_rss_activated.png
  124. BIN res/drawable-xhdpi/ic_lockscreen_rss_normal.png
  125. BIN res/drawable-xhdpi/ic_lockscreen_sms_activated.png
  126. BIN res/drawable-xhdpi/ic_lockscreen_sms_normal.png
  127. BIN res/drawable-xhdpi/ic_lockscreen_spotify_activated.png
  128. BIN res/drawable-xhdpi/ic_lockscreen_spotify_normal.png
  129. BIN res/drawable-xhdpi/ic_lockscreen_train_activated.png
  130. BIN res/drawable-xhdpi/ic_lockscreen_train_normal.png
  131. BIN res/drawable-xhdpi/ic_lockscreen_twitter_activated.png
  132. BIN res/drawable-xhdpi/ic_lockscreen_twitter_normal.png
  133. +12 −0 res/layout/main.xml
  134. +7 −0 res/values/strings.xml
  135. +99 −0 src/com/cyanogenmod/iconpicker/CmPickerActivity.java
@@ -0,0 +1,6 @@
+.classpath
+.project
+bin/
+gen/
+proguard-project.txt
+project.properties
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.cyanogenmod.iconpicker"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk android:minSdkVersion="15" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".CmPickerActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="com.cyanogenmod.ACTION_PICK_ICON" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<GridView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridview"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:numColumns="auto_fit"
+ android:verticalSpacing="10dp"
+ android:horizontalSpacing="10dp"
+ android:columnWidth="90dp"
+ android:stretchMode="columnWidth"
+ android:gravity="center"
+/>
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World, CmPickerActivity!</string>
+ <string name="app_name">CmPicker</string>
+
+</resources>
@@ -0,0 +1,99 @@
+package com.cyanogenmod.iconpicker;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.GridView;
+import android.widget.ImageView;
+
+public class CmPickerActivity extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ GridView gridview = (GridView) findViewById(R.id.gridview);
+ gridview.setAdapter(new ImageAdapter(this));
+ gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {
+ Intent in = new Intent();
+ DrawableInfo d = (DrawableInfo) adapterView.getAdapter().getItem(position);
+ in.putExtra("image_normal", ((BitmapDrawable)d.draw_normal).getBitmap());
+ in.putExtra("image_activated", ((BitmapDrawable)d.draw_activated).getBitmap());
+ setResult(Activity.RESULT_OK, in);
+ finish();
+ }
+ });
+ }
+
+
+ public class ImageAdapter extends BaseAdapter {
+ private Context mContext;
+ private ArrayList<DrawableInfo> mDrawables = new ArrayList<DrawableInfo>();
+
+ public ImageAdapter(Context c) {
+ mContext = c;
+ Field[] drawables = R.drawable.class.getFields();
+ for (Field f : drawables) {
+ if (f.getName().startsWith("ic_") && f.getName().endsWith("_normal")) {
+ int idNorm = getResources().getIdentifier(f.getName(), "drawable", getPackageName());
+ int idAct = getResources().getIdentifier(f.getName().replaceAll("_normal", "_activated"), "drawable", getPackageName());
+ if (idNorm != 0 && idAct != 0) {
+ Drawable drawNorm = getResources().getDrawable(idNorm);
+ Drawable drawAct = getResources().getDrawable(idAct);
+ if (drawNorm != null && drawAct != null) {
+ mDrawables.add(new DrawableInfo(drawNorm, drawAct));
+ }
+ }
+ }
+ }
+ }
+
+ public int getCount() {
+ return mDrawables.size();
+ }
+
+ public Object getItem(int position) {
+ return mDrawables.get(position);
+ }
+
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ImageView imageView;
+ if (convertView == null) {
+ imageView = new ImageView(mContext);
+ imageView.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, GridView.LayoutParams.WRAP_CONTENT));
+ imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ imageView.setPadding(8, 8, 8, 8);
+ } else {
+ imageView = (ImageView) convertView;
+ }
+ imageView.setImageDrawable(((DrawableInfo) getItem(position)).draw_normal);
+ return imageView;
+ }
+
+ }
+
+ private class DrawableInfo {
+ Drawable draw_normal;
+ Drawable draw_activated;
+ DrawableInfo(Drawable norm, Drawable act) {
+ draw_normal = norm;
+ draw_activated = act;
+ }
+ }
+}

0 comments on commit 504bcaf

Please sign in to comment.