use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.
the class UsbOtgTest method usbConnectionTest.
@Test
public void usbConnectionTest() {
ActivityController<MainActivity> controller = Robolectric.buildActivity(MainActivity.class).create();
MainActivity activity = controller.get();
addUsbOtgDevice(activity);
activity = controller.resume().get();
boolean hasOtgStorage = false;
ArrayList<StorageDirectoryParcelable> storageDirectories = activity.getStorageDirectories();
for (StorageDirectoryParcelable storageDirectory : storageDirectories) {
if (storageDirectory.path.startsWith(OTGUtil.PREFIX_OTG)) {
hasOtgStorage = true;
break;
}
}
assertTrue("No usb storage, known storages: '" + TextUtils.join("', '", storageDirectories) + "'", hasOtgStorage);
}
use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.
the class GeneralDialogCreation method showPasswordDialog.
public static void showPasswordDialog(@NonNull Context c, @NonNull final MainActivity main, @NonNull AppTheme appTheme, @StringRes int titleText, @StringRes int promptText, @NonNull MaterialDialog.SingleButtonCallback positiveCallback, @Nullable MaterialDialog.SingleButtonCallback negativeCallback) {
int accentColor = main.getAccent();
MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
View dialogLayout = View.inflate(main, R.layout.dialog_singleedittext, null);
WarnableTextInputLayout wilTextfield = dialogLayout.findViewById(R.id.singleedittext_warnabletextinputlayout);
EditText textfield = dialogLayout.findViewById(R.id.singleedittext_input);
textfield.setHint(promptText);
textfield.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
dialogLayout.post(() -> ExtensionsKt.openKeyboard(textfield, main.getApplicationContext()));
builder.customView(dialogLayout, false).theme(appTheme.getMaterialDialogTheme()).autoDismiss(false).canceledOnTouchOutside(false).title(titleText).positiveText(R.string.ok).positiveColor(accentColor).onPositive(positiveCallback).negativeText(R.string.cancel).negativeColor(accentColor);
if (negativeCallback != null)
builder.onNegative(negativeCallback);
else
builder.onNegative((dialog, which) -> dialog.cancel());
MaterialDialog dialog = builder.show();
new WarnableTextInputValidator(AppConfig.getInstance().getMainActivityContext(), textfield, wilTextfield, dialog.getActionButton(DialogAction.POSITIVE), (text) -> {
if (text.length() < 1) {
return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.field_empty);
}
return new WarnableTextInputValidator.ReturnState();
});
}
use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.
the class CloudSheetFragment method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.linear_layout_smb:
dismiss();
SmbSearchDialog smbDialog = new SmbSearchDialog();
smbDialog.show(getActivity().getFragmentManager(), "tab");
return;
case R.id.linear_layout_scp:
dismiss();
SftpConnectDialog sftpConnectDialog = new SftpConnectDialog();
Bundle args = new Bundle();
args.putBoolean("edit", false);
sftpConnectDialog.setArguments(args);
sftpConnectDialog.show(getFragmentManager(), "tab");
return;
case R.id.linear_layout_box:
((MainActivity) getActivity()).addConnection(OpenMode.BOX);
break;
case R.id.linear_layout_dropbox:
((MainActivity) getActivity()).addConnection(OpenMode.DROPBOX);
break;
case R.id.linear_layout_google_drive:
GeneralDialogCreation.showSignInWithGoogleDialog((MainActivity) getActivity());
break;
case R.id.linear_layout_onedrive:
((MainActivity) getActivity()).addConnection(OpenMode.ONEDRIVE);
break;
case R.id.linear_layout_get_cloud:
Intent cloudPluginIntent = new Intent(Intent.ACTION_VIEW);
cloudPluginIntent.setData(Uri.parse(getString(R.string.cloud_plugin_google_play_uri)));
try {
startActivity(cloudPluginIntent);
} catch (ActivityNotFoundException ifGooglePlayIsNotInstalled) {
cloudPluginIntent.setData(Uri.parse(getString(R.string.cloud_plugin_google_play_web_uri)));
startActivity(cloudPluginIntent);
}
break;
}
// dismiss this sheet dialog
dismiss();
}
use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.
the class AppsListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final MainActivity mainActivity = (MainActivity) getActivity();
Objects.requireNonNull(mainActivity);
UtilitiesProvider utilsProvider = mainActivity.getUtilsProvider();
modelProvider = new AppsAdapterPreloadModel(this, false);
ViewPreloadSizeProvider<String> sizeProvider = new ViewPreloadSizeProvider<>();
preloader = new RecyclerViewPreloader<>(GlideApp.with(this), modelProvider, sizeProvider, GlideConstants.MAX_PRELOAD_APPSADAPTER);
linearLayoutManager = new LinearLayoutManager(getContext());
updateViews(mainActivity, utilsProvider);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
isAscending = sharedPreferences.getBoolean(PREFERENCE_APPLIST_ISASCENDING, true);
sortby = sharedPreferences.getInt(PREFERENCE_APPLIST_SORTBY, 0);
fastScroller = rootView.findViewById(R.id.fastscroll);
fastScroller.setPressedHandleColor(mainActivity.getAccent());
fastScroller.setRecyclerView(getRecyclerView(), 1);
mainActivity.getAppbar().getAppbarLayout().addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
fastScroller.updateHandlePosition(verticalOffset, 112);
});
LoaderManager.getInstance(this).initLoader(ID_LOADER_APP_LIST, null, this);
}
use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.
the class TabFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = (ViewGroup) inflater.inflate(R.layout.tabfragment, container, false);
fragmentManager = getActivity().getSupportFragmentManager();
dragPlaceholder = rootView.findViewById(R.id.drag_placeholder);
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 lastOpenTab = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_CURRENT_TAB, PreferenceUtils.DEFAULT_CURRENT_TAB);
MainActivity.currentTab = lastOpenTab;
refactorDrawerStorages(true);
mViewPager.setAdapter(mSectionsPagerAdapter);
try {
mViewPager.setCurrentItem(lastOpenTab, 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);
UserColorPreferences userColorPreferences = mainActivity.getCurrentColorPreference();
// color of viewpager when current tab is 0
startColor = userColorPreferences.getPrimaryFirstTab();
// color of viewpager when current tab is 1
endColor = userColorPreferences.getPrimarySecondTab();
return rootView;
}
Aggregations