]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java
profile editor: offer a suitable color for new profiles
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / ProfileDetailActivity.java
index 4536e0d91f66aa6d22f1d6a48fadf6f64e9d9bad..323568b4ea9cdac4a339fe6b0512485f281ba413 100644 (file)
@@ -57,12 +57,18 @@ public class ProfileDetailActivity extends CrashReportingActivity {
                                     index));
 
                 debug("profiles", String.format(Locale.ENGLISH, "Editing profile %s (%s); hue=%d",
-                        profile.getName(), profile.getUuid(), profile.getThemeId()));
+                        profile.getName(), profile.getUuid(), profile.getThemeHue()));
             }
         }
 
         super.onCreate(savedInstanceState);
-        Colors.setupTheme(this, profile);
+        int themeHue;
+        if (profile != null)
+            themeHue = profile.getThemeHue();
+        else {
+            themeHue = Colors.getNewProfileThemeHue(Data.profiles.getValue());
+        }
+        Colors.setupTheme(this, themeHue);
         setContentView(R.layout.activity_profile_detail);
         Toolbar toolbar = findViewById(R.id.detail_toolbar);
         setSupportActionBar(toolbar);
@@ -87,6 +93,7 @@ public class ProfileDetailActivity extends CrashReportingActivity {
             // using a fragment transaction.
             Bundle arguments = new Bundle();
             arguments.putInt(ProfileDetailFragment.ARG_ITEM_ID, index);
+            arguments.putInt(ProfileDetailFragment.ARG_HUE, themeHue);
             mFragment = new ProfileDetailFragment();
             mFragment.setArguments(arguments);
             getSupportFragmentManager().beginTransaction()