diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1c268ed..e055ab1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,8 @@ - + + \ No newline at end of file diff --git a/app/src/main/java/io/github/h4mu/adoptedstorageaccess/MainActivity.java b/app/src/main/java/io/github/h4mu/adoptedstorageaccess/MainActivity.java index 0045867..0194547 100644 --- a/app/src/main/java/io/github/h4mu/adoptedstorageaccess/MainActivity.java +++ b/app/src/main/java/io/github/h4mu/adoptedstorageaccess/MainActivity.java @@ -5,8 +5,10 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.provider.Settings; import android.view.View; import android.widget.Checkable; @@ -28,12 +30,24 @@ protected void onCreate(Bundle savedInstanceState) { dir.setWritable(true, false); TextView folderPathText = (TextView) findViewById(R.id.folderPathText); - folderPathText.setText(dir.getPath()); - if (!dir.getAbsolutePath().startsWith("/mnt/expand/")) { - findViewById(R.id.warningLayout).setVisibility(View.VISIBLE); + folderPathText.setText(getString(R.string.path, dir)); + + updateWarnings(); + } + + private void updateWarnings() { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + if (!getFilesDir().getAbsolutePath().startsWith("/mnt/expand/")) { + findViewById(R.id.warningLayout).setVisibility(sharedPref.getBoolean("locationWarningEnabled", true) ? View.VISIBLE : View.GONE); } } + @Override + protected void onResume() { + super.onResume(); + updateWarnings(); + } + public void onOpenAppSettingsButtonClick(View view) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); @@ -42,10 +56,20 @@ public void onOpenAppSettingsButtonClick(View view) { } public void onFolderButtonClick(View view) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + boolean enableIntentData = sharedPref.getBoolean("enableIntentData", true); + boolean enableIntentType = sharedPref.getBoolean("enableIntentType", true); + String intentType = sharedPref.getString("intentType", "resource/folder"); + Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.fromFile(getFilesDir())); - if (!((Checkable) findViewById(R.id.enableActivityAttachmentSwitch)).isChecked()) { - intent.setType("resource/folder"); + if (enableIntentData && enableIntentType) { + intent.setDataAndType(Uri.fromFile(getFilesDir()), intentType); + } + else if (enableIntentData) { + intent.setData(Uri.fromFile(getFilesDir())); + } + else if (enableIntentType) { + intent.setType(intentType); } if (intent.resolveActivityInfo(getPackageManager(), 0) != null) { @@ -62,10 +86,10 @@ public void onClipboardButtonClick(View view) { } public void onSettingsButtonClick(View view) { -// startActivity(new Intent(getBaseContext(), SettingsActivity.class)); + startActivity(new Intent(this, SettingsActivity.class)); } public void onLicenseButtonClick(View view) { - startActivity(new Intent(getBaseContext(), LicenseActivity.class)); + startActivity(new Intent(this, LicenseActivity.class)); } } diff --git a/app/src/main/java/io/github/h4mu/adoptedstorageaccess/SettingsActivity.java b/app/src/main/java/io/github/h4mu/adoptedstorageaccess/SettingsActivity.java new file mode 100644 index 0000000..a8d3560 --- /dev/null +++ b/app/src/main/java/io/github/h4mu/adoptedstorageaccess/SettingsActivity.java @@ -0,0 +1,14 @@ +package io.github.h4mu.adoptedstorageaccess; + +import android.app.Activity; +import android.os.Bundle; +import android.preference.PreferenceActivity; + +public class SettingsActivity extends PreferenceActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.activity_settings); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2fb2859..0c83df4 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -19,6 +19,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/path" + android:textAlignment="center" + android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" @@ -49,14 +51,6 @@ android:text="@string/openAppSettings" /> - -