Permalink
Browse files

Merge pull request #7380 from zackhow/analytics

Android: Analytics - get android ui type when called instead of setting it ahead of time
  • Loading branch information...
delroth committed Aug 28, 2018
2 parents 3d56063 + bbf2184 commit b8b4e9af5e3ed21ea4fc72ee77d8719922685b75
@@ -1,22 +1,30 @@
package org.dolphinemu.dolphinemu;
import android.app.Application;
import android.content.Context;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
import org.dolphinemu.dolphinemu.utils.VolleyUtil;
public class DolphinApplication extends Application
{
private static DolphinApplication application;
@Override
public void onCreate()
{
super.onCreate();
application = this;
VolleyUtil.init(getApplicationContext());
System.loadLibrary("main");
if (PermissionsHandler.hasWriteAccess(getApplicationContext()))
DirectoryInitializationService.startService(getApplicationContext());
}
public static Context getAppContext()
{
return application.getApplicationContext();
}
}
@@ -11,6 +11,7 @@
import com.android.volley.Request;
import com.android.volley.toolbox.StringRequest;
import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
@@ -30,8 +31,6 @@
private static final String DEVICE_MODEL = "DEVICE_MODEL";
private static final String DEVICE_TYPE = "DEVICE_TYPE";
private static String deviceType;
public static void checkAnalyticsInit(Context context)
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
@@ -63,8 +62,6 @@ public static void checkAnalyticsInit(Context context)
showMessage(context, preferences);
}
}
// Get device type now since we have a context
deviceType = TvUtil.isLeanback(context) ? "android-tv" : "android-mobile";
}
private static void showMessage(Context context, SharedPreferences preferences)
@@ -120,7 +117,8 @@ public static String getValue(String key)
case DEVICE_OS:
return String.valueOf(Build.VERSION.SDK_INT);
case DEVICE_TYPE:
return deviceType;
return TvUtil.isLeanback(DolphinApplication.getAppContext()) ? "android-tv" :
"android-mobile";
default:
return "";
}

0 comments on commit b8b4e9a

Please sign in to comment.