Search in sources :

Example 11 with BaseActivity

use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.

the class RootsFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    final Context context = getActivity();
    final State state = ((BaseActivity) context).getDisplayState();
    state.showAdvanced = state.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(context);
    state.rootMode = SettingsActivity.getRootMode(getActivity());
    if (state.action == ACTION_BROWSE) {
        mList.setOnItemLongClickListener(mItemLongClickListener);
    } else {
        mList.setOnItemLongClickListener(null);
        mList.setLongClickable(false);
    }
    getLoaderManager().restartLoader(2, null, mCallbacks);
}
Also used : Context(android.content.Context) State(dev.dworks.apps.anexplorer.BaseActivity.State) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity)

Example 12 with BaseActivity

use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.

the class SaveFragment method onClick.

@Override
public void onClick(View v) {
    final BaseActivity activity = BaseActivity.get(SaveFragment.this);
    switch(v.getId()) {
        case android.R.id.button1:
            if (mReplaceTarget != null) {
                activity.onSaveRequested(mReplaceTarget);
            } else {
                final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
                final String displayName = mDisplayName.getText().toString();
                String extension = FileUtils.getExtFromFilename(displayName);
                activity.onSaveRequested(TextUtils.isEmpty(extension) ? mimeType : extension, displayName);
            }
            break;
        case android.R.id.button2:
            getActivity().getFragmentManager().beginTransaction().remove(this).commit();
            break;
    }
}
Also used : BaseActivity(dev.dworks.apps.anexplorer.BaseActivity)

Example 13 with BaseActivity

use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.

the class CreateConnectionFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = getActivity().getLayoutInflater();
    final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
    name = (AppCompatEditText) view.findViewById(R.id.name);
    host = (AppCompatEditText) view.findViewById(R.id.host);
    port = (AppCompatEditText) view.findViewById(R.id.port);
    path = (AppCompatEditText) view.findViewById(R.id.path);
    hostContainer = view.findViewById(R.id.hostContainer);
    pathContainer = view.findViewById(R.id.pathContainer);
    username = (AppCompatEditText) view.findViewById(R.id.username);
    usernameContainer = view.findViewById(R.id.usernameContainer);
    password = (AppCompatEditText) view.findViewById(R.id.password);
    passwordContainer = view.findViewById(R.id.passwordContainer);
    scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
    anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
    anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
            passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
        }
    });
    if (connection_id != 0) {
        NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id);
        ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
        int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
        scheme.setSelection(spinnerPosition);
        name.setText(connection.getName());
        host.setText(connection.getHost());
        port.setText(Integer.toString(connection.getPort()));
        path.setText(connection.getPath());
        username.setText(connection.getUserName());
        password.setText(connection.getPassword());
        anonymous.setChecked(connection.isAnonymousLogin());
        if (SERVER.equals(connection.getType())) {
            hostContainer.setVisibility(View.GONE);
            pathContainer.setVisibility(View.VISIBLE);
        }
    }
    builder.setTitle((connection_id == 0 ? "New" : "Edit") + " Connection");
    builder.setView(view);
    builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            final BaseActivity activity = (BaseActivity) getActivity();
            NetworkConnection networkConnection = getNetworkConnection();
            if (validate(networkConnection)) {
                new CreateConnectionTask(activity, networkConnection).executeOnExecutor(ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    return builder.create();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) NetworkConnection(dev.dworks.apps.anexplorer.network.NetworkConnection) View(android.view.View) LayoutInflater(android.view.LayoutInflater) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) OnClickListener(android.content.DialogInterface.OnClickListener) CompoundButton(android.widget.CompoundButton) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

BaseActivity (dev.dworks.apps.anexplorer.BaseActivity)13 Bundle (android.os.Bundle)6 Context (android.content.Context)5 State (dev.dworks.apps.anexplorer.BaseActivity.State)4 DialogInterface (android.content.DialogInterface)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 Intent (android.content.Intent)2 Loader (android.content.Loader)2 AlertDialog (android.support.v7.app.AlertDialog)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 RootsCache (dev.dworks.apps.anexplorer.misc.RootsCache)2 DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)2 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)2 RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)2 NetworkConnection (dev.dworks.apps.anexplorer.network.NetworkConnection)2 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 Point (android.graphics.Point)1 Uri (android.net.Uri)1