From a55a5908a0353af05df00dc6c7a5b274a7210335 Mon Sep 17 00:00:00 2001 From: Ashish Agatrao Pujari Date: Tue, 23 Jul 2019 21:11:24 +0530 Subject: [PATCH] migrate to android x and updated target version --- build.gradle | 13 +-- gradle.properties | 2 + .../j4velin/pedometer/ui/Activity_Main.java | 92 +++++++++++-------- src/main/AndroidManifest.xml | 2 +- .../pedometer/ui/Fragment_Overview.java | 7 +- src/main/res/layout/fragment_overview.xml | 37 ++++---- src/main/res/values/colors.xml | 9 ++ src/main/res/values/styles.xml | 26 ++++++ 8 files changed, 119 insertions(+), 69 deletions(-) create mode 100644 gradle.properties create mode 100644 src/main/res/values/colors.xml create mode 100644 src/main/res/values/styles.xml diff --git a/build.gradle b/build.gradle index 3ff741eb..88b29d00 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ android { buildToolsVersion rootProject.ext.buildToolsVersion } else { logger.warn('compileSdkVersion not found in rootProject') - compileSdkVersion = 27 + compileSdkVersion = 28 buildToolsVersion = "27.0.3" } @@ -81,13 +81,14 @@ repositories { } dependencies { - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.github.j4velin.colorpicker:colorpicker:1.20.6' - implementation 'com.github.j4velin.EazeGraph:EazeGraph:1.0.3' + implementation 'com.github.blackfizz:eazegraph:1.2.5l@aar' + implementation 'com.nineoldandroids:library:2.4.0' implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0' - playImplementation 'com.google.android.gms:play-services-fitness:15.0.1' - playImplementation 'com.google.android.gms:play-services-games:15.0.1' - playImplementation 'com.google.android.gms:play-services-identity:15.0.1' + playImplementation 'com.google.android.gms:play-services-fitness:17.0.0' + playImplementation 'com.google.android.gms:play-services-games:18.0.0' + playImplementation 'com.google.android.gms:play-services-identity:17.0.0' } def props = new Properties() diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..5465fec0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/src/fdroid/java/de/j4velin/pedometer/ui/Activity_Main.java b/src/fdroid/java/de/j4velin/pedometer/ui/Activity_Main.java index 353edc4b..212e2631 100644 --- a/src/fdroid/java/de/j4velin/pedometer/ui/Activity_Main.java +++ b/src/fdroid/java/de/j4velin/pedometer/ui/Activity_Main.java @@ -28,6 +28,7 @@ import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.content.PermissionChecker; +import android.support.v7.app.AppCompatActivity; import android.text.method.LinkMovementMethod; import android.view.MenuItem; import android.widget.TextView; @@ -36,7 +37,7 @@ import de.j4velin.pedometer.R; import de.j4velin.pedometer.SensorListener; -public class Activity_Main extends FragmentActivity { +public class Activity_Main extends AppCompatActivity { @Override protected void onCreate(final Bundle b) { @@ -46,10 +47,11 @@ protected void onCreate(final Bundle b) { // Create new fragment and transaction Fragment newFragment = new Fragment_Overview(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); - - // Replace whatever is in the fragment_container view with this - // fragment, - // and add the transaction to the back stack + /** + * Replace whatever is in the fragment_container view with this + * fragment, + * and add the transaction to the back stack + */ transaction.replace(android.R.id.content, newFragment); // Commit the transaction @@ -84,18 +86,7 @@ public boolean optionsItemSelected(final MenuItem item) { break; case R.id.action_leaderboard: case R.id.action_achievements: - AlertDialog.Builder builder2 = new AlertDialog.Builder(this); - builder2.setTitle("Google services required"); - builder2.setMessage( - "This feature is not available on the F-Droid version of the app"); - builder2.setNegativeButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - builder2.create().show(); + achievementsDialog(); break; case R.id.action_faq: startActivity(new Intent(Intent.ACTION_VIEW, @@ -103,31 +94,52 @@ public void onClick(DialogInterface dialog, int which) { .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; case R.id.action_about: - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.about); - TextView tv = new TextView(this); - tv.setPadding(10, 10, 10, 10); - tv.setText(R.string.about_text_links); - try { - tv.append(getString(R.string.about_app_version, - getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); - } catch (NameNotFoundException e1) { - // should not happen as the app is definitely installed when - // seeing the dialog - e1.printStackTrace(); - } - tv.setMovementMethod(LinkMovementMethod.getInstance()); - builder.setView(tv); - builder.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - @Override - public void onClick(final DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - builder.create().show(); + aboutDialog(); break; } return true; } + + private void achievementsDialog() { + AlertDialog.Builder builder2 = new AlertDialog.Builder(this); + builder2.setTitle("Google services required"); + builder2.setMessage( + "This feature is not available on the F-Droid version of the app"); + builder2.setNegativeButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder2.create().show(); + } + + private void aboutDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.about); + TextView tv = new TextView(this); + tv.setPadding(10, 10, 10, 10); + tv.setText(R.string.about_text_links); + try { + tv.append(getString(R.string.about_app_version, + getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); + } catch (NameNotFoundException e1) { + /** + * should not happen as the app is definitely installed when + * seeing the dialog + */ + e1.printStackTrace(); + } + tv.setMovementMethod(LinkMovementMethod.getInstance()); + builder.setView(tv); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + @Override + public void onClick(final DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.create().show(); + } } \ No newline at end of file diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index b57c74b1..941a0c53 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -23,7 +23,7 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" - android:theme="@android:style/Theme.DeviceDefault.Light.DarkActionBar" + android:theme="@style/AppTheme" tools:replace="label"> + xmlns:tools="http://schemas.android.com/tools" + xmlns:eaze="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="5dp" + tools:context=".ui.Activity_Main"> + eaze:egLegendHeight="0dp" /> + android:text="10.000" + android:textSize="45sp" /> + android:textSize="20sp" /> + android:textStyle="bold" /> + android:textStyle="bold" /> + android:text="@string/average" /> + android:text="@string/total" /> - + eaze:egShowValues="true" /> \ No newline at end of file diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml new file mode 100644 index 00000000..833dd5fa --- /dev/null +++ b/src/main/res/values/colors.xml @@ -0,0 +1,9 @@ + + + #ff42959a + #ff42959a + #ff42959a + #357CA5 + #ffffff + #000000 + diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml new file mode 100644 index 00000000..75dd0152 --- /dev/null +++ b/src/main/res/values/styles.xml @@ -0,0 +1,26 @@ + + + + + + + + + + +