This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Tray ViewModel * History and Bookmarks migration * Resize library tray icons when closing the library panels
- Loading branch information
Showing
16 changed files
with
399 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/common/shared/org/mozilla/vrbrowser/ui/viewmodel/BookmarksViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.mozilla.vrbrowser.ui.viewmodel; | ||
|
||
import android.app.Application; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.databinding.ObservableBoolean; | ||
import androidx.lifecycle.AndroidViewModel; | ||
import androidx.lifecycle.MutableLiveData; | ||
|
||
public class BookmarksViewModel extends AndroidViewModel { | ||
|
||
private MutableLiveData<ObservableBoolean> isLoading; | ||
private MutableLiveData<ObservableBoolean> isEmpty; | ||
private MutableLiveData<ObservableBoolean> isNarrow; | ||
|
||
public BookmarksViewModel(@NonNull Application application) { | ||
super(application); | ||
|
||
isLoading = new MutableLiveData<>(new ObservableBoolean(false)); | ||
isEmpty = new MutableLiveData<>(new ObservableBoolean(false)); | ||
isNarrow = new MutableLiveData<>(new ObservableBoolean(false)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsLoading() { | ||
return isLoading; | ||
} | ||
|
||
public void setIsLoading(boolean isLoading) { | ||
this.isLoading.setValue(new ObservableBoolean(isLoading)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsEmpty() { | ||
return isEmpty; | ||
} | ||
|
||
public void setIsEmpty(boolean isEmpty) { | ||
this.isEmpty.setValue(new ObservableBoolean(isEmpty)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsNarrow() { | ||
return isNarrow; | ||
} | ||
|
||
public void setIsNarrow(boolean isNarrow) { | ||
this.isNarrow.setValue(new ObservableBoolean(isNarrow)); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
app/src/common/shared/org/mozilla/vrbrowser/ui/viewmodel/HistoryViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.mozilla.vrbrowser.ui.viewmodel; | ||
|
||
import android.app.Application; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.databinding.ObservableBoolean; | ||
import androidx.lifecycle.AndroidViewModel; | ||
import androidx.lifecycle.MutableLiveData; | ||
|
||
public class HistoryViewModel extends AndroidViewModel { | ||
|
||
private MutableLiveData<ObservableBoolean> isLoading; | ||
private MutableLiveData<ObservableBoolean> isEmpty; | ||
private MutableLiveData<ObservableBoolean> isNarrow; | ||
|
||
public HistoryViewModel(@NonNull Application application) { | ||
super(application); | ||
|
||
isLoading = new MutableLiveData<>(new ObservableBoolean(false)); | ||
isEmpty = new MutableLiveData<>(new ObservableBoolean(false)); | ||
isNarrow = new MutableLiveData<>(new ObservableBoolean(false)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsLoading() { | ||
return isLoading; | ||
} | ||
|
||
public void setIsLoading(boolean isLoading) { | ||
this.isLoading.setValue(new ObservableBoolean(isLoading)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsEmpty() { | ||
return isEmpty; | ||
} | ||
|
||
public void setIsEmpty(boolean isEmpty) { | ||
this.isEmpty.setValue(new ObservableBoolean(isEmpty)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsNarrow() { | ||
return isNarrow; | ||
} | ||
|
||
public void setIsNarrow(boolean isNarrow) { | ||
this.isNarrow.setValue(new ObservableBoolean(isNarrow)); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
app/src/common/shared/org/mozilla/vrbrowser/ui/viewmodel/TrayViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.mozilla.vrbrowser.ui.viewmodel; | ||
|
||
import android.app.Application; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.databinding.ObservableBoolean; | ||
import androidx.lifecycle.AndroidViewModel; | ||
import androidx.lifecycle.MediatorLiveData; | ||
import androidx.lifecycle.MutableLiveData; | ||
import androidx.lifecycle.Observer; | ||
|
||
public class TrayViewModel extends AndroidViewModel { | ||
|
||
private MutableLiveData<ObservableBoolean> isMaxWindows; | ||
private MutableLiveData<ObservableBoolean> shouldBeVisible; | ||
private MutableLiveData<ObservableBoolean> isKeyboardVisible; | ||
private MediatorLiveData<ObservableBoolean> isVisible; | ||
|
||
public TrayViewModel(@NonNull Application application) { | ||
super(application); | ||
|
||
isMaxWindows = new MutableLiveData<>(new ObservableBoolean(true)); | ||
shouldBeVisible = new MutableLiveData<>(new ObservableBoolean(true)); | ||
isKeyboardVisible = new MutableLiveData<>(new ObservableBoolean(false)); | ||
isVisible = new MediatorLiveData<>(); | ||
isVisible.addSource(shouldBeVisible, mIsVisibleObserver); | ||
isVisible.addSource(isKeyboardVisible, mIsVisibleObserver); | ||
isVisible.setValue(new ObservableBoolean(false)); | ||
} | ||
|
||
Observer<ObservableBoolean> mIsVisibleObserver = new Observer<ObservableBoolean>() { | ||
@Override | ||
public void onChanged(ObservableBoolean observableBoolean) { | ||
boolean shouldShow = shouldBeVisible.getValue().get() && !isKeyboardVisible.getValue().get(); | ||
if (shouldShow != isVisible.getValue().get()) { | ||
isVisible.setValue(new ObservableBoolean(shouldShow)); | ||
} | ||
} | ||
}; | ||
|
||
public void refresh() { | ||
isMaxWindows.setValue(isMaxWindows.getValue()); | ||
shouldBeVisible.setValue(shouldBeVisible.getValue()); | ||
isKeyboardVisible.setValue(isKeyboardVisible.getValue()); | ||
} | ||
|
||
public void setIsMaxWindows(boolean isMaxWindows) { | ||
this.isMaxWindows.setValue(new ObservableBoolean(isMaxWindows)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsMaxWindows() { | ||
return isMaxWindows; | ||
} | ||
|
||
|
||
public void setShouldBeVisible(boolean shouldBeVisible) { | ||
this.shouldBeVisible.setValue(new ObservableBoolean(shouldBeVisible)); | ||
} | ||
|
||
public void setIsKeyboardVisible(boolean isVisible) { | ||
this.isKeyboardVisible.setValue(new ObservableBoolean(isVisible)); | ||
} | ||
|
||
public void setIsVisible(boolean isVisible) { | ||
this.isVisible.setValue(new ObservableBoolean(isVisible)); | ||
} | ||
|
||
public MutableLiveData<ObservableBoolean> getIsVisible() { | ||
return isVisible; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.