Главная страница

Протокол проверки вкр в системе Антиплагиат


Скачать 1.89 Mb.
НазваниеПротокол проверки вкр в системе Антиплагиат
Дата01.04.2023
Размер1.89 Mb.
Формат файлаpdf
Имя файлаKQdGzfNnTIE2.pdf
ТипПротокол
#1029322
страница4 из 4
1   2   3   4
MaterialBetterSpinner spinnerApps = (MaterialBetterSpinner) view.findViewById(R.id.spinner_apps); spinnerApps.setAdapter(adapterApps);
ArrayAdapter
adapterProtocols
=
new
ArrayAdapter(getContext(), android.R.layout.simple_dropdown_item_1line,
getResources().getStringArray(R.array.array_protocols));
MaterialBetterSpinner spinnerProtocols = (MaterialBetterSpinner) view.findViewById(R.id.spinner_protocol); spinnerProtocols.setAdapter(adapterProtocols);
Button buttonSetFilter = (Button) view.findViewById(R.id.button_set_filter); buttonSetFilter.setOnClickListener(new View.OnClickListener() {
100

@Override public void onClick(View view) { presenter.setFilter(editTextSource.getText().toString(), editTextDestination.getText().toString(), getUserApplication(getContext().getPackageManager(),
spinnerApps.getText().toString()),
Constants.TransportProtocol.valueOf(spinnerProtocols.getText().toString()));
}
});
Button buttonResetFilter
=
(Button)
view.findViewById(R.id.button_reset_filter); buttonResetFilter.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) { presenter.setFilter("",
"", null, null);
}
});
}
@Override public void setPacketFilter(PacketFilter packetFilter) {
((MainActivity) getActivity()).setPacketFilter(packetFilter);
101

} private ArrayList getInstalledAppsInfo(PackageManager manager) {
ArrayList listApplications = new ArrayList<>(); for (ApplicationInfo ainfo : manager.getInstalledApplications(0)) listApplications.add(ainfo.loadLabel(manager).toString()); return listApplications;
} private ApplicationInfo getUserApplication(PackageManager manager, String name) { for (ApplicationInfo ainfo : manager.getInstalledApplications(0)) if (ainfo.loadLabel(manager).toString().equals(name)) return ainfo; return null;
}
}
IFiltersView.java public interface IFiltersView { void setPacketFilter(PacketFilter packetFilter);
}
FiltersPresenter.java public class FiltersPresenter implements IFiltersPresenter {
102
private IFiltersView iFiltersView;
@Override public void bindView(IFiltersView view) { this.iFiltersView = view;
}
@Override public void unbindView() { this.iFiltersView = null;
}
@Override public void setFilter(String sourceAddress,
String destinationAddress,
ApplicationInfo applicationInfo,
Constants.TransportProtocol protocol) { boolean isFiltering = !((sourceAddress == null || sourceAddress.isEmpty())
&& (destinationAddress == null || destinationAddress.isEmpty())
&& protocol == null
&& applicationInfo == null);
PacketFilter packetFilter = new PacketFilter.Builder()
.sourceAddress(sourceAddress)
.destinationAddress(destinationAddress)
.protocol(protocol)
103

.applicationInfo(applicationInfo)
.isFiltering(isFiltering)
.build(); iFiltersView.setPacketFilter(packetFilter);
}
}
IfiltersPresenter.java public interface IFiltersPresenter { void bindView(IFiltersView view); void unbindView(); void setFilter(String sourceAddress,
String destinationAddress,
ApplicationInfo applicationInfo,
Constants.TransportProtocol protocol);
} public class FragmentDetails extends Fragment implements IDetailsView {
@Inject
IDetailsPresenter presenter; private Packet packet; public FragmentDetails() {
104

}
@Override public void onStart() { super.onStart();
}
@Override public void onStop() { presenter.unbindView(); super.onStop();
}
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);
MainActivity.get(getActivity()).applicationComponent()
.plus(new DetailsModule()).inject(this);
Bundle bundle = getArguments(); if (bundle != null) { this.packet = (Packet) bundle.getSerializable("packet");
}
}
@Nullable
@Override
105
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_packet_details, container, false); initView(view); presenter.bindView(this); return view;
} private void initView(View view) { if (packet != null) { showAppInfo(view); showPacketView(view);
}
} private void showAppInfo(View view) {
ApplicationInfo appInfo = packet.getApplicationInfo(); if (appInfo != null) {
ImageView appIcon
=
(ImageView)
view.findViewById(R.id.detail_app_icon);
TextView appName
=
(TextView)
view.findViewById(R.id.detail_app_name);
TextView appPackage
=
(TextView)
view.findViewById(R.id.detail_app_package);
106
appIcon.setImageDrawable(appInfo.loadIcon(getContext().getPackageManager())); appName.setText(appInfo.loadLabel(getContext().getPackageManager())); appPackage.setText(appInfo.packageName); setValues((View) view.findViewById(R.id.item_app_uid),
R.string.title_uid,
String.valueOf(appInfo.uid));
} setValues((View) view.findViewById(R.id.item_from),
R.string.title_from, packet.getSourceDomainName()); setValues((View) view.findViewById(R.id.item_to),
R.string.title_to, packet.getDestinationDomainName());
} private void showPacketView(View view) {
String sourceAddress = String.valueOf(packet.saddr)
+ ":" + String.valueOf(packet.sport);
String destinationAddress = String.valueOf(packet.daddr)
107

+ ":" + String.valueOf(packet.dport); setValues((View) view.findViewById(R.id.item_source),
R.string.title_source, sourceAddress); setValues((View) view.findViewById(R.id.item_destination),
R.string.title_destination, destinationAddress); setValues((View) view.findViewById(R.id.item_protocol),
R.string.title_protocol,
Constants.TransportProtocol.numberToEnum(packet.protocol).name()); setValues((View) view.findViewById(R.id.item_version),
R.string.title_version,
Constants.Version.numberToEnum(packet.version).name()); setValues((View) view.findViewById(R.id.item_flags),
R.string.title_flags,
Constants.Flags.stringToEnum(packet.flags).name()); setValues((View) view.findViewById(R.id.item_date),
R.string.title_data,
String.valueOf(packet.getDate()));
}
108
private void setValues(View view, int title, String subtitle) {
TextView textTitle = (TextView) view.findViewById(R.id.title);
TextView textSubtitle = (TextView) view.findViewById(R.id.subtitle); textTitle.setText(title); textSubtitle.setText(subtitle);
}
}
109

Приложение Б
(обязательное)
Протокол проверки ВКР в системе «Антиплагиат»
110

111

112
1   2   3   4


написать администратору сайта