Merge pull request #7380 from zackhow/analytics
Android: Analytics - get android ui type when called instead of setting it ahead of time
This commit is contained in:
commit
b8b4e9af5e
|
@ -1,6 +1,7 @@
|
|||
package org.dolphinemu.dolphinemu;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
|
||||
import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
|
||||
|
@ -8,15 +9,22 @@ 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 android.support.v4.content.LocalBroadcastManager;
|
|||
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 @@ public class Analytics
|
|||
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 class Analytics
|
|||
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 class Analytics
|
|||
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 "";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue