Skip to content

Commit

Permalink
app: introduce 1.0.8
Browse files Browse the repository at this point in the history
- Code cleanup
- Prevent system font-size managment from affecting to webview font size
  • Loading branch information
verNANDo57 committed Oct 3, 2021
1 parent ef3120e commit 272ed50
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 72 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.verNANDo57.rulebook_educational"
minSdkVersion 22
targetSdkVersion 30
versionCode 107
versionName '1.0.7'
versionCode 108
versionName '1.0.8'
multiDexEnabled true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.verNANDo57.rulebook_educational;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -24,8 +26,6 @@
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.tools.Utils;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppAboutApplicationActivity extends CustomThemeEngineAppCompatActivity
{
RulebookApplicationSharedPreferences preferences;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.verNANDo57.rulebook_educational;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;

import androidx.appcompat.widget.Toolbar;

Expand All @@ -19,8 +20,6 @@
import com.verNANDo57.rulebook_educational.search.AppSearchActivity;
import com.verNANDo57.rulebook_educational.tools.Utils;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppChooseYourDestiny extends CustomThemeEngineAppCompatActivity {

RulebookApplicationSharedPreferences preferences;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,32 @@

import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.DecelerateInterpolator;

import com.verNANDo57.rulebook_educational.extradata.R;

@SuppressLint("CustomViewStyleable")
public class AppRatingVector extends View {

private int faceColor, eyesColor, mouthColor, tongueColor;
private RectF faceBgOval, sadOval, neutralOval, slightHappyOval, happyOval, amazingOval, tongueOval, AwfulOval, AwfultongueOval;
private Paint paint;
int centerOffset, viewWidth, viewHeight,
whatToDraw = 2, defaultRating, strokeWidth, eyeRadius;

float centerOffset, viewWidth, viewHeight, whatToDraw = 2, defaultRating, strokeWidth, eyeRadius;
int currEyeLX, currEyeRX, currEyeY;

ValueAnimator rightEyeAnimatorX, leftEyeAnimatorX, eyesAnimatorY;
final long animationDuration = 300;

public AppRatingVector(Context context) {
super(context);

//Disable Hardware acceleration on device with API < 18
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}

public AppRatingVector(Context context, AttributeSet attrs) {
Expand Down Expand Up @@ -84,32 +78,32 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
eyeRadius = viewHeight / 25 + viewWidth / 25;
centerOffset = viewHeight / 3;

switch (whatToDraw) {
switch ((int) whatToDraw) {
case 0:
case 5:
currEyeLX = (viewWidth / 2) - (viewWidth / 100 * 23);
currEyeRX = (viewWidth / 2) + (viewWidth / 100 * 23);
currEyeY = (viewHeight / 100 * 23);
currEyeLX = (int) ((viewWidth / 2) - (viewWidth / 100 * 23));
currEyeRX = (int) ((viewWidth / 2) + (viewWidth / 100 * 23));
currEyeY = (int) (viewHeight / 100 * 23);
break;
case 1:
currEyeLX = (viewWidth / 2) - (viewWidth / 100 * 25);
currEyeRX = (viewWidth / 2) + (viewWidth / 100 * 25);
currEyeY = (viewHeight / 100 * 20);
currEyeLX = (int) ((viewWidth / 2) - (viewWidth / 100 * 25));
currEyeRX = (int) ((viewWidth / 2) + (viewWidth / 100 * 25));
currEyeY = (int) (viewHeight / 100 * 20);
break;
case 2:
currEyeLX = (viewWidth / 2) - (viewWidth / 100 * 20);
currEyeRX = (viewWidth / 2) + (viewWidth / 100 * 20);
currEyeY = (viewHeight / 100 * 20);
currEyeLX = (int) ((viewWidth / 2) - (viewWidth / 100 * 20));
currEyeRX = (int) ((viewWidth / 2) + (viewWidth / 100 * 20));
currEyeY = (int) (viewHeight / 100 * 20);
break;
case 3:
currEyeLX = (viewWidth / 2) - (viewWidth / 100 * 17);
currEyeRX = (viewWidth / 2) + (viewWidth / 100 * 17);
currEyeY = (viewHeight / 100 * 25);
currEyeLX = (int) ((viewWidth / 2) - (viewWidth / 100 * 17));
currEyeRX = (int) ((viewWidth / 2) + (viewWidth / 100 * 17));
currEyeY = (int) (viewHeight / 100 * 25);
break;
case 4:
currEyeLX = (viewWidth / 2) - (viewWidth / 100 * 19);
currEyeRX = (viewWidth / 2) + (viewWidth / 100 * 19);
currEyeY = (viewHeight / 100 * 22);
currEyeLX = (int) ((viewWidth / 2) - (viewWidth / 100 * 19));
currEyeRX = (int) ((viewWidth / 2) + (viewWidth / 100 * 19));
currEyeY = (int) (viewHeight / 100 * 22);
break;
}

Expand Down Expand Up @@ -153,7 +147,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawArc(faceBgOval, 0, 180, true, paint);


switch (whatToDraw) {
switch ((int) whatToDraw) {
case 0:
drawAwfulFace(canvas);
break;
Expand Down Expand Up @@ -334,24 +328,24 @@ public void setSmiley(float rating) {
}
}

private void startEyesAnimation(int... newPositions) {
private void startEyesAnimation(float... newPositions) {

leftEyeAnimatorX.setIntValues(currEyeLX, newPositions[0]);
leftEyeAnimatorX.setIntValues(currEyeLX, (int) newPositions[0]);
leftEyeAnimatorX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
currEyeLX = (int) animation.getAnimatedValue();
invalidate();
}
});
rightEyeAnimatorX.setIntValues(currEyeRX, newPositions[1]);
rightEyeAnimatorX.setIntValues(currEyeRX, (int) newPositions[1]);
rightEyeAnimatorX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
currEyeRX = (int) animation.getAnimatedValue();
}
});
eyesAnimatorY.setIntValues(currEyeY, newPositions[2]);
eyesAnimatorY.setIntValues(currEyeY, (int) newPositions[2]);
eyesAnimatorY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.verNANDo57.rulebook_educational.rules;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.webkit.WebView;

import androidx.annotation.NonNull;

import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
Expand All @@ -15,8 +22,6 @@
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.tools.Utils;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppLexiconActivity extends CustomThemeEngineAppCompatActivity {

public String lexiconfile = "lexicon.html";
Expand Down Expand Up @@ -99,4 +104,14 @@ public void onScrollChanged() {
}
});
}

