Going Gapp-Less, Again….

Trebuchet

Don’t worry, you can put the tinfoil hats away. That being said, I’m going Google App Less (gappless) again. A few years back, I tried to go gappless, and it was rather difficult. Everything seemed to be tied into Google somehow, and I just couldn’t make it with the limited number of apps available outside the Google Play Store. This time around, however, is a different story.

With my new Xperia XA2 Ultra, I decided to flash LineageOS 16 (android pie), but I also decided not to flash the Google Apps package (Gapps). So, my phone was complete, without any of Google’s apps, such as the Play Store, Gmail, Google Photos, etc. It’s not that I distrust Google. I’m just not sure if I trust them. So, I thought I’d see how well it works to go without them for a while.

The truth is: I haven’t even noticed they’re gone.

The big things that you need to replace though, if you don’t have Google’s apps, are gmail, app stores, calendar, and photo backup and sharing.

The first thing I did was use the Chromium browser (the open source front runner of Google Chrome, essentially, Chrome without Google’s additives), and downloaded F-Droid. This app “store” is a repository of free and open source apps.

I know what you’re thinking, but F-Droid has come a long, long way since it’s humble beginnings. There are a lot of high quality apps on there now, covering just about every major category. Not only are there tons of apps in it, they are all free and open source. F-Droid even has an update system that makes sure you keep your apps current!

qksms

From there I downloaded QKSMS for all of my texting needs. It’s one of the best texting apps out there, open or closed source! (I borrowed the above picture so as not to show you all of my contacts….) It’s high quality, open source, easy to use and very nice to look at.

I also downloaded Librem Mail to handle all of my emails and replace the Gmail app. It supports multiple accounts, works great with Gmail and other mail accounts (like SDF) and supports PGP encryption as well. I really like it. The color coding and unified inbox is great.

Of course, I also downloaded AndBible, an open source Bible reading app, and FOSS Browser for web surfing, and AsteroidOS’s app to sync to my LG Watch Urbane smart watch (running AsteroidOS). A chess clock app, and several games like frozen bubble. Amaze for file browsing, Android CUPS for printing, GetBack GPS and PocketMaps and SatStat for GPS navigation, and a few other odds and ends.

I needed a calendar replacement, and I tried several, but Simple Calendar is my favorite. It can import “.ics” extensions, which you can export from your old Google calendar online and put onto your phone. It’s not synced with my Google calendar, but that is what I was trying to avoid anyways. I’d show some pics, but I have a lot of work related things on my calendar that I can’t show here. But it supports customization for color. The author likes orange, but I prefer blue, and fortunately you can change the color scheme.

The other big elephant in the room is a replacement for the Google Photo app with unlimited storage, which is really, really hard to beat. This is actually what started my most recent kick to try going gappless, as there is now more information about how they process photos is becoming more interesting and complex. Actually, they were talking about it in 2015 and 2017. For this reason, I set up my own home server running Piwigo photo manager.

I know you probably think I’m crazy, but consider this: on my home server version of Piwigo, without any AI intelligence looking at my photos, each photo comes in with exif data, which can (and usually does) include stats for each photo, date, time, location, phone/camera taken with, aperture data, etc. Without even trying, on the exif data alone, Google *could* know your location, what kind of phone you have, etc.

Even without location enabled, the date/time stamp plus amount of sunlight can narrow down where in the world you are with little effort (I know, I used to navigate a submarine in the Navy, and we would use stars and sun position to double check our navigation equipment). Let alone if they actually look at the photo. They would know all your friends, who you are related to, what you like to eat, what kind of car you drive, etc.

Anyways, off the hobby horse.

So, after installing Piwigo on my home server (you can host them online at BlueHost or other places as well), I then installed a simple app called SyncTool from F-Droid which allows me to FTP sync my phone’s camera folder to my home computer. For all of this, you don’t actually need something like Piwigo, but it is nice that my wife and I can use the open source app (there are non open source ones too) or a web browser to view our photos or share them with friends.

So far, it’s worked out really, really well. Albeit, you would need to be a little more tech savvy to set this up yourself. Fortunately, you could host it places that will help you with that, but then you get back to cloud storage. At least with my home server, I know exactly who’s looking at my photos.

