use of org.flyve.mdm.agent.room.entity.Application in project android-mdm-agent by flyve-mdm.
the class FragmentAppList method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_app_list, container, false);
dataBase = AppDataBase.getAppDatabase(this.getActivity());
pb = v.findViewById(R.id.progressBar);
txtNoData = v.findViewById(R.id.txtNoData);
final SwipeRefreshLayout swipeLayout = v.findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeLayout.setRefreshing(false);
loadData();
}
});
lst = v.findViewById(R.id.lst);
lst.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Application app = apps[i];
Intent intent = new Intent(FragmentAppList.this.getContext(), InstallAppActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("APP_ID", app.appId);
intent.putExtra("APP_PATH", app.appPath);
FragmentAppList.this.getContext().startActivity(intent);
}
});
loadData();
return v;
}
use of org.flyve.mdm.agent.room.entity.Application in project android-mdm-agent by flyve-mdm.
the class InstallAppActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// pending
String status = "1";
switch(requestCode) {
case APP_INSTALL_REQUEST:
if (resultCode == RESULT_OK) {
FlyveLog.d("Package Installation Success");
// installed
status = "2";
} else {
FlyveLog.d("Installation failed");
}
}
try {
PackageManager packageManager = InstallAppActivity.this.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageArchiveInfo(appPath, 0);
packageInfo.applicationInfo.sourceDir = appPath;
packageInfo.applicationInfo.publicSourceDir = appPath;
String appName = packageManager.getApplicationLabel(packageInfo.applicationInfo).toString();
String appPackage = packageInfo.packageName;
AppDataBase dataBase = AppDataBase.getAppDatabase(InstallAppActivity.this);
if (dataBase.applicationDao().getApplicationById(id).length <= 0) {
Application apps = new Application();
apps.appId = id;
apps.appName = appName;
apps.appPath = appPath;
// 1 pending | 2 installed
apps.appStatus = status;
apps.appPackage = appPackage;
dataBase.applicationDao().insert(apps);
} else {
// update status to installed
dataBase.applicationDao().updateStatus(id, "2");
}
if (status.equals("2")) {
// remove notifications if exists
NotificationManager notificationManager = (NotificationManager) InstallAppActivity.this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(Integer.parseInt(id));
} else {
Helpers.sendToNotificationBar(InstallAppActivity.this, Integer.parseInt(id), getString(R.string.app_pending_to_install), appName, true, MainActivity.class);
}
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
}
finish();
}
use of org.flyve.mdm.agent.room.entity.Application in project android-mdm-agent by flyve-mdm.
the class ApplicationsAdapter method getView.
/**
* Get a View that displays the data at the specified position
* @param position of the item within the adapter's data set of the item whose View we want
* @param convertView the old View to reuse, if possible
* @param parent the parent that this View will eventually be attached to
* @return View a View corresponding to the data at the specified position
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Application app = data[position];
View vi = inflater.inflate(R.layout.list_item_application, null);
TextView txtStatus = vi.findViewById(R.id.txtStatus);
String status = parent.getResources().getString(R.string.app_installed);
if (app.appStatus.equals("1")) {
status = parent.getResources().getString(R.string.app_pending);
}
txtStatus.setText(status);
TextView txtAppName = vi.findViewById(R.id.txtAppName);
txtAppName.setText(app.appName);
TextView txtPackageName = vi.findViewById(R.id.txtPackageName);
txtPackageName.setText(app.appPackage);
ImageView imgApp = vi.findViewById(R.id.imgApp);
imgApp.setImageDrawable(Helpers.getApplicationImage(parent.getContext(), app.appPackage));
return vi;
}
Aggregations