mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
Android: Add version, GitHub, Discord to app
This commit is contained in:
parent
e579cd2eb2
commit
ead1be4728
|
@ -793,6 +793,11 @@ DEFINE_JNI_ARGS_METHOD(jstring, AndroidHostInterface_getScmVersion, jobject unus
|
|||
return env->NewStringUTF(g_scm_tag_str);
|
||||
}
|
||||
|
||||
DEFINE_JNI_ARGS_METHOD(jstring, AndroidHostInterface_getFullScmVersion, jobject unused)
|
||||
{
|
||||
return env->NewStringUTF(SmallString::FromFormat("DuckStation for Android %s (%s)\nBuilt %s %s", g_scm_tag_str, g_scm_branch_str, __DATE__, __TIME__));
|
||||
}
|
||||
|
||||
DEFINE_JNI_ARGS_METHOD(jobject, AndroidHostInterface_create, jobject unused, jobject context_object,
|
||||
jstring user_directory)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ public class AndroidHostInterface {
|
|||
private Context mContext;
|
||||
|
||||
static public native String getScmVersion();
|
||||
static public native String getFullScmVersion();
|
||||
|
||||
static public native AndroidHostInterface create(Context context, String userDirectory);
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.github.stenzek.duckstation;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -170,6 +172,15 @@ public class MainActivity extends AppCompatActivity {
|
|||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else if (id == R.id.action_show_version) {
|
||||
showVersion();
|
||||
return true;
|
||||
} else if (id == R.id.action_github_respository) {
|
||||
openGithubRepository();
|
||||
return true;
|
||||
} else if (id == R.id.action_discord_server) {
|
||||
openDiscordServer();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -377,4 +388,32 @@ public class MainActivity extends AppCompatActivity {
|
|||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showVersion() {
|
||||
final String message = AndroidHostInterface.getFullScmVersion();
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Version")
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
})
|
||||
.setNeutralButton("Copy", (dialog, button) -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
if (clipboard != null)
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText("Version", message));
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void openGithubRepository() {
|
||||
final String url = "https://github.com/stenzek/duckstation";
|
||||
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
|
||||
private void openDiscordServer() {
|
||||
final String url = "https://discord.gg/Buktv3t";
|
||||
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,15 @@
|
|||
<item
|
||||
android:id="@+id/action_import_bios"
|
||||
android:title="Import BIOS" />
|
||||
<item
|
||||
android:id="@+id/action_show_version"
|
||||
android:title="Show Version" />
|
||||
<item
|
||||
android:id="@+id/action_github_respository"
|
||||
android:title="GitHub Repository" />
|
||||
<item
|
||||
android:id="@+id/action_discord_server"
|
||||
android:title="Discord Server" />
|
||||
</group>
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
|
|
Loading…
Reference in a new issue