Skip to content

Commit

Permalink
release 3,1
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryolitia committed Jan 28, 2019
1 parent 1bbf84c commit 7317461
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
minSdkVersion 19
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 21
versionCode 9
versionName '3.0'
versionCode 10
versionName '3.1'
resConfigs "zh", "zh-rCN"
}
buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"3.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":10,"versionName":"3.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
7 changes: 7 additions & 0 deletions app/src/main/assets/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ <h3><font color="#448AFF">处理模式</font></h3>
<p>模式二:需要root,几乎适用于所有设备</p>
<h3><font color="#448AFF">处理格式</font></h3>
<p>手动设置如何将文件名格式化为日期,留空则使用默认内置算法。建议仅在内置算法不适用时使用。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<hr/>
<h4>调试工具</h4>
<p>该工具在旗舰机型上处理速度可达每秒千张左右,但总有部分用户反馈认为如此快的处理速度是工作不正常的表现,故增加此调试选项来设置处理时的延时,以期能带给用户更好的使用体验。该设置项并无任何意义,请尽量不要调整。单位:毫秒</p>
<input type="button" value="打开调整工具" onclick="openGit.updateDelay();">
</body>
</html>
22 changes: 20 additions & 2 deletions app/src/main/java/photoTimeFix/CoreK.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import android.support.design.widget.AppBarLayout
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.support.v7.app.AlertDialog
import android.text.InputType
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import android.widget.RadioGroup
import org.jetbrains.anko.longToast
Expand All @@ -33,7 +35,7 @@ import java.text.SimpleDateFormat
import java.util.*
import java.util.regex.Pattern

class CoreK(private var context: Context) {
class CoreK(private var context: Context, private var editor: SharedPreferences.Editor) {

fun initFragment(preferences: SharedPreferences, editor: SharedPreferences.Editor, chooseBtn: Button, radioGroup: RadioGroup, fragment: Fragment) {
radioGroup.check(preferences.getInt("mode", R.id.radioButton))
Expand All @@ -56,10 +58,11 @@ class CoreK(private var context: Context) {
webView.webViewClient = WebViewClient()
webView.loadUrl("file:///android_asset/about.html")
webView.settings.javaScriptEnabled = true
webView.requestFocusFromTouch()
webView.addJavascriptInterface(this, "openGit")
builder.setView(view)
} catch (e: Exception) {
builder.setMessage("加载Webview错误,已停止显示帮助窗口。\n该错误并不影响正常功能运行,且开发者仅在模拟器上遇到过,如果出现此对话框请与开发者联系。")
builder.setMessage("加载WebView错误,已停止显示帮助窗口。\n该错误并不影响正常功能运行,且开发者仅在模拟器上遇到过,如果出现此对话框请与开发者联系。")
e.printStackTrace()
}
builder.setPositiveButton("确定", null)
Expand Down Expand Up @@ -191,4 +194,19 @@ class CoreK(private var context: Context) {
context.toast("完成")
}

@JavascriptInterface
fun updateDelay () {
val et = EditText(context)
et.inputType = InputType.TYPE_CLASS_NUMBER
var input : Int
AlertDialog.Builder(context).setTitle("设置延时")
.setView(et)
.setPositiveButton("确定") { _,_ ->
input = et.text.toString().toInt()
editor.putInt("delay",input)
editor.apply()
}
.show()
}

}
4 changes: 2 additions & 2 deletions app/src/main/java/photoTimeFix/Fragment1.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Fragment1 : Fragment() {
override fun onCreateView(inflater: LayoutInflater, parent: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, parent, savedInstanceState)
val view = inflater.inflate(R.layout.fragment_1, parent, false)
coreK = CoreK(context!!)
preferences = activity!!.getPreferences(Context.MODE_PRIVATE)
editor = preferences.edit()
coreK = CoreK(context!!,editor)
locateTv = view!!.findViewById(R.id.locateText)
locateText = view.findViewById<EditText>(R.id.locateText)
locateText.setText(preferences.getString("locate", Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera"))
Expand All @@ -50,7 +50,7 @@ class Fragment1 : Fragment() {
val radio: Boolean = radioGroup.checkedRadioButtonId == R.id.radioButton
Log.d("radio", radioGroup.checkedRadioButtonId.toString())
Log.d("radio", R.id.radioButton.toString())
core.process(context, startNum, endNum, fileString, radio, activity, format, "")
core.process(context, startNum, endNum, fileString, radio, activity, format, "",preferences.getInt("delay",0))
}
val freshButton = view.findViewById<Button>(R.id.freshButton)
freshButton.setOnClickListener {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/photoTimeFix/Fragment2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Fragment2 : Fragment() {
super.onCreateView(inflater, parent, savedInstanceState)
val view : View = inflater.inflate(R.layout.fragment_2,parent,false)
locateTv = view.findViewById(R.id.locateText)
coreK = CoreK(context!!)
preferences = activity!!.getPreferences(Context.MODE_PRIVATE)
editor = preferences.edit()
coreK = CoreK(context!!,editor)
chooseBtn = view.findViewById(R.id.chooseButton)
radioGroup = view.findViewById(R.id.radioGroup)
dateEdit = view.findViewById(R.id.nowDate)
Expand Down Expand Up @@ -94,7 +94,7 @@ class Fragment2 : Fragment() {
val fileString: String = view.findViewById<EditText>(R.id.locateText).text.toString()
val radio: Boolean = radioGroup.checkedRadioButtonId == R.id.radioButton
val selectDate = choseDateEdit.text.toString()
core.process(context, 0, 0, fileString, radio, activity, "yyyyMMddHHmm", selectDate)
core.process(context, 0, 0, fileString, radio, activity, "yyyyMMddHHmm", selectDate,0)
}

return view
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/photoTimeFix/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MainActivity : AppCompatActivity() {
setSupportActionBar(toolbar)
preferences = getPreferences(Context.MODE_PRIVATE)
editor = preferences.edit()
coreK = CoreK(this)
coreK = CoreK(this,editor)
if (preferences.getBoolean("ifFirst",true)) {
coreK.showAbout()
editor.putBoolean("ifFirst",false)
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/tech/lincaiqi/PhotoTimeFix/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Core {

private boolean support = true;

public void process(Context context, int startnum, int endnum, String fileString, boolean radio, Activity activity, String format, String selectDate) {
public void process(Context context, int startnum, int endnum, String fileString, boolean radio, Activity activity, String format, String selectDate, int delay) {
File file = new File(fileString);
//Log.d("EditText", locateTv.getText().toString());
if (!file.exists()) {
Expand Down Expand Up @@ -51,7 +51,9 @@ public void process(Context context, int startnum, int endnum, String fileString

boolean retValue;

Toast.makeText(context,"正在获取ROOT权限",Toast.LENGTH_LONG);
Looper.prepare();
Toast.makeText(context, "正在获取ROOT权限……", Toast.LENGTH_LONG).show();
Looper.loop();

try {
suProcess = Runtime.getRuntime().exec("su");
Expand Down Expand Up @@ -138,11 +140,11 @@ public void process(Context context, int startnum, int endnum, String fileString
}
}

/*try {
Thread.sleep(100);
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
}
}

activity.runOnUiThread(() -> pd.incrementProgressBy(1));
Expand Down

0 comments on commit 7317461

Please sign in to comment.