diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..aa724b7
--- /dev/null
+++ b/.gitignore
@@ -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
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..fdf146a
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+MRF.Practice
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..a2d7c21
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..4527e1b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7f2f45e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+# Description
+MRF Practice is a vulnerable android application to practice request forgery, the application has an known vulnerabilities listed below.
+# Vulnerabilities
+Right now, the application is affected by three vulnerabilities and we will publish a full write-up about them on 11th Ramadan - 2nd April - In sha'Allah.
+# Hints
+The three vulnerabilities is two high-severity vulnerabilities and a 1-click RCE, exploits requires chaining with web application's low fruit bugs and best practices.
+
+---
+الحمدلله، والسلام عليكم
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..4a49f8a
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,56 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ compileSdk 32
+
+ defaultConfig {
+ applicationId "com.dphoeniixx.mrfpractice"
+ minSdk 21
+ targetSdk 32
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.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
+ }
+ buildFeatures {
+ viewBinding true
+ }
+}
+
+dependencies {
+ implementation 'com.squareup.retrofit2:retrofit:2.1.0'
+ implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
+ //noinspection GradleCompatible
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'commons-io:commons-io:+'
+ //noinspection GradleCompatible
+ implementation 'com.android.support:design:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:2.0.4'
+ implementation 'android.arch.navigation:navigation-fragment:1.0.0'
+ implementation 'android.arch.navigation:navigation-ui:1.0.0'
+ implementation 'com.android.support:support-annotations:28.0.0'
+ implementation 'android.arch.lifecycle:livedata:1.1.1'
+ implementation 'android.arch.lifecycle:viewmodel:1.1.1'
+ implementation 'com.google.android.material:material:1.8.0'
+// implementation 'androidx.appcompat:appcompat:1.6.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+ implementation 'androidx.navigation:navigation-fragment:2.5.3'
+ implementation 'androidx.navigation:navigation-ui:2.5.3'
+// implementation 'androidx.appcompat:appcompat:1.6.1'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
new file mode 100644
index 0000000..aa8b107
Binary files /dev/null and b/app/release/app-release.apk differ
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
new file mode 100644
index 0000000..38359d0
--- /dev/null
+++ b/app/release/output-metadata.json
@@ -0,0 +1,20 @@
+{
+ "version": 3,
+ "artifactType": {
+ "type": "APK",
+ "kind": "Directory"
+ },
+ "applicationId": "com.dphoeniixx.mrfpractice",
+ "variantName": "release",
+ "elements": [
+ {
+ "type": "SINGLE",
+ "filters": [],
+ "attributes": [],
+ "versionCode": 1,
+ "versionName": "1.0",
+ "outputFile": "app-release.apk"
+ }
+ ],
+ "elementType": "File"
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/dphoeniixx/mrfpractice/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/dphoeniixx/mrfpractice/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..6301ccb
--- /dev/null
+++ b/app/src/androidTest/java/com/dphoeniixx/mrfpractice/ExampleInstrumentedTest.java
@@ -0,0 +1,25 @@
+package com.dphoeniixx.mrfpractice;
+
+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.*;
+
+/**
+ * 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.dphoeniixx.mrfpractice", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..aed3db3
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/BlogFragment.java b/app/src/main/java/com/dphoeniixx/mrfpractice/BlogFragment.java
new file mode 100644
index 0000000..b874991
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/BlogFragment.java
@@ -0,0 +1,60 @@
+package com.dphoeniixx.mrfpractice;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+
+import com.dphoeniixx.mrfpractice.data.BlogAdapter;
+import com.dphoeniixx.mrfpractice.http.RESTClient;
+import com.dphoeniixx.mrfpractice.http.resposnes.BlogsResponse;
+import com.google.gson.Gson;
+
+import java.io.IOException;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+
+public class BlogFragment extends Fragment {
+ private static final String TAG = MainActivity.class.getSimpleName();
+
+ BlogAdapter blogAdapter;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ MRFApp.restClient.getBlogs().enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) throws IOException {
+ ListView listView = (ListView) getView().findViewById(R.id.blogsListView);
+ BlogsResponse blogsResponse = new Gson().fromJson(response.body().string(), BlogsResponse.class);
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ blogAdapter = new BlogAdapter(getContext(), blogsResponse.getData());
+ listView.setAdapter(blogAdapter);
+ }
+ });
+ response.close();
+ }
+
+ @Override
+ public void onFailure(Call call, IOException t) {
+ Log.d(TAG, t.getMessage() + " ::: " + call.toString());
+ }
+ });
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_blog, container, false);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/BlogpostActivity.java b/app/src/main/java/com/dphoeniixx/mrfpractice/BlogpostActivity.java
new file mode 100644
index 0000000..f82653a
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/BlogpostActivity.java
@@ -0,0 +1,78 @@
+package com.dphoeniixx.mrfpractice;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.dphoeniixx.mrfpractice.data.ImageDownloader;
+import com.dphoeniixx.mrfpractice.data.model.Blog;
+import com.dphoeniixx.mrfpractice.http.RESTClient;
+import com.dphoeniixx.mrfpractice.http.resposnes.BlogResponse;
+import com.dphoeniixx.mrfpractice.http.resposnes.BlogsResponse;
+import com.google.android.material.imageview.ShapeableImageView;
+import com.google.gson.Gson;
+
+import android.widget.TextView;
+
+import androidx.fragment.app.FragmentActivity;
+
+
+import java.io.IOException;
+
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
+public class BlogpostActivity extends FragmentActivity {
+
+
+ private static RESTClient API = MRFApp.restClient;
+
+ public static final String BLOGPOST_ID = "blogID";
+
+ private String blogID;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_blog_post);
+
+ Intent intent = getIntent();
+
+ blogID = intent.getStringExtra(BLOGPOST_ID);
+
+ TextView blogTitle = findViewById(R.id.blogTitle);
+ TextView blogText = findViewById(R.id.blogText);
+ ShapeableImageView blogImage = findViewById(R.id.blogImage);
+
+
+
+ API.getBlogById(blogID).enqueue(new okhttp3.Callback() {
+ @Override
+ public void onFailure(okhttp3.Call call, IOException e) {
+
+ }
+
+ @Override
+ public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException {
+ BlogResponse blogResponse = new Gson().fromJson(response.body().string(), BlogResponse.class);
+ Blog blog = blogResponse.getData();
+
+ MRFApp.setText(blogTitle, blog.getTitle());
+ MRFApp.setText(blogText, blog.getDescription());
+
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ImageDownloader imageDownloader = new ImageDownloader(Uri.parse(blog.getImage()));
+ blogImage.setImageBitmap(imageDownloader.download());
+ }
+ });
+ response.close();
+ }
+ });
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/ContextProvider.java b/app/src/main/java/com/dphoeniixx/mrfpractice/ContextProvider.java
new file mode 100644
index 0000000..d134243
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/ContextProvider.java
@@ -0,0 +1,7 @@
+package com.dphoeniixx.mrfpractice;
+
+import android.content.Context;
+
+public interface ContextProvider {
+ Context getActivityContext();
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/LoginFragment.java b/app/src/main/java/com/dphoeniixx/mrfpractice/LoginFragment.java
new file mode 100644
index 0000000..6be67e3
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/LoginFragment.java
@@ -0,0 +1,128 @@
+package com.dphoeniixx.mrfpractice;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
+import com.dphoeniixx.mrfpractice.data.SessionManager;
+import com.dphoeniixx.mrfpractice.http.RESTClient;
+import com.dphoeniixx.mrfpractice.http.resposnes.BlogResponse;
+import com.dphoeniixx.mrfpractice.http.resposnes.LoginResponse;
+import com.dphoeniixx.mrfpractice.http.resposnes.RegisterResponse;
+import com.google.gson.Gson;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+
+import okhttp3.Callback;
+import okhttp3.ResponseBody;
+import retrofit2.Call;
+import retrofit2.Converter;
+import retrofit2.Response;
+
+
+public class LoginFragment extends Fragment {
+
+ private static final RESTClient API = MRFApp.restClient;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ }
+
+ private void showFragment(Fragment fragment) {
+ FragmentManager fragmentManager = getParentFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+ fragmentTransaction.replace(R.id.flFragment, fragment, fragment.getClass().getSimpleName());
+ fragmentTransaction.commit();
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ TextView email = getView().findViewById(R.id.editTextTextEmailAddress);
+ TextView password = getView().findViewById(R.id.editTextTextPassword);
+ TextView name = getView().findViewById(R.id.editTextName);
+ TextView message = getView().findViewById(R.id.message);
+
+ Button loginButton = getView().findViewById(R.id.loginActionBtn);
+ Button registerButton = getView().findViewById(R.id.registerActionBtn);
+
+ loginButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ API.login(email.getText().toString(), password.getText().toString()).enqueue(new okhttp3.Callback() {
+ @Override
+ public void onFailure(okhttp3.Call call, IOException e) {
+ Log.d("ttt", e.getMessage());
+ }
+
+ @Override
+ public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException {
+ if (response.isSuccessful()) {
+ LoginResponse loginResponse = new Gson().fromJson(response.body().string(), LoginResponse.class);
+ SessionManager.setToken(loginResponse.getData().getToken());
+ Button profileBtn = getActivity().findViewById(R.id.profileBtn);
+ MRFApp.setText(profileBtn, "Profile");
+ showFragment(new ProfileFragment());
+ } else {
+ LoginResponse.Error error = new Gson().fromJson(response.body().string(), LoginResponse.Error.class);
+ MRFApp.setText(message, error.getMessage());
+ }
+ }
+ });
+ }
+ });
+ registerButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ API.register(name.getText().toString(), email.getText().toString(), password.getText().toString()).enqueue(new Callback() {
+ @Override
+ public void onFailure(okhttp3.Call call, IOException e) {
+
+ }
+
+ @Override
+ public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException {
+ if (response.isSuccessful()) {
+ RegisterResponse registerResponse = new Gson().fromJson(response.body().string(), RegisterResponse.class);
+ MRFApp.setText(message, registerResponse.getStatus() + "\nTry login now!");
+ } else {
+ RegisterResponse.Error error = new Gson().fromJson(response.body().string(), RegisterResponse.Error.class);
+ String errorString = "";
+ if (error.getErrors() != null) {
+ for (RegisterResponse.ValidationError errorVal : error.getErrors()) {
+ errorString += errorVal.getMsg() + "\n";
+ }
+ } else {
+ errorString = error.getMessage();
+ }
+ MRFApp.setText(message, errorString);
+ }
+ response.close();
+ }
+ });
+ }
+ });
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_login, container, false);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/MRFApp.java b/app/src/main/java/com/dphoeniixx/mrfpractice/MRFApp.java
new file mode 100644
index 0000000..61db0dc
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/MRFApp.java
@@ -0,0 +1,145 @@
+package com.dphoeniixx.mrfpractice;
+
+import android.app.Activity;
+import android.app.Application;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.StrictMode;
+import android.preference.PreferenceManager;
+import android.widget.TextView;
+
+import com.dphoeniixx.mrfpractice.http.RESTClient;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Arrays;
+
+public class MRFApp extends Application implements ContextProvider {
+
+ public static RESTClient restClient;
+ private static Context context;
+ private static Activity currentActivity;
+ private static String[] requiredLibraries = new String[]{"libcrypto.so", "libssl.so"};
+
+ @Override
+ public Context getActivityContext() {
+ return currentActivity;
+ }
+
+ @Override
+ public void onCreate(){
+ super.onCreate();
+ context = getApplicationContext();
+ restClient = new RESTClient();
+
+ int SDK_INT = android.os.Build.VERSION.SDK_INT;
+ if (SDK_INT > 8)
+ {
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
+ .permitAll().build();
+ StrictMode.setThreadPolicy(policy);
+
+ }
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ File libDir = new File(MRFApp.getContext().getApplicationContext().getApplicationInfo().dataDir, "libs/" + Build.SUPPORTED_ABIS[0]);
+
+ if(!prefs.getBoolean("firstTime", false)) {
+ libDir.mkdirs();
+ try {
+ for (String library: requiredLibraries){
+ downloadFile("http://52.139.154.230:8080/libs/" + Build.SUPPORTED_ABIS[0] + "/" + library + "?ItsNotTheRCE-MiTM-Solution-Not-Accepted.", libDir);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean("firstTime", true);
+ editor.commit();
+ }
+
+ for(String library: requiredLibraries){
+ System.load(libDir.toString() + "/" + library);
+ }
+
+ registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
+ @Override
+ public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
+ MRFApp.this.currentActivity = activity;
+ }
+
+ @Override
+ public void onActivityStarted(Activity activity) {
+ MRFApp.this.currentActivity = activity;
+ }
+
+ @Override
+ public void onActivityResumed(Activity activity) {
+ MRFApp.this.currentActivity = activity;
+ }
+
+ @Override
+ public void onActivityPaused(Activity activity) {
+ MRFApp.this.currentActivity = null;
+ }
+
+ @Override
+ public void onActivityStopped(Activity activity) {
+ // don't clear current activity because activity may get stopped after
+ // the new activity is resumed
+ }
+
+ @Override
+ public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
+
+ }
+
+ @Override
+ public void onActivityDestroyed(Activity activity) {
+ // don't clear current activity because activity may get destroyed after
+ // the new activity is resumed
+ }
+ });
+
+ }
+
+ public static Context getContext(){
+ return context;
+ }
+
+ public static Activity getCurrentActivity() {
+ return currentActivity;
+ }
+
+ public static void setText(final TextView text,final String value){
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ text.setText(value);
+ }
+ });
+ }
+
+ public static void downloadFile(String url, File dest) throws Exception {
+ URL urlDownloader = new URL(url);
+ InputStream inputStream = urlDownloader.openStream();
+ BufferedInputStream bis = new BufferedInputStream(inputStream);
+ FileOutputStream fos = new FileOutputStream(dest.toString() + "/" + Uri.parse(url).getLastPathSegment());
+ byte[] data = new byte[1024];
+ int count;
+ while ((count = bis.read(data, 0, 1024)) != -1) {
+ fos.write(data, 0, count);
+ }
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/MainActivity.java b/app/src/main/java/com/dphoeniixx/mrfpractice/MainActivity.java
new file mode 100644
index 0000000..888959e
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/MainActivity.java
@@ -0,0 +1,116 @@
+package com.dphoeniixx.mrfpractice;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.StrictMode;
+import android.view.View;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.navigation.ui.AppBarConfiguration;
+
+import com.dphoeniixx.mrfpractice.data.SessionManager;
+import com.dphoeniixx.mrfpractice.databinding.ActivityMainBinding;
+import com.dphoeniixx.mrfpractice.deeplink.DeeplinkHandler;
+
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Button;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.util.List;
+
+public class MainActivity extends FragmentActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ showFragment(new BlogFragment());
+
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
+ StrictMode.setThreadPolicy(policy);
+
+ Button blogButton = findViewById(R.id.blogBtn);
+ Button profileButton = findViewById(R.id.profileBtn);
+
+ if(SessionManager.getToken() == "") {
+ profileButton.setText("Login");
+ } else {
+ profileButton.setText("Profile");
+ }
+
+ blogButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+
+// Intent in = new Intent(Intent.ACTION_VIEW);
+// in.setData(Uri.parse("linkedin://profile/dphoeniixx?src=sdk&accessToken=eeeeeeerrrr"));
+// in.setFlags(0);
+// startActivityForResult(in, 300);
+
+ showFragment(new BlogFragment());
+ }
+ });
+
+ profileButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if(SessionManager.getToken() == ""){
+ showFragment(new LoginFragment());
+ }else {
+ showFragment(new ProfileFragment());
+ }
+ }
+ });
+
+ if (getIntent().getData() != null){
+ DeeplinkHandler deeplinkHandler = new DeeplinkHandler(getIntent().getData());
+ deeplinkHandler.handle();
+ }
+
+
+ }
+
+ private void showFragment(Fragment fragment) {
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+ fragmentTransaction.replace(R.id.flFragment, fragment, fragment.getClass().getSimpleName());
+ fragmentTransaction.commit();
+ }
+
+ @Override
+ public void startActivityForResult(Intent intent, int requestCode) {
+ try {
+ super.startActivityForResult(intent, requestCode);
+ } catch (Exception ignored){}
+ }
+
+ @Override
+ 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);
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/ProfileFragment.java b/app/src/main/java/com/dphoeniixx/mrfpractice/ProfileFragment.java
new file mode 100644
index 0000000..61ad403
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/ProfileFragment.java
@@ -0,0 +1,130 @@
+package com.dphoeniixx.mrfpractice;
+
+import static android.content.Context.MODE_PRIVATE;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.IdRes;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
+import com.dphoeniixx.mrfpractice.data.SessionManager;
+import com.dphoeniixx.mrfpractice.http.RESTClient;
+import com.dphoeniixx.mrfpractice.http.resposnes.ProfileResponse;
+import com.dphoeniixx.mrfpractice.http.resposnes.RegisterResponse;
+import com.google.gson.Gson;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+
+public class ProfileFragment extends Fragment {
+
+ private static final RESTClient API = MRFApp.restClient;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ TextView helloText = getView().findViewById(R.id.helloText);
+ TextView emailText = getView().findViewById(R.id.emailText);
+ Button logoutButton = getView().findViewById(R.id.logoutButton);
+ Button updateButton = getView().findViewById(R.id.updateButton);
+
+ if(SessionManager.getToken() == ""){
+ showFragment(new LoginFragment());
+ }
+
+ logoutButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ SessionManager.setToken("");
+ showFragment(new LoginFragment());
+ ((Button)getActivity().findViewById(R.id.profileBtn)).setText("Login");
+ }
+ });
+
+ updateButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ API.changeEmail(emailText.getText().toString()).enqueue(new Callback() {
+ @Override
+ public void onFailure(Call call, IOException e) {
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(MRFApp.getContext(),"Unknown error on updating email.", Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ @Override
+ public void onResponse(Call call, Response response) throws IOException {
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if(response.isSuccessful()){
+ Toast.makeText(MRFApp.getContext(),"Email Updated.", Toast.LENGTH_SHORT).show();
+ }else {
+ Toast.makeText(MRFApp.getContext(), "Unknown error on updating email.", Toast.LENGTH_SHORT).show();
+ }
+ response.close();
+ }
+ });
+ }
+ });
+ }
+ });
+
+ API.getProfile().enqueue(new okhttp3.Callback() {
+ @Override
+ public void onFailure(okhttp3.Call call, IOException e) {
+
+ }
+
+ @Override
+ public void onResponse(okhttp3.Call call, okhttp3.Response response) throws IOException {
+ if(response.isSuccessful()){
+ ProfileResponse profileResponse = new Gson().fromJson(response.body().string(), ProfileResponse.class);
+ MRFApp.setText(helloText, String.format("Hello, %s\nYour Email: %s", profileResponse.getUser().getName(), profileResponse.getUser().getEmail()) );
+ } else {
+ ProfileResponse.Error error = new Gson().fromJson(response.body().string(), ProfileResponse.Error.class);
+ MRFApp.setText(helloText, error.getMessage());
+ }
+ response.close();
+ }
+ });
+ }
+
+ private void showFragment(Fragment fragment) {
+ FragmentManager fragmentManager = getParentFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+ fragmentTransaction.replace(R.id.flFragment, fragment, fragment.getClass().getSimpleName());
+ fragmentTransaction.commit();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_profile, container, false);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/data/BlogAdapter.java b/app/src/main/java/com/dphoeniixx/mrfpractice/data/BlogAdapter.java
new file mode 100644
index 0000000..7d90981
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/data/BlogAdapter.java
@@ -0,0 +1,72 @@
+package com.dphoeniixx.mrfpractice.data;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.text.format.DateUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.dphoeniixx.mrfpractice.BlogpostActivity;
+import com.dphoeniixx.mrfpractice.R;
+import com.dphoeniixx.mrfpractice.data.model.Blog;
+import com.google.android.material.imageview.ShapeableImageView;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.TimeZone;
+
+public class BlogAdapter extends ArrayAdapter {
+ public BlogAdapter(@NonNull Context context, ArrayList dataArrayList) {
+ super(context, R.layout.blog_post, dataArrayList);
+ }
+ @NonNull
+ @Override
+ public View getView(int position, @Nullable View view, @NonNull ViewGroup parent) {
+ Blog Blog = getItem(position);
+ if (view == null){
+ view = LayoutInflater.from(getContext()).inflate(R.layout.blog_post, parent, false);
+ }
+ ShapeableImageView blogImage = view.findViewById(R.id.blogImage);
+ TextView blogTitle = view.findViewById(R.id.blogTitle);
+ TextView blogTime = view.findViewById(R.id.blogTime);
+
+ blogTitle.setText(Blog.getTitle());
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ CharSequence ago = null;
+ try {
+ long time = sdf.parse(Blog.getCreatedAt()).getTime();
+ long now = System.currentTimeMillis();
+ ago =
+ DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ blogTime.setText(ago);
+
+ ImageDownloader imageDownloader = new ImageDownloader(Uri.parse(Blog.getImage()));
+ blogImage.setImageBitmap(imageDownloader.download());
+
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intentBlogpost = new Intent(getContext(), BlogpostActivity.class);
+ intentBlogpost.putExtra(BlogpostActivity.BLOGPOST_ID, Blog.getID());
+ getContext().startActivity(intentBlogpost);
+ }
+ });
+
+
+ return view;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/data/ImageDownloader.java b/app/src/main/java/com/dphoeniixx/mrfpractice/data/ImageDownloader.java
new file mode 100644
index 0000000..3941926
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/data/ImageDownloader.java
@@ -0,0 +1,47 @@
+package com.dphoeniixx.mrfpractice.data;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import com.dphoeniixx.mrfpractice.data.Utils;
+
+import com.dphoeniixx.mrfpractice.MRFApp;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+
+public class ImageDownloader {
+
+ private static Uri downloadUri;
+ private static File cacheFile;
+ private static File destFile;
+
+ private static String CACHE_PATH = MRFApp.getContext().getApplicationContext().getCacheDir() + "/image-cache/";
+
+ public ImageDownloader(Uri uri) {
+ downloadUri = uri;
+ destFile = new File(CACHE_PATH, Utils.md5(downloadUri.toString()));
+ cacheFile = new File(destFile, downloadUri.getLastPathSegment());
+ destFile.mkdir();
+ }
+
+ public Bitmap download() {
+ if(isCached()){
+ return BitmapFactory.decodeFile(cacheFile.getAbsolutePath());
+ }
+ try {
+ MRFApp.downloadFile(downloadUri.toString(), destFile);
+ return BitmapFactory.decodeFile(cacheFile.getAbsolutePath());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static boolean isCached(){
+ return cacheFile.exists();
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/data/SessionManager.java b/app/src/main/java/com/dphoeniixx/mrfpractice/data/SessionManager.java
new file mode 100644
index 0000000..f198745
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/data/SessionManager.java
@@ -0,0 +1,20 @@
+package com.dphoeniixx.mrfpractice.data;
+
+import static android.content.Context.MODE_PRIVATE;
+
+import android.content.SharedPreferences;
+
+import com.dphoeniixx.mrfpractice.MRFApp;
+
+public class SessionManager {
+ private static SharedPreferences sharedPreferences = MRFApp.getContext().getSharedPreferences("user", MODE_PRIVATE);
+ private static String TOKEN_NAME = "auth_token";
+
+ public static String getToken() {
+ return sharedPreferences.getString(TOKEN_NAME, "");
+ }
+
+ public static void setToken(String token){
+ sharedPreferences.edit().putString(TOKEN_NAME, token).apply();
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/data/Utils.java b/app/src/main/java/com/dphoeniixx/mrfpractice/data/Utils.java
new file mode 100644
index 0000000..88fbdb3
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/data/Utils.java
@@ -0,0 +1,31 @@
+package com.dphoeniixx.mrfpractice.data;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+final class Utils {
+ public static String md5(final String s) {
+ final String MD5 = "MD5";
+ try {
+ // Create MD5 Hash
+ MessageDigest digest = java.security.MessageDigest
+ .getInstance(MD5);
+ digest.update(s.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ // Create Hex String
+ StringBuilder hexString = new StringBuilder();
+ for (byte aMessageDigest : messageDigest) {
+ String h = Integer.toHexString(0xFF & aMessageDigest);
+ while (h.length() < 2)
+ h = "0" + h;
+ hexString.append(h);
+ }
+ return hexString.toString();
+
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/data/model/Blog.java b/app/src/main/java/com/dphoeniixx/mrfpractice/data/model/Blog.java
new file mode 100644
index 0000000..618a08c
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/data/model/Blog.java
@@ -0,0 +1,56 @@
+package com.dphoeniixx.mrfpractice.data.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class Blog {
+ private String title;
+ private String description;
+ private String image;
+ private String createdAt;
+ private String _id;
+ private ArrayList tags;
+
+ public Blog(String _id, String title, String description, String image, ArrayList tags, String createdAt) {
+ this._id = _id;
+ this.title = title;
+ this.description = description;
+ this.image = image;
+ this.tags = tags;
+ this.createdAt = createdAt;
+ }
+
+ public String getID() {
+ return _id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public ArrayList getTags() {
+ return tags;
+ }
+
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ @Override
+ public String toString() {
+ return "Blog{" +
+ "title='" + title + '\'' +
+ ", description='" + description + '\'' +
+ ", image='" + image + '\'' +
+ ", tags=" + tags.toString() +
+ '}';
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/data/model/User.java b/app/src/main/java/com/dphoeniixx/mrfpractice/data/model/User.java
new file mode 100644
index 0000000..64e6df3
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/data/model/User.java
@@ -0,0 +1,37 @@
+package com.dphoeniixx.mrfpractice.data.model;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class User {
+
+ @SerializedName("_id")
+ @Expose
+ private String id;
+ @SerializedName("name")
+ @Expose
+ private String name;
+ @SerializedName("email")
+ @Expose
+ private String email;
+ @SerializedName("role")
+ @Expose
+ private String role;
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkEntry.java b/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkEntry.java
new file mode 100644
index 0000000..ac352bf
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkEntry.java
@@ -0,0 +1,19 @@
+package com.dphoeniixx.mrfpractice.deeplink;
+
+public class DeeplinkEntry {
+ private String entryRegex;
+ private String handlerMethod;
+
+ public DeeplinkEntry(String regex, String handlerMethod) {
+ this.entryRegex = regex;
+ this.handlerMethod = handlerMethod;
+ }
+
+ public String getRegex() {
+ return entryRegex;
+ }
+
+ public String getHandlerMethod() {
+ return handlerMethod;
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkHandler.java b/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkHandler.java
new file mode 100644
index 0000000..983d6ba
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkHandler.java
@@ -0,0 +1,45 @@
+package com.dphoeniixx.mrfpractice.deeplink;
+
+import android.net.Uri;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class DeeplinkHandler {
+ private static DeeplinkEntry HOME_DEEPLINK = new DeeplinkEntry("^mrf://dphoeniixx/home$", "handleHome");
+ private static DeeplinkEntry BLOGPOST_DEEPLINK = new DeeplinkEntry("^mrf://dphoeniixx/blog/(.*?)$", "handleBlog");
+ private static DeeplinkEntry REDEEM_DEEPLINK = new DeeplinkEntry("^mrf://dphoeniixx/redeem$", "handleRedeem");
+ private static ArrayList deeplinkEntries = new ArrayList(Arrays.asList(HOME_DEEPLINK, BLOGPOST_DEEPLINK, REDEEM_DEEPLINK));
+
+ private static DeeplinkEntry deeplinkEntry = null;
+ private static Uri deeplinkUri;
+
+ public DeeplinkHandler(Uri uri) {
+ deeplinkUri = uri;
+ deeplinkEntry = getDeeplinkEntry();
+ }
+
+ public static DeeplinkEntry getDeeplinkEntry(){
+ String URI = String.format("%s://%s%s", deeplinkUri.getScheme(), deeplinkUri.getAuthority(), deeplinkUri.getPath());;
+ for(DeeplinkEntry entry : deeplinkEntries){
+ Pattern pattern = Pattern.compile(entry.getRegex());
+ Matcher matcher = pattern.matcher(URI);
+ if(matcher.matches()){
+ return entry;
+ }
+ }
+ return null;
+ }
+
+ public void handle(){
+ if(deeplinkEntry != null){
+ try {
+ DeeplinkHandlers.class.getMethod(deeplinkEntry.getHandlerMethod(), Uri.class).invoke(null, deeplinkUri);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkHandlers.java b/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkHandlers.java
new file mode 100644
index 0000000..65289f4
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/deeplink/DeeplinkHandlers.java
@@ -0,0 +1,60 @@
+package com.dphoeniixx.mrfpractice.deeplink;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.widget.Toast;
+
+import com.dphoeniixx.mrfpractice.BlogpostActivity;
+import com.dphoeniixx.mrfpractice.MRFApp;
+import com.dphoeniixx.mrfpractice.MainActivity;
+import com.dphoeniixx.mrfpractice.http.RESTClient;
+
+import java.io.IOException;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+
+public class DeeplinkHandlers {
+ private static final RESTClient API = MRFApp.restClient;
+
+ public static void handleHome(Uri uri) {
+ Intent intent = new Intent(MRFApp.getContext(), MainActivity.class);
+ MRFApp.getCurrentActivity().startActivity(intent);
+ }
+
+ public static void handleBlog(Uri uri) {
+ Intent intent = new Intent(MRFApp.getContext(), BlogpostActivity.class);
+ intent.putExtra(BlogpostActivity.BLOGPOST_ID, uri.getPathSegments().get(1));
+ MRFApp.getCurrentActivity().startActivity(intent);
+ }
+
+ public static void handleRedeem(Uri uri) {
+ String redeemCode = uri.getQueryParameter("code");
+ API.redeem(redeemCode).enqueue(new Callback() {
+ @Override
+ public void onFailure(Call call, IOException e) {
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(MRFApp.getContext(), "Unknown error on redeeming.", Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ @Override
+ public void onResponse(Call call, Response response) {
+ MRFApp.getCurrentActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if(response.isSuccessful()){
+ Toast.makeText(MRFApp.getContext(),"Redeemed.", Toast.LENGTH_SHORT).show();
+ }else {
+ Toast.makeText(MRFApp.getContext(), "Unknown error on redeeming.", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/http/RESTClient.java b/app/src/main/java/com/dphoeniixx/mrfpractice/http/RESTClient.java
new file mode 100644
index 0000000..2d44da8
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/http/RESTClient.java
@@ -0,0 +1,232 @@
+package com.dphoeniixx.mrfpractice.http;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.dphoeniixx.mrfpractice.MRFApp;
+import com.dphoeniixx.mrfpractice.R;
+import com.dphoeniixx.mrfpractice.data.SessionManager;
+import com.dphoeniixx.mrfpractice.http.resposnes.LoginResponse;
+
+import org.apache.commons.io.IOUtils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
+import okhttp3.Authenticator;
+import okhttp3.Call;
+import okhttp3.CertificatePinner;
+import okhttp3.Connection;
+import okhttp3.FormBody;
+import okhttp3.Interceptor;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import okhttp3.Route;
+import okio.BufferedSink;
+
+public class RESTClient {
+ private static String BASE_URL = "https://52.139.154.230:8443/api/v1";
+
+ private static String LOGIN_ENDPOINT = "/user/login";
+ private static String REGISTER_ENDPOINT = "/user/register";
+ private static String UPDATE_ENDPOINT = "/user/update";
+ private static String PROFILE_ENDPOINT = "/user/profile";
+ private static String GET_BLOG_ENDPOINT = "/blogs/";
+ private static String GET_BLOGS_ENDPOINT = "/blogs";
+ private static String REDEEM_ENDPOINT = "/user/redeem/";
+
+ private static OkHttpClient client;
+ private static Interceptor interceptor = new Interceptor() {
+ @Override
+ public Response intercept(Chain chain) throws IOException {
+ Request request = chain.request();
+ if(SessionManager.getToken() != ""){
+ request = request.newBuilder()
+ .header("Authorization", "Bearer " + SessionManager.getToken())
+ .build();
+ }
+ return chain.proceed(request);
+ }
+ };
+
+
+ TrustManager TRUST_ALL_CERTS = new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) {
+ }
+
+ @Override
+ public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
+ }
+
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return new java.security.cert.X509Certificate[] {};
+ }
+ };
+
+ public static String convertStreamToString(InputStream is) throws Exception {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n");
+ }
+ is.close();
+ return sb.toString();
+ }
+
+ public static SSLContext getSslContext(Context context) throws Exception {
+ KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); // "BKS"
+ ks.load(null, null);
+
+ InputStream is = context.getResources().openRawResource(R.raw.certificate);
+ String certificate = convertStreamToString(is);
+
+ // generate input stream for certificate factory
+ InputStream stream = IOUtils.toInputStream(certificate);
+
+ // CertificateFactory
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ // certificate
+ Certificate ca;
+ try {
+ ca = cf.generateCertificate(stream);
+ } finally {
+ is.close();
+ }
+
+ ks.setCertificateEntry("my-ca", ca);
+
+ // TrustManagerFactory
+ String algorithm = TrustManagerFactory.getDefaultAlgorithm();
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm);
+ // Create a TrustManager that trusts the CAs in our KeyStore
+ tmf.init(ks);
+
+ // Create a SSLContext with the certificate that uses tmf (TrustManager)
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, tmf.getTrustManagers(), new SecureRandom());
+
+ return sslContext;
+ }
+
+ public RESTClient() {
+ try {
+ client = new OkHttpClient.Builder()
+ .addInterceptor(interceptor)
+ .addNetworkInterceptor(interceptor)
+ .sslSocketFactory(getSslContext(MRFApp.getContext()).getSocketFactory())
+ .certificatePinner(new CertificatePinner.Builder()
+ .add("52.139.154.230", "sha256/G34i6LjdY5oBYD33LSpgsg8MIVsOQeilOmlFcngZP7M=")
+ .build())
+ .build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Call login(String email, String password) {
+ RequestBody requestBody = new FormBody.Builder()
+ .add("email", email)
+ .add("password", password)
+ .build();
+
+ Request request = new Request.Builder()
+ .url(BASE_URL + LOGIN_ENDPOINT)
+ .post(requestBody)
+ .build();
+ Call call = client.newCall(request);
+ return call;
+ }
+
+ public Call register(String name, String email, String password) {
+ RequestBody requestBody = new FormBody.Builder()
+ .add("name", name)
+ .add("email", email)
+ .add("password", password)
+ .build();
+
+ Request request = new Request.Builder()
+ .url(BASE_URL + REGISTER_ENDPOINT)
+ .post(requestBody)
+ .build();
+ Call call = client.newCall(request);
+ return call;
+ }
+
+ public Call redeem(String code) {
+ RequestBody requestBody = new RequestBody() {
+ @Override
+ public MediaType contentType() {
+ return null;
+ }
+
+ @Override
+ public void writeTo(BufferedSink sink) throws IOException {
+
+ }
+ };
+
+ Request request = new Request.Builder()
+ .url(BASE_URL + REDEEM_ENDPOINT + code)
+ .post(requestBody)
+ .build();
+ Call call = client.newCall(request);
+ return call;
+ }
+
+ public Call changeEmail(String email) {
+ RequestBody requestBody = new FormBody.Builder()
+ .add("email", email)
+ .build();
+
+ Request request = new Request.Builder()
+ .url(BASE_URL + UPDATE_ENDPOINT)
+ .post(requestBody)
+ .build();
+
+ Call call = client.newCall(request);
+ return call;
+ }
+
+ public Call getProfile() {
+ Request request = new Request.Builder()
+ .url(BASE_URL + PROFILE_ENDPOINT)
+ .build();
+ Call call = client.newCall(request);
+ return call;
+ }
+
+ public Call getBlogById(String blogId) {
+ Request request = new Request.Builder()
+ .url(BASE_URL + GET_BLOG_ENDPOINT + blogId)
+ .build();
+ Call call = client.newCall(request);
+ return call;
+ }
+
+ public Call getBlogs() {
+ Request request = new Request.Builder()
+ .url(BASE_URL + GET_BLOGS_ENDPOINT)
+ .build();
+ Call call = client.newCall(request);
+ return call;
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/BlogResponse.java b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/BlogResponse.java
new file mode 100644
index 0000000..4b857ff
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/BlogResponse.java
@@ -0,0 +1,23 @@
+package com.dphoeniixx.mrfpractice.http.resposnes;
+
+import com.dphoeniixx.mrfpractice.data.model.Blog;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class BlogResponse {
+ @SerializedName("status")
+ @Expose
+ private String status;
+ @SerializedName("data")
+ @Expose
+ private Blog data;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public Blog getData() {
+ return data;
+ }
+
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/BlogsResponse.java b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/BlogsResponse.java
new file mode 100644
index 0000000..8bfd6a0
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/BlogsResponse.java
@@ -0,0 +1,25 @@
+package com.dphoeniixx.mrfpractice.http.resposnes;
+
+import com.dphoeniixx.mrfpractice.data.model.Blog;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+
+public class BlogsResponse {
+ @SerializedName("status")
+ @Expose
+ private String status;
+ @SerializedName("data")
+ @Expose
+ private ArrayList data;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public ArrayList getData() {
+ return data;
+ }
+
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/LoginResponse.java b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/LoginResponse.java
new file mode 100644
index 0000000..cc794b0
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/LoginResponse.java
@@ -0,0 +1,61 @@
+package com.dphoeniixx.mrfpractice.http.resposnes;
+
+import com.dphoeniixx.mrfpractice.data.model.User;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class LoginResponse {
+
+ @SerializedName("status")
+ @Expose
+ private String status;
+
+ @SerializedName("data")
+ @Expose
+ private LoginData data = new LoginData();
+
+ public String getStatus() {
+ return status;
+ }
+
+ public LoginData getData() {
+ return data;
+ }
+
+ public class LoginData {
+
+ @SerializedName("token")
+ @Expose
+ private String token;
+ @SerializedName("user")
+ @Expose
+ private User user;
+
+ public String getToken() {
+ return token;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ }
+
+ public class Error {
+ @SerializedName("status")
+ @Expose
+ private String status;
+ @SerializedName("message")
+ @Expose
+ private String message;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/ProfileResponse.java b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/ProfileResponse.java
new file mode 100644
index 0000000..ce49edc
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/ProfileResponse.java
@@ -0,0 +1,41 @@
+package com.dphoeniixx.mrfpractice.http.resposnes;
+
+import com.dphoeniixx.mrfpractice.data.model.User;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class ProfileResponse {
+ @SerializedName("status")
+ @Expose
+ private String status;
+
+ @SerializedName("data")
+ @Expose
+ private User data;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public User getUser() {
+ return data;
+ }
+
+ public class Error {
+ @SerializedName("status")
+ @Expose
+ private String status;
+ @SerializedName("message")
+ @Expose
+ private String message;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ }
+}
diff --git a/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/RegisterResponse.java b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/RegisterResponse.java
new file mode 100644
index 0000000..73b4b8f
--- /dev/null
+++ b/app/src/main/java/com/dphoeniixx/mrfpractice/http/resposnes/RegisterResponse.java
@@ -0,0 +1,74 @@
+package com.dphoeniixx.mrfpractice.http.resposnes;
+
+import com.dphoeniixx.mrfpractice.data.model.User;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+
+public class RegisterResponse {
+
+ @SerializedName("status")
+ @Expose
+ private String status;
+
+ @SerializedName("message")
+ @Expose
+ private String message;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public class Error {
+ @SerializedName("status")
+ @Expose
+ private String status;
+
+ @SerializedName("errors")
+ @Expose
+ private ArrayList errors;
+
+ @SerializedName("message")
+ @Expose
+ private String message;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public ArrayList getErrors() {
+ return errors;
+ }
+ }
+
+ public class ValidationError {
+ @SerializedName("value")
+ @Expose
+ private String value;
+
+ @SerializedName("msg")
+ @Expose
+ private String msg;
+
+ @SerializedName("param")
+ @Expose
+ private String param;
+
+ @SerializedName("location")
+ @Expose
+ private String location;
+
+ public String getMsg() {
+ return msg;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/font/advent_pro_thin.ttf b/app/src/main/res/font/advent_pro_thin.ttf
new file mode 100644
index 0000000..5f21778
Binary files /dev/null and b/app/src/main/res/font/advent_pro_thin.ttf differ
diff --git a/app/src/main/res/layout/activity_blog_post.xml b/app/src/main/res/layout/activity_blog_post.xml
new file mode 100644
index 0000000..9d14c9a
--- /dev/null
+++ b/app/src/main/res/layout/activity_blog_post.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..38e011a
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/blog_post.xml b/app/src/main/res/layout/blog_post.xml
new file mode 100644
index 0000000..328e4db
--- /dev/null
+++ b/app/src/main/res/layout/blog_post.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_blog.xml b/app/src/main/res/layout/fragment_blog.xml
new file mode 100644
index 0000000..b008241
--- /dev/null
+++ b/app/src/main/res/layout/fragment_blog.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_login.xml
new file mode 100644
index 0000000..4029ed8
--- /dev/null
+++ b/app/src/main/res/layout/fragment_login.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_profile.xml b/app/src/main/res/layout/fragment_profile.xml
new file mode 100644
index 0000000..5816307
--- /dev/null
+++ b/app/src/main/res/layout/fragment_profile.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..65f5ea5
--- /dev/null
+++ b/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c209e78
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..b2dfe3d
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..4f0f1d6
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..62b611d
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..948a307
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..1b9a695
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..28d4b77
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9287f50
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..aa7d642
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9126ae3
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml
new file mode 100644
index 0000000..9aaf1d4
--- /dev/null
+++ b/app/src/main/res/navigation/nav_graph.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/nav_graph2.xml b/app/src/main/res/navigation/nav_graph2.xml
new file mode 100644
index 0000000..41a796a
--- /dev/null
+++ b/app/src/main/res/navigation/nav_graph2.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/nav_graph3.xml b/app/src/main/res/navigation/nav_graph3.xml
new file mode 100644
index 0000000..e6c9542
--- /dev/null
+++ b/app/src/main/res/navigation/nav_graph3.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/raw/certificate b/app/src/main/res/raw/certificate
new file mode 100644
index 0000000..efe68f0
--- /dev/null
+++ b/app/src/main/res/raw/certificate
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDmzCCAoOgAwIBAgIUODzK/MHsRCNXnIC9W2SJFz3+C48wDQYJKoZIhvcNAQEL
+BQAwfTELMAkGA1UEBhMCWFgxDDAKBgNVBAgMA04vQTEMMAoGA1UEBwwDTi9BMSAw
+HgYDVQQKDBdTZWxmLXNpZ25lZCBjZXJ0aWZpY2F0ZTEwMC4GA1UEAwwnNTIuMTM5
+LjE1NC4yMzA6IFNlbGYtc2lnbmVkIGNlcnRpZmljYXRlMB4XDTIzMDMxMzE0NDU1
+MVoXDTI1MDMxMjE0NDU1MVowfTELMAkGA1UEBhMCWFgxDDAKBgNVBAgMA04vQTEM
+MAoGA1UEBwwDTi9BMSAwHgYDVQQKDBdTZWxmLXNpZ25lZCBjZXJ0aWZpY2F0ZTEw
+MC4GA1UEAwwnNTIuMTM5LjE1NC4yMzA6IFNlbGYtc2lnbmVkIGNlcnRpZmljYXRl
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsH3vKAU2pudyEMsVF4tE
+I10ia+VLdA9kaNFCZ1V1EoG/oCJxYbwGXLkipN6uBzq0TutMumblLApkfgfK2EqR
+5LJZdtb3hhFw4uMz5hxACi5fZLugJ6a4XeNiVxf3p4tkDJ4dNTEzcqdnXy3xSriT
+mSiNGcfw1pTkjdts0Y7Fta4rbSrm9lH7wM7NA8oXxzY9sB9EvVBEhwUfbX+kiY1Q
+9o8Q+9T0+QacsLrgk2ZY2EOQ1sdPk8WQ219SJ/7CH5JKT9h4wfTNm69Sba2zjr9U
+mmal1UQ14fVCCaPZrXcVXkIrkNGjkBVLzvfxywDCehTF7THBsOMpIhHI579Kenw5
+KwIDAQABoxMwETAPBgNVHREECDAGhwQ0i5rmMA0GCSqGSIb3DQEBCwUAA4IBAQCj
+16U0NY724FHyvNLCHG2Nhw3/MbmFm8WMjKPY8EZm5Z6j1HlBX4p54I0W2Z7YgBcl
+z4Is0onXI7ms2ywOE0q+7fAiWjYxBoYF3PhesVGwnqhA2zA7sajNHKmSTHzah0UE
+uW13/OidCIOCgqnq7xCGEgzPxJJxyrSuHO1sbXZcF5f7N+CREWPbrmjIO/PQ+9nY
+jhwUqyB+wG3K/oWOsohRFogumEPZpQ1CKC23VMEU81lDK7/6V8IOB3StJMR0KkML
+MOhX1Yv5Zdv2ouekDOedmmr0orm3Hl7Kumms7h5BR5+qJMvEnBtpGvMmOQNovenB
+0Sco/briLC6eKNI0w3VE
+-----END CERTIFICATE-----
\ No newline at end of file
diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml
new file mode 100644
index 0000000..a405d47
--- /dev/null
+++ b/app/src/main/res/values-land/dimens.xml
@@ -0,0 +1,4 @@
+
+ 48dp
+ 48dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
new file mode 100644
index 0000000..2678d55
--- /dev/null
+++ b/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-w1240dp/dimens.xml b/app/src/main/res/values-w1240dp/dimens.xml
new file mode 100644
index 0000000..cdf3842
--- /dev/null
+++ b/app/src/main/res/values-w1240dp/dimens.xml
@@ -0,0 +1,4 @@
+
+ 200dp
+ 200dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values-w600dp/dimens.xml b/app/src/main/res/values-w600dp/dimens.xml
new file mode 100644
index 0000000..a405d47
--- /dev/null
+++ b/app/src/main/res/values-w600dp/dimens.xml
@@ -0,0 +1,4 @@
+
+ 48dp
+ 48dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..f8c6127
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,10 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..b8c47cb
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+
+ 16dp
+
+ 16dp
+ 16dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..1cd9f21
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,27 @@
+
+ MRF.Practice
+ Settings
+
+ First Fragment
+ Second Fragment
+ Next
+ Previous
+
+ Hello first fragment
+ Hello second fragment. Arg: %1$s
+ FirstWebView
+ LoginActivity
+ Email
+ Password
+ Sign in or register
+ Sign in
+ "Welcome !"
+ Not a valid username
+ Password must be >5 characters
+ "Login failed"
+ Profile
+ Blog
+
+ Hello blank fragment
+ BlogPostActivity
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..b894cc7
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644
index 0000000..e2d1b4a
--- /dev/null
+++ b/app/src/main/res/values/themes.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/backup_rules.xml b/app/src/main/res/xml/backup_rules.xml
new file mode 100644
index 0000000..fa0f996
--- /dev/null
+++ b/app/src/main/res/xml/backup_rules.xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml
new file mode 100644
index 0000000..9ee9997
--- /dev/null
+++ b/app/src/main/res/xml/data_extraction_rules.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/com/dphoeniixx/mrfpractice/ExampleUnitTest.java b/app/src/test/java/com/dphoeniixx/mrfpractice/ExampleUnitTest.java
new file mode 100644
index 0000000..fdc772c
--- /dev/null
+++ b/app/src/test/java/com/dphoeniixx/mrfpractice/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.dphoeniixx.mrfpractice;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..a550ce3
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,9 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+ id 'com.android.application' version '7.2.1' apply false
+ id 'com.android.library' version '7.2.1' apply false
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..3d8e305
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,20 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
+
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..e708b1c
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..e1f8929
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Mar 03 21:39:06 EET 2023
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..4f906e0
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..ac1b06f
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..5a1d03d
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,16 @@
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ google()
+ mavenCentral()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+rootProject.name = "MRF.Practice"
+include ':app'