diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..b268ef3
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/x8192bit/diyeditmobile/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/x8192bit/diyeditmobile/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..d6ffa06
--- /dev/null
+++ b/app/src/androidTest/java/com/x8192bit/diyeditmobile/ExampleInstrumentedTest.java
@@ -0,0 +1,27 @@
+package com.x8192bit.diyeditmobile;
+
+import static org.junit.Assert.assertEquals;
+
+import android.content.Context;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.x8192Bit.DIYEdit_Mobile", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/x8192bit/diyeditmobile/AboutActivity.java b/app/src/main/java/com/x8192bit/diyeditmobile/AboutActivity.java
new file mode 100644
index 0000000..dfe43fa
--- /dev/null
+++ b/app/src/main/java/com/x8192bit/diyeditmobile/AboutActivity.java
@@ -0,0 +1,49 @@
+package com.x8192bit.diyeditmobile;
+
+import android.os.Bundle;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.appcompat.app.ActionBar;
+
+import x8192Bit.DIYEdit_Mobile.R;
+
+public class AboutActivity extends BaseActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.about_activity);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setHomeButtonEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+ findViewById(R.id.about_about_btn).setOnClickListener(this::OnAboutButtonClicked);
+ findViewById(R.id.about_osl_btn).setOnClickListener(this::OnLicenseButtonClicked);
+ OnAboutButtonClicked(null);
+ TextView tv = findViewById(R.id.about_info_tv);
+ tv.setText(getString(R.string.aboutTextKey).replace("\\n", "\n"));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ this.finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void OnAboutButtonClicked(View v) {
+ ((TextView) findViewById(R.id.about_info_tv)).setText(getString(R.string.aboutTextKey).replace("\\n", "\n"));
+ }
+
+
+ private void OnLicenseButtonClicked(View v) {
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/x8192bit/diyeditmobile/BaseActivity.java b/app/src/main/java/com/x8192bit/diyeditmobile/BaseActivity.java
index b2ab415..2f8ef07 100644
--- a/app/src/main/java/com/x8192bit/diyeditmobile/BaseActivity.java
+++ b/app/src/main/java/com/x8192bit/diyeditmobile/BaseActivity.java
@@ -1,7 +1,6 @@
package com.x8192bit.diyeditmobile;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
@@ -9,6 +8,8 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import com.x8192bit.diyeditmobile.utils.SPUtils;
+
import java.util.Locale;
public class BaseActivity extends AppCompatActivity {
@@ -20,17 +21,16 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
public void changeLanguage(Context context) {
- if (context == null) {
- return;
- }
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
- SharedPreferences sp = context.getSharedPreferences("com.x8192Bit.DIYEdit_Mobile_preferences", MODE_PRIVATE);
- String language = sp.getString("LanguageSelect", "system");
- if (!language.equals("system")) {
- String[] str = language.split("-");
- configuration.locale = new Locale(str[0], str[1]);
- }
+ configuration.locale = SPUtils.getLocale(context);
+ resources.updateConfiguration(configuration, null);
+ }
+
+ public void changeLanguage(Context context, Locale locale) {
+ Resources resources = context.getResources();
+ Configuration configuration = resources.getConfiguration();
+ configuration.locale = locale;
resources.updateConfiguration(configuration, null);
}
diff --git a/app/src/main/java/com/x8192bit/diyeditmobile/FileSelectActivity.java b/app/src/main/java/com/x8192bit/diyeditmobile/FileSelectActivity.java
new file mode 100644
index 0000000..46bed30
--- /dev/null
+++ b/app/src/main/java/com/x8192bit/diyeditmobile/FileSelectActivity.java
@@ -0,0 +1,230 @@
+package com.x8192bit.diyeditmobile;
+
+import static com.x8192bit.diyeditmobile.MainActivity.CHOOSE_RESULT;
+import static com.x8192bit.diyeditmobile.fragments.SaveEditFragment.IS_IMPORT_MIO;
+import static com.x8192bit.diyeditmobile.fragments.SaveEditFragment.IS_SAVE_EDIT;
+import static com.x8192bit.diyeditmobile.fragments.SaveEditFragment.SAVE_EDIT_COUNT;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Environment;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AlertDialog;
+
+import com.x8192bit.diyeditmobile.utils.SPUtils;
+
+import java.io.File;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+
+import x8192Bit.DIYEdit_Mobile.R;
+
+
+public class FileSelectActivity extends BaseActivity {
+ // TODO 快点重构你这坨狗屎
+ public static final int CHOOSE_FILE = 0;
+ public static final int CHOOSE_DIRECTORY = 1;
+ File CurrentPath = null;
+ private int chooseType = CHOOSE_FILE;
+ private boolean isImportMIO;
+ private boolean isSaveEdit;
+ private int saveEditCount;
+ private boolean isTimeSorted;
+ private boolean isNormalOrder;
+ private boolean showHiddenFiles;
+ public AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ File originalPath = CurrentPath;
+ try {
+ String path = (String) (((TextView) ((LinearLayout) view).getChildAt(1))).getText();
+ if (path.equals("..")) {
+ CurrentPath = CurrentPath.getParentFile();
+ } else {
+ CurrentPath = new File(CurrentPath.getAbsolutePath() + '/' + path);
+ if (CurrentPath.isFile() && chooseType == CHOOSE_FILE) {
+ Intent intentResult = new Intent();
+ intentResult.putExtra(CHOOSE_RESULT, CurrentPath.getAbsolutePath());
+ intentResult.putExtra(IS_SAVE_EDIT, isSaveEdit);
+ if (isSaveEdit) {
+ intentResult.putExtra(IS_IMPORT_MIO, isImportMIO);
+ intentResult.putExtra(SAVE_EDIT_COUNT, saveEditCount);
+ }
+ setResult(1919810, intentResult);
+ finish();
+ }
+ }
+ refreshList(getApplicationContext());
+ } catch (NullPointerException e) {
+ CurrentPath = originalPath;
+ } catch (Exception e) {
+ new AlertDialog.Builder(FileSelectActivity.this)
+ .setTitle("What the fuck????!!")
+ .setMessage("GO FUCK YOURSELF!!!!!!!!!!!!!!!!!11").show();
+ CurrentPath = originalPath;
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.fileselect_activity);
+
+ Intent intent = getIntent();
+ chooseType = intent.getIntExtra(MainActivity.CHOOSE_TYPE, CHOOSE_FILE);
+
+ Button selectDirectoryButton = findViewById(R.id.file_select_ok_btn);
+
+ if (chooseType == CHOOSE_FILE) {
+ // When selecting a file, the OK button is useless so remove
+ ((LinearLayout) findViewById(R.id.file_select_ll)).removeView(selectDirectoryButton);
+ } else {
+ selectDirectoryButton.setOnClickListener(v -> {
+ try {
+ Intent intentResult = new Intent();
+ String path = CurrentPath.getAbsolutePath();
+ intentResult.putExtra(CHOOSE_RESULT, path);
+ intentResult.putExtra(IS_SAVE_EDIT, isSaveEdit);
+ if (isSaveEdit) {
+ intentResult.putExtra(IS_IMPORT_MIO, isImportMIO);
+ intentResult.putExtra(SAVE_EDIT_COUNT, saveEditCount);
+ }
+ setResult(1919810, intentResult);
+ finish();
+ } catch (Exception e) {
+ new AlertDialog.Builder(FileSelectActivity.this)
+ .setTitle("What the fuck????!!")
+ .setMessage("GO FUCK YOURSELF!!!!!!!!!!!!!!!!!11").show();
+ }
+ });
+ }
+ isSaveEdit = intent.getBooleanExtra(IS_SAVE_EDIT, false);
+ if (isSaveEdit) {
+ isImportMIO = intent.getBooleanExtra(IS_IMPORT_MIO, false);
+ saveEditCount = intent.getIntExtra(SAVE_EDIT_COUNT, 0);
+ }
+
+ // initialize the actionbar so that we can add some button to it then
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setHomeButtonEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+
+ CurrentPath = Environment.getExternalStorageDirectory();
+
+ ListView fileChooser = findViewById(R.id.file_select_lv);
+
+ isTimeSorted = SPUtils.isTimeSorted(getApplicationContext());
+ isNormalOrder = SPUtils.isNormalOrder(getApplicationContext());
+ showHiddenFiles = SPUtils.isShowingHiddenFiles(getApplicationContext());
+
+ refreshList(getApplicationContext());
+
+ fileChooser.setOnItemClickListener(listener);
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ this.finish();
+ return true;
+ } else {
+ if (item.getItemId() == 0) {
+ isTimeSorted = !isTimeSorted;
+ SPUtils.setTimeSorted(getApplicationContext(), isTimeSorted);
+ refreshList(getApplicationContext());
+ } else if (item.getItemId() == 1) {
+ isNormalOrder = !isNormalOrder;
+ SPUtils.setNormalOrder(getApplicationContext(), isNormalOrder);
+ refreshList(getApplicationContext());
+ } else if (item.getItemId() == 2) {
+ showHiddenFiles = !showHiddenFiles;
+ SPUtils.setShowingHiddenFiles(getApplicationContext(), showHiddenFiles);
+ refreshList(getApplicationContext());
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ menu.clear();
+ menu.add(0, 0, 0, isTimeSorted ? R.string.nameSortedKey : R.string.timeSortedKey);
+ menu.add(0, 1, 1, isNormalOrder ? R.string.normalOrderKey : R.string.reverseOrderKey);
+ menu.add(0, 2, 2, showHiddenFiles ? R.string.hideHiddenFilesKey : R.string.showHiddenFilesKey);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ menu.clear();
+ menu.add(0, 0, 0, isTimeSorted ? R.string.nameSortedKey : R.string.timeSortedKey);
+ menu.add(0, 1, 1, isNormalOrder ? R.string.normalOrderKey : R.string.reverseOrderKey);
+ menu.add(0, 2, 2, showHiddenFiles ? R.string.hideHiddenFilesKey : R.string.showHiddenFilesKey);
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ public void refreshList(Context c) {
+ ListView fileChooser = findViewById(R.id.file_select_lv);
+ TextView PathView = findViewById(R.id.file_select_dir_tv);
+ String[] from = {"img", "text"};
+ int[] to = {R.id.file_select_item_iv, R.id.file_select_item_tv};
+ ArrayList