Search in sources :

Example 1 with MainActivity

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);
}
Also used : MainActivity(com.amaze.filemanager.ui.activities.MainActivity) StorageDirectoryParcelable(com.amaze.filemanager.adapters.data.StorageDirectoryParcelable) Test(org.junit.Test)

Example 2 with MainActivity

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();
    });
}
Also used : WarnableTextInputLayout(com.amaze.filemanager.ui.views.WarnableTextInputLayout) TextInputEditText(com.google.android.material.textfield.TextInputEditText) EditText(android.widget.EditText) RequiresApi(androidx.annotation.RequiresApi) LinearLayout(android.widget.LinearLayout) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) FileProperties(com.amaze.filemanager.filesystem.FileProperties) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) SortHandler(com.amaze.filemanager.database.SortHandler) MDButton(com.afollestad.materialdialogs.internal.MDButton) CompressedHelper(com.amaze.filemanager.filesystem.compressed.CompressedHelper) GeneralSecurityException(java.security.GeneralSecurityException) RootHelper(com.amaze.filemanager.filesystem.RootHelper) CheckBox(android.widget.CheckBox) View(android.view.View) Button(android.widget.Button) DialogSigninWithGoogleBinding(com.amaze.filemanager.databinding.DialogSigninWithGoogleBinding) PieChart(com.github.mikephil.charting.charts.PieChart) Log(android.util.Log) PieData(com.github.mikephil.charting.data.PieData) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) M(android.os.Build.VERSION_CODES.M) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) AsyncTask(android.os.AsyncTask) Entry(com.github.mikephil.charting.data.Entry) Set(java.util.Set) InputType(android.text.InputType) ExtensionsKt(com.amaze.filemanager.ui.ExtensionsKt) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) AppCompatButton(androidx.appcompat.widget.AppCompatButton) Executors(java.util.concurrent.Executors) EncryptDecryptUtils(com.amaze.filemanager.filesystem.files.EncryptDecryptUtils) Objects(java.util.Objects) FileUtils.toHybridFileArrayList(com.amaze.filemanager.filesystem.files.FileUtils.toHybridFileArrayList) List(java.util.List) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) HiddenAdapter(com.amaze.filemanager.adapters.HiddenAdapter) PREFERENCE_SORTBY_ONLY_THIS(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_SORTBY_ONLY_THIS) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) AppConfig(com.amaze.filemanager.application.AppConfig) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Legend(com.github.mikephil.charting.components.Legend) TextWatcher(android.text.TextWatcher) Typeface(android.graphics.Typeface) Context(android.content.Context) TextInputEditText(com.google.android.material.textfield.TextInputEditText) IValueFormatter(com.github.mikephil.charting.formatter.IValueFormatter) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) Intent(android.content.Intent) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) Sort(com.amaze.filemanager.database.models.explorer.Sort) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WarnableTextInputLayout(com.amaze.filemanager.ui.views.WarnableTextInputLayout) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) PieDataSet(com.github.mikephil.charting.data.PieDataSet) ShellNotRunningException(com.amaze.filemanager.file_operations.exceptions.ShellNotRunningException) PreferencesConstants(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants) DataUtils(com.amaze.filemanager.utils.DataUtils) Toast(android.widget.Toast) Build(android.os.Build) ExecutorService(java.util.concurrent.ExecutorService) Formatter(android.text.format.Formatter) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) DialogAction(com.afollestad.materialdialogs.DialogAction) TextUtils(android.text.TextUtils) ChangeFilePermissionsCommand(com.amaze.filemanager.filesystem.root.ChangeFilePermissionsCommand) WarnableTextInputValidator(com.amaze.filemanager.ui.views.WarnableTextInputValidator) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) SharedPreferences(android.content.SharedPreferences) CryptUtil(com.amaze.filemanager.filesystem.files.CryptUtil) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler) EncryptService(com.amaze.filemanager.asynchronous.services.EncryptService) ThemedActivity(com.amaze.filemanager.ui.activities.superclasses.ThemedActivity) PreferenceManager(androidx.preference.PreferenceManager) PieEntry(com.github.mikephil.charting.data.PieEntry) Collections(java.util.Collections) EditText(android.widget.EditText) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) WarnableTextInputValidator(com.amaze.filemanager.ui.views.WarnableTextInputValidator) View(android.view.View) TextView(android.widget.TextView)

Example 3 with MainActivity

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();
}
Also used : SftpConnectDialog(com.amaze.filemanager.ui.dialogs.SftpConnectDialog) ActivityNotFoundException(android.content.ActivityNotFoundException) Bundle(android.os.Bundle) Intent(android.content.Intent) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) SmbSearchDialog(com.amaze.filemanager.ui.dialogs.SmbSearchDialog)

Example 4 with MainActivity

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);
}
Also used : UtilitiesProvider(com.amaze.filemanager.ui.provider.UtilitiesProvider) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AppsAdapterPreloadModel(com.amaze.filemanager.adapters.glide.AppsAdapterPreloadModel) ViewPreloadSizeProvider(com.bumptech.glide.util.ViewPreloadSizeProvider)

Example 5 with MainActivity

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;
}
Also used : UserColorPreferences(com.amaze.filemanager.ui.colors.UserColorPreferences) MainActivity(com.amaze.filemanager.ui.activities.MainActivity)

Aggregations

MainActivity (com.amaze.filemanager.ui.activities.MainActivity)20 HybridFile (com.amaze.filemanager.filesystem.HybridFile)9 ArrayList (java.util.ArrayList)9 View (android.view.View)8 NonNull (androidx.annotation.NonNull)8 R (com.amaze.filemanager.R)8 Intent (android.content.Intent)7 SharedPreferences (android.content.SharedPreferences)7 Log (android.util.Log)7 TextView (android.widget.TextView)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)7 OpenMode (com.amaze.filemanager.file_operations.filesystem.OpenMode)7 FileUtils (com.amaze.filemanager.filesystem.files.FileUtils)7 MainFragment (com.amaze.filemanager.ui.fragments.MainFragment)7 Utils (com.amaze.filemanager.utils.Utils)7 File (java.io.File)7 Objects (java.util.Objects)7 Context (android.content.Context)6 Color (android.graphics.Color)6 Uri (android.net.Uri)6