package com.basic.security.fragment;
|
|
import android.content.Intent;
|
import android.view.View;
|
|
import com.alfeye.a1io.DeviceControl;
|
import com.basic.security.R;
|
import com.basic.security.base.BaseApplication;
|
import com.basic.security.base.BaseFragment;
|
import com.basic.security.manager.impl.cblite.AccountManager;
|
import com.basic.security.utils.Constants;
|
|
import org.androidannotations.annotations.AfterViews;
|
import org.androidannotations.annotations.Click;
|
import org.androidannotations.annotations.EFragment;
|
import org.androidannotations.annotations.ViewById;
|
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Set;
|
|
import de.hdodenhof.circleimageview.CircleImageView;
|
|
|
@EFragment(R.layout.fragment_toolbar)
|
public class ToolbarFragment extends BaseFragment {
|
|
@ViewById
|
public CircleImageView admin_photo;
|
|
@ViewById
|
public View home,
|
login,
|
logout,
|
admin_msg,
|
call,
|
menu;
|
|
List<View> toolbarButtons = new ArrayList<>();
|
|
public static void openWebRtc() {
|
Intent launchIntent = BaseApplication.getApplication().activity.getPackageManager().getLaunchIntentForPackage("org.appspot.apprtc");
|
if (launchIntent != null) {
|
launchIntent.putExtra("ip", "0.0.0.0");
|
launchIntent.putExtra("cameraIndex", "1");
|
launchIntent.putExtra("isServer", "true");
|
launchIntent.putExtra("orientation", "portrait");
|
launchIntent.putExtra("localCameraRotation", "270");
|
launchIntent.putExtra("remoteCameraRotation", "0");
|
BaseApplication.getApplication().activity.startActivity(launchIntent);
|
}
|
}
|
|
@AfterViews
|
public void afterViews() {
|
toolbarButtons.addAll(Arrays.asList(home,
|
login,
|
logout,
|
admin_msg,
|
call,
|
menu));
|
}
|
|
@Click
|
public void ll_login() {
|
login();
|
}
|
|
@Click
|
public void home() {
|
mainActivity().showFragment(mainActivity().fragment_home);
|
}
|
|
@Click
|
public void login() {
|
mainActivity().showFragment(mainActivity().fragment_admin_face_login);
|
}
|
|
@Click
|
public void logout() {
|
AccountManager.setAdminAccount(null);
|
showFragment(mainActivity().fragment_home);
|
}
|
|
@Click
|
public void menu() {
|
mainActivity().showOneFragment(mainActivity().fragment_menu);
|
}
|
|
public void showButtons(Set<View> visibleToolbarButtons) {
|
for (View toolbarButton : toolbarButtons) {
|
if (visibleToolbarButtons != null && visibleToolbarButtons.contains(toolbarButton)) {
|
toolbarButton.setVisibility(View.VISIBLE);
|
} else {
|
toolbarButton.setVisibility(View.GONE);
|
}
|
}
|
}
|
|
@Click
|
public void update_apk() {
|
// UpdateApk.installApk("/sdcard/download/"+Constants.updateApkFileName);
|
DeviceControl.startInstallApk(
|
BaseApplication.getApplication(),
|
"com.basic.security",
|
"/sdcard/download/" + Constants.updateApkFileName,
|
true,
|
true
|
);
|
}
|
|
@Click
|
public void call() {
|
// if (1==1) {
|
// Intent launchIntent = new Intent(mainActivity(), ConnectActivity.class);
|
// if (launchIntent != null) {
|
// launchIntent.putExtra("ip", "0.0.0.0");
|
// launchIntent.putExtra("cameraIndex", "1");
|
// launchIntent.putExtra("isServer", "true");
|
// launchIntent.putExtra("orientation", "portrait");
|
// launchIntent.putExtra("localCameraRotation", "270");
|
// launchIntent.putExtra("remoteCameraRotation", "90");
|
// startActivity(launchIntent);
|
// }
|
// return;
|
// }
|
// throw new RuntimeException("a");
|
openWebRtc();
|
}
|
|
}
|