On the other hand, all you need is a USB cable to just copy your photos to your computer every now and then. Just saying.

You might be wondering though, what about that closed source app I really need/want? Well, I have a few of those, like Bluino Loader, and arduino tool for using your phone to program arduino devices through the OTG cable. Well, it’s not open source, and not in the F-droid repository. Fortunately for me, though, there is Aptoide.

Aptoide comes in two variants, full and lite. I use the “lite” version myself. It uses less bandwidth and works faster, in my opinion. Aptoide is a Google Play Store alternative. The apps in this store are scanned with several virus scanners to ensure a good clean product. I’ve never had any issues with it myself.

For the most part, with a few exceptions, any non-paid app you can find on the Play Store seems to be here in Aptoide. It seems like they download the latest versions from the Play Store and host them here. Users can also make their own app store to host their own apps. (I did that once before… probably an old post about it on here somewhere.)

It has an update function, and you can also search back for old versions of the software, which is handy, like going back to the version before they started putting adds in! I’m not sure if it is regulated quite as well as the Play Store, and certainly not as well as F-Droid, so be careful to make sure the file scans virus free.

Another alternative is Amazon’s app store, which hosts all the usual paid apps you might need. One thing to keep in mind, though, is many apps require Google’s services running in the background to work. Thus far, I haven’t had a single issue with any of the apps I installed, though, which you can see is quite a few of them. Maybe you should try going gappless….

Linux – keep it simple.

Google’s Play Console App

Most people who are placing their apps on the Google Play Store are already aware of the Android version of the Play Console App. It’s an app to monitor the distribution of your apps. At first I was a bit skeptical of why I would need this tool, but I have to admit, it is a pretty handy to for keeping track of your apps which are on the Play Store.

It is a fairly straightforward and intuitive tool. Click on the app that you want to see and you will be instantly greeted with all the usual statistics you need. One one page they have placed the latest installs/uninstalls as well as your feedback and ratings. They even included your recent crashes that were reported to Google. That’s a lot of information in one spot.

By the way, if your version doesn’t look like mine, you might want to try out substratum for theme options. Here I am using Pitch Black Origins.

Some of the greatest features are the instant alerts if you want to know the minute that someone leaves you a review. For instance, you can select to know when you get any review, or if you just want reviews for 1 or 5 or any other number of stars. I can see how that might actually get annoying, if you were to develop an app that millions of people download, but for a small time app maker like myself, it doesn’t happen often enough to be a problem.

Another great feature is being able to read the reviews and respond to them. I was sure to show you one of my all time favorite comments that I received. But, for better or worse, it is nice to get a notification and an opportunity to respond to your customer feedback.

One thing I have noticed, though, is that there is a delay between collected data, and data pushed to your device. The ratings and customer reviews seem to happen instantly, but the data for the statistics seems to be one to three days behind. That’s not much of an issue for me, my apps stats are changing so slowly that it is easy to catch up, but if you needed the moment by moment charts, you might be better off by logging into the Play Console website instead.

While I haven’t searched out the depths of the Play Console App, I think it is a pretty neat tool overall. It’s great to get all of those statistics at a glance for your app.
Linux – keep it simple.

MechDome just got a whole lot more expensive….

I was really excited as an Android developer (probably an insult to real Android app makers, but I try…) when I heard about MechDome. If you read any of my earlier posts about MechDome, you can see that it is a really neat converter, which takes your finished APK, and turns it into an iOS program for iPhones. That in itself is pretty cool. One thing they also did, was create a program for open source users, making a purchase cost of $25 per open source app which is converted.

Recently, they have opened up their website and now are allowing subscriptions to be purchased by developers who wish to convert their apps. Unfortunately, it looks really expensive. According to the displayed price when I checked on my open source app, having a Pro subscription costs a little over $1500 per month! That is quite a bit more than I was thinking. Certainly way more than I was hoping for when it came to prices. Actually, I’m not really sure that I know any groups of developers that can afford that price.

At a cost of $1599, per the advertisement, you can convert one app 3 times per month, and up to 5 times per week in the simulator. Essentially, you can test it every workday in the simulator, but only 3 times a month can you actually convert your one app to a file which is useful on iOS devices. These guys are really, really smart, but I’m not sure that is going to work.

There is a “basic” package, however, it is not selectable for me when I click on it. That says to me that it requires me to put in my credit card information first, or that option is not available yet. Either one doesn’t bode well with me. Presumably, since the Pro package is 3 conversions per month, the basic package must only be one conversion per month, or perhaps a one time, one conversion cost.

Consider a few metrics in the finance department: If your app sold for $1.99 on the Apple store, you would need to sell 800 app downloads per month, and that only covers your MechDome expense, let alone the Apple play store fees. If you are banking on add revenue, with a HIGH revenue of .10c per playtime in advertisements, you would need 159900 people to play your app every month just to break even.

If you consider the yearly cost, you are planning to pay just under $20000 per year for that app to be on the Apple play store. If you took that $19, 200, you could easily pay for an app to be converted the “old fashioned” way, and then have all of the source code available for future work. If you use MechDome, and ever decide to stop, you are out all of your money with no way to continue development.

There certainly are apps out there that easily meet that criteria. Big apps will probably quickly overshadow that market. However, if you have an app that generates that much revenue, then you probably want to hire someone, or a team for iOS development. Mainly because there are some quirks with the converted apps. For instance, in my simple app tests, some of the colors are not the same in the converted app. If you are designing a big ticket app, then you will have a team of people making sure that your app looks “just right” on iOS as well. Let alone that you can’t use certain types of resources or libraries in your app, like libGDX, the graphics engine used in tons of games.

To be honest, I thought MechDome would have the best market share targeting midrange to low range applications. Apps that are too small to have a full iOS development team, but that are big enough to generate revenue on an iPhone market. This may sound laughable, but I was figuring on prices that were much cheaper, something in the $300 range. Actually, when I saw the price, I thought that was a Pro account price for multiple apps, but $1600 per month for just one app?

I’ve been wrong before, though. I only have one app that garnered more than 800 downloads, and that certainly is not per month! And my app was free! It just seems to me that if you have a great app which is making you enough money on Android that you want to put it on iOS, you could take this huge chunk of money and make much wiser decisions with your resources. It is a bummer, because I still think MechDome is one of the coolest tools/ideas of the decade when it comes to mobile app development.

I do still appreciate that they have reached out to open source developers with a one time conversion fee of $25, because that seems pretty reasonable. How well will their pricing work out in the future? Well that remains to be seen, but I wish them the best, I certainly would not be able to afford their new prices.

Linux – keep it simple.

Signing and installing your MechDome converted app on a simulated iPhone

In our last post, I talked about a really neat website: MechDome, which automatically converts your Android app into an iPhone application. If you haven’t read that article, I suggest you do to learn more about MechDome, which I think is going to be very big for Android developers in general. At the end of our last post, we had downloaded our converted app and run it in an iPhone simulator on our virtual Apple computer. In that post, though, I skipped all of the details of how we do that, and I would like to take a look at that question now.

So, get your Apple fired up (online, virtual, physical, etc.) and download your converted app from MechDome!

Now that you have your app downloaded, go ahead and launch Xcode. If you don’t have Xcode, it can be installed from the iStore. Once Xcode is open, go ahead and edit your preferences.

Xcode –> Preferences –> Accounts

If this is the first time you’ve been here, like it was for me, then it will be blank. press the “+” sign at the bottom and add your Apple ID account.

Once your Apple ID is added, you can now select it, and click on “View Details”. In the resulting popup, click “Create” for iOS developement. This will create the certificate you need for “signing” your test apps on your local simulator. There is not much to tell you how it went, but if the button to create disappears, it worked, so click “done”.

Now you are ready to launch the simulator. There is probably a better way to do this, but here is the simplest methode I found. Since you have Xcode open, go ahead and launch a new project. It will load fairly quickly with a default empty project. Now, press the play button at the top of the screen, which will automatically launch the simulator, boot the iPhone, and launch your empty app project.

Once that is open, you are litterally done with Xcode, so you can quite or close it, and the simulated iPhone will stay open.

Click on the iPhone window, and from the top menu, select Hardware –> Home to get back to the iPhone home screen.

Now open your OSX terminal. You can open it from the launcher by typing term and clicking on the terminal icon.

In your terminal, navigate to the downloaded zip file. For me, it was in “Downloads” and looked like an “app” but it was a directory.

$ cd Downloads

$ ls

stuff
stuff
stuff
Hourglass.app
stuff
etc….

Now, find your new certificate (key) to sign the app with:

$ security find-identity -p codesigning -v login.keychain
1) ALPHANUMERIC4404038dkldsf03893 “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)”
2) ALPHANUMERIC4404038dkldsf03893 “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)”
3) ALPHANUMERIC4404038dkldsf03893 “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)”

And set the default keychain:

$ security default-keychain -s login.keychain

And sign your “app”:

$ codesign -vfs “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)” –keychain login.keychain ./Hourglass.app/

Now that it is signed, you can install it into the already running iPhone simulator with the following:

$ xcrun simctl install booted Hourglass.app/

You should see it show up on your iPhone home screen, but it may be on one of the other screens, so swipe left and right to find it. Once you found it, go ahead and click on it to launch the app! There you go! Barring any other issues, it should work as expected.

hourglass

Apple – er, uh, wait! Linux – keep it simple!

 

MechDome: Run your Android apps on iPhones and iPads!

As an open source developer of simple Android applications, I can’t tell you how ecstatic I am about a new website: MechDome  (https://www.mechdome.com/). Finally, a one stop shop to turn your Android app into one that can be used on iOS devices, in minutes!

Can this really be? Is it really that simple? Drag and drop your Android apk file into their website and it spits out an iOS application? Well, I decided to try it for myself, and I’ve devoted this entire post to my experience.

TLDR: MechDome ROCKS! It successfully converted my opensource app: Hourglass, into an app for iPhones. If you are an Android developer, you should head over to MechDome right now!

Still with me? Great, then here are my thoughts on MechDome ….

Website Experience:

mechdome_home

The MechDome website is intuitively laid out in an informative and well thought out manner. From the opening page you will see all the information you need to get started, as well as informative placards telling you what MechDome will do for your app, namely convert it from a native Android apk to a native iOS application.

mechdome_intro

After clicking “Create App” at the top, you are asked to sign up for an account. The process is clean and intuitive, and I really liked the color scheme. Perhaps one of the best features of the website is the modern user interface and clean look.

I also tested the website out on my cell phone, and it worked beautifully.
mechdome_icon

Within a minute I had my app uploaded and was ready to test out this process. You have a couple of options about Firebase or Google ads, etc., as well as the option to use a custom icon. I think the choice to use a custom icon is great, as you may want something that looks more “iPhone-ish” or something to differentiate between your Android and iOS applications visually. After choosing your options, press save.

Once your settings are properly set, all you have to do is click the Simulator button. Presumably, when they open up the options to go to the Apple store, you can simply press the iOS button instead, but for now, free accounts are only able to upload one app for the simulator.

This is the only “problem” I saw with the website. After clicking the Simulator button, the button starts spinning, but there is no sort of progress report. After a while of waiting I ended up closing the browser, opening the page again and found the button still spinning, so I left the screen to do some research. After a few minutes, however, I received an email telling me that my app was ready for download.

So if you convert an app, after clicking Simulator, you can go about your business knowing that an email will be sent to you when your app is ready. That is really convenient. I do think the website should indicate that, though, after you click the Simulator button.

I tried this twice with my two email accounts. The first app I tested was done in a few minutes. The second app I tested was not done for several hours. Both of the apps were about the same size, albeit one was a little more complicated than the other.

mechdome_appready

Once your app is ready, the Simulator button changes from the orange “refresh” symbol to a green “download” symbol to let you know your app is ready for download.

A quick tap of the download button and I had a shiny new zip folder on my hard drive. Simple, short, sweet!

Now all I had to do is test it…..

App conversion:

It actually took me a while to get the hang of how to use an Apple computer so I could test the app that I converted. Since that is a bit of a rabbit trail, I will save that for the next post. Here I will just talk about how well the app conversion worked.

As I said before, I used my two email accounts to “cheat” and use MechDome twice. Currently, free accounts only get one trial download/conversion for simulator use only. Both apps that I tested did work rather well, so I will only discuss the open source app that I tested, which was my Hourglass app, available on F-Droid and the Google Play Store.

Here’s a few screen shots of my app in iOS action:

This slideshow requires JavaScript.

Overall the app worked great! It looked pretty close to what it looks like on Android, and as far as I could tell, every part of the app, every button, every slider, etc., worked flawlessly.

Notifications, however, were a bit different. Not wrong, just different. First, as you can see in the slideshow, I was prompted to ask if I would allow this app to send notifications or not. Choosing yes allowed the notification to pass through, and you could see it in the notifications bar, if you pull the bar down. When the timer on the app reaches 0:00, it is supposed to have a popup to tell you that your timer is up, but that didn’t happen. If the app was open, then that would transpire, but not if the app was closed. However, the sounds still played, so it seems to still function great as a background timer.

The other app I converted was a customer feedback type of app, which was not open source, so there are no pictures of it here, sorry. An interesting note, it used parse extensively, and seemed to work flawlessly. This proved to me that parse, networking, and intents were working great! The only oddity was the color of the “stars” for the ratings. In the Android version, the stars were orange/yellow, but in the iOS version, the stars were an odd gray color. Still functional, just a bit of a visual oddity. Overall, I was really impressed. Two thumbs way up from this Android developer!

Open source and Pricing potential:

I exchanged a few emails with the MechDome staff and was really impressed by how quickly they responded, as well as their professionalism, enthusiasm, and helpful attitude. In those emails I asked them about general pricing and open source development. They have not publicly finalized any pricing options, but it sounds like they plan on a tier subscriptions. Perhaps those who do multiple apps, or apps of a certain magnitude will fall under larger “tiers” and be charge extra.

Within our emails, we had a brief discussion in which I was proposing an open source developer account option. While I cannot speak on their behalf, they did seem very favorable to supporting open source development. Obviously, if you are making free applications, it doesn’t work to pay money to convert them for the iOS systems. They were curious to know what my thoughts are for what an open source developer account might look like.

These sort of things are probably best left to bean counters who usually handle this thing, but here are my thoughts on how to best support open source development:

  • Ideal: Give users the opportunity to create an open source developer account that can convert a limited number of open source apps per month, such as two or three, for free. No subscription costs, and if the account stays active, then it will not expire.
  • Less than ideal, but still helpful: Give users who already have paid subscriptions the ability to convert open source applications without counting against their monthly quota or subscription.
  • A one time setup cost: Another option might be a one time cost, rather than a subscription, for an open source account. E.g., a $25 setup fee for open source users to set up a developer account.

With either of the above options they will help support open source development. However, I suspect that if it costs anything for a subscription, a lot of open source developers will not be able to participate.

For instance, my open source applications and software work garner me $0 currently. I receive no donations currently, and do not get paid for my open source work, I don’t currently support advertisements, because this is my hobby. So if the subscription costs too much, I would not be able to maintain the subscription.

But, if there was a one time fee (like there is to get a Google developer account and put apps on the Play Store), or a free account with limited use for the open source developer, then I would be all in! Obviously, any account that used the software improperly, to convert closed source materials for free would need to be prosecuted, etc., but that is something I’m sure MechDome  is already looking at from a legal standpoint.

These are just my thoughts, and they do not reflect MechDome‘s opinion on the matter, as that remains to be seen. Hopefully they will consider the open source community and help it thrive by allowing some sort of use of their conversion software, because MechDome has proven to me to be exceptional when it comes to quality and customer service so far! Now all we have to wait on is their pricing.

In the mean time, head over to MechDome and try converting an app yourself! It works great! If you have trouble running that app in the simulator, be sure to check out my next post!

Linux – keep it simple.

P.S. I don’t want to sound like a broken record, MechDome is not offering me any special deals, payment, or benefits to write this, I just really liked my test run of their conversion software on their website.

Just letting the user know…

When making apps, I have begun to realize that I don’t do a very good job of creating intuitive and informative interfaces. The fact that the user his the export button doesn’t really tell the Just Notes app user that they actually did anything, or that notes were exported. That is why I added this commit:

https://github.com/alaskalinuxuser/app_justnotes/commit/9162b2bb87c46574765ced7b4a7f9b8ff223756f

Essentially, I created a pop up (called a toast) that tells the user their notes were, in fact, exported. Something I probably should have done a long time ago!

Linux – keep it simple.

Critical Velocity! A fun side scrolling arcade style game.

After finishing my Android developer course, I decided to try to put my new found (fledgling) skills to use by making a game. It’s a classic side scroller with an arcade feel to it. The story line is pretty short and to the point: you are a captain of a space ship that must escape a tunnel buried beneath the surface of a collapsing planet.

As you pass each object in the tunnel, you gain speed. There are power ups and bonus points, all the usual suspects in arcade game play, so be sure to check it out in my “Homemade Apps” section, on the play store, or in my github (it is licensed under the Apache 2.0 open source license.)

The background for the game was provided by the Quiet Learner ( https://qlfiles.net/ ), the music is “Space Blockbuster” by Soulbringer ( http://freemusicarchive.org/music/Soulbringer/Soulbringer/Soulbringer_-_Space_Blockbuster ), and the graphics were modified from Dan Cook’s work which he released to the public ( http://www.lostgarden.com/2005/03/game-post-mortem-hard-vacuum.html ). It’s great when people share their work so others can build upon it or with it. The same applies for my work on this game, if you can use it, do!

Linux – keep it simple.

Adding Parse to your App in Android Studio

Parse is a really neat tool for your Android applications, allowing you to have online servers that store game scores, driver id’s, names, logins, you name it! Whatever storage your app needs, you can just about always use parse for the job.

The usual way of getting parse set up in your app used to be downloading the latest parse “starter kit” app. An empty app that has parse libraries and the code needed already built in. But that is a bit of a hassle now, since they have closed down the parse website.

However, as I mentioned before, parse did make all of their material open source as they faded off into the wild blue yonder, but it left newbies like myself struggling to figure out how to implement parse into new apps.

The great news is, you do not need to get a “parse starter kit” or some such app. The pros already had this figured out, but if you are new like me, then here is my take on importing parse into your app in Android Studio (this should work on any Android Studio, but for reference, I used Android Studio 2.3.1).

Step 1. Make a new app, name it whatever you want.

Step 2. From the file menu, click “project structure”.

addparse1

Step 3. In the window that pops up, under Modules, click “app”.

addparse2

Step 4. Click on the “Dependencies” tab.

addparse3

Step 5. Click the green “+” arrow, and choose #1, Library.

addparse4

Step 6. When the Library Dependency window opens, type “parse” and press enter. Now choose the latest “com.parse:parse-android XXXXXXXXXX” version, and press OK.

addparse5

Step 7. You should now be returned to your Dependencies tab, with the parse library added. Press OK to close the window.

addparse6

Step 8. Add these lines to your MainActivity.java file (Or whatever you chose to call the first launched activity) :

// Enable Local Datastore.
Parse.enableLocalDatastore(this);

// Add your initialization code here
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
        .applicationId("ENTERYOURINFOHERE")
        .clientKey("ENTERYOURINFOHERE")
        .server("https://ENTERYOURINFOHERE/parse/")
        .build()
);

I put that data into the “onCreate” method, so it is called as soon as you launch the app. Now you just have to fill it in with your app id, key, and url for your parse server, and you should be good to go! Then you can start adding your parse commands as usual.

I hope that helps some other parse/app making newbie like myself!

Linux – keep it simple.

 

All about parse!

As many of you probably already know, the parse server service was shut down some time ago. However, on the way out the door, they released all of their material as open source for the community at large to benefit from. This is great for open source junkies like me, but also is an incredible resource for Android app developers, who can deploy these parse servers to places like Heroku, or self host the services, either locally or over the internet.

As part of my Android app developer course, I had to do several exercises with parse servers and app integration, so I committed my parse work to my github with this commit:

https://github.com/alaskalinuxuser/apps_small/commit/9e746535ab4f6b869d4c02517f50f6c4d08eae64

Or you can go to my “all things parse” folder by clicking this link:

https://github.com/alaskalinuxuser/apps_small/tree/master/EverythingParsePossible

The folder contains an app that I made with many parse options and examples in it. Contrary to the name, there are actually a lot of other parse options, too, but this will definitely get you started!

Linux – keep it simple.

Searching an Array List

Searching an array list:

// When we click the search button.
public void searchACity (View searchView) {

    // Set our boolean to false.
    searchYes = false;

    // Defining an array of titles and urls.
    searchCityList = new ArrayList<String>();
    searchCityUrl = new ArrayList<String>();

    // Clear the lists, so we don't get duplicates.
    searchCityList.clear();
    searchCityUrl.clear();

    // Get our text and turn it into a string that is lowercase.
    String search = searchMyLocal.getText().toString().toLowerCase();

    // Testing only // Log.i("WJH", search);

    // Okay, now search the citylist for that string.
    for (int i = 0; i < cityList.size(); i++) {

        // If it contains the search string....
        if (cityList.get(i).contains(search)) {

            // Testing only // Log.i("WJH", cityList.get(i) + urlList.get(i));

            // Then add it to our new search lists.
            searchCityList.add(cityList.get(i));
            searchCityUrl.add(urlList.get(i));

            // And set our search boolean to true, because we found something.
            searchYes = true;

        }
    }

    // So, if we found something....
    if (searchYes) {

        // Clear the old lists.
        cityList.clear();
        urlList.clear();

        // For each item in our new search lists....
        for (int g = 0; g < searchCityList.size(); g++) {

            // Add them to our lists.
            cityList.add(searchCityList.get(g));
            urlList.add(searchCityUrl.get(g));

            // And notify of an update and update the list view.
            addaptedAray.notifyDataSetChanged();
            theList.invalidateViews();

        }

    } else { // But if nothing found....

        // The only way to see this, is if the search yielded no results.
        Toast.makeText(getApplicationContext(), "Nothing found that matches your search.", Toast.LENGTH_SHORT).show();

        // Reset the list
        addCities();

        // Update the list view.
        addaptedAray.notifyDataSetChanged();
        theList.invalidateViews();

    }

    // Get rid of the keyboard, so they can see the results...
    InputMethodManager imm = (InputMethodManager)getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);

} // searchACity end.

In my Just Craigslist app, the user used to select their location from a list. I thought that was a good system when I made the app, because there is only one Craigslist city choice in my area. Once I chose my location, the preferences were saved in the app, so I never needed to change it.citysearch

However, it was pointed out to me that some people live close to two or more Craigslist areas, and have to search between these areas, constantly choosing another location. With the long list of places to choose from, this became very tedious.

So, I needed a way to search the list. Not only that, but I needed a way to re-list the searched passing criteria, and that is what I have done in the above code. Hopefully people will find that intuitive.

Essentially, I am taking the array lists that existed, and searching them with this line:

// If it contains the search string....
        if (cityList.get(i).contains(search)) {

Which I just looped through every city in the list, seeing if it contains the search criteria. If it does, then I add it to a temporary list. After the loop has finished searching, Android then clears the master list, and adds the temporary list to it, and refreshes the view, so now you can choose from your list of matching criteria. Ex: if you search for Georgia, you will be given a list of all the cities in Georgia that have a Craigslist area.

There were two problems:

  1. Case sensitive. The search is case sensitive. I solved this by forcing all queries to be lower case, and edited the city list to be all lower case as well. Even if they type in all caps, it will only search in lower case.
  2. No results. Some searches will naturally yield no results. Obviously, if you search for places on Mars or Saturn, you wont find them here on Earth, and certainly not in the Craigslist listings. So, when the search fails, you are given the original entire list again, as well as a popup to say that nothing was found.

It is my hope that this will make it easier for people to change locations. Only time will tell.

Linux – keep it simple.