[android-developers] Calculating size of imageview in recyclerview it finished loading
Hi. I'm about to release my first app and one issue remains. The app has a big recyclerview containing a dynamic amount of images (roughly ~600). I use Picasso to load images into the items (they are imageviews inside cardviews) and the images are loaded from my .NET API. I query the .NET API for the images, which returns a JSON list of those 600 images with their ID, URL, width and height. The width and height are important because I want to pre-set the height of the imageview so that during the scrolling, it won't constantly jump up and down because an image just finished loading. To achieve this, I wrote the following piece of code: http://pastebin.com/JdXv8sGK This basically checks if the width of the image is bigger than the width of the cardview it is in. If it is, then it checks how much percent the width is reduced and takes the same percentage off of the height. The issue is that sometimes images are getting resized incorrectly, with with values. And it's at random too because often a refresh solves it. It happens on all kind of devices (got 7 devices to test on, so it's not a brand issue). Does anyone have a clue? Thanks for reading! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at http://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/77346ad4-0f03-4d02-a669-c7e5d8ac4504%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Re: USB to PC connection
Hi Al, You make an interesting point. I was intending to use the keys for authentication, and the phone is playing a server role here, meaning that only the computer would need a private key. Once it has been generated, the public key could indeed be sent over wifi safely. You do still have the two problems left, selecting a phone and getting the key unmodified, but those are solvable indeed. However, I have been thinking about this and I feel it might be necessary to extend the service beyond the original idea of only using it over wifi and allow use over the internet as well. The idea would still be the same: having a phone app and a computer application communicate (possibly through a server). Here it might be necessary to encrypt all data sent and thus we may need to have a key pair on both ends. However, that's not really what changes the situation. What changes the situation is that the two problems above get so much bigger. The data will now be sent over a much less secure connection and there are many more wrong phones you might connect to. I am not saying that isn't solvable, but this makes me want to at least offer USB setup as an option. It is possible to just connect over usb like that? On Monday, October 1, 2012 11:22:24 AM UTC+2, al wrote: Getting cryptography right is non-trivial. So take this with caution. As I understand it, you want to generate a key pair on each side and exchange the public keys. That can be done easily via wifi too since you only exchange _public_ keys. The problem is to be sure you got the right ones (i.e. that they have not been faked by e.g. a man in the middle attack). To ensure this, you might e.g. calculate a cryptographic hash of the public keys (to shorten the data that has to be compared) and display them on both sides. The user may then compare the hashes. Am Samstag, 29. September 2012 15:21:51 UTC+2 schrieb Jasper Horn: I have an idea for an app that will both have a component that runs on the computer of the user and a component that runs on the phone. The idea will be that the two will communicate over wifi. To make this secure, I want to set up a public/private key pair on the computer and the phone. In order to do this in a user-friendly way, I want to do so automatically over usb. However, in exploring how much of what I want is actually possible on android, I have been unable to find out how to have an app communicate over usb to a program on the computer. Technically, it would be similar to using the computer as a USB accessory, but I doubt it would actually be similar enough to make this work. I have also read that it might be possible using ADB port forwarding, but this doesn't really look like it would make it more user-friendly for end users. Finally, I suppose I could solve the problems by only using the file system and mounting it, storing the public key in a file on the s-card, but it's not really the ease of use that I am looking for. Is there a way of communicating between an application running on a pc and an app running on an android device that I have missed? Is there a mistake in my current understanding of the possibilities? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] USB to PC connection
I have an idea for an app that will both have a component that runs on the computer of the user and a component that runs on the phone. The idea will be that the two will communicate over wifi. To make this secure, I want to set up a public/private key pair on the computer and the phone. In order to do this in a user-friendly way, I want to do so automatically over usb. However, in exploring how much of what I want is actually possible on android, I have been unable to find out how to have an app communicate over usb to a program on the computer. Technically, it would be similar to using the computer as a USB accessory, but I doubt it would actually be similar enough to make this work. I have also read that it might be possible using ADB port forwarding, but this doesn't really look like it would make it more user-friendly for end users. Finally, I suppose I could solve the problems by only using the file system and mounting it, storing the public key in a file on the s-card, but it's not really the ease of use that I am looking for. Is there a way of communicating between an application running on a pc and an app running on an android device that I have missed? Is there a mistake in my current understanding of the possibilities? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Abusing accessibility property
I am currently investigating the possibilities for an app idea I recently had. One of the things I want the app to be able to do is read your notifications. However, this normally can't be done. My research has led me to believe that if I mark my app as an accessibility tool and have my users enable it as such. Is this correct? Are there any disadvantages to marking an app as an accessibility app when it isn't? (Besides having to explain to my users to turn it on as such, even though it actually isn't an accessibility tool.) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Inadvertent breakage by SDK going forward
And doesn't this also mean that there's an implicit requirement that I prefix my methods with a tag to avoid future version name collisions? If I have a method in my 1.6 app called MyView.doSomething(), and MyView extends an Android class like TextView, and subsequent to 1.6, Google adds a method to TextView called doSomething(), my method would overwrite Google's method, even though I'm compiling for the 1.6 platform? If Mike's post is true, then even if I compile with the 1.6 target and run on the 2.1 target, the 1.6 app's method will overwrite the 2.1 method. Therefore, this is an implicit requirement that I should prefix all of my methods with my own tag like myDoSomething(). But I already have hundreds of methods in my app - what a pain. On Feb 12, 4:01 pm, Mike Collins mike.d.coll...@gmail.com wrote: Ran into the below issue and wanted to see what solutions people have... In SDK 1.6 Activity did not have a method onBackPressed (), in 2.0 it appeared. Using the current docs I added an onBackPressed to a couple of our classes. We build against 1.6 (customer requirement) it seemed a bit odd that the compiler got upset when I put in a @Override, so I took it out and proceeded to verify that everything was working, which it was, the method was being invoked exactly as expected. Turns out this works only on phones/emulators with 2.0 or greater firmware. On 1.6 firmware it fails to function at all because nobody calls it. OK, with hindsight it's obvious what's happening and we've made the @Override an error not a warning. But it raises the issue of how to I protect my app if in the future Android implements a method that collides with the name of method I invent for my derived class. In this case Android will be calling my method at inappropriate times and expecting it to do things that it probably doesn't do. One solution is prefix every method of ours of every class that derives from an Android class with something specific to the app. Or use a different naming convention, like always use an initial capital or an underscore etc. thoughts? mike -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Inadvertent breakage by SDK going forward
Does this truly mean that even if I compile to the 1.6 platform, if my code implements a 2.1 callback method, that method will *never* be invoked on 1.6 devices but *will* be invoked on 2.1 devices? Even though I compiled to the 1.6 platform? That's crazy! On Feb 12, 4:01 pm, Mike Collins mike.d.coll...@gmail.com wrote: Ran into the below issue and wanted to see what solutions people have... In SDK 1.6 Activity did not have a method onBackPressed (), in 2.0 it appeared. Using the current docs I added an onBackPressed to a couple of our classes. We build against 1.6 (customer requirement) it seemed a bit odd that the compiler got upset when I put in a @Override, so I took it out and proceeded to verify that everything was working, which it was, the method was being invoked exactly as expected. Turns out this works only on phones/emulators with 2.0 or greater firmware. On 1.6 firmware it fails to function at all because nobody calls it. OK, with hindsight it's obvious what's happening and we've made the @Override an error not a warning. But it raises the issue of how to I protect my app if in the future Android implements a method that collides with the name of method I invent for my derived class. In this case Android will be calling my method at inappropriate times and expecting it to do things that it probably doesn't do. One solution is prefix every method of ours of every class that derives from an Android class with something specific to the app. Or use a different naming convention, like always use an initial capital or an underscore etc. thoughts? mike -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: problem sending an email with an attachment programmatically
I'm trying to embed an HTML reference to an image to include in an HTML email. I used a SpannableString to successfully create an email that has a http href in it, as shown below. But I have not been able to add an image into the body of the email. Other programs add something like this directly to the body of the email: img src=http://thumbs1.ebaystatic.com/pict/ 1804380093048080_1.jpg This doesn't work for me - the text is a hot link. I've tried various permutations of using SpannableString but can't get the image to appear. Any tips for this would be muchly appreciated. Here's the body of an email message I've successfully created: pCheck out this item I found on eBay:/p pa href=http://cgi.ebay.com/DEALS-cps-QA-bid-test-do-not-bid-4- BID- BIN_W0QQitemZ250528416791QQcategoryZ30120QQcmdZViewItemDEALS cps QA bid test do not bid 4 BID + BIN/a/p Here's the code that successfully creates the above email message: String email_subject = getResources().getString (R.string.default_share_subject).trim(); final Intent i = new Intent(Intent.ACTION_SEND); i.setType(message/rfc822); i.putExtra(Intent.EXTRA_SUBJECT, email_subject); SpannableString item = new SpannableString (mFoundItem.getTitle().Value()); item.setSpan(new URLSpan(mFoundItem.GetItemUrl().Value ()), 0, item.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); SpannableStringBuilder email_body = new SpannableStringBuilder(getResources().getString (R.string.default_share_text) + \n\n); email_body.append(item); i.putExtra(Intent.EXTRA_TEXT, email_body); startActivity(Intent.createChooser(i, getResources ().getString(R.string.share_chooser))); -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en