Skip to content
Snippets Groups Projects
Commit 2a8e8593 authored by vivek1826's avatar vivek1826
Browse files

Adding Our Special main Clean India app

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 781 additions and 0 deletions
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintExtraText" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintGradleCompatible" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Database2.iml" filepath="$PROJECT_DIR$/Database2.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
/build
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.srinivasan.database2"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\SRINIVASAN\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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
package com.example.srinivasan.database2;
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.*;
/**
* Instrumentation 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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.srinivasan.database2", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.srinivasan.database2">
<uses-permission
android:name="android.hardware.camera"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Start"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_login"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Loggedin"
android:label="@string/title_activity_loggedin"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Float"
android:label="@string/title_activity_float"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Login"
android:label="@string/title_activity_start"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".SingleView"
android:label="@string/title_activity_single_view"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Navmenu"
android:label="@string/title_activity_navmenu"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ScrollingActivity"
android:label="@string/title_activity_scrolling"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
\ No newline at end of file
package com.example.srinivasan.database2;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by SRINIVASAN on 3/26/2017.
*/
public class DatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME="users.db";
private static final String TABLE_NAME="user_table";
private static final String COLOUMN_ID="ID";
private static final String COLOUMN_NAME ="NAME";
private static final String COLOUMN_PASSWORD="PASSWORD";
SQLiteDatabase db;
public DatabaseHelper(Context context){
super(context, DATABASE_NAME , null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT , NAME TEXT, PASSWORD TEXT)");
}
public String searchpass(String uname){
db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("select NAME,PASSWORD from " +TABLE_NAME,null);
String a,b;
b= "not found";
if (cursor.moveToFirst()){
do{
a=cursor.getString(0);
if (a.equals(uname))
{
b=cursor.getString(1);
break;
}
}
while (cursor.moveToNext());
}
return b;
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
onCreate(db);
}
public boolean insertdata(String name,String password)
{
SQLiteDatabase db= this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COLOUMN_NAME,name);
contentValues.put(COLOUMN_PASSWORD,password);
long result = db.insert(TABLE_NAME,null,contentValues);
if (result == -1){
return false;
}
else {
return true;
}
}
}
package com.example.srinivasan.database2;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.widget.ImageView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by SRINIVASAN on 4/17/2017.
*/
public class DatabaseHelperTwo extends SQLiteOpenHelper {
private static final String DATABASE_NAME="users2.db";
private static final String TABLE_NAME="photo_table";
private static final String COLOUMN_DATE="DATE";
private static final String COLOUMN_TIME ="TIME";
private static final String COLOUMN_CONTENT="CONTENT";
private static final String KEY_IMAGE = "image_data";
SQLiteDatabase db;
private static final String CREATE_TABLE_IMAGE = "CREATE TABLE " +TABLE_NAME +"(ID INTEGER PRIMARY KEY AUTOINCREMENT,"+
"DATE TEXT," + " TIME TEXT," + " CONTENT TEXT," + KEY_IMAGE + " BLOB);";
public DatabaseHelperTwo(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_IMAGE);
}
public boolean addEntry( String date,String time,String content, byte[] image) throws SQLiteException {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(COLOUMN_DATE, date);
cv.put(COLOUMN_TIME, time);
cv.put(COLOUMN_CONTENT, content);
cv.put(KEY_IMAGE, image);
long result = db.insert(TABLE_NAME, null, cv);
if (result == -1){
return false;
}
else {
return true;
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
public ArrayList<Bitmap> searchpass() {
db = this.getReadableDatabase();
Cursor cursor= db.rawQuery("select * from " +TABLE_NAME,null);
Bitmap myBitMap ;
ArrayList<Bitmap> bitmapArray1 = new ArrayList<Bitmap>();
if (cursor.moveToFirst()){
do{
byte[] image = cursor.getBlob(4);
BitmapFactory.Options options = new BitmapFactory.Options();
try {
myBitMap = BitmapFactory.decodeByteArray(image, 0, image.length, options);
bitmapArray1.add(myBitMap);
}catch (NullPointerException e){
break;
}
} while (cursor.moveToNext());
}
return bitmapArray1;
}
public String[] dat(){
db = this.getReadableDatabase();
Cursor cursor= db.rawQuery("select * from " +TABLE_NAME,null);
String date;
int i=0;
String[] a = new String[500];
if (cursor.moveToFirst()){
do{
date = cursor.getString(1);
try {
a[i]=date;
i++;
}catch (ArrayIndexOutOfBoundsException e){
break;
}
} while (cursor.moveToNext());
}
return a;
}
public String[] tim(){
db = this.getReadableDatabase();
Cursor cursor= db.rawQuery("select * from " +TABLE_NAME,null);
String date;
int i=0;
String[] a = new String[500];
if (cursor.moveToFirst()){
do{
date = cursor.getString(2);
try {
a[i]=date;
i++;
}catch (ArrayIndexOutOfBoundsException e){
break;
}
} while (cursor.moveToNext());
}
return a;
}
public String[] com(){
db = this.getReadableDatabase();
Cursor cursor= db.rawQuery("select * from " +TABLE_NAME,null);
String date;
int i=0;
String[] a = new String[500];
if (cursor.moveToFirst()){
do{
date = cursor.getString(3);
try {
a[i]=date;
i++;
}catch (ArrayIndexOutOfBoundsException e){
break;
}
} while (cursor.moveToNext());
}
return a;
}
}
package com.example.srinivasan.database2;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import java.util.Calendar;
/**
* Created by SRINIVASAN on 3/26/2017.
*/
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(),this,year,month,day);
}
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
EditText textdate = (EditText) getActivity().findViewById(R.id.date);
textdate.setText(String.valueOf(dayOfMonth)+"/"+String.valueOf(monthOfYear) + "/" + String.valueOf(year)+"\n");
}
}
package com.example.srinivasan.database2;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
public class Float extends AppCompatActivity {
Session s;
DatabaseHelperTwo databaseHelperTwo;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_float);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/*
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id){
Intent i = new Intent(Float.this, SingleView.class);
// Pass image index
i.putExtra("id", position);
startActivity(i);
}
});
*/
RecyclerView recyclerView;
RecyclerView.LayoutManager layoutManager;
RecyclerView.Adapter adapter;
recyclerView =
(RecyclerView) findViewById(R.id.recycler_view);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
adapter = new RecyclerAdapter(this);
recyclerView.setAdapter(adapter);
button=(Button)findViewById(R.id.button);
databaseHelperTwo=new DatabaseHelperTwo(getApplicationContext());
databaseHelperTwo.searchpass();
s=new Session(this);
if (!s.loggedIn()){
logout();
}
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logout();
}
});
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(Float.this,Loggedin.class);
startActivity(intent);
}
});
}
private void logout(){
s.setLoggedIn(false);
finish();
startActivity(new Intent(Float.this,Login.class));
}
}
package com.example.srinivasan.database2;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import java.util.ArrayList;
/**
* Created by SRINIVASAN on 4/18/2017.
*/
public class ImageAdapter extends BaseAdapter {
private Context mContext;
DatabaseHelperTwo db2;
ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>();
// Constructor
public ImageAdapter(Context c) {
mContext = c;
db2=new DatabaseHelperTwo(mContext);
bitmapArray=db2.searchpass();
}
public int getCount() {
return bitmapArray.size() ;
//return 5;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(150, 150));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
}
else
{
imageView = (ImageView) convertView;
}
//v imageView.setImageResource(mThumbIds[position]);
imageView.setImageBitmap(bitmapArray.get(position));
return imageView;
}
public Integer[] mThumbIds = {
R.drawable.clean, R.drawable.bmwz,
R.drawable.calvin, R.drawable.doggy,
R.drawable.babysmile,R.drawable.cutebunny
};
}
package com.example.srinivasan.database2;
import android.annotation.TargetApi;
import android.app.DialogFragment;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
public class Loggedin extends AppCompatActivity {
DatabaseHelperTwo myDb;
public static final int REQUEST_CAPTURE =1;
ImageView resultPhoto;
EditText date,time,query;
Button add;
byte[] a;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loggedin);
myDb=new DatabaseHelperTwo(this);
Button click = (Button)findViewById(R.id.take);
resultPhoto = (ImageView)findViewById(R.id.photo);
date = (EditText)findViewById(R.id.date);
time = (EditText)findViewById(R.id.time);
query = (EditText)findViewById(R.id.query);
if(!hasCamera()){
click.setEnabled(false);
}
AddData();
}
public boolean hasCamera(){
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
}
public void launchCamera(View view){
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i,REQUEST_CAPTURE);
}
protected void onActivityResult(int requestCode,int resultCode,Intent data){
if(requestCode == REQUEST_CAPTURE && resultCode == RESULT_OK){
Bundle extras= data.getExtras();
Bitmap photo = (Bitmap)extras.get("data");
a=getBytes(photo);
resultPhoto.setImageBitmap(photo);
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void showDatePickerDialog(View v){
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(),"datePicker");
}
public void showTimePickerDialog(View v){
DialogFragment newFragment = new TimePickerFragment();
newFragment.show(getFragmentManager(),"datePicker");
}
public void AddData(){
add =(Button)findViewById(R.id.add);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean inserted= myDb.addEntry(date.getText().toString(),time.getText().toString(),query.getText().toString(),a);
if(inserted == true){
Intent intent=new Intent(Loggedin.this,Float.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),"Your feedback has been sent ",Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(getApplicationContext(),"Data not inserted",Toast.LENGTH_SHORT).show();
}
}
});
}
public static byte[] getBytes(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream);
return stream.toByteArray();
}
public static Bitmap getImage(byte[] image) {
return BitmapFactory.decodeByteArray(image, 0, image.length);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment