Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0eb9559 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Issue 6624: CM File manager: Mount RW does not work if i slide the...

Merge "Issue 6624: CM File manager: Mount RW does not work if i slide the slider from ro to rw." into jellybean
parents 57633421 b3d9e642
Loading
Loading
Loading
Loading
+43 −30
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;
import android.widget.TextView;

@@ -46,7 +48,7 @@ import com.cyanogenmod.filemanager.util.MountPointHelper;
 * A class that wraps a dialog for showing information about a mount point.<br />
 * This class display information like mount point name, device name, size, type, ...
 */
public class FilesystemInfoDialog implements OnClickListener {
public class FilesystemInfoDialog implements OnClickListener, OnCheckedChangeListener {

    /**
     * An interface to communicate when the user change the mount state
@@ -178,7 +180,7 @@ public class FilesystemInfoDialog implements OnClickListener {

        //Gets text views
        this.mSwStatus = (Switch)contentView.findViewById(R.id.filesystem_info_status);
        this.mSwStatus.setOnClickListener(this);
        this.mSwStatus.setOnCheckedChangeListener(this);
        TextView tvMountPoint =
                (TextView)contentView.findViewById(R.id.filesystem_info_mount_point);
        TextView tvDevice = (TextView)contentView.findViewById(R.id.filesystem_info_device);
@@ -290,14 +292,50 @@ public class FilesystemInfoDialog implements OnClickListener {
                });
                break;

            case R.id.filesystem_info_msg:
                //Change the console
                boolean superuser = ConsoleBuilder.changeToPrivilegedConsole(this.mContext);
                if (superuser) {
                    this.mInfoMsgView.setOnClickListener(null);

                    // Is filesystem able to be mounted?
                    boolean mountAllowed = MountPointHelper.isMountAllowed(this.mMountPoint);
                    if (mountAllowed) {
                        this.mInfoMsgView.setVisibility(View.GONE);
                        this.mInfoMsgView.setBackground(null);
                        this.mSwStatus.setEnabled(true);
                        this.mIsMountAllowed = true;
                        break;
                    }

                    // Show the message
                    this.mInfoMsgView.setText(
                            this.mContext.getString(
                                    R.string.filesystem_info_cant_be_mounted_msg));
                    this.mInfoMsgView.setVisibility(View.VISIBLE);
                    this.mIsMountAllowed = false;
                }
                break;

            default:
                break;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch (buttonView.getId()) {
            case R.id.filesystem_info_status:
                //Mount the filesystem
                Switch sw = (Switch)v;
                Switch sw = (Switch)buttonView;
                boolean ret = false;
                try {
                    ret = CommandHelper.remount(
                            this.mContext,
                            this.mMountPoint, sw.isChecked(), null);
                            this.mMountPoint, isChecked, null);
                    //Hide warning message
                    this.mInfoMsgView.setVisibility(View.GONE);
                    //Communicate the mount change
@@ -315,32 +353,7 @@ public class FilesystemInfoDialog implements OnClickListener {
                    //Show warning message
                    this.mInfoMsgView.setText(R.string.filesystem_info_mount_failed_msg);
                    this.mInfoMsgView.setVisibility(View.VISIBLE);
                    sw.setChecked(!sw.isChecked());
                }
                break;

            case R.id.filesystem_info_msg:
                //Change the console
                boolean superuser = ConsoleBuilder.changeToPrivilegedConsole(this.mContext);
                if (superuser) {
                    this.mInfoMsgView.setOnClickListener(null);

                    // Is filesystem able to be mounted?
                    boolean mountAllowed = MountPointHelper.isMountAllowed(this.mMountPoint);
                    if (mountAllowed) {
                        this.mInfoMsgView.setVisibility(View.GONE);
                        this.mInfoMsgView.setBackground(null);
                        this.mSwStatus.setEnabled(true);
                        this.mIsMountAllowed = true;
                        break;
                    }

                    // Show the message
                    this.mInfoMsgView.setText(
                            this.mContext.getString(
                                    R.string.filesystem_info_cant_be_mounted_msg));
                    this.mInfoMsgView.setVisibility(View.VISIBLE);
                    this.mIsMountAllowed = false;
                    sw.setChecked(!isChecked);
                }
                break;