Skip to content

Commit

Permalink
Updated UptadeChecker. Included now links to Play Store
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Mar 5, 2018
1 parent 171d725 commit c085b61
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -7,7 +7,7 @@ android {
applicationId "javinator9889.bitcoinpools"
minSdkVersion 21
targetSdkVersion 27
versionCode 40
versionCode 41
versionName "1.18-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Binary file modified app/debug/app-debug.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/debug/output.json
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":40},"path":"app-debug.apk","properties":{"packageId":"javinator9889.bitcoinpools","split":"","minSdkVersion":"21"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":41},"path":"app-debug.apk","properties":{"packageId":"javinator9889.bitcoinpools","split":"","minSdkVersion":"21"}}]
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -19,8 +19,9 @@
android:theme="@style/CustomTheme">
<activity
android:name=".DataLoaderScreen"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:configChanges=
"screenSize|smallestScreenSize|screenLayout|orientation"
android:theme="@style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -30,8 +31,8 @@
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:configChanges="orientation">
</activity>
<activity
android:name=".License"
Expand Down
@@ -1,6 +1,7 @@
package javinator9889.bitcoinpools.AppUpdaterManager;

import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -39,7 +40,7 @@ public class CheckUpdates {
private static JSONArray RETRIEVED_DATA;
private static String LATEST_VERSION;
private static String DOWNLOAD_URL = null;
private static String MORE_INFO;
private static String MORE_INFO = "https://play.google.com/store/apps/details?id=com.fastaccess.github";
private static String APK_NAME;
private static boolean HTML_PAGE = false;

Expand All @@ -54,17 +55,17 @@ public CheckUpdates(@NonNull String GitHub_User, @NonNull String GitHub_Repo) {
}

public void checkForUpdates(final Context dialogContext, String title, String description, String positiveText, String negativeText, String neutralText) {
if (!APP_VERSION.equals(LATEST_VERSION) && (Float.parseFloat(APP_VERSION) < Float.parseFloat(LATEST_VERSION))) {
if (!APP_VERSION.equals(LATEST_VERSION)) {// && (Float.parseFloat(APP_VERSION) < Float.parseFloat(LATEST_VERSION))) {
Log.d(Constants.LOG.CTAG, Constants.LOG.NEW_VERSION + APP_VERSION + " | " + LATEST_VERSION);
MaterialDialog materialDialog;
if (!HTML_PAGE) {
Log.d(Constants.LOG.CTAG, Constants.LOG.DOW_NOTIFICATION);
materialDialog = new MaterialDialog.Builder(dialogContext)
.title(title)
.content(description)
.positiveText(positiveText)
//.positiveText(positiveText)
.negativeText(negativeText)
.neutralText(neutralText)
.neutralText(positiveText)
.cancelable(false)
.onAny(new MaterialDialog.SingleButtonCallback() {
@Override
Expand All @@ -82,9 +83,15 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
manager.enqueue(downloadRequest);
break;
case NEUTRAL:
Uri webUri = Uri.parse(MORE_INFO);
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, webUri);
dialogContext.startActivity(launchBrowser);
try {
Uri webUri = Uri.parse("market://details?id=com.fastaccess.github");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, webUri);
dialogContext.startActivity(launchBrowser);
} catch (ActivityNotFoundException e) {
Uri webUri = Uri.parse(MORE_INFO);
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, webUri);
dialogContext.startActivity(launchBrowser);
}
break;
case NEGATIVE:
dialog.dismiss();
Expand Down Expand Up @@ -145,7 +152,7 @@ private void getData() {
if (DOWNLOAD_URL == null) {
HTML_PAGE = true;
}
MORE_INFO = RETRIEVED_DATA.getJSONObject(i).getString("html_url");
//MORE_INFO = RETRIEVED_DATA.getJSONObject(i).getString("html_url");
}
}
} catch (InterruptedException | ExecutionException | JSONException | NullPointerException e) {
Expand Down
38 changes: 33 additions & 5 deletions app/src/main/java/javinator9889/bitcoinpools/MainActivity.java
Expand Up @@ -2,9 +2,11 @@

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.PictureInPictureParams;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
Expand All @@ -20,6 +22,7 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.Rational;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
Expand Down Expand Up @@ -59,6 +62,7 @@
public class MainActivity extends AppCompatActivity {
@SuppressLint("StaticFieldLeak")
public static Toolbar MAINACTIVITY_TOOLBAR;
public static AppCompatActivity mainActivity;

private float mpu;
private HashMap<String, Float> retrievedData;
Expand All @@ -72,6 +76,7 @@ public class MainActivity extends AppCompatActivity {
@SuppressWarnings("unchecked")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainActivity = this;
//if (BitCoinApp.isOnline()) {
Log.d(Constants.LOG.MATAG, Constants.LOG.CREATING_MAINVIEW);
setContentView(R.layout.activity_main);
Expand Down Expand Up @@ -116,7 +121,7 @@ protected void onCreate(Bundle savedInstanceState) {

Log.d(Constants.LOG.MATAG, Constants.LOG.INIT_VALUES);
//checkPermissions();
//CheckUpdates ck = new CheckUpdates(Constants.GITHUB_USER, Constants.GITHUB_REPO);
CheckUpdates ck = new CheckUpdates(Constants.GITHUB_USER, Constants.GITHUB_REPO);

SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
MAINACTIVITY_TOOLBAR = findViewById(R.id.toolbar);
Expand All @@ -133,7 +138,7 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(Constants.LOG.MATAG, Constants.LOG.CREATING_CHART);

Log.d(Constants.LOG.MATAG, Constants.LOG.LISTENING);
//ck.checkForUpdates(this, getString(R.string.updateAvailable), getString(R.string.updateDescrip), getString(R.string.updateNow), getString(R.string.updateLater), getString(R.string.updatePage));
ck.checkForUpdates(this, getString(R.string.updateAvailable), getString(R.string.updateDescrip), getString(R.string.updateNow), getString(R.string.updateLater), getString(R.string.updatePage));
//DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 10);
/*} else {
new MaterialDialog.Builder(this)
Expand All @@ -152,12 +157,35 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
}*/
}

/*@Override
public void onUserLeaveHint() {
if (Build.VERSION.SDK_INT >= 26) {
Rational aspectRatio = new Rational(1080, 1920);
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio);
enterPictureInPictureMode(builder.build());
} else {
super.onUserLeaveHint();
}
}
@Override
public void onPictureInPictureModeChanged(boolean isInPictureInPicture, Configuration newConfig) {
if (isInPictureInPicture)
this.moveTaskToBack(false);
else {
Intent restoreActivity = new Intent(MainActivity.this, MainActivity.class);
restoreActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(restoreActivity);
}
}*/

@Override
protected void onResume() {
super.onResume();
//DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 5);
//DataLoaderScreen.progressDialog.dismiss();
Toast.makeText(this, "Hi, the activity is fully loaded", Toast.LENGTH_LONG).show();
DataLoaderScreen.progressDialog.dismiss();
//Toast.makeText(this, "Hi, the activity is fully loaded", Toast.LENGTH_LONG).show();
DataLoaderScreen.dataLoaderScreenActivity.finish();
}

Expand Down Expand Up @@ -195,7 +223,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void run() {
Intent intentSettings = new Intent(MainActivity.this, SpinnerActivity.class);
startActivity(intentSettings);
MainActivity.this.finish();
//MainActivity.this.finish();
}
};
settingsThread.setName("settings_thread");
Expand Down
Expand Up @@ -120,11 +120,14 @@ public void onBackPressed() {
Toast.makeText(this, R.string.prefUpdated, Toast.LENGTH_LONG).show();
if (NEW_VALUE_ENABLED && !ACTUAL_ENABLED)
BitCoinApp.forceRestartBackgroundJobs();
refresh();
}
refresh();
//refresh();
super.onBackPressed();
}

private void refresh() {
MainActivity.mainActivity.finish();
Intent intentMain = new Intent(SpinnerActivity.this, DataLoaderScreen.class);
intentMain.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intentMain);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/bitcoindata.xml
Expand Up @@ -60,6 +60,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:alpha=".7"
android:drawablePadding="8dp"
android:drawableStart="@drawable/ic_info_outline_black_18dp"
android:text=""
android:textAlignment="center"
Expand Down

0 comments on commit c085b61

Please sign in to comment.