Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhamTyagi committed Feb 2, 2019
1 parent ba5925b commit 9666788
Show file tree
Hide file tree
Showing 48 changed files with 1,073 additions and 281 deletions.
73 changes: 73 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
17 changes: 6 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

/*
def keystorePropertiesFile = rootProject.file("keystore.properties")
Expand All @@ -50,8 +50,8 @@ android {
applicationId "ai.loko.hk.ui"
minSdkVersion 19 //19
targetSdkVersion 28
versionCode 26
versionName '2.2.1'
versionCode 27
versionName '2.2.2'
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionNameSuffix '-capybara'
Expand Down Expand Up @@ -102,14 +102,9 @@ dependencies {
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

implementation 'com.google.android.gms:play-services-vision:17.0.2'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
transitive = true;
}

def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
Expand Down Expand Up @@ -137,4 +132,4 @@ dependencies {
gradle.taskGraph.whenReady {
setOutputName
}*/
apply plugin: 'com.google.gms.google-services'

16 changes: 1 addition & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<application
android:name="ai.loko.hk.ui.MyApplication"
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down Expand Up @@ -90,20 +90,6 @@
android:name="android.accessibilityservice"
android:resource="@xml/accessibilty"/>
</service>
<service android:name="ai.loko.hk.ui.notification.MyNotificationService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="ai.loko.hk.ui.notification.IDReceiver">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>

<meta-data
android:name="io.fabric.ApiKey"
android:value="87d0d959fa9b880a5f2cfed1a1707f4a6c41504e"/>

<activity
android:name="ai.loko.hk.ui.activities.SettingsActivity"
Expand Down
97 changes: 11 additions & 86 deletions app/src/main/java/ai/loko/hk/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
import android.widget.TextView;
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
import com.nightonke.boommenu.BoomButtons.ButtonPlaceEnum;
import com.nightonke.boommenu.BoomButtons.HamButton;
import com.nightonke.boommenu.BoomButtons.OnBMClickListener;
Expand All @@ -70,36 +64,30 @@

import ai.loko.hk.ui.activities.ProfileActivity;
import ai.loko.hk.ui.activities.SettingsActivity;
import ai.loko.hk.ui.activities.TestActivity;
import ai.loko.hk.ui.constants.Constant;
import ai.loko.hk.ui.data.Data;
import ai.loko.hk.ui.services.Floating;
import ai.loko.hk.ui.services.OCRFloating;
import ai.loko.hk.ui.utils.Logger;
import cn.pedant.SweetAlert.SweetAlertDialog;
import io.fabric.sdk.android.Fabric;
import ui.BuildConfig;
import ui.R;


public class MainActivity extends AppCompatActivity {

private final Handler mHandler = new Handler();
SharedPreferences sharedPref;
private FirebaseAnalytics mFirebaseAnalytics;

private Intent mFloatingIntent;
private Button mOverlayPermmissionBtn, mAccessibilityPermissionBtn, startStopBtn, ocrBtn;
private FirebaseRemoteConfig mFirebaseRemoteConfig;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_launcher);
setupActionBar();

Fabric.with(this, new Crashlytics());
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

mFloatingIntent = new Intent(MainActivity.this, Floating.class);
takeStoragePermission();

Expand Down Expand Up @@ -130,7 +118,7 @@ public void onClick(View view) {
}

givePermission();
getUpdate();


}

Expand Down Expand Up @@ -214,91 +202,27 @@ private void setupActionBar() {
@Override
public void onBoomButtonClick(int index) {
startActivity(new Intent(MainActivity.this, SettingsActivity.class));

}
}));
rightBmb.addBuilder(new HamButton.Builder().normalImageRes(R.drawable.ic_directions_run_black_24dp).subNormalText("Here you can test your question").normalText("Test your app").listener(new OnBMClickListener() {
@Override
public void onBoomButtonClick(int index) {
startActivity(new Intent(MainActivity.this, TestActivity.class));
}
}));

