private void finishLogin() { RemoteClient remoteClient = m_app.getRemoteClientManager().getRemoteClient(); remoteClient.finishLogin(); if (remoteClient.finishLogin() && remoteClient.isAuthenticated()) { switchToTodolist(); localBroadcastManager.sendBroadcast(new Intent(Constants.BROADCAST_START_SYNC_FROM_REMOTE)); } }
@Override public View onCreateView( @NotNull LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) { Log.v(TAG, "onCreateView() this:" + this + " savedInstance:" + savedInstanceState); Bundle arguments = getArguments(); actionbar = getActivity().getActionBar(); Log.v(TAG, "Fragment bundle:" + this + " arguments:" + arguments); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.other_filter, container, false); cbHideCompleted = (CheckBox) layout.findViewById(R.id.cb_show_completed); cbHideFuture = (CheckBox) layout.findViewById(R.id.cb_show_future); cbHideLists = (CheckBox) layout.findViewById(R.id.cb_show_lists); cbHideTags = (CheckBox) layout.findViewById(R.id.cb_show_tags); if (savedInstanceState != null) { cbHideCompleted.setChecked( !savedInstanceState.getBoolean(ActiveFilter.INTENT_HIDE_COMPLETED_FILTER, false)); cbHideFuture.setChecked( !savedInstanceState.getBoolean(ActiveFilter.INTENT_HIDE_FUTURE_FILTER, false)); cbHideLists.setChecked( !savedInstanceState.getBoolean(ActiveFilter.INTENT_HIDE_LISTS_FILTER, false)); cbHideTags.setChecked( !savedInstanceState.getBoolean(ActiveFilter.INTENT_HIDE_TAGS_FILTER, false)); } else { cbHideCompleted.setChecked( !arguments.getBoolean(ActiveFilter.INTENT_HIDE_COMPLETED_FILTER, false)); cbHideFuture.setChecked(!arguments.getBoolean(ActiveFilter.INTENT_HIDE_FUTURE_FILTER, false)); cbHideLists.setChecked(!arguments.getBoolean(ActiveFilter.INTENT_HIDE_LISTS_FILTER, false)); cbHideTags.setChecked(!arguments.getBoolean(ActiveFilter.INTENT_HIDE_TAGS_FILTER, false)); } gestureDetector = new GestureDetector(TodoApplication.getAppContext(), new FilterGestureDetector()); OnTouchListener gestureListener = new OnTouchListener() { @Override public boolean onTouch(@NotNull View v, @NotNull MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { MotionEvent cancelEvent = MotionEvent.obtain(event); cancelEvent.setAction(MotionEvent.ACTION_CANCEL); v.onTouchEvent(cancelEvent); return true; } return false; } }; layout.setOnTouchListener(gestureListener); return layout; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); m_app = (TodoApplication) getApplication(); setTheme(m_app.getActiveTheme()); setContentView(R.layout.login); localBroadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("nl.mpcjanssen.simpletask.ACTION_LOGIN"); m_broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Intent i = new Intent(context, Simpletask.class); startActivity(i); finish(); } }; localBroadcastManager.registerReceiver(m_broadcastReceiver, intentFilter); Button m_LoginButton = (Button) findViewById(R.id.login); m_LoginButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { startLogin(); } }); RemoteClient remoteClient = m_app.getRemoteClientManager().getRemoteClient(); if (remoteClient.isAuthenticated()) { switchToTodolist(); } }
void startLogin() { final RemoteClient client = m_app.getRemoteClientManager().getRemoteClient(); client.startLogin(); }