Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to android x and updated target version #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you'd need a new library? Also, I had some additions in my fork of the EazeGraph lib, is there any specific reason to change to this other version of the lib?

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()
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.enableJetifier=true
android.useAndroidX=true
92 changes: 52 additions & 40 deletions src/fdroid/java/de/j4velin/pedometer/ui/Activity_Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -84,50 +86,60 @@ 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,
Uri.parse("http://j4velin.de/faq/index.php?app=pm"))
.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();
}
}
2 changes: 1 addition & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<activity
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/de/j4velin/pedometer/ui/Fragment_Overview.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ public void onClick(final View view) {
}
});

pg.setDrawValueInPie(false);
pg.setUsePieRotation(true);
pg.setUseInnerValue(false);
pg.setRotation(360);

pg.startAnimation();
return v;
}

@Override
public void onResume() {
super.onResume();
getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);
// getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);

Database db = Database.getInstance(getActivity());

Expand Down
37 changes: 18 additions & 19 deletions src/main/res/layout/fragment_overview.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
tools:context=".Activity_Main">
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">

<org.eazegraph.lib.charts.PieChart
xmlns:eaze="http://schemas.android.com/apk/res-auto"
android:id="@+id/graph"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp"
eaze:egLegendHeight="0dp"
eaze:egHighlightStrength="1"
eaze:egInnerPadding="75"
eaze:egHighlightStrength="1"/>
eaze:egLegendHeight="0dp" />

<TextView
android:id="@+id/steps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="75dp"
android:gravity="center"
android:textSize="45sp"
android:text="10.000"/>
android:text="10.000"
android:textSize="45sp" />

<TextView
android:id="@+id/unit"
Expand All @@ -31,14 +31,14 @@
android:layout_below="@+id/steps"
android:layout_centerHorizontal="true"
android:text="@string/steps"
android:textSize="20sp"/>
android:textSize="20sp" />

<LinearLayout
android:id="@+id/averageandtotal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/graph"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp">

<TextView
Expand All @@ -48,7 +48,7 @@
android:layout_weight="1"
android:gravity="center_horizontal"
android:textSize="20sp"
android:textStyle="bold"/>
android:textStyle="bold" />

<TextView
android:id="@+id/total"
Expand All @@ -57,7 +57,7 @@
android:layout_weight="1"
android:gravity="center_horizontal"
android:textSize="20sp"
android:textStyle="bold"/>
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
Expand All @@ -71,24 +71,23 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="@string/average"/>
android:text="@string/average" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="@string/total"/>
android:text="@string/total" />
</LinearLayout>

<org.eazegraph.lib.charts.BarChart
xmlns:eaze="http://schemas.android.com/apk/res-auto"
<org.eazegraph.lib.charts.BarChart xmlns:eaze="http://schemas.android.com/apk/res-auto"
android:id="@+id/bargraph"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_below="@+id/averageandtotaltext"
android:layout_marginTop="50dp"
eaze:egLegendHeight="35dp"
eaze:egShowValues="true"/>
eaze:egShowValues="true" />

</RelativeLayout>
9 changes: 9 additions & 0 deletions src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#ff42959a</color>
<color name="colorPrimaryDark">#ff42959a</color>
<color name="colorAccent">#ff42959a</color>
<color name="corner">#357CA5</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
</resources>
26 changes: 26 additions & 0 deletions src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="AppTheme.WhiteAccent">
<item name="colorAccent">@color/white</item> <!-- Whatever color you want-->
</style>


</resources>