blob: 193cb0c15a542572d231be550a12be4cb1ad79c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package top.trumeet.redirectstorage.simple;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.text.Html;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import top.trumeet.redirectstorage.RedirectStorage;
public class MainActivity extends Activity {
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text);
updateText();
Switch s = findViewById(R.id.switch_widget);
s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b) {
RedirectStorage.enable(getExternalFilesDir(null)
.getAbsolutePath().substring(RedirectStorage.getRealPath().getAbsolutePath()
.length()));
} else {
RedirectStorage.disable();
}
updateText();
}
});
}
private void updateText () {
textView.setText(Html.fromHtml(getString(R.string.text,
Environment.getExternalStorageDirectory().getAbsolutePath(),
String.valueOf(RedirectStorage.isEnable()),
RedirectStorage.getRealPath())));
}
}
|