diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentIntro.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentIntro.java
index 513b930f5..988b18371 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentIntro.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentIntro.java
@@ -16,7 +16,10 @@
along with this program. If not, see . */
package nodomain.freeyourgadget.gadgetbridge.activities.welcome;
+import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -24,11 +27,18 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+
+import com.google.android.material.textfield.MaterialAutoCompleteTextView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
+
+import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class WelcomeFragmentIntro extends Fragment {
private static final Logger LOG = LoggerFactory.getLogger(WelcomeFragmentIntro.class);
@@ -37,6 +47,28 @@ public class WelcomeFragmentIntro extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
- return inflater.inflate(R.layout.fragment_welcome_intro, container, false);
+
+ final View view = inflater.inflate(R.layout.fragment_welcome_intro, container, false);
+ final String[] themes = getResources().getStringArray(R.array.pref_theme_values);
+ final Prefs prefs = GBApplication.getPrefs();
+ final String currentTheme = prefs.getString("pref_key_theme", getString(R.string.pref_theme_value_system));
+ final int currentThemeIndex = Arrays.asList(themes).indexOf(currentTheme);
+
+ final MaterialAutoCompleteTextView themeMenu = view.findViewById(R.id.app_theme_dropdown_menu);
+ themeMenu.setSaveEnabled(false); // https://github.com/material-components/material-components-android/issues/1464#issuecomment-1258051448
+ themeMenu.setText(getResources().getStringArray(R.array.pref_theme_options)[currentThemeIndex], false);
+ themeMenu.setOnItemClickListener((adapterView, view1, i, l) -> {
+ final SharedPreferences.Editor editor = prefs.getPreferences().edit();
+ editor.putString("pref_key_theme", themes[i]).apply();
+ final Handler handler = new Handler();
+ handler.postDelayed(() -> {
+ // Delay recreation of the Activity to give the dropdown some time to settle.
+ // If we recreate it immediately, the theme popup will reopen, which is not what the user expects.
+ Intent intent = new Intent();
+ intent.setAction(GBApplication.ACTION_THEME_CHANGE);
+ LocalBroadcastManager.getInstance(requireContext()).sendBroadcast(intent);
+ }, 500);
+ });
+ return view;
}
}
diff --git a/app/src/main/res/layout/fragment_welcome_intro.xml b/app/src/main/res/layout/fragment_welcome_intro.xml
index 3808e6090..188d627b4 100644
--- a/app/src/main/res/layout/fragment_welcome_intro.xml
+++ b/app/src/main/res/layout/fragment_welcome_intro.xml
@@ -1,6 +1,7 @@
@@ -40,5 +41,21 @@
android:textAlignment="center"
android:text="@string/first_start_intro_tag_line" />
+
+
+
+
+
\ No newline at end of file