rightBmb.addBuilder(new HamButton.Builder().normalImageRes(R.drawable.ic_apps_black_24dp).subNormalText("Supported App that are currently working").normalText("Supported Apps").listener(new OnBMClickListener() {
@Override
public void onBoomButtonClick(int index) {
supportedApps();
}
}));
rightBmb.addBuilder(new HamButton.Builder().normalImageRes(R.drawable.ic_info_white_24dp).normalText("About").listener(new OnBMClickListener() {
rightBmb.addBuilder(new HamButton.Builder().normalImageRes(R.drawable.ic_info_white_24dp).normalText("About").subNormalText("About me").listener(new OnBMClickListener() {
@Override
public void onBoomButtonClick(int index) {
about();
}
}));
}

private void getUpdate() {

mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings;
if (Constant.DEBUG) {
configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
} else {
configSettings = new FirebaseRemoteConfigSettings.Builder()
.build();
}
mFirebaseRemoteConfig.setConfigSettings(configSettings);
mFirebaseRemoteConfig.setDefaults(R.xml.updates);
long cacheExpiration = 6 * 60 * 60;
if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
mFirebaseRemoteConfig.fetch(cacheExpiration).addOnCompleteListener(this, new OnCompleteListener<Void>() {
rightBmb.addBuilder(new HamButton.Builder().normalImageRes(R.drawable.ic_directions_run_black_24dp).subNormalText("Click here to go to github release page").normalText("Update.").listener(new OnBMClickListener() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful())
mFirebaseRemoteConfig.activateFetched();

public void onBoomButtonClick(int index) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/SubhamTyagi/loco-answers/releases/")));
}
});

int latest = Integer.valueOf(mFirebaseRemoteConfig.getString(Constant.LATEST));
if (latest - Constant.VERSION > 1) {

new SweetAlertDialog(this, SweetAlertDialog.NORMAL_TYPE)
.setTitleText("New update is available")
.setContentText("Kindly update the app, Some problems are fixed and accuracy is extremely improved and much more.. ")
.setConfirmText("Update now")
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sweetAlertDialog) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/SubhamTyagi/loco-answers/releases/")));
sweetAlertDialog.dismissWithAnimation();
}
}).show();
} else if (latest > Constant.VERSION) {
new SweetAlertDialog(this, SweetAlertDialog.NORMAL_TYPE)
.setTitleText("New update is available")
.setContentText("Kindly update the app, Some problems are fixed and accuracy is extremely improved and much more.. ")
.setConfirmText("Update now")
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sweetAlertDialog) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/SubhamTyagi/loco-answers/releases/")));

}
})
.setCancelText("Later")
.setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sweetAlertDialog) {
sweetAlertDialog.dismissWithAnimation();
}
})
.show();
}
}));
}

private boolean isServiceRunning(Class<?> serviceClass) {
Expand Down Expand Up @@ -427,7 +351,7 @@ protected void onResume() {
private void about() {
new SweetAlertDialog(this, SweetAlertDialog.NORMAL_TYPE)
.setTitleText("Trivia Hack VERSION " + Constant.VERSION_NAME)
.setContentText("Trivia Hack " + Constant.VERSION_NAME)
.setContentText("This app is free and open source hosted on GitHub")
.setConfirmText("Ok")
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
Expand All @@ -454,6 +378,7 @@ public void onClick(SweetAlertDialog sweetAlertDialog) {
}).show();
}


@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
//if ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import android.content.pm.PackageManager;
import android.media.projection.MediaProjectionManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
Expand Down Expand Up @@ -69,7 +70,7 @@
import ai.loko.hk.ui.ocr.Points;
import ai.loko.hk.ui.services.OCRFloating;
import cn.pedant.SweetAlert.SweetAlertDialog;
import io.fabric.sdk.android.services.concurrency.AsyncTask;

import ui.R;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
Expand All @@ -79,9 +80,12 @@ public class ProfileActivity extends AppCompatActivity implements ListItemSwipeL
private static final int storageReadPermission = 412;
private final String TAG = "ProfileActivity";
List<Profile> profiles = new ArrayList<>();

private CoordinatorLayout coordinatorLayout;

private RecyclerView mRecyclerView;
private ProfileAdapter mProfileAdapter;

private AppDatabase db;
private MediaProjectionManager mMediaProjectionManager;
private Intent mScreenshotIntent;
Expand Down Expand Up @@ -262,7 +266,7 @@ public void onClick(View view) {
}

private void setUpDataFromDB() {
new AsyncTask<Void, Void, Void>() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
List<ProfileEntity> profileEntities = db.profileDAO().getAll();
Expand Down
9 changes: 2 additions & 7 deletions app/src/main/java/ai/loko/hk/ui/constants/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,14 @@
import ui.BuildConfig;

public class Constant {
//TODO:why i am using this, Why not using BuildConfig "i don't know :)"
public static final int VERSION = 26;
public static final String VERSION_NAME = "2.2.1";
public static final boolean DEBUG = BuildConfig.DEBUG;

public static final String VERSION_NAME = "2.2.2";
public static final int CODE_DRAW_OVER_OTHER_APP_PERMISSION = 2084;
public static final int CODE_FOR_SCREEN_CAPTURE = 1349;
public static final String LATEST = "latest";

public static final String path = Environment.getExternalStorageDirectory() + "/TriviaHacK/";
public static final String pathToErrors = Environment.getExternalStorageDirectory() + "/TriviaHacK/errors";
public static final String pathToTesseract = Environment.getExternalStorageDirectory() + "/tesseract/tessdata/";
public static final String tesseractPath = Environment.getExternalStorageDirectory() + "/tesseract/";

public static final String X1_FLOAT = "X1_FLOAT";
public static final String X2_FLOAT = "X2_FLOAT";
public static final String Y1_FLOAT = "Y1_FLOAT";
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ai/loko/hk/ui/utils/CustomToast.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@

import ui.R;

public class CustomToast {
public class CustomToast {
private Context context = null;
private String msg;
private int duration=0;
private int duration = 0;

public CustomToast(Context context) {
this.context = context;
Expand Down
Loading

0 comments on commit 9666788

Please sign in to comment.