diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/.gitignore b/Android/Mahesh/AndroidSplashScreenAssignment/.gitignore new file mode 100644 index 00000000..aa724b77 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.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/Android/Mahesh/AndroidSplashScreenAssignment/.idea/.gitignore b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/.idea/compiler.xml b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/compiler.xml new file mode 100644 index 00000000..fb7f4a8a --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/.idea/gradle.xml b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/gradle.xml new file mode 100644 index 00000000..5cd135a0 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/.idea/jarRepositories.xml b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/jarRepositories.xml new file mode 100644 index 00000000..0380d8d3 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/.idea/misc.xml b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/misc.xml new file mode 100644 index 00000000..6199cc2a --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/.idea/runConfigurations.xml b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/runConfigurations.xml new file mode 100644 index 00000000..797acea5 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/.gitignore b/Android/Mahesh/AndroidSplashScreenAssignment/app/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/build.gradle b/Android/Mahesh/AndroidSplashScreenAssignment/app/build.gradle new file mode 100644 index 00000000..1b60c35c --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/build.gradle @@ -0,0 +1,46 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.example.androidsplashscreenassignment" + minSdkVersion 23 + targetSdkVersion 30 + 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 + } + buildFeatures { + viewBinding true + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.navigation:navigation-fragment:2.3.5' + implementation 'androidx.navigation:navigation-ui:2.3.5' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation "androidx.viewpager2:viewpager2:1.0.0" +} \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/proguard-rules.pro b/Android/Mahesh/AndroidSplashScreenAssignment/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/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/Android/Mahesh/AndroidSplashScreenAssignment/app/src/androidTest/java/com/example/androidsplashscreenassignment/ExampleInstrumentedTest.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/androidTest/java/com/example/androidsplashscreenassignment/ExampleInstrumentedTest.java new file mode 100644 index 00000000..b2480c15 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/androidTest/java/com/example/androidsplashscreenassignment/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.androidsplashscreenassignment; + +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.androidsplashscreenassignment", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/AndroidManifest.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a67384aa --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/FirstFragment.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/FirstFragment.java new file mode 100644 index 00000000..0cc80ef7 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/FirstFragment.java @@ -0,0 +1,47 @@ +package com.example.androidsplashscreenassignment; + +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.example.androidsplashscreenassignment.databinding.FragmentFirstBinding; + +public class FirstFragment extends Fragment { + + private FragmentFirstBinding binding; + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + + binding = FragmentFirstBinding.inflate(inflater, container, false); + return binding.getRoot(); + + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + binding.buttonFirst.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(FirstFragment.this) + .navigate(R.id.action_FirstFragment_to_SecondFragment); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + +} \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/HomeScreen.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/HomeScreen.java new file mode 100644 index 00000000..8f3db2fb --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/HomeScreen.java @@ -0,0 +1,51 @@ +package com.example.androidsplashscreenassignment; + +import android.os.Bundle; + +import com.google.android.material.snackbar.Snackbar; + +import androidx.appcompat.app.AppCompatActivity; + +import android.view.View; + +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; + +import com.example.androidsplashscreenassignment.databinding.ActivityHomeScreenBinding; + +public class HomeScreen extends AppCompatActivity { + + private AppBarConfiguration appBarConfiguration; + private ActivityHomeScreenBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityHomeScreenBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + setSupportActionBar(binding.toolbar); + + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_home_screen); + appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build(); + NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); + + binding.fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + public boolean onSupportNavigateUp() { + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_home_screen); + return NavigationUI.navigateUp(navController, appBarConfiguration) + || super.onSupportNavigateUp(); + } +} \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/ScreenSlidePagerActivity.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/ScreenSlidePagerActivity.java new file mode 100644 index 00000000..77239f1c --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/ScreenSlidePagerActivity.java @@ -0,0 +1,101 @@ +package com.example.androidsplashscreenassignment; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.viewpager2.adapter.FragmentStateAdapter; +import androidx.viewpager2.widget.ViewPager2; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +public class ScreenSlidePagerActivity extends FragmentActivity { + /** + * The number of pages (wizard steps) to show in this demo. + */ + private static final int NUM_PAGES = 3; + + /** + * The pager widget, which handles animation and allows swiping horizontally to access previous + * and next wizard steps. + */ + private ViewPager2 viewPager; + + /** + * The pager adapter, which provides the pages to the view pager widget. + */ + private FragmentStateAdapter pagerAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_screen_slide); + + // Instantiate a ViewPager2 and a PagerAdapter. + viewPager = findViewById(R.id.pager); + pagerAdapter = new ScreenSlidePagerAdapter(this); + viewPager.setAdapter(pagerAdapter); + } + + @Override + public void onBackPressed() { + if (viewPager.getCurrentItem() == 0) { + // If the user is currently looking at the first step, allow the system to handle the + // Back button. This calls finish() on this activity and pops the back stack. + super.onBackPressed(); + } else { + // Otherwise, select the previous step. + viewPager.setCurrentItem(viewPager.getCurrentItem() - 1); + } + } + + /** + * A simple pager adapter that represents 3 ScreenSlidePageFragment objects, in + * sequence. + */ + private class ScreenSlidePagerAdapter extends FragmentStateAdapter { + public ScreenSlidePagerAdapter(FragmentActivity fa) { + super(fa); + } + + @Override + public Fragment createFragment(int position) { + return new SplashScreenFragment(position); + } + + @Override + public int getItemCount() { + return NUM_PAGES; + } + } + + /* Button OnClick Methods */ + public void onClickNext(View view) + { + int currentItem = viewPager.getCurrentItem(); + // Next button will go to the next page, except in the last page case + if (currentItem < NUM_PAGES - 1) + { + viewPager.setCurrentItem(viewPager.getCurrentItem() + 1); + } + // Otherwise, the process continues + else + { + goToFirstActivity(); + } + } + public void onClickBack(View view) + { + onBackPressed(); + } + public void onClickSkip(View view) + { + // The Activity is skipped, so the first activity after splash screen is called + goToFirstActivity(); + } + private void goToFirstActivity() + { + Intent goToNextActivity = new Intent(getApplicationContext(), HomeScreen.class); + startActivity(goToNextActivity); + } +} diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SecondFragment.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SecondFragment.java new file mode 100644 index 00000000..ffa452d9 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SecondFragment.java @@ -0,0 +1,47 @@ +package com.example.androidsplashscreenassignment; + +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.example.androidsplashscreenassignment.databinding.FragmentSecondBinding; + +public class SecondFragment extends Fragment { + + private FragmentSecondBinding binding; + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + + binding = FragmentSecondBinding.inflate(inflater, container, false); + return binding.getRoot(); + + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + binding.buttonSecond.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(SecondFragment.this) + .navigate(R.id.action_SecondFragment_to_FirstFragment); + } + }); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + +} \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SplashScreenData.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SplashScreenData.java new file mode 100644 index 00000000..ff9c287e --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SplashScreenData.java @@ -0,0 +1,37 @@ +package com.example.androidsplashscreenassignment; + +import java.util.HashMap; + +public class SplashScreenData { + + static String splashTitle1 = "Hello."; + static String splashTitle2 = "Easy to Use."; + static String splashTitle3 = "Get Started Today."; + + static String splashTextPage1 = "Welcome to LeafScan, an indispensable scanning service to suit your botanical requirements."; + static String splashTextPage2 = "Quickly identify and locate any and all plant species with a few taps."; + static String splashTextPage3 = "Take the first step of your green journey today."; + + /* + In the future, should change implementation of splash text to more sophisticated structure + */ + public static String GetSplashTitle(int position) + { + switch (position){ + case 0: return splashTitle1; + case 1: return splashTitle2; + case 2: return splashTitle3; + default: return ""; + } + } + public static String GetSplashText(int position) + { + switch (position){ + case 0: return splashTextPage1; + case 1: return splashTextPage2; + case 2: return splashTextPage3; + default: return ""; + } + } + +} diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SplashScreenFragment.java b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SplashScreenFragment.java new file mode 100644 index 00000000..319a3532 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/java/com/example/androidsplashscreenassignment/SplashScreenFragment.java @@ -0,0 +1,40 @@ +package com.example.androidsplashscreenassignment; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.Locale; + +public class SplashScreenFragment extends Fragment { + + private final int splashPosition; + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View splashPageView = inflater.inflate(R.layout.activity_launch, container, false); + + setSplashTextContent(splashPageView); + + return splashPageView; + + } + + private void setSplashTextContent(View splashPageView) { + TextView splashText1 = (TextView) splashPageView.findViewById(R.id.splashText1); + splashText1.setText(SplashScreenData.GetSplashText(splashPosition)); + + TextView splashTitle = (TextView) splashPageView.findViewById(R.id.splashTitle); + splashTitle.setText(SplashScreenData.GetSplashTitle(splashPosition)); + } + + public SplashScreenFragment(int position) + { + splashPosition = position; + } +} \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/ic_launcher_background.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/ic_leaf_vector_asset.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/ic_leaf_vector_asset.xml new file mode 100644 index 00000000..76941e98 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/ic_leaf_vector_asset.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/splash_screen_gradient.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/splash_screen_gradient.xml new file mode 100644 index 00000000..bb690964 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/drawable/splash_screen_gradient.xml @@ -0,0 +1,8 @@ + + + + diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/layout/activity_home_screen.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/layout/activity_home_screen.xml new file mode 100644 index 00000000..b28ad30f --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/layout/activity_home_screen.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/layout/activity_launch.xml b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/layout/activity_launch.xml new file mode 100644 index 00000000..fad1cf92 --- /dev/null +++ b/Android/Mahesh/AndroidSplashScreenAssignment/app/src/main/res/layout/activity_launch.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + +