Skip to content

Commit

Permalink
Solved bug #2 and completed extra #7. Added new libraries to "License…
Browse files Browse the repository at this point in the history
…" section
  • Loading branch information
Javinator9889 committed Mar 6, 2018
1 parent ff4e5c8 commit 91e8cee
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 14 deletions.
20 changes: 10 additions & 10 deletions app/build.gradle
Expand Up @@ -7,7 +7,7 @@ android {
applicationId "javinator9889.bitcoinpools"
minSdkVersion 21
targetSdkVersion 27
versionCode 41
versionCode 45
versionName "1.18-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand All @@ -31,27 +31,27 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-invites:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
compile 'com.android.support:preference-v14:27.0.2'
compile 'com.android.support:preference-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
compile 'com.android.support:preference-v14:27.1.0'
compile 'com.android.support:preference-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
compile 'ch.acra:acra:4.9.2'
implementation('com.mikepenz:aboutlibraries:6.0.2@aar') {
transitive = true
}
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:support-annotations:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:support-annotations:27.1.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.jpardogo.materialtabstrip:library:1.1.1'
compile 'com.google.firebase:firebase-core:11.8.0'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
Expand Down
27 changes: 24 additions & 3 deletions app/src/main/java/javinator9889/bitcoinpools/BitCoinApp.java
Expand Up @@ -17,11 +17,15 @@

import java.io.IOException;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

import javinator9889.bitcoinpools.BackgroundJobs.CacheJobSchedulerService;
Expand Down Expand Up @@ -76,10 +80,10 @@ private static void startBackgroundJobs() {
}

if (isJobCreationNeeded(mJobScheduler)) {
System.out.println("Creating job for cache - true");
//JobScheduler cacheJobScheduler = (JobScheduler) APPLICATION_CONTEXT.getSystemService(Context.JOB_SCHEDULER_SERVICE);
JobInfo.Builder cacheBuilder = new JobInfo.Builder(2, new ComponentName(APPLICATION_CONTEXT.getPackageName(), CacheJobSchedulerService.class.getName()));


cacheBuilder.setPeriodic(TimeUnit.DAYS.toMillis(1));
cacheBuilder.setPersisted(Constants.PERSISTED);
cacheBuilder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
Expand Down Expand Up @@ -143,14 +147,31 @@ public static boolean isJobCreationNeeded(JobScheduler applicationJobScheduler)
Iterator<JobInfo> currentPendingJob = pendingJobs.iterator();
boolean equals = false;
while (currentPendingJob.hasNext() && !equals) {
equals = currentPendingJob.next().toString().equals("job:2/javinator9889.bitcoinpools/.BackgroundJobs.CacheJobSchedulerService");
JobInfo pending = currentPendingJob.next();
equals = pending.toString().equals("(job:2/javinator9889.bitcoinpools/.BackgroundJobs.CacheJobSchedulerService)");
}
return !equals;
final long MILLIS_A_DAY = 86400000;
long timeDiff = timeDifference();
return timeDiff >= MILLIS_A_DAY && !equals;
//return (timeDifference() >= MILLIS_A_DAY) || !equals;
} else {
SharedPreferences.Editor newEntry = SHARED_PREFERENCES.edit();
newEntry.putBoolean(Constants.SHARED_PREFERENCES.CACHE_JOB, false);
newEntry.apply();
return true;
}
}

private static long timeDifference() {
CacheManaging cache = CacheManaging.newInstance(APPLICATION_CONTEXT);
try {
HashMap<String, String> cachedValues = cache.readCache();
String date = cachedValues.get("date");
DateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.US);
Date dateInCache = format.parse(date);
return (Calendar.getInstance().getTime().getTime() - dateInCache.getTime());
} catch (Exception e) {
return Long.MAX_VALUE;
}
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/javinator9889/bitcoinpools/License.java
Expand Up @@ -45,6 +45,14 @@ protected void onCreate(Bundle savedInstanceState) {
.withAutoDetect(true)
.withAboutDescription(getString(R.string.bitcoindesc))
.withLicenseDialog(true)
.withLibraries(getString(R.string.library_donations_libraryName))
/*.withLibraryModification("Donations", Libs.LibraryFields.LIBRARY_NAME, "Donations")
.withLibraryModification("Donations", Libs.LibraryFields.LIBRARY_DESCRIPTION,
"Android Donations Lib supports donations by Google Play Store, Flattr, PayPal, and Bitcoin.")
.withLibraryModification("Donations", Libs.LibraryFields.LICENSE_NAME, getString(R.string.license_Apache_2_0_licenseName))
.withLibraryModification("Donations", Libs.LibraryFields.AUTHOR_NAME, "PrivacyApps")
.withLibraryModification("Donations", Libs.LibraryFields.LIBRARY_REPOSITORY_LINK, "https://github.com/PrivacyApps/donations")
.withLibraryModification("Donations", Libs.LibraryFields.LIBRARY_VERSION, "2.5")*/
.supportFragment();

FragmentManager fragmentManager = getSupportFragmentManager();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_loading.xml
Expand Up @@ -26,6 +26,7 @@
android:layout_marginBottom="44dp"
android:layout_marginStart="20dp"
android:text="@string/loadingData"
android:textColor="#FAFAFA"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/progressBar2" />
</android.support.constraint.ConstraintLayout>
4 changes: 3 additions & 1 deletion app/src/main/res/layout/bitcoindata.xml
Expand Up @@ -67,8 +67,10 @@
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include" />
app:layout_constraintTop_toBottomOf="@+id/include"
app:layout_constraintVertical_bias="0.0" />

</android.support.constraint.ConstraintLayout>

Expand Down
21 changes: 21 additions & 0 deletions app/src/main/res/values/aboutlibraries_donations.xml
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="define_int_donations"></string>
<!-- Author section -->
<string name="library_donations_author">PrivacyApps</string>
<string name="library_donations_authorWebsite">https://github.com/PrivacyApps/</string>
<!-- Library section -->
<string name="library_donations_libraryName">Donations</string>
<string name="library_donations_libraryDescription">Android Donations Lib supports donations by Google Play Store, Flattr, PayPal, and Bitcoin.</string>
<string name="library_donations_libraryWebsite">https://github.com/PrivacyApps/donations</string>
<string name="library_donations_libraryVersion">2.5</string>
<!-- OpenSource section -->
<string name="library_donations_isOpenSource">true</string>
<string name="library_donations_repositoryLink">https://github.com/PrivacyApps/donations</string>
<!-- ClassPath for autoDetect section -->
<string name="library_donations_classPath"></string>
<!-- License section -->
<string name="library_donations_licenseId">apache_2_0</string>
<!-- Custom variables section -->
</resources>

0 comments on commit 91e8cee

Please sign in to comment.