Skip to content

Commit

Permalink
Remade the application icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
YangDai committed Nov 27, 2023
1 parent 4af84a1 commit bc16e99
Show file tree
Hide file tree
Showing 26 changed files with 122 additions and 32 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.yangdai.calc"
minSdk 28
targetSdk 34
versionCode 47
versionName '5.7'
versionCode 48
versionName '5.8'
resourceConfigurations += ["en", "zh", "de"]
}

Expand Down Expand Up @@ -59,6 +59,7 @@ dependencies {
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'

implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.activity:activity:1.8.1'
implementation 'androidx.window:window:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions app/src/main/java/com/yangdai/calc/main/MainFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,17 @@ public void handleOnBackCancelled() {
viewPager2.setCurrentItem(0);
}

// @RequiresApi(34)
// @Override
// public void handleOnBackProgressed(@NonNull BackEventCompat backEvent) {
// super.handleOnBackProgressed(backEvent);
// viewPager2.setCurrentItem(1);
// }

@RequiresApi(34)
@Override
public void handleOnBackProgressed(@NonNull BackEventCompat backEvent) {
super.handleOnBackProgressed(backEvent);
public void handleOnBackStarted(@NonNull BackEventCompat backEvent) {
super.handleOnBackStarted(backEvent);
viewPager2.setCurrentItem(1);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CalculatorFragment extends Fragment implements SharedPreferences.On
, View.OnClickListener, TTSInitializationListener {
private TextView inputView;
private TextView outputView;
SharedPreferences settings, history;
SharedPreferences defaultSp, historySp;
private boolean switched = false;
private TTS tts;
private boolean ttsAvailable;
Expand Down Expand Up @@ -76,9 +76,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

settings = PreferenceManager.getDefaultSharedPreferences(requireContext());
settings.registerOnSharedPreferenceChangeListener(this);
history = requireActivity().getSharedPreferences("history", MODE_PRIVATE);
defaultSp = PreferenceManager.getDefaultSharedPreferences(requireContext());
defaultSp.registerOnSharedPreferenceChangeListener(this);
historySp = requireActivity().getSharedPreferences("history", MODE_PRIVATE);

// 初始化TextToSpeech对象
tts = new TTS();
Expand Down Expand Up @@ -111,7 +111,7 @@ public void afterTextChanged(Editable editable) {
for (int buttonId : BUTTON_IDS) {
View view1 = view.findViewById(buttonId);
if (null != view1) {
view1.setHapticFeedbackEnabled(settings.getBoolean("vib", false));
view1.setHapticFeedbackEnabled(defaultSp.getBoolean("vib", false));
view1.setOnClickListener(this);
TouchAnimation touchAnimation = new TouchAnimation(view1);
view1.setOnTouchListener(touchAnimation);
Expand Down Expand Up @@ -139,10 +139,10 @@ public void afterTextChanged(Editable editable) {
} else {
inputView.setText(inputtedEquation + "+" + selected);
}
boolean useDeg = settings.getBoolean("mode", false);
boolean useDeg = defaultSp.getBoolean("mode", false);
Calculator formulaUtil1 = new Calculator(useDeg);
fromUser = false;
viewModel.handleEqualButton(inputView.getText().toString(), formulaUtil1, settings, history, fromUser, getString(R.string.bigNum), getString(R.string.formatError));
viewModel.handleEqualButton(inputView.getText().toString(), formulaUtil1, defaultSp, historySp, fromUser, getString(R.string.bigNum), getString(R.string.formatError));
}
highlightSpecialSymbols(inputView);
}
Expand All @@ -159,17 +159,17 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, @Null
for (int buttonId : BUTTON_IDS) {
View view = requireView().findViewById(buttonId);
if (view != null) {
view.setHapticFeedbackEnabled(settings.getBoolean("vib", false));
view.setHapticFeedbackEnabled(defaultSp.getBoolean("vib", false));
}
}
} else if ("scale".equals(s) || "mode".equals(s)) {
String inputStr1 = inputView.getText().toString();
//自动运算
boolean useDeg = settings.getBoolean("mode", false);
boolean useDeg = defaultSp.getBoolean("mode", false);
if (inputStr1.length() > 0) {
Calculator formulaUtil1 = new Calculator(useDeg);
fromUser = false;
viewModel.handleEqualButton(inputStr1, formulaUtil1, settings, history, false, getString(R.string.bigNum), getString(R.string.formatError));
viewModel.handleEqualButton(inputStr1, formulaUtil1, defaultSp, historySp, false, getString(R.string.bigNum), getString(R.string.formatError));
}
}
}
Expand All @@ -188,15 +188,15 @@ public void onDestroy() {
super.onDestroy();
// 释放TextToSpeech资源
tts.ttsDestroy();
settings.unregisterOnSharedPreferenceChangeListener(this);
defaultSp.unregisterOnSharedPreferenceChangeListener(this);
}

@SuppressLint({"UseCompatLoadingForDrawables", "SetTextI18n"})
@Override
public void onClick(View v) {

boolean useDeg = settings.getBoolean("mode", false);
boolean canSpeak = settings.getBoolean("voice", false);
boolean useDeg = defaultSp.getBoolean("mode", false);
boolean canSpeak = defaultSp.getBoolean("voice", false);

//获取输入
String inputStr = inputView.getText().toString();
Expand All @@ -208,7 +208,7 @@ public void onClick(View v) {
tts.ttsSpeak(getString(R.string.equal));
}
fromUser = true;
viewModel.handleEqualButton(inputStr, formulaUtil, settings, history, true, getString(R.string.bigNum), getString(R.string.formatError));
viewModel.handleEqualButton(inputStr, formulaUtil, defaultSp, historySp, true, getString(R.string.bigNum), getString(R.string.formatError));
} else if (v.getId() == R.id.Clean) {
if (canSpeak) {
tts.ttsSpeak(getString(R.string.resetInput));
Expand Down Expand Up @@ -258,7 +258,7 @@ public void onClick(View v) {
if (inputStr1.length() > 0) {
Calculator formulaUtil1 = new Calculator(useDeg);
fromUser = false;
viewModel.handleEqualButton(inputStr1, formulaUtil1, settings, history, false, getString(R.string.bigNum), getString(R.string.formatError));
viewModel.handleEqualButton(inputStr1, formulaUtil1, defaultSp, historySp, false, getString(R.string.bigNum), getString(R.string.formatError));
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @author 30415
*/
public class CurrencyActivity extends AppCompatActivity {
private SharedPreferences sharedPreferences;
private SharedPreferences defaultSp;
private Spinner fromCurrencySpinner;
private Spinner toCurrencySpinner;
private EditText amountEditText;
Expand Down Expand Up @@ -81,9 +81,9 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setElevation(0f);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
defaultSp = PreferenceManager.getDefaultSharedPreferences(this);

if (sharedPreferences.getBoolean("screen", false)) {
if (defaultSp.getBoolean("screen", false)) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Expand All @@ -102,7 +102,7 @@ protected void onCreate(Bundle savedInstanceState) {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calculateCurrency();
if (!first) {
SharedPreferences.Editor editor = sharedPreferences.edit();
SharedPreferences.Editor editor = defaultSp.edit();
editor.putInt("from", position);
editor.apply();
}
Expand All @@ -119,7 +119,7 @@ public void onNothingSelected(AdapterView<?> parent) {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calculateCurrency();
if (!first) {
SharedPreferences.Editor editor = sharedPreferences.edit();
SharedPreferences.Editor editor = defaultSp.edit();
editor.putInt("to", position);
editor.apply();
}
Expand All @@ -143,8 +143,8 @@ public void onNothingSelected(AdapterView<?> parent) {

if (first) {
first = false;
fromCurrencySpinner.setSelection(sharedPreferences.getInt("from", 0));
toCurrencySpinner.setSelection(sharedPreferences.getInt("to", 0));
fromCurrencySpinner.setSelection(defaultSp.getInt("from", 0));
toCurrencySpinner.setSelection(defaultSp.getInt("to", 0));
}

String date;
Expand Down
Binary file removed app/src/main/multicalc-playstore.png
Binary file not shown.
39 changes: 39 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="108dp"
android:height="108dp"
android:viewportWidth="572"
android:viewportHeight="573">
<group
android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="143.25"
android:translateY="143.25">

<path
android:fillColor="#80868a"
android:pathData="M44,272L272,272L272,44L121,44C98.64,44 73.39,39.65 56.09,57.09C39.67,73.65 44,98.79 44,120L44,272z"
android:strokeColor="#00000000" />
<path
android:fillColor="#35383c"
android:pathData="M302,44L302,267C314.4,260.83 325.09,251.95 338,246.43C375.76,230.27 418.48,226.95 458,238.72C472.66,243.09 487.01,249.34 500,257.42C510.14,263.73 517.62,272 530,272L530,121C530,99.35 534.38,74.09 517.91,57.04C501.1,39.65 475.9,44 454,44L302,44z"
android:strokeColor="#00000000" />
<path
android:fillColor="#f1f1f1"
android:pathData="M143,143C134.77,143 124.69,141.52 117,145.07C107.25,149.58 106.11,163.85 115.09,169.85C122.65,174.9 134.39,173 143,173C143,181.61 141.1,193.35 146.15,200.91C152.14,209.87 166.37,208.7 170.93,198.99C174.51,191.34 173,181.2 173,173C181.4,173 192.34,174.72 199.96,170.43C209.78,164.91 209.16,149.84 198.99,145.07C191.34,141.49 181.2,143 173,143C173,134.6 174.72,123.66 170.43,116.04C165.23,106.8 150.58,106.51 145.45,116.04C141.32,123.72 143,134.6 143,143M381,143.44C376.66,144.14 372.43,145.47 369.65,149.1C364.32,156.1 366.92,167.49 375,171.01C382.27,174.17 391.29,173 399,173L435,173C441.89,173 449.39,173.76 456,171.39C468.66,166.84 467.6,148.07 455,144.3C445.96,141.6 435.33,143 426,143C411.43,143 395.39,141.12 381,143.44z"
android:strokeColor="#00000000" />
<path
android:fillColor="#4485f5"
android:pathData="M392,261.42C369.74,264.38 347.98,271 329,283.35C311.65,294.63 296.83,308.76 285.33,326C247.16,383.24 254.04,464.01 303.02,512.98C336.81,546.78 385.07,561.37 432,554.71C451.5,551.95 470.27,544.44 487,534.19C502.08,524.95 515.17,513.07 525.87,499C575.12,434.23 562.66,338.34 497,289.48C481.87,278.22 464.21,269.95 446,265.15C429.05,260.69 409.42,259.11 392,261.42z"
android:strokeColor="#00000000" />
<path
android:fillColor="#606368"
android:pathData="M44,302L44,454C44,475.21 39.67,500.35 56.09,516.91C73.34,534.3 98.71,530 121,530L272,530C272,517.46 263.67,510.31 257.45,500C249.67,487.1 243.48,473.39 239.02,459C226.76,419.37 230.19,375.93 246.43,338C251.95,325.09 260.23,314.16 267,302L44,302z"
android:strokeColor="#00000000" />
<path
android:fillColor="#f1f1f1"
android:pathData="M370,369.53C356.88,372.72 355.29,391.85 368,396.85C373.95,399.2 381.72,398 388,398L427,398C433.79,398 442.63,399.47 449,396.77C460.93,391.72 460.6,373.76 448,369.8C440.24,367.37 430.07,369 422,369L388,369C382.22,369 375.65,368.16 370,369.53M128,377.65C120.09,380.14 117.04,389.65 120.01,397C121.63,400.99 125.03,404.01 128,407C130.32,409.33 135.8,413.15 134.79,417C133.05,423.64 123.58,427.74 120.46,434C114.13,446.66 127.34,459.87 140,453.54C144.74,451.17 148.25,446.62 152,443.01C153.58,441.49 155.58,439.06 158,439.06C161.46,439.06 164.79,443.81 167,446C172.85,451.81 179.19,457.12 188,454.35C195.91,451.86 198.96,442.35 195.99,435C194.37,431.01 190.97,427.99 188,425C185.68,422.67 180.2,418.85 181.21,415C182.95,408.36 192.41,404.26 195.54,398C201.87,385.34 188.66,372.13 176,378.46C171.26,380.83 167.75,385.38 164,388.99C162.42,390.51 160.42,392.94 158,392.94C154.54,392.94 151.21,388.19 149,386C143.15,380.19 136.81,374.88 128,377.65M370,419.53C356.88,422.72 355.29,441.85 368,446.85C373.95,449.2 381.72,448 388,448L427,448C433.79,448 442.63,449.47 449,446.77C460.93,441.72 460.6,423.76 448,419.8C440.24,417.37 430.07,419 422,419L388,419C382.22,419 375.65,418.16 370,419.53z"
android:strokeColor="#00000000"
tools:ignore="VectorPath" />
</group>
</vector>
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/ic_launcher_mono.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="108dp"
android:height="108dp"
android:viewportWidth="572"
android:viewportHeight="573">
<group
android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="143.25"
android:translateY="143.25">

<path
android:fillColor="#f1f1f1"
android:pathData="M143,143C134.77,143 124.69,141.52 117,145.07C107.25,149.58 106.11,163.85 115.09,169.85C122.65,174.9 134.39,173 143,173C143,181.61 141.1,193.35 146.15,200.91C152.14,209.87 166.37,208.7 170.93,198.99C174.51,191.34 173,181.2 173,173C181.4,173 192.34,174.72 199.96,170.43C209.78,164.91 209.16,149.84 198.99,145.07C191.34,141.49 181.2,143 173,143C173,134.6 174.72,123.66 170.43,116.04C165.23,106.8 150.58,106.51 145.45,116.04C141.32,123.72 143,134.6 143,143M381,143.44C376.66,144.14 372.43,145.47 369.65,149.1C364.32,156.1 366.92,167.49 375,171.01C382.27,174.17 391.29,173 399,173L435,173C441.89,173 449.39,173.76 456,171.39C468.66,166.84 467.6,148.07 455,144.3C445.96,141.6 435.33,143 426,143C411.43,143 395.39,141.12 381,143.44z"
android:strokeColor="#00000000" />

<path
android:fillColor="#f1f1f1"
android:pathData="M370,369.53C356.88,372.72 355.29,391.85 368,396.85C373.95,399.2 381.72,398 388,398L427,398C433.79,398 442.63,399.47 449,396.77C460.93,391.72 460.6,373.76 448,369.8C440.24,367.37 430.07,369 422,369L388,369C382.22,369 375.65,368.16 370,369.53M128,377.65C120.09,380.14 117.04,389.65 120.01,397C121.63,400.99 125.03,404.01 128,407C130.32,409.33 135.8,413.15 134.79,417C133.05,423.64 123.58,427.74 120.46,434C114.13,446.66 127.34,459.87 140,453.54C144.74,451.17 148.25,446.62 152,443.01C153.58,441.49 155.58,439.06 158,439.06C161.46,439.06 164.79,443.81 167,446C172.85,451.81 179.19,457.12 188,454.35C195.91,451.86 198.96,442.35 195.99,435C194.37,431.01 190.97,427.99 188,425C185.68,422.67 180.2,418.85 181.21,415C182.95,408.36 192.41,404.26 195.54,398C201.87,385.34 188.66,372.13 176,378.46C171.26,380.83 167.75,385.38 164,388.99C162.42,390.51 160.42,392.94 158,392.94C154.54,392.94 151.21,388.19 149,386C143.15,380.19 136.81,374.88 128,377.65M370,419.53C356.88,422.72 355.29,441.85 368,446.85C373.95,449.2 381.72,448 388,448L427,448C433.79,448 442.63,449.47 449,446.77C460.93,441.72 460.6,423.76 448,419.8C440.24,417.37 430.07,419 422,419L388,419C382.22,419 375.65,418.16 370,419.53z"
android:strokeColor="#00000000"
tools:ignore="VectorPath" />
</group>
</vector>
10 changes: 9 additions & 1 deletion app/src/main/res/layout/fragment_history_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
android:id="@+id/historyList"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/bottomSheetDragHandleView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:id="@+id/bottomSheetDragHandleView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_mono"/>
</adaptive-icon>
3 changes: 2 additions & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_mono"/>
</adaptive-icon>
Binary file not shown.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#2B2B2B</color>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="AppTheme" parent="Theme.Material3.DynamicColors.Dark">
<item name="android:windowSplashScreenBackground" tools:targetApi="s">@color/background
</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- Customize your theme here. -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#FEFEFE</color>
<color name="Very_Severely_underweight">#FF4081</color>
<color name="Severely_underweight">#FF5722</color>
<color name="Underweight">#FF9800</color>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#4D5C71</color>
<color name="ic_launcher_background">@color/background</color>
</resources>
Loading

0 comments on commit bc16e99

Please sign in to comment.