Skip to content

Commit

Permalink
app: introduce 1.0.5
Browse files Browse the repository at this point in the history
- code have been cleaned
- give UI better look
- remove useless stuff
- code have been optimized
- from now custom themes should work properly on Android R and above
- fix bugs while checking if storage access is granted
  • Loading branch information
verNANDo57 committed May 16, 2021
1 parent eca195a commit b95d754
Show file tree
Hide file tree
Showing 67 changed files with 480 additions and 806 deletions.
10 changes: 5 additions & 5 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 104
versionName '1.0.4'
versionCode 105
versionName '1.0.5'
multiDexEnabled true
}

Expand All @@ -34,8 +34,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility "1.8"
targetCompatibility "1.8"
}
dependenciesInfo {
includeInApk false
Expand All @@ -51,7 +51,7 @@ dependencies {
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.0'
}
repositories {
mavenCentral()
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.verNANDo57.rulebook_educational.for_pills">
package="com.verNANDo57.rulebook_educational.extradata">

<!-- <uses-permission android:name="android.permission.INTERNET" /> -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down Expand Up @@ -113,10 +113,5 @@
android:label="@string/label_theme_picker"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|navigation"/>

<activity
android:name="com.verNANDo57.rulebook_educational.tools.PermissionsCheck"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|navigation"
android:theme="@style/Theme.MaterialComponents.NoDisplay_Custom"/>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineAppCompatActivity;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.tools.Utils;

Expand Down Expand Up @@ -66,8 +64,10 @@ public void onClick(View v) {
}
});

//Press the title to view the bottomappbar
//TextViews
TextView app_about_title = findViewById(R.id.app_about_title);
TextView appaboutTextView2 = findViewById(R.id.appaboutTextView2);
appaboutTextView2.setText(getString(R.string.app_about_extended) + Utils.getApplicationVersionInfo(this, Utils.PACKAGEMANAGER_GET_APP_VERISON_NAME));

ScrollView about_scrollview = findViewById(R.id.about_scrollview);
about_scrollview.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import com.google.android.material.navigation.NavigationView;
import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineAppCompatActivity;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.rules.AppLexiconActivity;
import com.verNANDo57.rulebook_educational.rules.AppRulesInSchemesAndTablesActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.google.android.material.bottomappbar.BottomAppBar;
import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineAppCompatActivity;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.tools.Utils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import android.view.View;
import android.view.animation.DecelerateInterpolator;

import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;

