session-android/src/org/thoughtcrime/securesms/TypingIndicatorIntroFragment.java

77 lines
2.7 KiB
Java
Raw Normal View History

2018-10-29 15:14:31 -07:00
package org.thoughtcrime.securesms;
2018-11-27 17:45:58 -08:00
import android.content.Context;
2018-10-29 15:14:31 -07:00
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
2018-10-29 15:14:31 -07:00
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.thoughtcrime.securesms.components.TypingIndicatorView;
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
2019-07-24 12:30:23 +10:00
import network.loki.messenger.R;
2018-10-29 15:14:31 -07:00
public class TypingIndicatorIntroFragment extends Fragment {
2018-11-27 17:45:58 -08:00
private Controller controller;
2018-10-29 15:14:31 -07:00
public static TypingIndicatorIntroFragment newInstance() {
TypingIndicatorIntroFragment fragment = new TypingIndicatorIntroFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public TypingIndicatorIntroFragment() {}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
2018-11-27 17:45:58 -08:00
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (!(getActivity() instanceof Controller)) {
throw new IllegalStateException("Parent activity must implement the Controller interface.");
}
controller = (Controller) getActivity();
}
2018-10-29 15:14:31 -07:00
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
2018-11-27 17:45:58 -08:00
View view = inflater.inflate(R.layout.experience_upgrade_typing_indicators_fragment, container, false);
View yesButton = view.findViewById(R.id.experience_yes_button);
View noButton = view.findViewById(R.id.experience_no_button);
((TypingIndicatorView) view.findViewById(R.id.typing_indicator)).startAnimation();
yesButton.setOnClickListener(v -> onButtonClicked(true));
noButton.setOnClickListener(v -> onButtonClicked(false));
return view;
}
private void onButtonClicked(boolean typingEnabled) {
TextSecurePreferences.setTypingIndicatorsEnabled(getContext(), typingEnabled);
ApplicationContext.getInstance(requireContext())
.getJobManager()
2019-03-28 08:56:35 -07:00
.add(new MultiDeviceConfigurationUpdateJob(TextSecurePreferences.isReadReceiptsEnabled(requireContext()),
typingEnabled,
2019-01-15 00:41:05 -08:00
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(getContext()),
TextSecurePreferences.isLinkPreviewsEnabled(getContext())));
2018-11-27 17:45:58 -08:00
2019-01-15 00:41:05 -08:00
controller.onTypingIndicatorsFinished();
2018-11-27 17:45:58 -08:00
}
public interface Controller {
2019-01-15 00:41:05 -08:00
void onTypingIndicatorsFinished();
2018-10-29 15:14:31 -07:00
}
}