2015-11-19 10:21:19 -08:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.content.res.Configuration;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
2019-03-18 11:14:18 -03:00
|
|
|
import android.support.annotation.NonNull;
|
2015-11-19 10:21:19 -08:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2015-11-19 10:21:19 -08:00
|
|
|
public class DeviceLinkFragment extends Fragment implements View.OnClickListener {
|
|
|
|
|
|
|
|
private LinearLayout container;
|
|
|
|
private LinkClickedListener linkClickedListener;
|
|
|
|
private Uri uri;
|
|
|
|
|
|
|
|
@Override
|
2019-03-18 11:14:18 -03:00
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
|
2015-11-19 10:21:19 -08:00
|
|
|
this.container = (LinearLayout) inflater.inflate(R.layout.device_link_fragment, container, false);
|
|
|
|
this.container.findViewById(R.id.link_device).setOnClickListener(this);
|
|
|
|
|
|
|
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
|
|
container.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
} else {
|
|
|
|
container.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfiguration) {
|
2019-03-18 11:14:18 -03:00
|
|
|
super.onConfigurationChanged(newConfiguration);
|
2015-11-19 10:21:19 -08:00
|
|
|
if (newConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
|
|
container.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
} else {
|
|
|
|
container.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLinkClickedListener(Uri uri, LinkClickedListener linkClickedListener) {
|
|
|
|
this.uri = uri;
|
|
|
|
this.linkClickedListener = linkClickedListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
if (linkClickedListener != null) {
|
|
|
|
linkClickedListener.onLink(uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public interface LinkClickedListener {
|
2019-03-18 11:14:18 -03:00
|
|
|
void onLink(Uri uri);
|
2015-11-19 10:21:19 -08:00
|
|
|
}
|
|
|
|
}
|