diff --git a/.gitignore b/.gitignore index aa724b7..56cc642 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,85 @@ +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ *.iml -.gradle -/local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -/build -/captures +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later .externalNativeBuild -.cxx -local.properties +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..be40271 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Green Software Lab + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/app/Utils.java b/app/Utils.java deleted file mode 100644 index 939a624..0000000 --- a/app/Utils.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.example.simplefootexam.utils; - -import android.content.Context; -import androidx.annotation.RawRes; -import com.example.simplefootexam.R; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import java.io.InputStream; -import java.util.Scanner; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class Utils { - - @HunterDebug - public String readRawResource(@RawRes int res, Context context) { - return readStream(context.getResources().openRawResource(res)); - } - - @HunterDebug - private static String readStream(InputStream is) { - Scanner s = new Scanner(is).useDelimiter("\\A"); - return s.hasNext() ? s.next() : ""; - } - - @HunterDebug - public static JSONArray loadSONFile(Context ctx) { - String filecontent = null; - JSONArray jo = new JSONArray(); - try { - filecontent = readStream(ctx.getResources().openRawResource(R.raw.questions)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - return new JSONArray(filecontent); - } catch (JSONException e) { - e.printStackTrace(); - } - return jo; - } -} diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 72b27c7..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -plugins { - id 'com.android.application' - id 'hunter-debug' -} - -android { - lintOptions { - abortOnError false - } - dexOptions { - preDexLibraries false - javaMaxHeapSize "8g" - } - compileSdkVersion 30 - buildToolsVersion "30.0.0" - - defaultConfig { - applicationId "com.example.simplefootexam" - minSdkVersion 27 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - } - - 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 'com.github.bumptech.glide:glide:4.13.2' - //annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.4.0' - implementation 'com.jakewharton:butterknife:10.2.3' - annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.navigation:navigation-fragment:2.3.2' - implementation 'androidx.navigation:navigation-ui:2.3.2' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' -} -dependencies{ - implementation 'io.github.greensoftwarelab:hunter-emanafa-library:1.0.1' - } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 481bb43..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/simplefootexam/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/simplefootexam/ExampleInstrumentedTest.java deleted file mode 100644 index 08b180b..0000000 --- a/app/src/androidTest/java/com/example/simplefootexam/ExampleInstrumentedTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.example.simplefootexam; - -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 Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.example.simplefootexam", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index dc6b5db..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/example/simplefootexam/CustomButton.java b/app/src/main/java/com/example/simplefootexam/CustomButton.java deleted file mode 100644 index 037597f..0000000 --- a/app/src/main/java/com/example/simplefootexam/CustomButton.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.example.simplefootexam; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.util.AttributeSet; -import androidx.appcompat.widget.AppCompatButton; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class CustomButton extends AppCompatButton { - - private boolean isWrong = false; - - private int color_wrong; - - public CustomButton(Context context) { - super(context); - } - - @HunterDebug - public CustomButton(Context context, AttributeSet attrs) { - super(context, attrs); - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomButton, 0, 0); - color_wrong = a.getColor(R.styleable.CustomButton_valueColor, Color.RED); - } - - @Override - @HunterDebug - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - if (isWrong) { - Paint p = new Paint(); - p.setColor(color_wrong); - p.setStrokeWidth(10); - canvas.drawLine(0, this.getY(), this.getWidth(), this.getHeight(), p); - canvas.drawLine(0, this.getHeight(), this.getWidth(), this.getY(), p); - } - } - - public void setWrong(boolean wrong) { - isWrong = wrong; - } -} diff --git a/app/src/main/java/com/example/simplefootexam/MainActivity.java b/app/src/main/java/com/example/simplefootexam/MainActivity.java deleted file mode 100644 index 437d2ad..0000000 --- a/app/src/main/java/com/example/simplefootexam/MainActivity.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.example.simplefootexam; - -import android.os.Bundle; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import android.view.Menu; -import android.view.MenuItem; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class MainActivity extends AppCompatActivity { - - @Override - @HunterDebug - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - } - - @Override - @HunterDebug - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_main, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - if (id == R.id.action_settings) { - return true; - } - return super.onOptionsItemSelected(item); - } -} diff --git a/app/src/main/java/com/example/simplefootexam/MainMenuFragment.java b/app/src/main/java/com/example/simplefootexam/MainMenuFragment.java deleted file mode 100644 index 7ac2a55..0000000 --- a/app/src/main/java/com/example/simplefootexam/MainMenuFragment.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.example.simplefootexam; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.navigation.fragment.NavHostFragment; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class MainMenuFragment extends Fragment { - - @Override - @HunterDebug - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_first, container, false); - } - - @HunterDebug - public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View view) { - NavHostFragment.findNavController(MainMenuFragment.this).navigate(R.id.action_FirstFragment_to_QuestionFragment); - } - }); - } -} diff --git a/app/src/main/java/com/example/simplefootexam/QuestionCardRecyclerViewAdapter.java b/app/src/main/java/com/example/simplefootexam/QuestionCardRecyclerViewAdapter.java deleted file mode 100644 index 2e3a41d..0000000 --- a/app/src/main/java/com/example/simplefootexam/QuestionCardRecyclerViewAdapter.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.example.simplefootexam; - -import androidx.navigation.Navigation; -import androidx.recyclerview.widget.RecyclerView; -import android.graphics.BitmapFactory; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import com.example.simplefootexam.model.Question; -import java.util.List; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class QuestionCardRecyclerViewAdapter extends RecyclerView.Adapter { - - private final List mValues; - - public QuestionCardRecyclerViewAdapter(List items) { - mValues = items; - } - - @Override - @HunterDebug - public QuestionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_question_item, parent, false); - return new QuestionViewHolder(v); - } - - @Override - @HunterDebug - public void onBindViewHolder(final QuestionViewHolder holder, int position) { - holder.mIdView.setText(mValues.get(position).getId()); - holder.mImageView.setImageBitmap(BitmapFactory.decodeResource(holder.mView.getResources(), mValues.get(position).getImageId())); - holder.mQuestionview.setText(mValues.get(position).getQuestion()); - holder.mView.setOnClickListener( view -> { - Bundle bundle = new Bundle(); - bundle.putParcelable("question", mValues.get(position)); - Navigation.findNavController(view).navigate(R.id.selectQuestionAction, bundle); - }); - } - - @Override - public int getItemCount() { - return mValues.size(); - } - - public static class QuestionViewHolder extends RecyclerView.ViewHolder { - - public final View mView; - - public final TextView mIdView; - - public final TextView mQuestionview; - - public final ImageView mImageView; - - public QuestionViewHolder(View view) { - super(view); - mView = view; - mIdView = view.findViewById(R.id.text_question_id); - mImageView = view.findViewById(R.id.cardimage); - mQuestionview = view.findViewById(R.id.text_question); - } - } -} diff --git a/app/src/main/java/com/example/simplefootexam/QuestionListFragment.java b/app/src/main/java/com/example/simplefootexam/QuestionListFragment.java deleted file mode 100644 index 1220348..0000000 --- a/app/src/main/java/com/example/simplefootexam/QuestionListFragment.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.example.simplefootexam; - -import android.content.Context; -import android.os.AsyncTask; -import android.os.Bundle; -import androidx.fragment.app.Fragment; -import androidx.lifecycle.ViewModelProvider; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import com.example.simplefootexam.viewmodel.QuestionViewModel; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class QuestionListFragment extends Fragment { - - private static final String ARG_COLUMN_COUNT = "column-count"; - - private int mColumnCount = 1; - - private QuestionViewModel questionViewModel; - - public QuestionListFragment() { - } - - @HunterDebug - public static QuestionListFragment newInstance(int columnCount) { - QuestionListFragment fragment = new QuestionListFragment(); - Bundle args = new Bundle(); - args.putInt(ARG_COLUMN_COUNT, columnCount); - fragment.setArguments(args); - return fragment; - } - - @Override - @HunterDebug - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT); - } - ViewModelProvider.AndroidViewModelFactory factory = ViewModelProvider.AndroidViewModelFactory.getInstance(this.getActivity().getApplication()); - questionViewModel = new ViewModelProvider(this, factory).get(QuestionViewModel.class); - } - - @Override - @HunterDebug - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_question_list, container, false); - if (view instanceof RecyclerView) { - Context context = view.getContext(); - RecyclerView recyclerView = (RecyclerView) view; - if (mColumnCount <= 1) { - recyclerView.setLayoutManager(new LinearLayoutManager(context)); - } else { - recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount)); - } - QuestionCardRecyclerViewAdapter adapter = new QuestionCardRecyclerViewAdapter(questionViewModel.getQuestions()); - recyclerView.setAdapter(adapter); - } - return view; - } - - @Override - @HunterDebug - public void onResume() { - super.onResume(); - } -} diff --git a/app/src/main/java/com/example/simplefootexam/SingleQuestionFragment.java b/app/src/main/java/com/example/simplefootexam/SingleQuestionFragment.java deleted file mode 100644 index 8ad90dc..0000000 --- a/app/src/main/java/com/example/simplefootexam/SingleQuestionFragment.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.example.simplefootexam; - -import android.graphics.BitmapFactory; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import com.example.simplefootexam.model.Question; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class SingleQuestionFragment extends Fragment { - - @BindView(R.id.textViewQuestion) - TextView textViewQuestion; - - @BindView(R.id.imageQuestion) - ImageView questionImage; - - @BindView(R.id.button_top_left) - CustomButton buttonTopLeft; - - @BindView(R.id.button_top_right) - CustomButton buttonTopRight; - - @BindView(R.id.button_bottom_left) - CustomButton buttonBottomLeft; - - @BindView(R.id.button_bottom_right) - CustomButton buttonBottomRight; - - Question question; - - @Override - @HunterDebug - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fragment_single_question, container, false); - ButterKnife.bind(this, v); - return v; - } - - @OnClick({ R.id.button_top_left, R.id.button_top_right, R.id.button_bottom_left, R.id.button_bottom_right }) - @HunterDebug - public void onClickOnButtons(View view) { - if (view instanceof CustomButton) { - String txt = ((CustomButton) view).getText().toString(); - if (txt.equals(question.getAnswer())) { - Toast.makeText(getContext(), "Your answer is correct", Toast.LENGTH_LONG).show(); - } else { - ((CustomButton) view).setWrong(true); - view.invalidate(); - } - } - } - - @HunterDebug - public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - Question q = getArguments().getParcelable("question"); - setQuestion(q); - } - - @HunterDebug - public void setQuestion(Question quest) { - question = quest; - List l = new ArrayList<>(Arrays.asList(question.alternatives)); - Collections.shuffle(l); - buttonTopLeft.setText(l.get(0)); - buttonTopRight.setText(l.get(1)); - buttonBottomLeft.setText(l.get(2)); - buttonBottomRight.setText(l.get(3)); - textViewQuestion.setText(question.getQuestion()); - questionImage.setImageBitmap(BitmapFactory.decodeResource(this.getResources(), quest.getImageId())); - } -} diff --git a/app/src/main/java/com/example/simplefootexam/model/Question.java b/app/src/main/java/com/example/simplefootexam/model/Question.java deleted file mode 100644 index 8504482..0000000 --- a/app/src/main/java/com/example/simplefootexam/model/Question.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.example.simplefootexam.model; - -import android.os.Parcel; -import android.os.Parcelable; -import com.example.simplefootexam.R; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class Question implements Parcelable { - - private final String id; - - private final String question; - - private final int imageId; - - public String[] alternatives; - - @HunterDebug - public Question(String id, int image_id) { - this.id = id; - this.imageId = image_id; - this.question = "?"; - this.alternatives = new String[4]; - } - - @HunterDebug - public Question(String id, String question, int image_id, String answer) { - this.id = id; - this.imageId = image_id; - this.question = question; - this.alternatives = new String[4]; - } - - @HunterDebug - protected Question(Parcel in) { - id = in.readString(); - question = in.readString(); - imageId = in.readInt(); - in.readStringArray(alternatives); - } - - @HunterDebug - public Question(int id, JSONObject jo) throws JSONException, NoSuchFieldException, IllegalAccessException { - this.id = String.valueOf(id); - this.question = jo.getString("question"); - this.imageId = R.drawable.class.getField(jo.getString("image")).getInt(null); - ; - JSONArray alts = jo.getJSONArray("alternatives"); - this.alternatives = new String[4]; - for (int i = 0; i < alts.length() && i < 4; i++) { - this.alternatives[i] = alts.get(i).toString(); - } - } - - @HunterDebug - public String getId() { - return id; - } - - @HunterDebug - public String getQuestion() { - return question; - } - - @HunterDebug - public int getImageId() { - return imageId; - } - - @HunterDebug - public String[] getAlternatives() { - return alternatives; - } - - @HunterDebug - public void setAlternatives(String[] alternatives) { - this.alternatives = alternatives; - } - - @HunterDebug - public static Creator getCREATOR() { - return CREATOR; - } - - @HunterDebug - public String getAnswer() { - return this.alternatives.length > 0 ? this.alternatives[0] : null; - } - - public static final Creator CREATOR = new Creator() { - - @Override - @HunterDebug - public Question createFromParcel(Parcel in) { - return new Question(in); - } - - @Override - @HunterDebug - public Question[] newArray(int size) { - return new Question[size]; - } - }; - - @Override - @HunterDebug - public String toString() { - return question + id; - } - - @Override - @HunterDebug - public int describeContents() { - return 0; - } - - @Override - @HunterDebug - public void writeToParcel(Parcel parcel, int i) { - parcel.writeString(id); - parcel.writeString(question); - parcel.writeInt(imageId); - parcel.writeStringArray(alternatives); - } -} diff --git a/app/src/main/java/com/example/simplefootexam/utils/Utils.java b/app/src/main/java/com/example/simplefootexam/utils/Utils.java deleted file mode 100644 index 939a624..0000000 --- a/app/src/main/java/com/example/simplefootexam/utils/Utils.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.example.simplefootexam.utils; - -import android.content.Context; -import androidx.annotation.RawRes; -import com.example.simplefootexam.R; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import java.io.InputStream; -import java.util.Scanner; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class Utils { - - @HunterDebug - public String readRawResource(@RawRes int res, Context context) { - return readStream(context.getResources().openRawResource(res)); - } - - @HunterDebug - private static String readStream(InputStream is) { - Scanner s = new Scanner(is).useDelimiter("\\A"); - return s.hasNext() ? s.next() : ""; - } - - @HunterDebug - public static JSONArray loadSONFile(Context ctx) { - String filecontent = null; - JSONArray jo = new JSONArray(); - try { - filecontent = readStream(ctx.getResources().openRawResource(R.raw.questions)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - return new JSONArray(filecontent); - } catch (JSONException e) { - e.printStackTrace(); - } - return jo; - } -} diff --git a/app/src/main/java/com/example/simplefootexam/viewmodel/QuestionViewModel.java b/app/src/main/java/com/example/simplefootexam/viewmodel/QuestionViewModel.java deleted file mode 100644 index ae71c35..0000000 --- a/app/src/main/java/com/example/simplefootexam/viewmodel/QuestionViewModel.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.example.simplefootexam.viewmodel; - -import android.app.Application; -import android.content.Context; -import android.os.AsyncTask; -import androidx.annotation.NonNull; -import androidx.lifecycle.AndroidViewModel; -import com.example.simplefootexam.model.Question; -import com.example.simplefootexam.utils.Utils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import com.hunter.library.debug.HunterDebug; -import android.content.Context; - -public class QuestionViewModel extends AndroidViewModel { - - private static Map questions = new HashMap<>(); - - private static boolean isLoaded = false; - - @HunterDebug - public QuestionViewModel(@NonNull Application application) { - super(application); - initQuestions(application.getApplicationContext()); - } - - @HunterDebug - private void initQuestions(Context ctx) { - if (isLoaded) { - return; - } - JSONArray jsonArray = Utils.loadSONFile(ctx); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject jo = null; - try { - jo = jsonArray.getJSONObject(i); - Question q = new Question(i, jo); - questions.put(q.getId(), q); - } catch (JSONException | NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - } - isLoaded = true; - } - - @HunterDebug - public List getQuestions() { - return new ArrayList<>(questions.values()); - } -} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/marega.jpg b/app/src/main/res/drawable/marega.jpg deleted file mode 100644 index c498aff..0000000 Binary files a/app/src/main/res/drawable/marega.jpg and /dev/null differ diff --git a/app/src/main/res/drawable/otavio.jpg b/app/src/main/res/drawable/otavio.jpg deleted file mode 100644 index 6d3567b..0000000 Binary files a/app/src/main/res/drawable/otavio.jpg and /dev/null differ diff --git a/app/src/main/res/drawable/ronaldinho.jpg b/app/src/main/res/drawable/ronaldinho.jpg deleted file mode 100644 index 5e5bfaf..0000000 Binary files a/app/src/main/res/drawable/ronaldinho.jpg and /dev/null differ diff --git a/app/src/main/res/drawable/rounded_button.xml b/app/src/main/res/drawable/rounded_button.xml deleted file mode 100644 index d149f72..0000000 --- a/app/src/main/res/drawable/rounded_button.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/zaidu.jpg b/app/src/main/res/drawable/zaidu.jpg deleted file mode 100644 index 07116a6..0000000 Binary files a/app/src/main/res/drawable/zaidu.jpg and /dev/null differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 2a0b736..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml deleted file mode 100644 index c4e7db6..0000000 --- a/app/src/main/res/layout/content_main.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_first.xml b/app/src/main/res/layout/fragment_first.xml deleted file mode 100644 index 3e1173d..0000000 --- a/app/src/main/res/layout/fragment_first.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - -