Skip to content

Commit

Permalink
Merge pull request #40 from gatheringhallstudios/develop
Browse files Browse the repository at this point in the history
Release V2.0.2
  • Loading branch information
JosephMichels committed Sep 15, 2018
2 parents 1f82d96 + e44fece commit 163c34b
Show file tree
Hide file tree
Showing 117 changed files with 1,556 additions and 1,695 deletions.
Expand Up @@ -56,7 +56,7 @@
*/
public class SQLiteAssetHelper extends SQLiteOpenHelper {

private static final String TAG = SQLiteAssetHelper.class.getSimpleName();
private static final String TAG = "SQLiteAssetHelper";
private static final String ASSET_DB_PATH = "databases";

private final Context mContext;
Expand Down Expand Up @@ -385,17 +385,21 @@ public void setForcedUpgrade() {
private SQLiteDatabase createOrOpenDatabase(boolean force) throws SQLiteAssetException {
File file = new File (mDatabasePath + "/" + mName);
boolean fileExists = file.exists();
SQLiteDatabase db = null;

// If the file exists and force is enabled, assume there is a DB
if (fileExists && force) {
Log.w(TAG, "forcing database upgrade!");
db = returnDatabase();
preCopyDatabase(db);
copyDatabaseFromAssets();
return returnDatabase();
db = returnDatabase();
postCopyDatabase(db);
return db;
}

// test for the existence of the db file first and don't attempt open
// to prevent the error trace in log on API 14+
SQLiteDatabase db = null;
if (fileExists) {
db = returnDatabase();
}
Expand Down
12 changes: 8 additions & 4 deletions app/build.gradle
Expand Up @@ -19,8 +19,12 @@ android {
//1.1.0 Version Code: 4 Released 7-31-2016
//1.1.1 Version Code: 5 Released 8-05-2016
//1.1.2 Version Code: 6 Released 10-17-2016
versionCode 9
versionName "2.0.1"
//????? Version Code: 7 Released ????????
//2.0.0 Version Code: 8 Released 9-8-2018
//2.0.1 Version Code: 9 Released 9-8-2018
//2.0.2 Version Code:10 Released 9-??-2018
versionCode 10
versionName "2.0.2"

compileOptions {
// we'll still be able to target lower java versions because of desugar
Expand All @@ -38,8 +42,8 @@ android {

buildTypes {
release {
minifyEnabled false
shrinkResources false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.txt
@@ -0,0 +1 @@
-keep class android.support.v7.widget.SearchView { *; }
1 change: 0 additions & 1 deletion app/release/output.json

This file was deleted.

Binary file modified app/src/main/assets/databases/mhgu.db.zip
Binary file not shown.
Binary file added app/src/main/icon-res/drawable/icon_bottle_empty.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/icon-res/drawable/monster_agnaktor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/icon-res/drawable/monster_gravios.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/icon-res/drawable/monster_royal_ludroth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/icon-res/drawable/monster_snowbaron_lagombi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/icon-res/drawable/monster_volvidon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 27 additions & 2 deletions app/src/main/java/com/ghstudios/android/AssetLoader.kt
Expand Up @@ -5,6 +5,7 @@ import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.support.v4.content.ContextCompat
import android.widget.ImageView
import com.ghstudios.android.data.classes.Gathering
import com.ghstudios.android.data.classes.QuestHub
import com.ghstudios.android.mhgendatabase.R
import com.ghstudios.android.util.MHUtils
Expand Down Expand Up @@ -48,8 +49,12 @@ object AssetLoader {
}

@JvmStatic
fun setIcon(iv: ImageView, item: ITintedIcon) {
iv.setImageDrawable(loadIconFor(item))
fun setIcon(iv: ImageView, item: ITintedIcon?) {
if (item == null) {
iv.setImageDrawable(null)
} else {
iv.setImageDrawable(loadIconFor(item))
}
}

/**
Expand All @@ -64,4 +69,24 @@ object AssetLoader {
QuestHub.PERMIT -> ctx.getString(R.string.type_hub_permit)
null -> "NULL"
}

/**
* Returns a localized string that represents the gathering node's site modifier.
* For example, Fixed, Rare, Common
*/
@JvmStatic fun localizeGatherModifier(gather: Gathering) = when {
gather.isFixed -> ctx.getString(R.string.item_gather_fixed)
gather.isRare -> ctx.getString(R.string.item_gather_rare)
else -> ctx.getString(R.string.item_gather_common)
}

/**
* Returns a localized string that represents the gathering type.
* For example, Mine [Fixed] and Gather [Rare].
* TODO: Localize the first part...
*/
@JvmStatic fun localizeGatherNodeFull(gather: Gathering): String {
val modifier = localizeGatherModifier(gather)
return ctx.getString(R.string.item_gather_full, gather.site, modifier)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/ghstudios/android/MHApplication.kt
@@ -1,7 +1,7 @@
package com.ghstudios.android

import android.app.Application
import com.ghstudios.android.data.database.DataManager
import com.ghstudios.android.data.DataManager

class MHApplication : Application() {
override fun onCreate() {
Expand Down
Expand Up @@ -92,7 +92,7 @@ public void bindView(Context context, WeaponListEntry entry) {
if (element2 != ElementStatus.NONE) {
elementIconView2.setTag(weapon.getId());

int elementIconId = AssetRegistry.getElementRegistry().get(element, R.color.transparent);
int elementIconId = AssetRegistry.getElementRegistry().get(element2, R.color.transparent);
Drawable icon = ContextCompat.getDrawable(context, elementIconId);
elementIconView2.setImageDrawable(icon);

Expand Down
87 changes: 87 additions & 0 deletions app/src/main/java/com/ghstudios/android/components/SlotsView.kt
@@ -0,0 +1,87 @@
package com.ghstudios.android.components

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import com.ghstudios.android.mhgendatabase.R
import kotlin.math.roundToInt

/**
* Custom view used to render a list of slots for a piece of equipments.
* These slots can be empty or filled in.
*/
class SlotsView : LinearLayout {
private lateinit var decorationImageViews: List<ImageView>

/**
* A flag used to control whether extra non-existant slots are not rendered.
* If false, non-existant slots are rendered using a line.
* If true, their visibility is set to GONE
*/
var hideExtras: Boolean = false

constructor(context: Context): super(context) {
init(0, 0)
}

constructor(context: Context, attrs: AttributeSet): super(context, attrs) {
val attributes = context.obtainStyledAttributes(attrs, R.styleable.SlotsView)
try {
hideExtras = attributes.getBoolean(R.styleable.SlotsView_hideExtras, false)
val maxSlots = attributes.getInt(R.styleable.SlotsView_maxSlots, 0)
val usedSlots = attributes.getInt(R.styleable.SlotsView_usedSlots, 0)

init(maxSlots, usedSlots)
} finally {
attributes.recycle()
}
}

fun init(maxSlots: Int, usedSlots: Int) {
layoutParams = ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)

val imageSize = context.resources.getDimension(R.dimen.image_size_xsmall).roundToInt()
val gap = imageSize / 5

// Create image views. They should have gaps between them
decorationImageViews = listOf(ImageView(context), ImageView(context), ImageView(context))
for ((idx, decorationImage) in decorationImageViews.withIndex()) {
val isLast = decorationImageViews.size - 1 == idx
decorationImage.layoutParams = LayoutParams(imageSize, imageSize).apply {
if (!isLast) {
setMargins(0, 0, gap, 0)
}
}
addView(decorationImage)
}

setSlots(maxSlots, usedSlots)
}

/**
* Updates this view's count of max slots and used slots.
* Elements past the maximum number of slots may be hidden based on the value of hideExtras.
*/
fun setSlots(maxSlots: Int, usedSlots: Int) {
for (i in 0..2) {
val view = decorationImageViews[i]

if (i >= maxSlots && hideExtras) {
view.visibility = View.GONE
continue
}
view.visibility = View.VISIBLE

val resource = when {
i >= maxSlots -> R.drawable.decoration_none
i >= usedSlots -> R.drawable.decoration_empty
else -> R.drawable.decoration_real
}

view.setImageResource(resource)
}
}
}
@@ -1,4 +1,4 @@
package com.ghstudios.android.data.database
package com.ghstudios.android.data

import android.app.Application
import android.content.Context
Expand Down Expand Up @@ -38,6 +38,7 @@ import com.ghstudios.android.data.cursors.WishlistComponentCursor
import com.ghstudios.android.data.cursors.WishlistCursor
import com.ghstudios.android.data.cursors.WishlistDataCursor
import com.ghstudios.android.data.cursors.WyporiumTradeCursor
import com.ghstudios.android.data.database.*
import com.ghstudios.android.util.first
import com.ghstudios.android.util.firstOrNull
import com.ghstudios.android.util.toList
Expand Down

0 comments on commit 163c34b

Please sign in to comment.