2018-10-29 22:14:31 +00:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
|
2018-11-28 01:45:58 +00:00
|
|
|
import android.content.Context;
|
2018-10-29 22:14:31 +00:00
|
|
|
import android.os.Bundle;
|
2019-05-22 16:51:56 +00:00
|
|
|
import android.support.annotation.NonNull;
|
2018-10-29 22:14:31 +00:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
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 02:30:23 +00:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2018-10-29 22:14:31 +00:00
|
|
|
public class TypingIndicatorIntroFragment extends Fragment {
|
|
|
|
|
2018-11-28 01:45:58 +00:00
|
|
|
private Controller controller;
|
|
|
|
|
2018-10-29 22:14:31 +00: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-28 01:45:58 +00: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 22:14:31 +00:00
|
|
|
@Override
|
2019-05-22 16:51:56 +00:00
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
2018-11-28 01:45:58 +00: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())
|
2018-11-28 17:21:19 +00:00
|
|
|
.getJobManager()
|
2019-03-28 15:56:35 +00:00
|
|
|
.add(new MultiDeviceConfigurationUpdateJob(TextSecurePreferences.isReadReceiptsEnabled(requireContext()),
|
2018-11-28 17:21:19 +00:00
|
|
|
typingEnabled,
|
2019-01-15 08:41:05 +00:00
|
|
|
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(getContext()),
|
|
|
|
TextSecurePreferences.isLinkPreviewsEnabled(getContext())));
|
2018-11-28 01:45:58 +00:00
|
|
|
|
2019-01-15 08:41:05 +00:00
|
|
|
controller.onTypingIndicatorsFinished();
|
2018-11-28 01:45:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public interface Controller {
|
2019-01-15 08:41:05 +00:00
|
|
|
void onTypingIndicatorsFinished();
|
2018-10-29 22:14:31 +00:00
|
|
|
}
|
|
|
|
}
|