Merge pull request 'Upgrade Android Version' (#1) from dev into main
Reviewed-on: #1
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
# android-hypergames
|
||||
|
||||
Games written for fun to practice Android programming and animation.
|
||||
|
@@ -1,14 +1,14 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion "24.0.2"
|
||||
namespace "com.hyperling.apps.games"
|
||||
compileSdkVersion 36
|
||||
defaultConfig {
|
||||
applicationId "apps.hyperling.com.platformer"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 24
|
||||
versionCode 10
|
||||
versionName "0.9"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 36
|
||||
versionCode 11
|
||||
versionName "0.0.10"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
@@ -20,11 +20,19 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
/*
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
compile 'com.android.support:appcompat-v7:24.2.1'
|
||||
compile 'com.google.android.gms:play-services-ads:9.8.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
*/
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
// https://mvnrepository.com/artifact/com.android.support/appcompat-v7
|
||||
implementation group: 'com.android.support', name: 'appcompat-v7', version: '28.0.0'
|
||||
}
|
||||
|
@@ -1,26 +0,0 @@
|
||||
package com.hyperling.apps.games;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumentation test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("apps.hyperling.com.platformer", appContext.getPackageName());
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.hyperling.apps.games">
|
||||
|
||||
<!-- Include required permissions for Google Mobile Ads to run. -->
|
||||
@@ -9,21 +10,17 @@
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/icon"
|
||||
android:roundIcon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
|
||||
<!-- android:configChanges="orientation|keyboardHidden|screenSize" -->
|
||||
|
||||
<!-- This meta-data tag is required to use Google Play Services. -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
|
||||
<activity android:name="com.hyperling.apps.games.MainActivity">
|
||||
<activity android:name="com.hyperling.apps.games.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
@@ -1,36 +0,0 @@
|
||||
package com.hyperling.apps.games;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
import com.google.android.gms.ads.MobileAds;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/26/16.
|
||||
*/
|
||||
|
||||
public class AdsHelper {
|
||||
|
||||
// To be called in onResume in Activities
|
||||
public static void toggleAds(SharedPreferences sharedPreferences, String adsKey, Context applicationContext, AdView mAdView){
|
||||
// Enable ads?
|
||||
boolean adsEnabled = sharedPreferences.getBoolean(adsKey, false);
|
||||
if (adsEnabled) {
|
||||
mAdView.setVisibility(View.VISIBLE);
|
||||
MobileAds.initialize(applicationContext, "ca-app-pub-3940256099942544~3347511713");
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("C6A494DC6E7C9AC29102694D48487084") // Nexus 7
|
||||
.addTestDevice("6545BCC9B60A394005546783687339B7") // Moto G
|
||||
.build();
|
||||
mAdView.loadAd(adRequest);
|
||||
}
|
||||
else{
|
||||
mAdView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -7,11 +7,9 @@ import android.util.Log;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
public class HighScoreActivity extends AppCompatActivity {
|
||||
|
||||
private String sharedPreferencesKey, adsKey, TAG, html;
|
||||
private String sharedPreferencesKey, TAG, html;
|
||||
private String[] allBirdScoreKeys, allChickenScoreKeys;
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -29,7 +27,6 @@ public class HighScoreActivity extends AppCompatActivity {
|
||||
sharedPreferencesKey = getString(R.string.sharedPreferencesKey);
|
||||
allBirdScoreKeys = getResources().getStringArray(R.array.allBirdScoreKeys);
|
||||
allChickenScoreKeys = getResources().getStringArray(R.array.allChickenScoreKeys);
|
||||
adsKey = getString(R.string.adsKey);
|
||||
|
||||
// Shared preferences
|
||||
sharedPreferences = getSharedPreferences(sharedPreferencesKey, MODE_PRIVATE);
|
||||
@@ -89,7 +86,6 @@ public class HighScoreActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
leaderboardHelper = new LeaderboardHelper();
|
||||
displayAds();
|
||||
super.onResume();
|
||||
|
||||
Runnable getHTML = new Runnable() {
|
||||
@@ -106,10 +102,6 @@ public class HighScoreActivity extends AppCompatActivity {
|
||||
Log.d(TAG, "HighScoreActivity.onResume() html=" + html);
|
||||
}
|
||||
|
||||
private void displayAds(){
|
||||
AdsHelper.toggleAds(sharedPreferences, adsKey, getApplicationContext(), (AdView) findViewById(R.id.adViewHighScores));
|
||||
}
|
||||
|
||||
private boolean isNumeric(char c){
|
||||
try{
|
||||
String s = "" + c;
|
||||
|
@@ -8,13 +8,11 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private Button btnGameBird, btnGameCow, btnGamePig, btnGameChicken, btnGameCat, btnGameSquirrel, btnOptions, btnHighScores, btnHelp;
|
||||
|
||||
private String TAG, sharedPreferencesKey, adsKey, birdScoreKey, chickenScoreKey;
|
||||
private String TAG, sharedPreferencesKey, birdScoreKey, chickenScoreKey;
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
@@ -28,7 +26,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
// Keys
|
||||
sharedPreferencesKey = getString(R.string.sharedPreferencesKey);
|
||||
adsKey = getString(R.string.adsKey);
|
||||
birdScoreKey = getString(R.string.birdScoreKey);
|
||||
chickenScoreKey = getString(R.string.chickenScoreKey);
|
||||
|
||||
@@ -101,8 +98,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
displayAds();
|
||||
|
||||
// Append high scores to button text
|
||||
int score;
|
||||
String newText;
|
||||
@@ -160,10 +155,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(options);
|
||||
}
|
||||
|
||||
private void displayAds(){
|
||||
AdsHelper.toggleAds(sharedPreferences, adsKey, getApplicationContext(), (AdView) findViewById(R.id.adViewMain));
|
||||
}
|
||||
|
||||
private void doHighScoresButton(){
|
||||
Intent highScores = new Intent(MainActivity.this, HighScoreActivity.class);
|
||||
startActivity(highScores);
|
||||
|
@@ -10,23 +10,19 @@ import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
import com.google.android.gms.ads.MobileAds;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/22/16.
|
||||
*/
|
||||
|
||||
public class OptionsActivity extends AppCompatActivity {
|
||||
|
||||
private String sharedPreferencesKey, adsKey, higherQualityKey, fpsKey;
|
||||
private String sharedPreferencesKey, higherQualityKey, fpsKey;
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
private RelativeLayout layoutAds, layoutHigherQuality, layoutFPS;
|
||||
private CheckBox cbAds, cbHigherQuality, cbFPS;
|
||||
private boolean adsEnabled, higherQualityEnabled, fpsEnabled;
|
||||
private RelativeLayout layoutHigherQuality, layoutFPS;
|
||||
private CheckBox cbHigherQuality, cbFPS;
|
||||
private boolean higherQualityEnabled, fpsEnabled;
|
||||
|
||||
private Button btnDeletePreferences, btnConfirmDeletePreferences;
|
||||
|
||||
@@ -42,24 +38,6 @@ public class OptionsActivity extends AppCompatActivity {
|
||||
sharedPreferencesKey = getString(R.string.sharedPreferencesKey);
|
||||
sharedPreferences = getSharedPreferences(sharedPreferencesKey, MODE_PRIVATE);
|
||||
|
||||
// Set up Ads
|
||||
adsKey = getString(R.string.adsKey);
|
||||
layoutAds = (RelativeLayout) findViewById(R.id.optionAdsLayout);
|
||||
cbAds = (CheckBox) findViewById(R.id.optionAdsCheckBox);
|
||||
layoutAds.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
flipOption(adsKey);
|
||||
}
|
||||
});
|
||||
cbAds.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
flipOption(adsKey);
|
||||
}
|
||||
});
|
||||
setAds();
|
||||
|
||||
// Higher Quality Content
|
||||
higherQualityKey = getString(R.string.higherQualityKey);
|
||||
layoutHigherQuality = (RelativeLayout) findViewById(R.id.optionHigherQualityLayout);
|
||||
@@ -123,10 +101,7 @@ public class OptionsActivity extends AppCompatActivity {
|
||||
editor.apply();
|
||||
|
||||
// Change the box
|
||||
if (key.equals(adsKey)){
|
||||
setAds();
|
||||
}
|
||||
else if (key.equals(higherQualityKey)){
|
||||
if (key.equals(higherQualityKey)){
|
||||
setHigherQuality();
|
||||
}
|
||||
else if (key.equals(fpsKey)){
|
||||
@@ -134,31 +109,6 @@ public class OptionsActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void setAds(){
|
||||
adsEnabled = sharedPreferences.getBoolean(adsKey, false);
|
||||
cbAds.setChecked(adsEnabled);
|
||||
toggleAds();
|
||||
}
|
||||
|
||||
private void toggleAds(){
|
||||
// Enable ads?
|
||||
adsEnabled = sharedPreferences.getBoolean(adsKey, false);
|
||||
AdView mAdView = (AdView) findViewById(R.id.adViewOptions);
|
||||
if (adsEnabled) {
|
||||
mAdView.setVisibility(View.VISIBLE);
|
||||
MobileAds.initialize(getApplicationContext(), "ca-app-pub-3940256099942544~3347511713");
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("C6A494DC6E7C9AC29102694D48487084") // Nexus 7
|
||||
.addTestDevice("6545BCC9B60A394005546783687339B7") // Moto G
|
||||
.build();
|
||||
mAdView.loadAd(adRequest);
|
||||
}
|
||||
else{
|
||||
mAdView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHigherQuality() {
|
||||
higherQualityEnabled = sharedPreferences.getBoolean(higherQualityKey, false);
|
||||
cbHigherQuality.setChecked(higherQualityEnabled);
|
||||
|
@@ -9,25 +9,16 @@
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:layout_marginTop="?android:actionBarSize"
|
||||
tools:context="com.hyperling.apps.games.HighScoreActivity">
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adViewHighScores"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="gone"
|
||||
ads:adSize="BANNER"
|
||||
ads:adUnitId="@string/interstitial_ad_unit_id_high_score" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollViewHighScore"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_above="@+id/adViewHighScores">
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -9,25 +9,16 @@
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:layout_marginTop="?android:actionBarSize"
|
||||
tools:context="com.hyperling.apps.games.MainActivity">
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adViewMain"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="gone"
|
||||
ads:adSize="BANNER"
|
||||
ads:adUnitId="@string/interstitial_ad_unit_id_main" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollViewMain"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_above="@+id/adViewMain">
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@@ -10,23 +10,14 @@
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:layout_marginTop="?android:actionBarSize"
|
||||
tools:context="com.hyperling.apps.games.OptionsActivity">
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adViewOptions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:visibility="gone"
|
||||
ads:adSize="BANNER"
|
||||
ads:adUnitId="@string/interstitial_ad_unit_id_options" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollViewOptions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/adViewOptions"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_alignParentTop="true">
|
||||
|
||||
@@ -35,6 +26,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!--
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -77,6 +69,7 @@
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/spaceSize" />
|
||||
-->
|
||||
|
||||
<TextView
|
||||
android:text="@string/optionGroupInGame"
|
||||
|
@@ -36,7 +36,6 @@
|
||||
<string name="optionGroupOnline">Online</string>
|
||||
<string name="optionGroupOther">Other</string>
|
||||
|
||||
<string name="optionAds">Allow Ads on Menu Screens?</string>
|
||||
<string name="optionPracticeRound">Play Practice Round when Starting New Games?</string>
|
||||
<string name="optionHigherQuality">Allow Higher Quality Images and Animations?</string>
|
||||
<string name="optionFPS">Display FPS?</string>
|
||||
@@ -52,7 +51,6 @@
|
||||
<!-- Shared Preferences -->
|
||||
<string name="sharedPreferencesKey">HyperGames</string>
|
||||
<!-- Options -->
|
||||
<string name="adsKey">Ads</string>
|
||||
<string name="practiceRoundKey">Practice</string>
|
||||
<string name="higherQualityKey">HigherQuality</string>
|
||||
<string name="fpsKey">FPS</string>
|
||||
@@ -82,11 +80,4 @@
|
||||
<item>ChickenScore008(Alpha)</item>
|
||||
</string-array>
|
||||
|
||||
<!-- -
|
||||
This is an ad unit ID for an interstitial test ad. Replace with your own interstitial ad unit id.
|
||||
For more information, see https://support.google.com/admob/answer/3052638
|
||||
<!- -->
|
||||
<string name="interstitial_ad_unit_id_main">ca-app-pub-9712416021907617/7877767281</string>
|
||||
<string name="interstitial_ad_unit_id_options">ca-app-pub-9712416021907617/3307966880</string>
|
||||
<string name="interstitial_ad_unit_id_high_score">ca-app-pub-9712416021907617/4784700088</string>
|
||||
</resources>
|
||||
|
@@ -1,17 +0,0 @@
|
||||
package com.hyperling.apps.games;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
14
build.gradle
14
build.gradle
@@ -2,11 +2,18 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
google()
|
||||
maven {
|
||||
url 'https://maven.google.com/'
|
||||
name 'Google'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath 'com.android.tools.build:gradle:8.11.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
@@ -15,7 +22,8 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
}
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Thu Jan 10 06:49:36 CST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
|
Reference in New Issue
Block a user