use of com.amaze.filemanager.fragments.ProcessViewerFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method onNewIntent.
@Override
public void onNewIntent(Intent i) {
intent = i;
path = i.getStringExtra("path");
if (path != null) {
if (new File(path).isDirectory()) {
MainFragment ma = getCurrentMainFragment();
if (ma != null) {
ma.loadlist(path, false, OpenMode.FILE);
} else
goToMain(path);
} else
FileUtils.openFile(new File(path), mainActivity, getPrefs());
} else if (i.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) {
ArrayList<HybridFileParcelable> failedOps = i.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS);
if (failedOps != null) {
mainActivityHelper.showFailedOperationDialog(failedOps, this);
}
} else if (i.getCategories() != null && i.getCategories().contains(CLOUD_AUTHENTICATOR_GDRIVE)) {
// we used an external authenticator instead of APIs. Probably for Google Drive
CloudRail.setAuthenticationResponse(intent);
} else if ((openProcesses = i.getBooleanExtra(KEY_INTENT_PROCESS_VIEWER, false))) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.content_frame, new ProcessViewerFragment(), KEY_INTENT_PROCESS_VIEWER);
// transaction.addToBackStack(null);
drawer.setSomethingSelected(true);
openProcesses = false;
// title.setText(utils.getString(con, R.string.process_viewer));
// Commit the transaction
transaction.commitAllowingStateLoss();
supportInvalidateOptionsMenu();
} else if (intent.getAction() != null) {
checkForExternalIntent(intent);
if (SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
if (getPrefs().getString(KEY_PREF_OTG, null) == null) {
getPrefs().edit().putString(KEY_PREF_OTG, VALUE_PREF_OTG_NULL).apply();
drawer.refreshDrawer();
}
} else if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) {
getPrefs().edit().putString(KEY_PREF_OTG, null).apply();
drawer.refreshDrawer();
}
}
}
}
use of com.amaze.filemanager.fragments.ProcessViewerFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method onPrepareOptionsMenu.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem s = menu.findItem(R.id.view);
MenuItem search = menu.findItem(R.id.search);
MenuItem paste = menu.findItem(R.id.paste);
Fragment fragment = getFragmentAtFrame();
if (fragment instanceof TabFragment) {
appbar.setTitle(R.string.appbar_name);
if (getBoolean(PREFERENCE_VIEW)) {
s.setTitle(getResources().getString(R.string.gridview));
} else {
s.setTitle(getResources().getString(R.string.listview));
}
try {
MainFragment ma = getCurrentMainFragment();
if (ma.IS_LIST)
s.setTitle(R.string.gridview);
else
s.setTitle(R.string.listview);
appbar.getBottomBar().updatePath(ma.getCurrentPath(), ma.results, MainActivityHelper.SEARCH_TEXT, ma.openMode, ma.folder_count, ma.file_count, ma);
} catch (Exception e) {
}
appbar.getBottomBar().setClickListener();
invalidatePasteButton(paste);
search.setVisible(true);
if (indicator_layout != null)
indicator_layout.setVisibility(View.VISIBLE);
menu.findItem(R.id.search).setVisible(true);
menu.findItem(R.id.home).setVisible(true);
menu.findItem(R.id.history).setVisible(true);
menu.findItem(R.id.sethome).setVisible(true);
menu.findItem(R.id.sort).setVisible(true);
if (getBoolean(PREFERENCE_SHOW_HIDDENFILES))
menu.findItem(R.id.hiddenitems).setVisible(true);
menu.findItem(R.id.view).setVisible(true);
menu.findItem(R.id.extract).setVisible(false);
invalidatePasteButton(menu.findItem(R.id.paste));
findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE);
} else if (fragment instanceof AppsListFragment || fragment instanceof ProcessViewerFragment || fragment instanceof FTPServerFragment) {
appBarLayout.setExpanded(true);
menu.findItem(R.id.sethome).setVisible(false);
if (indicator_layout != null)
indicator_layout.setVisibility(View.GONE);
findViewById(R.id.buttonbarframe).setVisibility(View.GONE);
menu.findItem(R.id.search).setVisible(false);
menu.findItem(R.id.home).setVisible(false);
menu.findItem(R.id.history).setVisible(false);
menu.findItem(R.id.extract).setVisible(false);
if (fragment instanceof ProcessViewerFragment) {
menu.findItem(R.id.sort).setVisible(false);
} else {
menu.findItem(R.id.dsort).setVisible(false);
menu.findItem(R.id.sortby).setVisible(false);
}
menu.findItem(R.id.hiddenitems).setVisible(false);
menu.findItem(R.id.view).setVisible(false);
menu.findItem(R.id.paste).setVisible(false);
} else if (fragment instanceof CompressedExplorerFragment) {
appbar.setTitle(R.string.appbar_name);
menu.findItem(R.id.sethome).setVisible(false);
if (indicator_layout != null)
indicator_layout.setVisibility(View.GONE);
getAppbar().getBottomBar().resetClickListener();
menu.findItem(R.id.search).setVisible(false);
menu.findItem(R.id.home).setVisible(false);
menu.findItem(R.id.history).setVisible(false);
menu.findItem(R.id.sort).setVisible(false);
menu.findItem(R.id.hiddenitems).setVisible(false);
menu.findItem(R.id.view).setVisible(false);
menu.findItem(R.id.paste).setVisible(false);
menu.findItem(R.id.extract).setVisible(true);
}
return super.onPrepareOptionsMenu(menu);
}
use of com.amaze.filemanager.fragments.ProcessViewerFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initialisePreferences();
initializeInteractiveShell();
dataUtils.registerOnDataChangedListener(this);
CustomSshJConfig.init();
AppConfig.setActivityContext(con);
setContentView(R.layout.main_toolbar);
appbar = new AppBar(this, getPrefs(), queue -> {
if (!queue.isEmpty()) {
mainActivityHelper.search(getPrefs(), queue);
}
});
initialiseViews();
tabHandler = new TabHandler(this);
utilsHandler = AppConfig.getInstance().getUtilsHandler();
cloudHandler = new CloudHandler(this);
mainActivityHelper = new MainActivityHelper(this);
// TODO: 7/12/2017 not init when actionIntent != null
initialiseFab();
if (CloudSheetFragment.isCloudProviderAvailable(this)) {
getSupportLoaderManager().initLoader(REQUEST_CODE_CLOUD_LIST_KEYS, null, this);
}
path = getIntent().getStringExtra("path");
openProcesses = getIntent().getBooleanExtra(KEY_INTENT_PROCESS_VIEWER, false);
intent = getIntent();
if (intent.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) {
ArrayList<HybridFileParcelable> failedOps = intent.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS);
if (failedOps != null) {
mainActivityHelper.showFailedOperationDialog(failedOps, this);
}
}
checkForExternalIntent(intent);
if (savedInstanceState != null) {
drawer.setSomethingSelected(savedInstanceState.getBoolean(KEY_DRAWER_SELECTED));
}
// setting window background color instead of each item, in order to reduce pixel overdraw
if (getAppTheme().equals(AppTheme.LIGHT)) {
/*if(Main.IS_LIST)
getWindow().setBackgroundDrawableResource(android.R.color.white);
else
getWindow().setBackgroundDrawableResource(R.color.grid_background_light);
*/
getWindow().setBackgroundDrawableResource(android.R.color.white);
} else if (getAppTheme().equals(AppTheme.BLACK)) {
getWindow().setBackgroundDrawableResource(android.R.color.black);
} else {
getWindow().setBackgroundDrawableResource(R.color.holo_dark_background);
}
/*findViewById(R.id.drawer_buttton).setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View view) {
if (mDrawerLayout.isOpen(mDrawerLinear)) {
mDrawerLayout.close(mDrawerLinear);
} else mDrawerLayout.openDrawer(mDrawerLinear);
}
});*/
drawer.setDrawerIndicatorEnabled();
// recents header color implementation
if (SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(), getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
setTaskDescription(taskDescription);
}
if (!getBoolean(PREFERENCE_BOOKMARKS_ADDED)) {
utilsHandler.addCommonBookmarks();
getPrefs().edit().putBoolean(PREFERENCE_BOOKMARKS_ADDED, true).commit();
}
AppConfig.runInBackground(new AppConfig.CustomAsyncCallbacks() {
@Override
public <E> E doInBackground() {
dataUtils.setHiddenFiles(utilsHandler.getHiddenFilesConcurrentRadixTree());
dataUtils.setHistory(utilsHandler.getHistoryLinkedList());
dataUtils.setGridfiles(utilsHandler.getGridViewList());
dataUtils.setListfiles(utilsHandler.getListViewList());
dataUtils.setBooks(utilsHandler.getBookmarksList());
ArrayList<String[]> servers = new ArrayList<String[]>();
servers.addAll(utilsHandler.getSmbList());
servers.addAll(utilsHandler.getSftpList());
dataUtils.setServers(servers);
return null;
}
@Override
public Void onPostExecute(Object result) {
drawer.refreshDrawer();
if (savedInstanceState == null) {
if (openProcesses) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.content_frame, new ProcessViewerFragment(), KEY_INTENT_PROCESS_VIEWER);
// transaction.addToBackStack(null);
drawer.setSomethingSelected(true);
openProcesses = false;
// title.setText(utils.getString(con, R.string.process_viewer));
// Commit the transaction
transaction.commit();
supportInvalidateOptionsMenu();
} else if (intent.getAction() != null && intent.getAction().equals(TileService.ACTION_QS_TILE_PREFERENCES)) {
// tile preferences, open ftp fragment
FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
transaction2.replace(R.id.content_frame, new FTPServerFragment());
appBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
drawer.setSomethingSelected(true);
drawer.deselectEverything();
transaction2.commit();
} else {
if (path != null && path.length() > 0) {
HybridFile file = new HybridFile(OpenMode.UNKNOWN, path);
file.generateMode(MainActivity.this);
if (file.isDirectory(MainActivity.this))
goToMain(path);
else {
goToMain(null);
FileUtils.openFile(new File(path), MainActivity.this, getPrefs());
}
} else {
goToMain(null);
}
}
} else {
pasteHelper = savedInstanceState.getParcelable(PASTEHELPER_BUNDLE);
oppathe = savedInstanceState.getString(KEY_OPERATION_PATH);
oppathe1 = savedInstanceState.getString(KEY_OPERATED_ON_PATH);
oparrayList = savedInstanceState.getParcelableArrayList(KEY_OPERATIONS_PATH_LIST);
operation = savedInstanceState.getInt(KEY_OPERATION);
// mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
}
return null;
}
@Override
public Void onPreExecute() {
return null;
}
@Override
public Void publishResult(Object... result) {
return null;
}
@Override
public <T> T[] params() {
return null;
}
});
}
Aggregations