Android: Display version in title
This commit is contained in:
parent
e457d4ca0c
commit
f94fef11ac
|
@ -17,6 +17,7 @@
|
|||
#include "frontend-common/imgui_styles.h"
|
||||
#include "frontend-common/opengl_host_display.h"
|
||||
#include "frontend-common/vulkan_host_display.h"
|
||||
#include "scmversion/scmversion.h"
|
||||
#include <android/native_window_jni.h>
|
||||
#include <cmath>
|
||||
#include <imgui.h>
|
||||
|
@ -629,6 +630,11 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||
#define DEFINE_JNI_ARGS_METHOD(return_type, name, ...) \
|
||||
extern "C" JNIEXPORT return_type JNICALL Java_com_github_stenzek_duckstation_##name(JNIEnv* env, __VA_ARGS__)
|
||||
|
||||
DEFINE_JNI_ARGS_METHOD(jstring, AndroidHostInterface_getScmVersion, jobject unused)
|
||||
{
|
||||
return env->NewStringUTF(g_scm_tag_str);
|
||||
}
|
||||
|
||||
DEFINE_JNI_ARGS_METHOD(jobject, AndroidHostInterface_create, jobject unused, jobject context_object,
|
||||
jstring user_directory)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ public class AndroidHostInterface {
|
|||
private long mNativePointer;
|
||||
private Context mContext;
|
||||
|
||||
static public native String getScmVersion();
|
||||
static public native AndroidHostInterface create(Context context, String userDirectory);
|
||||
|
||||
public AndroidHostInterface(Context context) {
|
||||
|
|
|
@ -45,6 +45,15 @@ public class MainActivity extends AppCompatActivity {
|
|||
return prefs.getBoolean("Main/SaveStateOnExit", true);
|
||||
}
|
||||
|
||||
private static String getTitleString() {
|
||||
String scmVersion = AndroidHostInterface.getScmVersion();
|
||||
final int gitHashPos = scmVersion.indexOf("-g");
|
||||
if (gitHashPos > 0)
|
||||
scmVersion = scmVersion.substring(0, gitHashPos);
|
||||
|
||||
return String.format("DuckStation %s", scmVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -52,6 +61,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setTitle(getTitleString());
|
||||
|
||||
findViewById(R.id.fab_add_game_directory).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue