use of com.amaze.filemanager.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method onRequestPermissionsResult.
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == 77) {
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
drawer.refreshDrawer();
TabFragment tabFragment = getTabFragment();
boolean b = getBoolean(PREFERENCE_NEED_TO_SET_HOME);
// reset home and current paths according to new storages
if (b) {
tabHandler.clear();
if (drawer.getStorageCount() > 1) {
tabHandler.addTab(new Tab(1, drawer.getSecondPath(), "/"));
} else {
tabHandler.addTab(new Tab(1, "/", "/"));
}
if (drawer.getFirstPath() != null) {
String pa = drawer.getFirstPath();
tabHandler.addTab(new Tab(2, pa, pa));
} else {
tabHandler.addTab(new Tab(2, drawer.getSecondPath(), "/"));
}
if (tabFragment != null) {
Fragment main = tabFragment.getFragmentAtIndex(0);
if (main != null)
((MainFragment) main).updateTabWithDb(tabHandler.findTab(1));
Fragment main1 = tabFragment.getFragmentAtIndex(1);
if (main1 != null)
((MainFragment) main1).updateTabWithDb(tabHandler.findTab(2));
}
getPrefs().edit().putBoolean(PREFERENCE_NEED_TO_SET_HOME, false).commit();
} else {
// just refresh list
if (tabFragment != null) {
Fragment main = tabFragment.getFragmentAtIndex(0);
if (main != null)
((MainFragment) main).updateList();
Fragment main1 = tabFragment.getFragmentAtIndex(1);
if (main1 != null)
((MainFragment) main1).updateList();
}
}
} else {
Toast.makeText(this, R.string.grantfailed, Toast.LENGTH_SHORT).show();
requestStoragePermission();
}
}
}
use of com.amaze.filemanager.fragments.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivity method goToMain.
public void goToMain(String path) {
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// title.setText(R.string.app_name);
TabFragment tabFragment = new TabFragment();
if (path != null && path.length() > 0) {
Bundle b = new Bundle();
b.putString("path", path);
tabFragment.setArguments(b);
}
transaction.replace(R.id.content_frame, tabFragment);
// Commit the transaction
drawer.setSomethingSelected(true);
transaction.addToBackStack("tabt" + 1);
transaction.commitAllowingStateLoss();
appbar.setTitle(null);
floatingActionButton.setVisibility(View.VISIBLE);
floatingActionButton.getMenuButton().show();
if (openzip && zippath != null) {
if (zippath.endsWith(".zip") || zippath.endsWith(".apk"))
openZip(zippath);
else {
openRar(zippath);
}
zippath = null;
}
}
use of com.amaze.filemanager.fragments.TabFragment 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.TabFragment in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method search.
/**
* Creates a fragment which will handle the search AsyncTask {@link SearchWorkerFragment}
*
* @param query the text query entered the by user
*/
public void search(SharedPreferences sharedPrefs, String query) {
TabFragment tabFragment = mainActivity.getTabFragment();
if (tabFragment == null)
return;
final MainFragment ma = (MainFragment) tabFragment.getCurrentTabFragment();
final String fpath = ma.getCurrentPath();
/*SearchTask task = new SearchTask(ma.searchHelper, ma, query);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fpath);*/
// ma.searchTask = task;
SEARCH_TEXT = query;
mainActivity.mainFragment = (MainFragment) mainActivity.getTabFragment().getCurrentTabFragment();
FragmentManager fm = mainActivity.getSupportFragmentManager();
SearchWorkerFragment fragment = (SearchWorkerFragment) fm.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);
if (fragment != null) {
if (fragment.mSearchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
fragment.mSearchAsyncTask.cancel(true);
}
fm.beginTransaction().remove(fragment).commit();
}
addSearchFragment(fm, new SearchWorkerFragment(), fpath, query, ma.openMode, mainActivity.isRootExplorer(), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX, false), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX_MATCHES, false));
}
Aggregations