From 17e76a490419d4ff5f410b4998d40aa8b9f74ba2 Mon Sep 17 00:00:00 2001 From: Mikey Date: Thu, 25 Aug 2016 18:08:54 +0100 Subject: [PATCH 1/3] Add ability to view raw Bitmap images. --- .../co/ashtonbrsc/intentexplode/Explode.java | 44 +++++++++++++++++- .../main/res/drawable-hdpi/checkerboard.png | Bin 0 -> 947 bytes .../main/res/drawable-mdpi/checkerboard.png | Bin 0 -> 945 bytes .../main/res/drawable-xhdpi/checkerboard.png | Bin 0 -> 948 bytes .../main/res/drawable-xxhdpi/checkerboard.png | Bin 0 -> 950 bytes .../res/drawable-xxxhdpi/checkerboard.png | Bin 0 -> 953 bytes app/src/main/res/drawable/checkerboard.png | Bin 0 -> 945 bytes .../res/drawable/checkerboard_pattern.xml | 5 ++ 8 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/checkerboard.png create mode 100644 app/src/main/res/drawable-mdpi/checkerboard.png create mode 100644 app/src/main/res/drawable-xhdpi/checkerboard.png create mode 100644 app/src/main/res/drawable-xxhdpi/checkerboard.png create mode 100644 app/src/main/res/drawable-xxxhdpi/checkerboard.png create mode 100644 app/src/main/res/drawable/checkerboard.png create mode 100644 app/src/main/res/drawable/checkerboard_pattern.xml diff --git a/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java b/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java index f9cba6b..eb8db0a 100644 --- a/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java +++ b/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java @@ -19,6 +19,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.graphics.Bitmap; import android.graphics.Typeface; import android.net.Uri; import android.os.Build; @@ -35,12 +36,14 @@ import android.text.style.LeadingMarginSpan; import android.text.style.ParagraphStyle; import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; @@ -58,7 +61,6 @@ import uk.co.ashtonbrsc.android.intentintercept.R; //TODO add icon -which icon - app icons??? -//TODO add bitmaps/images (from intent extras?) //TODO add getCallingActivity() - will only give details for startActivityForResult(); /** @@ -321,7 +323,12 @@ private void showAllIntentData(TextView textViewToIgnore) { Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, extrasLayout); } - } else { + } else if(extraItem instanceof Bitmap) { + addBitmapToLayout(getString(R.string.extra_item_value_title) + BLANK, + Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, + (Bitmap) extraItem, extrasLayout); + } + else { addTextToLayout(getString(R.string.extra_item_value_title) + BLANK + extraItem .toString(), Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, @@ -401,6 +408,39 @@ private void checkAndShowMatchingActivites() { } } + private void addBitmapToLayout(String text, int typeface, int paddingLeft, Bitmap bitmap, LinearLayout linearLayout) { + LinearLayout bitmapLayout = new LinearLayout(this); + TextView textView = new TextView(this); + ParagraphStyle style_para = new LeadingMarginSpan.Standard(0, + (int) (STANDARD_INDENT_SIZE_IN_DIP * density)); + SpannableString styledText = new SpannableString(text); + styledText.setSpan(style_para, 0, styledText.length(), + Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + textView.setText(styledText); + textView.setTextAppearance(this, R.style.TextFlags); + textView.setTypeface(null, typeface); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + textView.setTextIsSelectable(true); + } + LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, + LayoutParams.WRAP_CONTENT); + params.setMargins((int) (paddingLeft * density), 0, 0, 0); + + // At most 144dsp. + float maxHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 144, getResources().getDisplayMetrics()); + int height = (int) Math.min(bitmap.getHeight(), maxHeight); + int width = bitmap.getWidth() * (height/bitmap.getHeight()); + + LinearLayout.LayoutParams bitmapParams = new LayoutParams(width, height); + ImageView bitmapView = new ImageView(this); + bitmapView.setImageBitmap(bitmap); + bitmapView.setBackgroundResource(R.drawable.checkerboard_pattern); + bitmapLayout.setOrientation(LinearLayout.HORIZONTAL); + bitmapLayout.addView(textView); + bitmapLayout.addView(bitmapView, bitmapParams); + linearLayout.addView(bitmapLayout, params); + } + private void addTextToLayout(String text, int typeface, int paddingLeft, LinearLayout layout) { TextView textView = new TextView(this); diff --git a/app/src/main/res/drawable-hdpi/checkerboard.png b/app/src/main/res/drawable-hdpi/checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..cf17d34c10c27a2aacdf9cb3f202d91e81547892 GIT binary patch literal 947 zcmaJ=J#W)M7`CWXRaGm27zlLWa0fsl{z~j(E2eVngj%XYltgMaaO_KBCH5KLrFJs1 zAvS&jGwQ;~04odZU6EM%3E`Y3DFeZ>eII(B=Y8*epL^SEJm25Fx63fhzI|e~=(wGK zJ2&VbU1ay^aF^7&q>cI{brZ-KKI%bWhwcEjpzBXxe}ff<*BJ?<{FYzq=+J(M#RmE z5k6cgSP*+j5R(8!AXjvIXhL+BW_opmFkZ_>cv&V|Fg|l*UgU)QNGqV@{2v;IYcwV; zc%AP*g>h#ZL%szunj{`=T>mf+6>DY!U4oJhLgQ5xn?pnp9-mbT1gaZiczXRt;&Wf38rdUYI()AkT(foL{?n? znrm(3=2i$}8rgzLa1Q-?f|c#uZBh5+)3t5s zVr_gFQMV`5*5|jkFX@$dXj?`nyX;l)uf458;o!h5obDBvcQ=2|=ko_2KMj7o|8NU@ XWnS_-=*20gb9fO ziGi&f6H=wl3=B-Lu=4|0`3d1UjZ+4KW&3^ToOAEH_q;cq_S2p1yW12+?O4Z#L&odH zSKT82`|oeL(D`?!mSICB$7HGMRIzzW?FbfD|cUVMWMimK2-uaEooGu1;O;}#eu z4`afnsK#L)yWRw1Fo2^V(&*oxztAA?HTp!dIXl+jI5?gsusd(}y!pgaeERS)Xyhsp z2qAVs9-c<2nrrk@S0(deo29`Lf+re%nN;8I039U|NQ_wXIGzWx%<%h?Ec1_m!0`gh zkyozq`>G_XLLICgnnX+dq3Re%t5{^E(PNBbm1VOmV=|FJ$%y3@MJY4{p+*q3bQWPZ zuSMx@sbIj=OM(~&C<29|J3v#c(InH$BZToLZav!HySv9Q%)WJQbm&;f zzQPXuUj!#V=x~Ra1JXq!k~lGBY91OwUbhaa(1K~XxsmX2Ehi6 zNeABK`%huqn@5oEK#XRwOB**j%0fk2BZdw^aSx%Zyo&7!A_z}V1R7lh9QXauLkT`v z;cZ*9LQI^{g_fbSRDtt-Pm?57l_3HGGe!Ye9a;0Y=b~=aTXVhbxzx6Dd72ELHTJJY=Udc0*>q!D zy4V;WhScpbwe{Oq2MN6r$Cgp+rQe5D{Ij@QynT51;oD{LKJ)9~<#M@vj=#LtFK#_x Zc8W~>Ya!}?{H$j8$TC~ToBHEte*pTuBQgL0 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/checkerboard.png b/app/src/main/res/drawable-xxhdpi/checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..eab73a15f9aa6d1b1aade9b2dcd50ae752b630e0 GIT binary patch literal 950 zcmaJ=O^ee&7>>J_Wob_fih?lAUUaef>NeYi#3)`b+?B|M|wJw{*Bkj6Uh&AxWJWF-;E-5U>JgggVIaW)~k(gJHIz-|LgU{YY_fz&bgG z&4P%s8K!ZZMUFc`1Psu~4^{Z%-FpapPlabSo3|qkjs4SkjJoqy&z($T*aa*6^;ps6pl;NlufHFjz^pz%W|$EiWQ2eB(sn> zStU&N3k4k|ZtO?I$05iSodKQ_71B&Ej}Sy_*)Um^i585@oQM-xK0i_cwC(>xgJ6wL zNC#cz`%mGdH;WM0K?$D5E^XX!KMxftT8tcm;~vK6MHSm)OmH&B5zx94xO3)*9!`_H zOT29>R+tbcbdja2kSegg@6l44nkMst)HJGsU`TS^IMPIuuhr!$Z#IR3t7CT>ppXzmCe&_kq1i%9c%nqQa!5$3=(0W2&IA}$ufXYkjn~$@-0x5 z)+%L}{ps;%qh(W+j0{Ls70)tEon@SYU`k zJP)Xy6oPmsQ$RR&A}^#K2|%i7_sNuMJj?X#2!6Ph4dPXqSi!`^4nJl=^s@NJ4O5za-fzg5B#-SIu zWES6C;w?)xgP7WZgH5FIOhNEGS8YI~8&zF_dc7#ib*L)_LX`?qWTkE(9c5fZoT-lk znsME8F5JjXt>A|&GQyGf0K1Kd_+WWt)!Up)X`|kX>u%1aypb!iWW=FPWV(v+& zYumEL+W0tNZjYF)f16+4u`5w9k={+d_G|ICi(Bw$GI?_E`N=VoULIfh_~Z2S;j7ET h&o8d$cYk_ZPU808<{rH%*MFs#$*ecg>;0q0e*neIDRlq< literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/checkerboard.png b/app/src/main/res/drawable/checkerboard.png new file mode 100644 index 0000000000000000000000000000000000000000..69436650c1e9c97ab1acdac044e0ca7105f35165 GIT binary patch literal 945 zcmaJ=O^=g67{;x}x^aJio+fNGZnVJkgD#}F(n4JlX&TyOdz8YoC0!VVsn8zvWa7cZ zgNXfc|Ye>xAS;!_x3KsFnh+aX3_O( z_7!*N|L)rx2Xwhb^a1JN5lQR_F{+D)2pGOSMi#Q&`Ll1R!7v5Z>kr7ld?Gv8=j;r_ zrG7}+4AVGDL))1m0)}Yp1q%E7(`OcVuEL(wOu-CWXyP3&BGg-S`p#nNNG^Ny5HwPm z3iycFAoWj!SWXpor7P2YX69M2f{>}gUIaBTyP$<51ZrHR_lEjJRE>b(H`O%QCJ%3MGAhnkqzQ?nP|cI)DC&b30X=x&@}%K_5BSx zCKkGk_n*RXe;y*^D1^HnBaJVL(uAp;NFQBxHyRq zR(R8tjUXm=;2=X&SgOEzo-0dDL28RlK~yyep)NKnbxEhD=3!l}wp;a_t6^v6qk!aG z_mT^@aaDr%)>zc`RxVG2;j_m6)#%(rrzhKP z#+Dv7gO36_?GYX8_rJa#(kpSt(A0kVW7vp)-YgVeo}a@v?(osh>*aEJ-5P)Ypuf9P Y6qsvYij(`=*~jb>8G1)MYd(GP2M)R-(f|Me literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/checkerboard_pattern.xml b/app/src/main/res/drawable/checkerboard_pattern.xml new file mode 100644 index 0000000..f19db54 --- /dev/null +++ b/app/src/main/res/drawable/checkerboard_pattern.xml @@ -0,0 +1,5 @@ + + \ No newline at end of file From 4a38c712d6c88bf4a1f7d3990c8b0337f269c510 Mon Sep 17 00:00:00 2001 From: Mikey Date: Sat, 30 Sep 2017 18:33:32 +0100 Subject: [PATCH 2/3] Allow intercepting of media links. --- app/src/main/AndroidManifest.xml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8c4b1be..101521c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,12 +25,20 @@ + + + + + + + + + - - - + + From 27557115419628cee91122be4afbed80fa3c411f Mon Sep 17 00:00:00 2001 From: Mikey Date: Sat, 30 Sep 2017 18:38:31 +0100 Subject: [PATCH 3/3] Show quick previews of Bundle and array object entries. --- .../co/ashtonbrsc/intentexplode/Explode.java | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java b/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java index eb8db0a..5795228 100644 --- a/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java +++ b/app/src/main/java/uk/co/ashtonbrsc/intentexplode/Explode.java @@ -327,8 +327,49 @@ private void showAllIntentData(TextView textViewToIgnore) { addBitmapToLayout(getString(R.string.extra_item_value_title) + BLANK, Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, (Bitmap) extraItem, extrasLayout); - } - else { + } else if(extraItem instanceof Bundle) { + Bundle bundle = (Bundle) extraItem; + StringBuilder stringBuilder = new StringBuilder("Bundle{"); + for (String key : bundle.keySet()) { + stringBuilder + .append("\n ") + .append(key) + .append(": ") + .append(bundle.get(key)); + } + stringBuilder.append("\n}"); + addTextToLayout(getString(R.string.extra_item_value_title) + BLANK + stringBuilder + .toString(), + Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, + extrasLayout); + } else if(extraItem.getClass().isArray()) { + // Item is an array, preview first 20 elements. + Object[] items = (Object[]) extraItem; + int max = Math.min(items.length, 20); + StringBuilder stringBuilder = new StringBuilder(extraItem.getClass().getComponentType().getSimpleName()); + stringBuilder + .append('[').append(items.length).append("]{"); + for (int i = 0; i < max; i++) { + stringBuilder + .append("\n ") + .append(i) + .append(": ") + .append(items[i]); + } + if(max < items.length) { + // preview of the end of the array. + stringBuilder + .append("\n...\n ") + .append(items.length - 1) + .append(": ") + .append(items[items.length -1]); + } + stringBuilder.append("\n}"); + addTextToLayout(getString(R.string.extra_item_value_title) + BLANK + stringBuilder + .toString(), + Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, + extrasLayout); + } else { addTextToLayout(getString(R.string.extra_item_value_title) + BLANK + extraItem .toString(), Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP,