mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
Android: Add an update notification about controller bindings
This commit is contained in:
parent
a5e316b916
commit
ad991c122d
|
@ -179,6 +179,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
AndroidHostInterface.getInstance().setContext(this);
|
||||
mGameList.refresh(false, false, this);
|
||||
UpdateNotes.displayUpdateNotes(this);
|
||||
}
|
||||
|
||||
private void startAddGameDirectory() {
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.github.stenzek.duckstation;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
public class UpdateNotes {
|
||||
private static final int VERSION_CONTROLLER_UPDATE = 1;
|
||||
private static final int CURRENT_VERSION = VERSION_CONTROLLER_UPDATE;
|
||||
|
||||
private static final String CONFIG_KEY = "Main/UpdateNotesVersion";
|
||||
|
||||
private static int getVersion(MainActivity parent) {
|
||||
try {
|
||||
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(parent);
|
||||
return sp.getInt(CONFIG_KEY, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return CURRENT_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setVersion(MainActivity parent, int version) {
|
||||
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(parent);
|
||||
sp.edit().putInt(CONFIG_KEY, version).commit();
|
||||
}
|
||||
|
||||
public static boolean displayUpdateNotes(MainActivity parent) {
|
||||
final int version = getVersion(parent);
|
||||
|
||||
if (version < VERSION_CONTROLLER_UPDATE ) {
|
||||
displayControllerUpdateNotes(parent);
|
||||
setVersion(parent, VERSION_CONTROLLER_UPDATE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void displayControllerUpdateNotes(MainActivity parent) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(parent);
|
||||
builder.setTitle(R.string.update_notes_title);
|
||||
builder.setMessage(R.string.update_notes_message_version_controller_update);
|
||||
builder.setPositiveButton(R.string.main_activity_yes, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent(parent, ControllerSettingsActivity.class);
|
||||
parent.startActivity(intent);
|
||||
});
|
||||
builder.setNegativeButton(R.string.main_activity_no, (dialog, which) -> dialog.dismiss());
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
|
@ -312,4 +312,6 @@
|
|||
<string name="memory_card_editor_import_card_failed">Failed to import card \'%s\'. It may not be a supported format.</string>
|
||||
<string name="memory_card_editor_import_card_success">Imported card \'%s\'.</string>
|
||||
<string name="menu_game_list_entry_choose_cover_image">Choose Cover Image</string>
|
||||
<string name="update_notes_title">Update Notes</string>
|
||||
<string name="update_notes_message_version_controller_update">This DuckStation update includes support for multiple controllers, and binding devices such as keyboards/volume buttons.\n\nYou must re-bind your controllers, otherwise they will no longer function. Do you want to do this now?</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue