Skip to content

Commit

Permalink
SVGs look much better. (#692)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Carra <rksh@wigle.net>
  • Loading branch information
rksh and Andy Carra authored Mar 8, 2024
1 parent 5186b30 commit d53f0eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions wiglewifiwardriving/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation 'com.google.maps.android:android-maps-utils:3.1.1'
implementation 'org.apache.commons:commons-csv:1.10.0'
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.1'
implementation 'com.caverock:androidsvg-aar:1.4'
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test:core:1.5.0'
Expand Down Expand Up @@ -122,6 +123,7 @@ tasks.register('createMccMncDB') {
new File("$inputMxcSqlDir/").eachFileMatch(~/.*\.sql/) { loadScript(sql, it) }
def inputFile = new File(mxcDictionaryFile.toString())
def mccMap = new JsonSlurper().parseText(inputFile.text)
assert mccMap instanceof Map
def insertSql = 'INSERT OR REPLACE INTO wigle_mcc_mnc (mcc, mnc, type, countryName, countryCode, brand, operator, status, bands, notes) VALUES (?,?,?,?,?,?,?,?,?,?)'
def myKeyNames = ['mcc', 'mnc']
mccMap.each { mcc, mncMap ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PictureDrawable;
import android.media.AudioManager;
import android.os.Bundle;

Expand All @@ -25,6 +25,7 @@
import android.widget.ScrollView;
import android.widget.TextView;

import com.caverock.androidsvg.SVG;
import com.google.android.material.navigation.NavigationView;

import net.wigle.wigleandroid.model.api.UserStats;
Expand Down Expand Up @@ -341,14 +342,15 @@ public BadgeImageRunnable(final Handler handler, final ImageView badgeImageView)

@Override
public void run() {
try {
InputStream in = new java.net.URL(UrlConfig.WIGLE_BASE_URL+stats.getImageBadgeUrl()).openStream();
final Bitmap badge = BitmapFactory.decodeStream(in);
try (InputStream in = new java.net.URL(UrlConfig.WIGLE_BASE_URL+
stats.getImageBadgeUrl().replace(".png",".svg")).openStream()) {
SVG svg = SVG.getFromInputStream(in);
Drawable drawable = new PictureDrawable(svg.renderToPicture());
handler.post(() -> {
badgeImageView.setImageBitmap(badge);
badgeImageView.setImageDrawable(drawable);
});
} catch (Exception e) {
Logging.error("Failed to download bage image ", e);
Logging.error("Failed to download badge image ", e);
}
}
}
Expand Down

0 comments on commit d53f0eb

Please sign in to comment.