Skip to content

Commit

Permalink
Merge "Issue 6624: CM File manager: Mount RW does not work if i slide…
Browse files Browse the repository at this point in the history
… the slider from ro to rw." into jellybean
  • Loading branch information
DvTonder authored and Gerrit Code Review committed Nov 16, 2012
2 parents 5763342 + b3d9e64 commit a0eb955
Showing 1 changed file with 43 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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;

Expand All @@ -46,7 +48,7 @@
* 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
Expand Down Expand Up @@ -178,7 +180,7 @@ private void fillData(View contentView) {

//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);
Expand Down Expand Up @@ -290,14 +292,50 @@ public void run() {
});
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
Expand All @@ -315,32 +353,7 @@ public void run() {
//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;

Expand Down

0 comments on commit a0eb955

Please sign in to comment.