Refactor naming, fix kalculate

This commit is contained in:
icewithcola 2024-06-01 17:14:53 +08:00
parent 14b41f2f2d
commit 96dd0869d4
14 changed files with 34 additions and 14 deletions

2
.gitignore vendored
View file

@ -15,3 +15,5 @@
local.properties local.properties
app/release app/release
/.idea/inspectionProfiles/Project_Default.xml /.idea/inspectionProfiles/Project_Default.xml
/.idea/deploymentTargetSelector.xml
/.idea/studiobot.xml

View file

@ -16,7 +16,7 @@
android:theme="@style/Theme.Android101"> android:theme="@style/Theme.Android101">
<receiver <receiver
android:name=".vibrationBroadcastReceiver.vibrationBroadcastReceiver" android:name=".misc.vibrationBroadcastReceiver.vibrationBroadcastReceiver"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:permission="android.permission.VIBRATE"> android:permission="android.permission.VIBRATE">

View file

@ -25,6 +25,8 @@ import androidx.core.view.WindowInsetsCompat;
import java.util.Arrays; import java.util.Arrays;
import uk.kagurach.android101.helper.PageHelper;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
PageHelper pageHelper; PageHelper pageHelper;

View file

@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -21,7 +20,9 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets; import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import androidx.room.util.StringUtil;
import uk.kagurach.android101.helper.PageHelper;
import uk.kagurach.android101.helper.ToastHelper;
public class MainActivity2 extends AppCompatActivity { public class MainActivity2 extends AppCompatActivity {

View file

@ -1,6 +1,6 @@
package uk.kagurach.android101; package uk.kagurach.android101;
import static uk.kagurach.android101.KaculateKt.Kaculate; import static uk.kagurach.android101.misc.KaculateKt.Kaculate;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
@ -14,6 +14,8 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import uk.kagurach.android101.helper.PageHelper;
public class Page3 extends AppCompatActivity { public class Page3 extends AppCompatActivity {
PageHelper pageHelper; PageHelper pageHelper;

View file

@ -19,7 +19,8 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import uk.kagurach.android101.vibrationBroadcastReceiver.vibrationBroadcastReceiver; import uk.kagurach.android101.helper.PageHelper;
import uk.kagurach.android101.misc.vibrationBroadcastReceiver.vibrationBroadcastReceiver;
public class Page4 extends AppCompatActivity { public class Page4 extends AppCompatActivity {

View file

@ -8,6 +8,8 @@ import android.util.Log;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import uk.kagurach.android101.helper.ToastHelper;
public class Page4OtherActivity extends AppCompatActivity { public class Page4OtherActivity extends AppCompatActivity {
@Override @Override

View file

@ -21,7 +21,9 @@ import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import chatgpt.AnimalDatabaseHelper; import chatgpt.AnimalDatabaseHelper;
import uk.kagurach.android101.misc.AutoCompleHelper.AnimalTypeAutoCompleteHelper; import uk.kagurach.android101.helper.PageHelper;
import uk.kagurach.android101.helper.ToastHelper;
import uk.kagurach.android101.helper.AutoCompleHelper.AnimalTypeAutoCompleteHelper;
public class Page5 extends AppCompatActivity { public class Page5 extends AppCompatActivity {

View file

@ -1,4 +1,4 @@
package uk.kagurach.android101.misc.AutoCompleHelper; package uk.kagurach.android101.helper.AutoCompleHelper;
import android.content.Context; import android.content.Context;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;

View file

@ -1,4 +1,4 @@
package uk.kagurach.android101.misc.AutoCompleHelper; package uk.kagurach.android101.helper.AutoCompleHelper;
import android.content.Context; import android.content.Context;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;

View file

@ -1,4 +1,4 @@
package uk.kagurach.android101; package uk.kagurach.android101.helper;
import static androidx.core.content.ContextCompat.startActivity; import static androidx.core.content.ContextCompat.startActivity;
@ -16,14 +16,14 @@ public class PageHelper {
private final Class<?> _next; private final Class<?> _next;
private Activity _activity = null; private Activity _activity = null;
PageHelper(Context curr, Class<?> prev, Class<?> next) { public PageHelper(Context curr, Class<?> prev, Class<?> next) {
_curr = curr; _curr = curr;
_prev = prev; _prev = prev;
_next = next; _next = next;
} }
PageHelper(Context curr, Class<?> prev, Class<?> next, Activity activity) { public PageHelper(Context curr, Class<?> prev, Class<?> next, Activity activity) {
_curr = curr; _curr = curr;
_prev = prev; _prev = prev;
_next = next; _next = next;

View file

@ -1,4 +1,4 @@
package uk.kagurach.android101 package uk.kagurach.android101.helper
import android.content.Context import android.content.Context
import android.widget.Toast import android.widget.Toast

View file

@ -1,6 +1,7 @@
package uk.kagurach.android101 package uk.kagurach.android101.misc
import android.content.Context import android.content.Context
import uk.kagurach.android101.helper.ToastHelper
import kotlin.math.pow import kotlin.math.pow
fun Kaculate(src: String, ctx: Context): String { fun Kaculate(src: String, ctx: Context): String {
@ -14,6 +15,13 @@ fun Kaculate(src: String, ctx: Context): String {
var _curnum = "" var _curnum = ""
// Fix for expression starts with operator
val src = if (src[0] in OpList){
"0" + src
}else{
src
}
for (i in src.indices) { for (i in src.indices) {
if (src[i] in '0'..'9' || src[i] == '.') { if (src[i] in '0'..'9' || src[i] == '.') {
_curnum += src[i] _curnum += src[i]

View file

@ -1,4 +1,4 @@
package uk.kagurach.android101.vibrationBroadcastReceiver; package uk.kagurach.android101.misc.vibrationBroadcastReceiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;