Search in sources :

Example 11 with NetworkConnection

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

the class ServerFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setRetainInstance(true);
    root = getArguments().getParcelable(EXTRA_ROOT);
    NetworkConnection connection = NetworkConnection.fromRootInfo(getActivity(), root);
    path.setText(connection.getPath());
    username.setText(connection.getUserName());
    password.setText(connection.getPassword());
}
Also used : NetworkConnection(dev.dworks.apps.anexplorer.network.NetworkConnection)

Example 12 with NetworkConnection

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

the class ConnectionsAdapter method getDocumentView.

private View getDocumentView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();
    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_connection_list, parent, false);
    }
    final Cursor cursor = getItem(position);
    NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final View iconMimeBackground = convertView.findViewById(R.id.icon_mime_background);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final ImageView icon1 = (ImageView) convertView.findViewById(android.R.id.icon1);
    final TextView summary = (TextView) convertView.findViewById(android.R.id.summary);
    final View popupButton = convertView.findViewById(R.id.button_popup);
    popupButton.setVisibility(isTelevision() ? View.INVISIBLE : View.VISIBLE);
    popupButton.setOnClickListener(mListener);
    title.setText(networkConnection.getName());
    summary.setText(networkConnection.getSummary());
    iconMimeBackground.setVisibility(View.VISIBLE);
    iconMimeBackground.setBackgroundColor(IconColorUtils.loadSchmeColor(context, networkConnection.getType()));
    iconMime.setImageDrawable(IconUtils.loadSchemeIcon(context, networkConnection.type));
    // ContextCompat.getDrawable(context, R.drawable.ic_connection_network));
    return convertView;
}
Also used : Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) NetworkConnection(dev.dworks.apps.anexplorer.network.NetworkConnection) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Cursor(android.database.Cursor) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 13 with NetworkConnection

use of dev.dworks.apps.anexplorer.network.NetworkConnection 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

NetworkConnection (dev.dworks.apps.anexplorer.network.NetworkConnection)13 NetworkFile (dev.dworks.apps.anexplorer.network.NetworkFile)5 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 Context (android.content.Context)3 Cursor (android.database.Cursor)3 MatrixCursor (dev.dworks.apps.anexplorer.cursor.MatrixCursor)3 Uri (android.net.Uri)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 BaseActivity (dev.dworks.apps.anexplorer.BaseActivity)2 TargetApi (android.annotation.TargetApi)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 SQLiteFullException (android.database.sqlite.SQLiteFullException)1 ArrayMap (android.support.v4.util.ArrayMap)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 AlertDialog (android.support.v7.app.AlertDialog)1