Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PrarthanaBhatt committed Feb 23, 2021
0 parents commit 58a2fe3
Show file tree
Hide file tree
Showing 61 changed files with 1,856 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

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

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

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

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

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

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

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

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

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

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.android.androidcomponents"
minSdkVersion 16
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
}
}

dependencies {

implementation 'androidx.appcompat:appcompat: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'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//material design
implementation 'com.google.android.material:material:1.2.1'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

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

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

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

import android.content.Context;

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

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

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.android.androidcomponents", appContext.getPackageName());
}
}
30 changes: 30 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.androidcomponents">

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AndroidComponents">
<activity android:name=".service.ServiceActivity"></activity>
<activity android:name=".contentproviders.ContentProviderActivity" />
<activity android:name=".notification.NotificationActivity" />
<activity android:name=".ReplaceFrsgmentActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<receiver android:name=".NotificationReceiver" />

<service android:name=".service.MyService2" />
</application>

</manifest>
43 changes: 43 additions & 0 deletions app/src/main/java/com/android/androidcomponents/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.android.androidcomponents;

import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;

public class App extends Application{

public static final String CHANNEL_1_ID = "channel1";
public static final String CHANNEL_2_ID = "channel2";

@Override
public void onCreate() {
super.onCreate();

createNotificationChannels();
}

private void createNotificationChannels() {
//oreo or higher
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel(
CHANNEL_1_ID,
"Channel 1",
NotificationManager.IMPORTANCE_HIGH
);
channel.setDescription("This is Channel 1");

NotificationChannel channel2 = new NotificationChannel(
CHANNEL_2_ID,
"Channel 2",
NotificationManager.IMPORTANCE_LOW
);
channel2.setDescription("This is Channel 2");

NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
manager.createNotificationChannel(channel2);
}

}
}
93 changes: 93 additions & 0 deletions app/src/main/java/com/android/androidcomponents/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.android.androidcomponents;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.Toast;

import com.android.androidcomponents.contentproviders.ContentProviderActivity;
import com.android.androidcomponents.contentproviders.ContentProviderFragment;
import com.android.androidcomponents.notification.NotificationActivity;
import com.android.androidcomponents.notification.NotificationFragment;
import com.android.androidcomponents.service.ServiceActivity;
import com.android.androidcomponents.service.ServiceFragment;

public class MainActivity extends AppCompatActivity {

Button button1,button2,button3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);

button1 = findViewById(R.id.button1);
button2 = findViewById(R.id.button2);
button3 = findViewById(R.id.button3);

button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Button1....", Toast.LENGTH_SHORT).show();

// FragmentManager manager = getSupportFragmentManager();
//// int count = manager.getBackStackEntryCount();
//
// getSupportFragmentManager().popBackStack();
//
// FragmentTransaction ft = manager.beginTransaction();
// ft.replace(R.id.mainContener, new NotificationFragment());
// ft.commit();


Intent intent = new Intent(MainActivity.this, NotificationActivity.class);
startActivity(intent);


}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Button2....", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, ServiceActivity.class);
startActivity(intent);
// FragmentManager manager = getSupportFragmentManager();
// int count = manager.getBackStackEntryCount();
//
// getSupportFragmentManager().popBackStack();
//
// FragmentTransaction ft = manager.beginTransaction();
// ft.replace(R.id.mainContener, new ServiceFragment());
// ft.commit();
}
});

button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Button3....", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, ContentProviderActivity.class);
startActivity(intent);

// FragmentManager manager = getSupportFragmentManager();
// int count = manager.getBackStackEntryCount();
//
// getSupportFragmentManager().popBackStack();
//
// FragmentTransaction ft = manager.beginTransaction();
// ft.replace(R.id.mainContener, new ContentProviderFragment());
// ft.commit();
}
});

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.android.androidcomponents;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class NotificationReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getStringExtra("toastMessage");
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.android.androidcomponents;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class ReplaceFrsgmentActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_replace_frsgment);
}
}
Loading

0 comments on commit 58a2fe3

Please sign in to comment.