mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Add a "user data" screen
To make it clearer for users where Dolphin is storing user data, now that there's more than one possible place.
This commit is contained in:
parent
258832dad4
commit
9c8bb24293
@ -120,6 +120,12 @@
|
||||
android:exported="false"
|
||||
android:theme="@style/DolphinBase" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.UserDataActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/user_data_submenu"
|
||||
android:theme="@style/DolphinSettingsBase" />
|
||||
|
||||
<service
|
||||
android:name=".utils.DirectoryInitialization"
|
||||
android:exported="false"/>
|
||||
|
@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||
|
||||
public class UserDataActivity extends AppCompatActivity
|
||||
{
|
||||
public static void launch(Context context)
|
||||
{
|
||||
Intent launcher = new Intent(context, UserDataActivity.class);
|
||||
context.startActivity(launcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_user_data);
|
||||
|
||||
TextView textType = findViewById(R.id.text_type);
|
||||
TextView textPath = findViewById(R.id.text_path);
|
||||
TextView textAndroid11 = findViewById(R.id.text_android_11);
|
||||
|
||||
textType.setText(DirectoryInitialization.isUsingLegacyUserDirectory() ?
|
||||
R.string.user_data_old_location : R.string.user_data_new_location);
|
||||
|
||||
textPath.setText(DirectoryInitialization.getUserDirectory());
|
||||
|
||||
boolean show_android_11_text = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
|
||||
!DirectoryInitialization.isUsingLegacyUserDirectory();
|
||||
textAndroid11.setVisibility(show_android_11_text ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import android.text.TextUtils;
|
||||
import org.dolphinemu.dolphinemu.DolphinApplication;
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.activities.UserDataActivity;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting;
|
||||
@ -252,6 +253,8 @@ public final class SettingsFragmentPresenter
|
||||
sl.add(new SubmenuSetting(mContext, R.string.advanced_submenu, MenuTag.CONFIG_ADVANCED));
|
||||
sl.add(new SubmenuSetting(mContext, R.string.log_submenu, MenuTag.CONFIG_LOG));
|
||||
sl.add(new SubmenuSetting(mContext, R.string.debug_submenu, MenuTag.DEBUG));
|
||||
sl.add(new RunRunnable(mContext, R.string.user_data_submenu, 0, 0, 0,
|
||||
() -> UserDataActivity.launch(mContext)));
|
||||
}
|
||||
|
||||
private void addGeneralSettings(ArrayList<SettingsItem> sl)
|
||||
|
@ -43,6 +43,7 @@ public final class DirectoryInitialization
|
||||
private static volatile boolean areDirectoriesAvailable = false;
|
||||
private static String userPath;
|
||||
private static AtomicBoolean isDolphinDirectoryInitializationRunning = new AtomicBoolean(false);
|
||||
private static boolean isUsingLegacyUserDirectory = false;
|
||||
|
||||
public enum DirectoryInitializationState
|
||||
{
|
||||
@ -108,7 +109,10 @@ public final class DirectoryInitialization
|
||||
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
|
||||
return false;
|
||||
|
||||
File path = preferLegacyUserDirectory(context) && PermissionsHandler.hasWriteAccess(context) ?
|
||||
isUsingLegacyUserDirectory =
|
||||
preferLegacyUserDirectory(context) && PermissionsHandler.hasWriteAccess(context);
|
||||
|
||||
File path = isUsingLegacyUserDirectory ?
|
||||
getLegacyUserDirectoryPath() : context.getExternalFilesDir(null);
|
||||
|
||||
if (path == null)
|
||||
@ -388,6 +392,11 @@ public final class DirectoryInitialization
|
||||
isExternalFilesDirEmpty(context) && legacyUserDirectoryExists();
|
||||
}
|
||||
|
||||
public static boolean isUsingLegacyUserDirectory()
|
||||
{
|
||||
return isUsingLegacyUserDirectory;
|
||||
}
|
||||
|
||||
public static boolean isWaitingForWriteAccess(Context context)
|
||||
{
|
||||
// This first check is only for performance, not correctness
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_type"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/spacing_medlarge"
|
||||
tools:text="@string/user_data_new_location"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/text_path"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintWidth_max="400dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_path"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/spacing_medlarge"
|
||||
tools:text="/storage/emulated/0/Android/data/org.dolphinemu.dolphinemu/files"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_type"
|
||||
app:layout_constraintBottom_toTopOf="@id/text_android_11"
|
||||
app:layout_constraintWidth_max="400dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_android_11"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/spacing_medlarge"
|
||||
android:text="@string/user_data_new_location_android_11"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_path"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintWidth_max="400dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -324,6 +324,12 @@
|
||||
<string name="debug_jitbranchoff">Jit Branch Disabled</string>
|
||||
<string name="debug_jitregistercacheoff">Jit Register Cache Disabled</string>
|
||||
|
||||
<!-- User Data -->
|
||||
<string name="user_data_submenu">User Data</string>
|
||||
<string name="user_data_old_location">Your user data is stored in a location which will <b>not</b> be deleted when you uninstall the app:</string>
|
||||
<string name="user_data_new_location">Your user data is stored in a location which <b>will be deleted</b> when you uninstall the app:</string>
|
||||
<string name="user_data_new_location_android_11">Because you\'re using Android 11 or newer, you can\'t access this location using file manager apps. However, you can access it using the file manager in the system settings, or by connecting your device to a PC.</string>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
Loading…
Reference in New Issue
Block a user