summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/userstatus
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2018-02-14 16:00:13 +0100
committercyBerta <cyberta@riseup.net>2018-02-14 16:00:13 +0100
commit96e5db80d9a949435df32d2d0c46497b86d1fff4 (patch)
tree9b5d099e8fd897612101d938087fd1a818bde331 /app/src/main/java/se/leap/bitmaskclient/userstatus
parent9b6c368a25510c462ea357121c97edb6d0310021 (diff)
#8846 remove legacy code and files: Dashboard, LogWindow, UserStatusFragment, FabButton library etc.
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/userstatus')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java28
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java158
2 files changed, 0 insertions, 186 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java
deleted file mode 100644
index d1c56dee..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/FabButton.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package se.leap.bitmaskclient.userstatus;
-
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import mbanje.kurt.fabbutton.CircleImageView;
-import se.leap.bitmaskclient.R;
-
-public class FabButton extends mbanje.kurt.fabbutton.FabButton {
-
-
- public FabButton(Context context) {
- super(context);
- }
-
- public FabButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public FabButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- private CircleImageView getImage() {
- return (CircleImageView) findViewById(R.id.fabbutton_circle);
- }
-}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
deleted file mode 100644
index 2d8b5c6f..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package se.leap.bitmaskclient.userstatus;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.TextView;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Observable;
-import java.util.Observer;
-
-import butterknife.ButterKnife;
-import butterknife.InjectView;
-import butterknife.OnClick;
-import se.leap.bitmaskclient.Provider;
-import se.leap.bitmaskclient.ProviderAPI;
-import se.leap.bitmaskclient.ProviderAPICommand;
-import se.leap.bitmaskclient.ProviderAPIResultReceiver;
-import se.leap.bitmaskclient.R;
-
-public class UserStatusFragment extends Fragment implements Observer {
-
- public final static String TAG = UserStatusFragment.class.getSimpleName();
- private ProviderAPIResultReceiver providerAPI_result_receiver;
-
- private Provider provider;
-
- @InjectView(R.id.user_status_username)
- TextView username;
- @InjectView(R.id.user_status_icon)
- FabButton icon;
- @InjectView(R.id.user_status_button)
- Button button;
-
- private UserStatus status;
- private boolean allowsRegistration = false;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- status = UserStatus.getInstance(getResources());
- status.addObserver(this);
- }
-
- @Override
- public void onSaveInstanceState(@NotNull Bundle outState) {
- if (username != null && username.getVisibility() == TextView.VISIBLE)
- outState.putSerializable(UserStatus.TAG, status.sessionStatus());
-
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- View view = inflater.inflate(R.layout.user_session_fragment, container, false);
- ButterKnife.inject(this, view);
-
- Bundle arguments = getArguments();
- allowsRegistration = arguments.getBoolean(Provider.ALLOW_REGISTRATION);
- handleNewStatus(status);
-
- return view;
- }
-
- @Override
- public void onAttach(Context context) {
- super.onAttach(context);
- }
-
- public void restoreSessionStatus(Bundle savedInstanceState) {
- if (savedInstanceState != null)
- if (savedInstanceState.containsKey(UserStatus.TAG)) {
- UserStatus.SessionStatus status = (UserStatus.SessionStatus) savedInstanceState.getSerializable(UserStatus.TAG);
- UserStatus.updateStatus(status, getResources());
- }
- }
-
- @OnClick(R.id.user_status_button)
- public void handleButton() {
- android.util.Log.d(TAG, status.toString());
- if(status.isLoggedIn())
- logOut();
- else if(status.isLoggedOut())
- Log.w(TAG, "implement login from here?");
- //MainActivity.sessionDialog(Bundle.EMPTY);
- else if(status.inProgress())
- cancelLoginOrSignup();
- }
-
- @Override
- public void update(Observable observable, Object data) {
- if (observable instanceof UserStatus) {
- final UserStatus status = (UserStatus) observable;
- getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- handleNewStatus(status);
- }
- });
- }
- }
-
- private void handleNewStatus(UserStatus status) {
- this.status = status;
- if (allowsRegistration) {
- if (this.status.inProgress())
- showUserSessionProgressBar();
- else
- hideUserSessionProgressBar();
- changeMessage();
- updateButton();
- }
- }
-
- private void showUserSessionProgressBar() {
- icon.showProgress(true);
- }
-
- private void hideUserSessionProgressBar() {
- icon.showProgress(false);
- }
-
- private void changeMessage() {
- final String message = User.userName();
- username.setText(message);
- }
-
- private void updateButton() {
- if(status.isLoggedIn() || status.didntLogOut())
- button.setText(getActivity().getString(R.string.logout_button));
- else if(allowsRegistration) {
- if (status.isLoggedOut() || status.notLoggedIn())
- button.setText(getActivity().getString(R.string.login_button));
- else if (status.inProgress())
- button.setText(getActivity().getString(android.R.string.cancel));
- }
- }
-
-
- public void logOut() {
- android.util.Log.d(TAG, "Log out");
- ProviderAPICommand.execute(getActivity(), ProviderAPI.LOG_OUT, provider, providerAPI_result_receiver);
- }
-
- public void cancelLoginOrSignup() {
- //EipStatus.getInstance().setConnectedOrDisconnected();
- }
-
-}