use of com.amaze.filemanager.database.TabHandler in project AmazeFileManager by TeamAmaze.
the class TabFragment method updatepaths.
public void updatepaths(int pos) {
if (tabHandler == null)
tabHandler = new TabHandler(getActivity());
int i = 1;
// Getting old path from database before clearing
tabHandler.clear();
for (Fragment fragment : fragments) {
if (fragment instanceof MainFragment) {
MainFragment m = (MainFragment) fragment;
if (i - 1 == MainActivity.currentTab && i == pos) {
mainActivity.getAppbar().getBottomBar().updatePath(m.getCurrentPath(), m.results, MainActivityHelper.SEARCH_TEXT, m.openMode, m.folder_count, m.file_count, m);
mainActivity.getDrawer().selectCorrectDrawerItemForPath(m.getCurrentPath());
}
if (m.openMode == OpenMode.FILE) {
tabHandler.addTab(new Tab(i, m.getCurrentPath(), m.home));
} else {
tabHandler.addTab(new Tab(i, m.home, m.home));
}
i++;
}
}
}
use of com.amaze.filemanager.database.TabHandler 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;
}
});
}
use of com.amaze.filemanager.database.TabHandler in project AmazeFileManager by TeamAmaze.
the class TabFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.tabfragment, container, false);
tabHandler = new TabHandler(getContext());
fragmentManager = getActivity().getSupportFragmentManager();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
indicator = getActivity().findViewById(R.id.indicator);
} else {
circleDrawable1 = getActivity().findViewById(R.id.tab_indicator1);
circleDrawable2 = getActivity().findViewById(R.id.tab_indicator2);
}
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
savepaths = sharedPrefs.getBoolean("savepaths", true);
mViewPager = rootView.findViewById(R.id.pager);
if (getArguments() != null) {
path = getArguments().getString("path");
}
mainActivity = ((MainActivity) getActivity());
mainActivity.supportInvalidateOptionsMenu();
mViewPager.addOnPageChangeListener(this);
mSectionsPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());
if (savedInstanceState == null) {
int l = sharedPrefs.getInt(PreferenceUtils.KEY_CURRENT_TAB, PreferenceUtils.DEFAULT_CURRENT_TAB);
MainActivity.currentTab = l;
List<Tab> tabs1 = tabHandler.getAllTabs();
int i = tabs1.size();
if (i == 0) {
// creating tabs in db for the first time, probably the first launch of app
if (mainActivity.getDrawer().getFirstPath() != null) {
addNewTab(1, mainActivity.getDrawer().getFirstPath());
} else {
if (mainActivity.getDrawer().getSecondPath() != null) {
addNewTab(1, mainActivity.getDrawer().getSecondPath());
} else {
sharedPrefs.edit().putBoolean(PreferencesConstants.PREFERENCE_ROOTMODE, true).apply();
addNewTab(1, "/");
}
}
if (mainActivity.getDrawer().getSecondPath() != null) {
addNewTab(2, mainActivity.getDrawer().getSecondPath());
} else {
addNewTab(2, mainActivity.getDrawer().getFirstPath());
}
} else {
if (path != null && path.length() != 0) {
if (l == 1) {
addTab(tabHandler.findTab(1), "");
}
addTab(tabHandler.findTab(l + 1), path);
if (l == 0) {
addTab(tabHandler.findTab(2), "");
}
} else {
addTab(tabHandler.findTab(1), "");
addTab(tabHandler.findTab(2), "");
}
}
mViewPager.setAdapter(mSectionsPagerAdapter);
try {
mViewPager.setCurrentItem(l, true);
if (circleDrawable1 != null && circleDrawable2 != null) {
updateIndicator(mViewPager.getCurrentItem());
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
fragments.clear();
try {
if (fragmentManager == null) {
fragmentManager = getActivity().getSupportFragmentManager();
}
fragments.add(0, fragmentManager.getFragment(savedInstanceState, "tab" + 0));
fragments.add(1, fragmentManager.getFragment(savedInstanceState, "tab" + 1));
} catch (Exception e) {
e.printStackTrace();
}
mSectionsPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());
mViewPager.setAdapter(mSectionsPagerAdapter);
int pos1 = savedInstanceState.getInt(KEY_POSITION, 0);
MainActivity.currentTab = pos1;
mViewPager.setCurrentItem(pos1);
mSectionsPagerAdapter.notifyDataSetChanged();
}
if (indicator != null)
indicator.setViewPager(mViewPager);
// color of viewpager when current tab is 0
startColor = mainActivity.getColorPreference().getColor(ColorUsage.PRIMARY);
// color of viewpager when current tab is 1
endColor = mainActivity.getColorPreference().getColor(ColorUsage.PRIMARY_TWO);
// update the views as there is any change in {@link MainActivity#currentTab}
// probably due to config change
/*colorDrawable.setColor(Color.parseColor(MainActivity.currentTab==1 ?
ThemedActivity.skinTwo : ThemedActivity.skin));
mainActivity.updateViews(colorDrawable);*/
mainActivity.mainFragment = (MainFragment) getCurrentTabFragment();
return rootView;
}
Aggregations