package com.chess.genesis;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

final class UpgradeHandler
{
	private static Context context;
	private static PackageInfo pinfo;
	private static SharedPreferences pref;

	private UpgradeHandler()
	{
	}

	public static void run(final Context _context)
	{
	try {
		context = _context;
		pinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
		pref = PreferenceManager.getDefaultSharedPreferences(context);

		upgrade(pref.getInt("appVersion", 0), pinfo.versionCode);
	} catch (NameNotFoundException e) {
		e.printStackTrace();
		throw new RuntimeException();
	}
	}

	private static void upgrade(final int oldVer, final int newVer)
	{
		if (oldVer == newVer)
			return;

		final Editor edit = pref.edit();

		if (oldVer < 28) {
			edit.putBoolean("isLoggedIn", false);
			edit.putString("username", "!error!");
		}

		edit.putInt("appVersion", newVer);
		edit.commit();
	}
}

@@ -326,117 +326,8 @@
 r%0A%7B%0A
-%09private static Context context;%0A%09private static PackageInfo pinfo;%0A%09private static SharedPreferences pref;%0A%0A
 %09pri
@@ -393,17 +393,16 @@
 Context 
-_
 context)
@@ -418,30 +418,26 @@
 %7B%0A%09%09
-context = _context;%0A%09%09
+final PackageInfo 
 pinf
@@ -515,16 +515,40 @@
 , 0);%0A%09%09
+final SharedPreferences 
 pref = P
@@ -613,16 +613,22 @@
 upgrade(
+pref, 
 pref.get
@@ -799,24 +799,54 @@
 grade(final 
+SharedPreferences pref, final 
 int oldVer, 

remove static class variables from UpgradeHandler