Skip to content

Commit

Permalink
Added Android files
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvraj-2503 authored Mar 28, 2021
1 parent 911c356 commit 0bab02a
Show file tree
Hide file tree
Showing 100 changed files with 1,469 additions and 0 deletions.
59 changes: 59 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'kotlin-android'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.shakshya"
minSdkVersion 17
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
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.8.0')

// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics-ktx'

// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.volley:volley:1.2.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 'com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
39 changes: 39 additions & 0 deletions google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "510131882439",
"project_id": "shakshya-9b7f2",
"storage_bucket": "shakshya-9b7f2.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:510131882439:android:177a15f212c482e5fb71e2",
"android_client_info": {
"package_name": "com.example.shakshya"
}
},
"oauth_client": [
{
"client_id": "510131882439-6t2ak1ajp5j6jk8ek9sq4974ikqktjl7.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBGR_xrgGaHU4vne8rHD0YXrEl92eECjHw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "510131882439-6t2ak1ajp5j6jk8ek9sq4974ikqktjl7.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
21 changes: 21 additions & 0 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

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

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

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.shakshya

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

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

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.shakshya", appContext.packageName)
}
}
27 changes: 27 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shakshya">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/app_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/app_icon_round"
android:supportsRtl="true"
android:resizeableActivity="false"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/Theme.SHAKSHYA">
<activity android:name=".activity.MainActivity"
android:screenOrientation="portrait" android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

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

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.Settings
import android.view.MenuItem
import android.widget.FrameLayout
import android.widget.Toast
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.app.ActivityCompat
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.example.shakshya.R
import com.example.shakshya.fragment.AboutUsFragment
import com.example.shakshya.fragment.ContactUsFragment
import com.example.shakshya.fragment.DashboardFragment
import com.example.shakshya.fragment.TeamFragment
import com.example.shakshya.util.ConnectionManager
import com.google.android.material.navigation.NavigationView

class MainActivity : AppCompatActivity() {
lateinit var frameLayout: FrameLayout
lateinit var coordinatorLayout: CoordinatorLayout
lateinit var navigationView: NavigationView
lateinit var drawerLayout: DrawerLayout
lateinit var toolbar: androidx.appcompat.widget.Toolbar
var previousMenuItem: MenuItem? =null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
frameLayout=findViewById(R.id.frameLayout)
coordinatorLayout=findViewById(R.id.coordinatorLayout)
navigationView=findViewById(R.id.navigationView)
drawerLayout=findViewById(R.id.drawerLayout)
toolbar=findViewById(R.id.toolBar)
setUpToolbar()
openDashboard()
val actionBarDrawerToggle= ActionBarDrawerToggle(
this@MainActivity,
drawerLayout,
R.string.open_drawer,
R.string.close_drawer)
drawerLayout.addDrawerListener(actionBarDrawerToggle)
actionBarDrawerToggle.syncState()

navigationView.setNavigationItemSelectedListener {
if (previousMenuItem!=null)
previousMenuItem?.isChecked=false
it.isCheckable=true
it.isChecked=true
previousMenuItem=it
when(it.itemId){
R.id.dashboard -> {
openDashboard()
drawerLayout.closeDrawers()
}
R.id.about_app -> {
supportFragmentManager.beginTransaction()
.replace(R.id.frameLayout, AboutUsFragment())
.commit()
supportActionBar?.title="About Us"
drawerLayout.closeDrawers()
}
R.id.team -> {
supportFragmentManager.beginTransaction()
.replace(R.id.frameLayout, TeamFragment())
.commit()
supportActionBar?.title="Our Team"
drawerLayout.closeDrawers()
}
R.id.contact -> {
supportFragmentManager.beginTransaction()
.replace(R.id.frameLayout, ContactUsFragment())
.commit()
supportActionBar?.title="Contact Us"
drawerLayout.closeDrawers()
}
}
return@setNavigationItemSelectedListener true
}
if(ConnectionManager().checkConnectivity(this)){
//Internet available
Toast.makeText(this,"Internet Connected.", Toast.LENGTH_SHORT).show()
}else{
//Internet not available
val dialog= AlertDialog.Builder(this)
dialog.setTitle("Error")
dialog.setMessage("Internet Not Connected..!!")
dialog.setPositiveButton("Open Settings"){text,listener ->
val settingsIntent= Intent(Settings.ACTION_WIRELESS_SETTINGS)
startActivity(settingsIntent)
finish()
}
dialog.setNegativeButton("Exit"){text,listener ->
ActivityCompat.finishAffinity(this)
}
dialog.create()
dialog.show()
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id=item.itemId
if (id==android.R.id.home){
drawerLayout.openDrawer(GravityCompat.START)
}
return super.onOptionsItemSelected(item)
}
fun setUpToolbar(){
setSupportActionBar(toolbar)
supportActionBar?.title ="Toolbar Title"
supportActionBar?.setHomeButtonEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

override fun onBackPressed() {
val flag=supportFragmentManager.findFragmentById(R.id.frameLayout)
when(flag){
!is DashboardFragment -> openDashboard()
else -> super.onBackPressed()
}
drawerLayout.closeDrawers()
}
fun openDashboard(){
val transaction=supportFragmentManager.beginTransaction()
val fragment=DashboardFragment()
transaction.replace(R.id.frameLayout,fragment)
transaction.commit()
supportActionBar?.title="Dashboard"
navigationView.setCheckedItem(R.id.dashboard)
}
override fun onPause() {
super.onPause()
finish()
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/example/shakshya/fragment/AboutUsFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.shakshya.fragment

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.example.shakshya.R

class AboutUsFragment : Fragment() {

lateinit var btnLink:Button
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
val view=inflater.inflate(R.layout.fragment_about_us, container, false)
btnLink=view.findViewById(R.id.btnKnowMore)
btnLink.setOnClickListener {
val intent= Intent(Intent.ACTION_VIEW, Uri.parse("https://himanshu-0624.github.io/Shakshya/index.html"))
startActivity(intent)
}
return view
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/example/shakshya/fragment/ContactUsFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.shakshya.fragment

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 androidx.annotation.NonNull
import com.example.shakshya.R
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView

class ContactUsFragment : Fragment() {

lateinit var youTubeView: YouTubePlayerView
lateinit var emailLink: TextView
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view=inflater.inflate(R.layout.fragment_contact_us, container, false)
return view
}
}
Loading

0 comments on commit 0bab02a

Please sign in to comment.