//Prevent system font-size managment from affecting to webview font size
@Override
protected void attachBaseContext(@NonNull Context newBase) {
super.attachBaseContext(newBase);
final Configuration override = new Configuration(newBase.getResources().getConfiguration());
override.fontScale = 1.0f;
applyOverrideConfiguration(override);
Log.i(LOG_TAG,"WEBVIEW fontScale now is 1.0f");
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.verNANDo57.rulebook_educational.rules;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.webkit.WebView;

import androidx.annotation.NonNull;

import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
Expand All @@ -15,8 +22,6 @@
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.tools.Utils;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppRulesInSchemesAndTablesActivity extends CustomThemeEngineAppCompatActivity {

public String simplewaytolearninfile = "simplewaytolearn.html";
Expand Down Expand Up @@ -99,4 +104,14 @@ public void onScrollChanged() {
}
});
}

//Prevent system font-size managment from affecting to webview font size
@Override
protected void attachBaseContext(@NonNull Context newBase) {
super.attachBaseContext(newBase);
final Configuration override = new Configuration(newBase.getResources().getConfiguration());
override.fontScale = 1.0f;
applyOverrideConfiguration(override);
Log.i(LOG_TAG,"WEBVIEW fontScale now is 1.0f");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.verNANDo57.rulebook_educational.rules.analyze_methods;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
Expand All @@ -15,8 +17,6 @@
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.rules.AppExtraBooleans;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

@SuppressLint("InflateParams")
public class AppAnalyzeMethods extends CustomThemeEngineAppCompatActivity {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.verNANDo57.rulebook_educational.rules.analyze_methods;

import android.annotation.SuppressLint;
import android.content.res.AssetManager;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -35,13 +33,8 @@

import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppAnalyzeMethodsScrollableActivity extends CustomThemeEngineAppCompatActivity {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.verNANDo57.rulebook_educational.rules.dictionaries;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
Expand All @@ -15,8 +17,6 @@
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.rules.AppExtraBooleans;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppDictionaries extends CustomThemeEngineAppCompatActivity {
RulebookApplicationSharedPreferences preferences;
private AppExtraBooleans booleansInMainRules;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.verNANDo57.rulebook_educational.rules.dictionaries;

import android.annotation.SuppressLint;
import android.content.res.AssetManager;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -35,13 +33,8 @@

import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

public class AppDictionariesScrollableActivity extends CustomThemeEngineAppCompatActivity {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.verNANDo57.rulebook_educational.rules.mainrules;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;

import android.os.Bundle;
import android.view.View;

Expand All @@ -13,8 +15,6 @@
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.rules.mainrules.adapter.CustomPagerAdapter;

import static com.verNANDo57.rulebook_educational.tools.Utils.LOG_TAG;


public class AppMainRulesActivity extends CustomThemeEngineAppCompatActivity
{
Expand Down
Loading

0 comments on commit 272ed50

Please sign in to comment.