public class AppRatingAgressiveVector extends View {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,21 @@

import com.verNANDo57.rulebook_educational.customthemeengine.CustomThemeEngine;
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.rules.RulebookBooleans;
import com.verNANDo57.rulebook_educational.rules.AppExtraBooleans;

public class AppRulebookClass extends Application {

RulebookApplicationSharedPreferences preferences;
RulebookBooleans booleansInMainRules;
AppExtraBooleans booleansInMainRules;

private static AppRulebookClass rulebookClass = null;

public static AppRulebookClass getInstance() {

if(rulebookClass == null)
{
rulebookClass = new AppRulebookClass();
}
return rulebookClass;
}
public void onCreate() {

//CustomThemeEngine.init
CustomThemeEngine.init(this, getResources());

//Load Preferences
preferences = new RulebookApplicationSharedPreferences(this);
booleansInMainRules = new RulebookBooleans(this);
booleansInMainRules = new AppExtraBooleans(this);

//TODO: Crash fix
booleansInMainRules.setRulebookMainRulesFragmentOpenedBoolean("null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.google.android.material.navigation.NavigationView;
import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineBottomSheetDialogFragment;
import com.verNANDo57.rulebook_educational.customthemeengine.utils.ColorUtils;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.preferences.AppSettingsActivity;
import com.verNANDo57.rulebook_educational.rules.dictionaries.AppDictionaries;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.google.android.material.navigation.NavigationView;
import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineBottomSheetDialogFragment;
import com.verNANDo57.rulebook_educational.customthemeengine.utils.ColorUtils;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.rules.AppRulesInSchemesAndTablesActivity;
import com.verNANDo57.rulebook_educational.rules.analyze_methods.AppAnalyzeMethods;
import com.verNANDo57.rulebook_educational.rules.mainrules.AppMainRulesActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;

import androidx.core.content.ContextCompat;

import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineAppCompatActivity;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.rules.dictionaries.AppDictionaries;
import com.verNANDo57.rulebook_educational.tools.PermissionsCheck;
import com.verNANDo57.rulebook_educational.tools.Utils;

public class MainActivity extends CustomThemeEngineAppCompatActivity
Expand Down Expand Up @@ -92,13 +88,6 @@ public void onClick(View v) {
app_exit();
}
});

//Check if needed permissions are granted (only if user use Android M or newer
if (Build.VERSION.SDK_INT >= 23) {
final Intent checkPermissions = new Intent(this, com.verNANDo57.rulebook_educational.tools.PermissionsCheck.class);
checkPermissions.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(checkPermissions);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,61 @@
/*
This app uses these permissions to save user needed rules as txt files:
android.permission.WRITE_EXTERNAL_STORAGE,
android.permission.READ_EXTERNAL_STORAGE,
android.permission.MANAGE_EXTERNAL_STORAGE
*/

package com.verNANDo57.rulebook_educational;

import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ProgressBar;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.verNANDo57.rulebook_educational.customthemeengine.app.CustomThemeEngineAppCompatActivity;
import com.verNANDo57.rulebook_educational.customthemeengine.utils.ColorUtils;
import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;
import com.verNANDo57.rulebook_educational.preferences.RulebookApplicationSharedPreferences;
import com.verNANDo57.rulebook_educational.tools.Utils;

import java.util.Arrays;

public class SplashScreenActivity extends CustomThemeEngineAppCompatActivity {
private static RulebookApplicationSharedPreferences preferences;

public static final int THREAD_SLEEP_TIME_MILLISECONDS = 1000;

public class SplashScreenActivity extends CustomThemeEngineAppCompatActivity
{
RulebookApplicationSharedPreferences preferences;
public static final int STORAGE_PERMISSION_CODE = 1;

public static final int PERMISSION_GRANTED = 0;
public static final int PERMISSION_DENIED = -1;

private ProgressBar Indicator1;
private ProgressBar Indicator2;
private ProgressBar Indicator3;

private final int totalProgressTime = 10;

public void onCreate(Bundle savedInstanceState)
{
preferences = new RulebookApplicationSharedPreferences(this);

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.app_strangescreen);
preferences = new RulebookApplicationSharedPreferences(this);

setContentView(R.layout.app_splashscreen);

int BackgroundTintColor = ColorUtils.lighter(getResources().getColor(R.color.coloraccent), 0.01f);

ImageView strangescreen_image = findViewById(R.id.strangescreen_image);
ImageView splashscreen_image = findViewById(R.id.splashscreen_image);

Indicator1 = findViewById(R.id.appSplashScreenProgressBar1); //Indicator1(ProgressBar1)
Indicator2 = findViewById(R.id.appSplashScreenProgressBar2); //Indicator2(ProgressBar2)
Expand All @@ -49,12 +73,12 @@ public void onCreate(Bundle savedInstanceState)
Indicator2.setMax(totalProgressTime);
Indicator3.setMax(totalProgressTime);

//Intent to MainActivity after splashscreen process ends
final Intent StrangeActivityEnd = new Intent(this, MainActivity.class);

//splashscreen process start
new Thread(new Runnable() {
public void run() {
//Can't create handler inside thread Thread that has not called Looper.prepare()
Looper.prepare();

int counter = 0;
while (counter < totalProgressTime) {
try {
Expand All @@ -64,14 +88,103 @@ public void run() {
Indicator2.setProgress(counter);
Indicator3.setProgress(counter);
} catch (InterruptedException e) {
Log.e(Utils.LOG_TAG, getString(R.string.app_error_occured));
e.printStackTrace();
}
}
startActivity(StrangeActivityEnd);
finish();
checkPermission();
}
}).start();
}


}

public void checkPermission() {
if (Build.VERSION.SDK_INT >= 30) {
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
preferences.setAppPermissionsAreGrantedBooleanState(false);

if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
createShouldShowRequestPermissionRationaleAlertDialogCompat();
} else {
requestPermissions(new String[]
{
Manifest.permission.MANAGE_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
},
STORAGE_PERMISSION_CODE);
}
} else {
preferences.setAppPermissionsAreGrantedBooleanState(true);
finishSplashScreenActivity();
}
} else if (Build.VERSION.SDK_INT >= 23 && Build.VERSION.SDK_INT <= 29) {
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
preferences.setAppPermissionsAreGrantedBooleanState(false);

if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
createShouldShowRequestPermissionRationaleAlertDialogCompat();
} else {
requestPermissions(new String[]
{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
},
STORAGE_PERMISSION_CODE);
}
} else {
preferences.setAppPermissionsAreGrantedBooleanState(true);
finishSplashScreenActivity();
}
}
}

public void createShouldShowRequestPermissionRationaleAlertDialogCompat(){
androidx.appcompat.app.AlertDialog.Builder builder = new androidx.appcompat.app.AlertDialog.Builder(this);
builder.setTitle(getString(R.string.app_warning));
builder.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_warning_outline));
builder.setMessage(getString(R.string.app_reason_why_these_permissions_are_needed));
builder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Re-request needed permissions
checkPermission();
}
});
builder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
finishSplashScreenActivity();
}
});
androidx.appcompat.app.AlertDialog alert = builder.create();
alert.setCancelable(false);
alert.setCanceledOnTouchOutside(false);
alert.show();
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == STORAGE_PERMISSION_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
preferences.setAppPermissionsAreGrantedBooleanState(true);
Log.w(Utils.LOG_TAG, Arrays.toString(permissions) + " - " + getString(R.string.app_granted));
finishSplashScreenActivity();
} else {
preferences.setAppPermissionsAreGrantedBooleanState(false);
Log.w(Utils.LOG_TAG, Arrays.toString(permissions) + " - " + getString(R.string.app_denied));
finishSplashScreenActivity();
}
}
}

private void finishSplashScreenActivity(){
startActivity(new Intent(this, MainActivity.class));
finish();
}

@Override
public void onResume() {
super.onResume();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import androidx.core.graphics.ColorUtils;

import com.verNANDo57.rulebook_educational.for_pills.R;
import com.verNANDo57.rulebook_educational.extradata.R;

class ColorPaletteAdapter extends BaseAdapter {

Expand Down
Loading

0 comments on commit b95d754

Please sign in to comment.