import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
+import androidx.lifecycle.ViewModelProvider;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
+import net.ktnx.mobileledger.ui.profiles.ProfileDetailModel;
import net.ktnx.mobileledger.utils.Colors;
+import org.jetbrains.annotations.NotNull;
+
import java.util.ArrayList;
import java.util.Locale;
public class ProfileDetailActivity extends CrashReportingActivity {
private MobileLedgerProfile profile = null;
private ProfileDetailFragment mFragment;
+ @NotNull
+ private ProfileDetailModel getModel() {
+ return new ViewModelProvider(this).get(ProfileDetailModel.class);
+ }
@Override
protected void onCreate(Bundle savedInstanceState) {
final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
themeHue = Colors.getNewProfileThemeHue(Data.profiles.getValue());
}
Colors.setupTheme(this, themeHue);
+ final ProfileDetailModel model = getModel();
+ model.initialThemeHue = themeHue;
setContentView(R.layout.activity_profile_detail);
Toolbar toolbar = findViewById(R.id.detail_toolbar);
setSupportActionBar(toolbar);
+
// Show the Up button in the action bar.
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Objects;
-import static net.ktnx.mobileledger.utils.Colors.profileThemeId;
import static net.ktnx.mobileledger.utils.Logger.debug;
/**
});
huePickerView.setOnClickListener(v -> {
- HueRingDialog d = new HueRingDialog(
- Objects.requireNonNull(ProfileDetailFragment.this.getContext()), profileThemeId,
+ HueRingDialog d = new HueRingDialog(ProfileDetailFragment.this.requireContext(),
+ model.initialThemeHue,
(Integer) v.getTag());
d.show();
d.setColorSelectedListener(model::setThemeId);
}
@NotNull
private ProfileDetailModel getModel() {
- return new ViewModelProvider(this).get(ProfileDetailModel.class);
+ return new ViewModelProvider(requireActivity()).get(ProfileDetailModel.class);
}
private void onSaveFabClicked() {
if (!checkValidity())
import net.ktnx.mobileledger.async.SendTransactionTask;
import net.ktnx.mobileledger.model.Currency;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
+import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.Misc;
public class ProfileDetailModel extends ViewModel {
private final MutableLiveData<String> authPassword = new MutableLiveData<>(null);
private final MutableLiveData<String> preferredAccountsFilter = new MutableLiveData<>(null);
private final MutableLiveData<Integer> themeId = new MutableLiveData<>(-1);
+ public int initialThemeHue = Colors.DEFAULT_HUE_DEG;
public ProfileDetailModel() {
}
String getProfileName() {