Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Vesi
Jan 12, 2005

pikachu looking at?

Scaramouche posted:

Based on some Googling, an XBF is apparently a binary of a XAML file, which I obviously don't have since I'm not the developer of the app. Is there a way for me to generate these XBF files in Chinese?

binary XML can always be decompiled back into plaintext, your first step would be to look for a xaml decompiler to see what the files look like

Adbot
ADBOT LOVES YOU

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Vesi posted:

binary XML can always be decompiled back into plaintext, your first step would be to look for a xaml decompiler to see what the files look like

Hmm, I tried this guy:
https://xamldecompiler.codeplex.com

But it just generates this:
code:
Application: XAML Decompiler.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at Xbf2Xaml.XBFReader.ReadHeader()
   at Xbf2Xaml.XBFReader.ReadXBFFile()
(not expecting you to troubleshoot that, just going in for completelyness' sake)

The only other one I can find is xamlspy, but it's a paid program. It's apparently built into Visual Studio in the XAMLBinaryWriter method but I'm not installing VS just for this.

I popped it open in a hex editor and there's a header GUIX, a bunch of gobbleygook, and then the last 3 chars are XBF.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

UPDATE: I may be a moron.

XBF=External Binary/Bitmap Font

and NOT

XBF=XAML Binary File

Splinter
Jul 4, 2003
Cowabunga!
Some Android newb questions:

Should I ever use ListView over RecyclerView? The tutorials I'm doing are a few years old. They teach ListView, then RecyclerView, saying RecyclerView is a new and improved (better performing) ListView, but didn't go into much depth beyond that.

Where is the proper place to store API keys? Right now I just have it in the app code, but that means it'll be publicly viewable if I ever put the project on github, and also had the thought that it might be possible to decompile the APK to grab it.

What min SDK version should I use? The tutorials have me targeted ICS (API level 15), but again, these tutorials are a few years old. I know support for older versions is a big part of Android development, but would it be better to learn using a smaller range of API levels?

Taffer
Oct 15, 2010


Splinter posted:

Should I ever use ListView over RecyclerView? The tutorials I'm doing are a few years old. They teach ListView, then RecyclerView, saying RecyclerView is a new and improved (better performing) ListView, but didn't go into much depth beyond that.

Never. RecyclerView is better in all ways.


Splinter posted:

What min SDK version should I use? The tutorials have me targeted ICS (API level 15), but again, these tutorials are a few years old. I know support for older versions is a big part of Android development, but would it be better to learn using a smaller range of API levels?

Depends on what features you want to target and how much of the base you're willing to cut off. I use 19 as a compromise. Your life will be a lot easier with 21, but that cuts off a lot.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Splinter posted:

Where is the proper place to store API keys? Right now I just have it in the app code, but that means it'll be publicly viewable if I ever put the project on github, and also had the thought that it might be possible to decompile the APK to grab it.

Your API key isn't secret. Your keystore, otoh...

Splinter
Jul 4, 2003
Cowabunga!

Volmarias posted:

Your API key isn't secret. Your keystore, otoh...

Hmm, not sure I understand. For a specific example, I"m using the Dark Sky API to get forecast data for a weather app. My secret API key for Dark Sky is included in part of the request URL and I'm billed based on how many requests are made each day using that key (after exhausting daily free uses). In theory, someone could get a hold of my key either through the app code or maybe by monitoring traffic for the request URL, then use that key in their app leaving me with the bill for their traffic. Not an actual concern for this basic weather app I built for practice, but I thought it would be good to learn the secure way to do this. I've seen people recommend fetching the key from a server at run time (seems like this would still be vulnerable to snooping), or having the server handle the entire API interaction (forwarding the data back to the app). But with both of those solutions it seems like you've essentially made another API that you then need to worry about securing...

Tunga
May 7, 2004

Grimey Drawer

Splinter posted:

I've seen people recommend fetching the key from a server at run time (seems like this would still be vulnerable to snooping)
You can use public key pinning in the app to prevent proxying of network communication (but there'll probably be some other flaw in your scheme that becomes the next easiest attack vector).

speng31b
May 8, 2010

Tunga posted:

You can use public key pinning in the app to prevent proxying of network communication (but there'll probably be some other flaw in your scheme that becomes the next easiest attack vector).

Fwiw this is as far down the rabbit hole as I've ever seen anyone get with worrying about this. Make a config service to get your keys, secure it within reason, leave it at that.

Most importantly, monitor your keys for abuse and roll them if something happens. That's where the backend piece comes in really handy - ad hoc key rolling, no adoption overhead.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Splinter posted:

I've seen people recommend fetching the key from a server at run time (seems like this would still be vulnerable to snooping), or having the server handle the entire API interaction (forwarding the data back to the app). But with both of those solutions it seems like you've essentially made another API that you then need to worry about securing...

You're right, it's turtles all the way down. You're relying on someone you're giving a secret key to not being able to figure out what that key you just gave them is.

Pretty much what speng said, your goal is to figure out what "good enough" is and reach that.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Splinter posted:

Where is the proper place to store API keys? Right now I just have it in the app code, but that means it'll be publicly viewable if I ever put the project on github, and also had the thought that it might be possible to decompile the APK to grab it.

For my spare time teach-yourself-Android projects, I keep Web service APIs in a separate XML resource file, and I put that filename in a .gitignore

kitten smoothie
Dec 29, 2001

Lutha Mahtin posted:

For my spare time teach-yourself-Android projects, I keep Web service APIs in a separate XML resource file, and I put that filename in a .gitignore

A slightly cleaner (at least because you're not ignoring an XML deep into your code tree) is to lean on Gradle tooling to do this. Edit your gradle.properties (which you .gitignore)

code:
twitterApiKey="butts"
twitterApiSecret="lol"
Then in the "android" block in your project build.gradle

code:
defaultConfig {
    buildConfigField "String", "TWITTER_API_KEY", twitterApiKey
    buildConfigField "String", "TWITTER_API_SECRET", twitterApiSecret
}
Then the Android Gradle plugin will create fields for you that you can use in your code; just say BuildConfig.TWITTER_API_KEY.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

kitten smoothie posted:

A slightly cleaner (at least because you're not ignoring an XML deep into your code tree) is to lean on Gradle tooling to do this. Edit your gradle.properties (which you .gitignore)

Then the Android Gradle plugin will create fields for you that you can use in your code; just say BuildConfig.TWITTER_API_KEY.

The only differences I see between this way and mine is that (1) I'm ignoring a different file and (2) the string reference in the code will be named a bit differently. Is it really considered "less clean" to ignore /app/src/main/res/values/totallysecret.xml versus doing the Gradle thing? My way still gives me fields to use in my code, the only difference is that instead of your BuildConfig.SECRETSQUIRREL I put on my robe and R.string.SECRETSQUIRREL hat.

kitten smoothie
Dec 29, 2001

The scheme I detailed gets it in a top level config file rather than .gitignoring something deep in your tree. Since it's not stored under your src/ tree you're less likely to accidentally refactor it into some place that's not .gitignored. Also since it's not a string resource, you don't need a Context handy to read the value of your secrets.

Tunga
May 7, 2004

Grimey Drawer
Also you can use your local gradle.properties file rather than the one in the project and then there is no need to gitignore anything and no risk of ever commiting it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Lutha Mahtin posted:

The only differences I see between this way and mine is that (1) I'm ignoring a different file and (2) the string reference in the code will be named a bit differently. Is it really considered "less clean" to ignore /app/src/main/res/values/totallysecret.xml versus doing the Gradle thing? My way still gives me fields to use in my code, the only difference is that instead of your BuildConfig.SECRETSQUIRREL I put on my robe and R.string.SECRETSQUIRREL hat.

Now you have two separate files storing configuration information. A bespoke one and a standardized one.

brap
Aug 23, 2004

Grimey Drawer
I'm trying to create an Android AppWidget. I'm trying to figure out a reasonable heuristic for when to update it. If the data in the widget is more than 30 seconds old, it's stale and no longer useful.

On iOS, the system calls your update callback when the widget becomes visible. It doesn't look like any proxy to this exists on Android. In addition, the update interval that you provide in XML is a minimum of 30 minutes--basically designed for weather and news widgets, not for real time transit widgets.

When SHOULD I be updating this thing? If I could receive a broadcast for "the user went to the home screen and may or may not be looking at the widget", that would be adequate and presumably not too battery draining.

Telephones
Apr 28, 2013
I am writing an app to tag images. These tags need to be shared with another app and they need to be searchable. So I am using a content provider with a SQLite database for storage.

I do not know how to proceed - I don't know how I should go about populating my database with data from the mediastore, and I don't know how to ensure that these values are properly updated when the mediastore is updated. I also can't find any code example similar to what I am attempting to do, to my surprise.

What should I do?

Telephones fucked around with this message at 23:29 on Apr 10, 2017

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

are you familiar with the relational algebra

Doctor w-rw-rw-
Jun 24, 2008
https://techcrunch.com/2017/04/18/facebook-expands-its-open-source-portfolio-with-new-ui-framework-for-android/
Essentially ComponentKit for Android, and ComponentKit is essentially React* for iOS.

* The pattern – React is both a pattern and an implementation, but this fact gets often overlooked because React is so strongly associated with React.js.

FAT32 SHAMER
Aug 16, 2012



Does anyone have any experience with UiAutomator? Any tips or best practices? I keep getting this weird NullExceptionPointer error when I try to have it click on android system dialog buttons so I'm not sure what's up with that

John F Bennett
Jan 30, 2013

I always wear my wedding ring. It's my trademark.

About database, any experiences with using Realm instead of SQLite? I've been researching some stuff and it looks promising. It comes with its' own ORM, which is always nice.

Taffer
Oct 15, 2010


John F Bennett posted:

About database, any experiences with using Realm instead of SQLite? I've been researching some stuff and it looks promising. It comes with its' own ORM, which is always nice.

I use it. It's really good, I recommend it. On the other hand I've never used SQL so I can't compare :v:

Telephones
Apr 28, 2013

Lutha Mahtin posted:

are you familiar with the relational algebra

Sorry for the late response - no, I'm not. I have a basic understanding of SQL, which on a quick glance seems to have a lot of the same ideas.

Let me be more specific with how I think this should go...
-When I create my provider, I will create an empty table.
-When the user adds a tag to an image, I will insert a row with an ID matching the image's MediaStore.Images.ImageColumns.BUCKET_ID. (...but what if there is more than one tag?)
-When the user deletes an image, I will delete the row with an ID matching the image's MediaStore.Images.ImageColumns.BUCKET_ID. (...but how can I tell when an image has been deleted from the mediastore? This could happen outside of my application.)
-When the user queries my provider for an image, would it be ok to direct the query to the mediastore?

I read the API guides on Content Providers and Creating Content Providers, but I'm pretty inexperienced, so I'm not sure what additional information would be useful to me. Am I moving in the right direction?

Telephones fucked around with this message at 00:25 on May 2, 2017

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

relational algebra is the mathematical framework from which SQL is derived, yeah

to be honest, you being stumped on how to create features such as "have more than one tag per image" and "be notified when an image is deleted" leads me to suspect that you don't really have the most robust knowledge of relational data models. i apologize if that sounds pretty blunt but i say it in the hopes that it might save you a lot of banging your head against the wall. having a relationship such as "one image can have zero or more tags" is what you will find described in the literature as a "one to many" relationship, and it's one of the basic building blocks that a person is almost required to know in order to create a successful and well-functioning SQL database. my advice for you is to go read more about relational databases, and more specifically the topics of: data modeling, keys, triggers, and updates/deletes (specifically: updates and deletes that "cascade").

Telephones
Apr 28, 2013
Thanks, I will do some reading.

Mezzanine
Aug 23, 2009

funny Star Wars parody posted:

Does anyone have any experience with UiAutomator? Any tips or best practices? I keep getting this weird NullExceptionPointer error when I try to have it click on android system dialog buttons so I'm not sure what's up with that

Pretty sure Android system dialog buttons have different "android.R.id"'s depending on the OS version, model, etc, so you may want to have it search by text or something?

FAT32 SHAMER
Aug 16, 2012



Mezzanine posted:

Pretty sure Android system dialog buttons have different "android.R.id"'s depending on the OS version, model, etc, so you may want to have it search by text or something?

I managed to get it working, but the issue is I'm doing this on apk's that companies won't release the source code to us and it's extremely tedious to hook UiObject2 methods onto objects so I was hoping I'm just retarded and doing it wrong, seems like I'm not based on the results though

:shrug:

brap
Aug 23, 2004

Grimey Drawer
Learn what triggers are, and then don't write them.

Unkempt
May 24, 2003

...perfect spiral, scientists are still figuring it out...
My wife got me a Sony SmartWatch 3. I think it's cool. I dug out Android Studio and wrote myself a new watch face for it. That's also pretty cool.

Except now if I try and use the voice recognition stuff, it thinks I'm speaking French. I have no idea how that happened or how to fix it. Anyone know what controls that and how I could have screwed it up with a watch face?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

american watches default to hands at 10 and 2. french watches default to pencil-thin hands at 4 and 8 with an eyeroll complication. this might be your problem

joke answer

Unkempt
May 24, 2003

...perfect spiral, scientists are still figuring it out...
Actually I think it might just have forced a sync with my phone which apparently was set to french for some reason? Or something. I'll play with it a bit more.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Unkempt posted:

Actually I think it might just have forced a sync with my phone which apparently was set to french for some reason? Or something. I'll play with it a bit more.

Is there a lot of cheese shops, wine stores, and baguette bakeries in your Google Timeline? Could happen to the best of us

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Check your salad dressing option, set it back to Ranch if you haven't yet already. Be careful that you don't select Russian by accident!

FAT32 SHAMER
Aug 16, 2012



This is probably based on your browsing habits so thanks for revealing your French maid fetish

John F Bennett
Jan 30, 2013

I always wear my wedding ring. It's my trademark.

After a week of working with Realm, I have to say that I'm very happy and impressed with it. I won't be going back to SQLite any time soon.

One thing that is a bit less than ideal is that it's not possible to create RealmLists with primitive wrapper types. As an example, you can't do something like this:

code:
RealmList<Integer> numbers = new RealmList<>();
You have to make a custom class that inherits from RealmObject:

code:
 
public class RealmInteger extends RealmObject {

private int number;

}
And then you can use it like:

code:
RealmList<RealmInteger> numbers = new RealmList<>();
It's a bit of a workaround but at least it works. So this might help you if you run into this.

Overall it's a very nice system to use.

Taffer
Oct 15, 2010


Yeah, I would say that's an edge case that's pretty easy to work around. A more annoying issue (imo) is that you can't store an array of non-realm objects within a realm object. That one has been pretty frustrating for me, I'd really like to be able to store arrays of ints or strings in a Realm object. Otherwise though I really like it and it's been really easy to use.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Native support for Lists of any supported datatype is actually what I'm working on Right Now, although it'll be a while before it makes it to the Java SDK.

Telephones
Apr 28, 2013
How do I import OpenCamera into Android Studio, or any IDE for that matter? In one of the Issues on GitHub, the owner suggests it is trivial...

quote:

...there are no nuances in build process - import into IDE and build. All libraries will be added and compiled/linked. You should be sure you specify path to your NDK and your build command (in c/c++ build) is ndk-build. Check if there are any errors in console.

I imported the project into both Eclipse and Android Studio and tried to "build" it but to no success. I installed the NDK but everything in Android Studio is just grayed out. I don't understand the task on a basic level. Importing a project should be trivial! What am I missing?

Telephones fucked around with this message at 05:06 on May 16, 2017

Adbot
ADBOT LOVES YOU

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
This is definitely built for eclipse, likely before Android Studio was a thing. Unfortunately, I can't help you with Android Studio NDK builds, you might want to ask in Stack Overflow too.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply