Skip to content

Commit

Permalink
FirstUpload
Browse files Browse the repository at this point in the history
  • Loading branch information
xdingya committed Jul 15, 2023
0 parents commit 584f68e
Show file tree
Hide file tree
Showing 53 changed files with 1,574 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
44 changes: 44 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id 'com.android.application'
}

android {
namespace 'com.unbaiding.scoreassist'
compileSdk 33

defaultConfig {
applicationId "com.unbaiding.scoreassist"
minSdk 23
targetSdk 33
versionCode 202302
versionName '1.2'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
dataBinding {
enabled true
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.unbaiding.scoreassist",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 202302,
"versionName": "1.2",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.unbaiding.scoreassist;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented 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() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.unbaiding.scoreassist", appContext.getPackageName());
}
}
26 changes: 26 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ScoreAssist"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions app/src/main/java/com/unbaiding/scoreassist/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.unbaiding.scoreassist;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;

import com.unbaiding.scoreassist.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {
MyViewModel myviewModel;
ActivityMainBinding binding;
public final static String KEY_NUMBER_A = "score_numberA";
public final static String KEY_NUMBER_B = "score_numberB";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this,R.layout.activity_main);
myviewModel = new ViewModelProvider(this).get(MyViewModel.class);
binding.setData(myviewModel);
binding.setLifecycleOwner(this);

}

}
52 changes: 52 additions & 0 deletions app/src/main/java/com/unbaiding/scoreassist/MyViewModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.unbaiding.scoreassist;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.SavedStateHandle;

public class MyViewModel extends androidx.lifecycle.ViewModel {

private int aBack,bBack;
private SavedStateHandle handleA,handleB;

public MyViewModel(SavedStateHandle handle) {
this.handleA = handle;
this.handleB = handle;
}

public MutableLiveData<Integer> getaTeamScore(){
if(!handleA.contains(MainActivity.KEY_NUMBER_A)){
handleA.set(MainActivity.KEY_NUMBER_A,0);
}
return handleA.getLiveData(MainActivity.KEY_NUMBER_A);
}
public MutableLiveData<Integer> getbTeamScore(){
if(!handleB.contains(MainActivity.KEY_NUMBER_B)){
handleB.set(MainActivity.KEY_NUMBER_B,0);
}
return handleB.getLiveData(MainActivity.KEY_NUMBER_B);
}

public void AddaTeamScore(int p){
aBack = getaTeamScore().getValue();
bBack = getbTeamScore().getValue();
getaTeamScore().setValue(getaTeamScore().getValue() + p);
}

public void AddbTeamScore(int p){
aBack = getaTeamScore().getValue();
bBack = getbTeamScore().getValue();
getbTeamScore().setValue(getbTeamScore().getValue() + p);
}

public void reset(){
aBack = getaTeamScore().getValue();
bBack = getbTeamScore().getValue();
handleA.set(MainActivity.KEY_NUMBER_A,0);
handleB.set(MainActivity.KEY_NUMBER_B,0);
}

public void undo(){
handleA.set(MainActivity.KEY_NUMBER_A,aBack);
handleB.set(MainActivity.KEY_NUMBER_B,bBack);
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_loop_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,4L12,1L8,5l4,4L12,6c3.31,0 6,2.69 6,6 0,1.01 -0.25,1.97 -0.7,2.8l1.46,1.46C19.54,15.03 20,13.57 20,12c0,-4.42 -3.58,-8 -8,-8zM12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24,7.74C4.46,8.97 4,10.43 4,12c0,4.42 3.58,8 8,8v3l4,-4 -4,-4v3z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_undo_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#000000" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12.5,8c-2.65,0 -5.05,0.99 -6.9,2.6L2,7v9h9l-3.62,-3.62c1.39,-1.16 3.16,-1.88 5.12,-1.88 3.54,0 6.55,2.31 7.6,5.5l2.37,-0.78C21.08,11.03 17.15,8 12.5,8z"/>
</vector>
Loading

0 comments on commit 584f68e

Please sign in to comment.