73
APPENDIX Application Store Admin build.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } app/build.gradle apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig { applicationId "com.example.root.projectku" minSdkVersion 17 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro' } } } dependencies { A

Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

APPENDIX

Application Store Admin

build.gradle

// Top-level build file where you can add configuration optionscommon to all sub-projects/modules.buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; theybelong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}

app/build.gradle

apply plugin: 'com.android.application'android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig { applicationId "com.example.root.projectku" minSdkVersion 17 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies {

A

Page 2: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

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 files('libs/android-async-http-1.4.6.jar') compile files('libs/http-core-4.1.jar') compile files('libs/httpclient-4.0.3.jar') compile 'com.android.support:appcompat-v7:25.3.0' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.google.firebase:firebase-auth:9.4.0' compile 'com.google.firebase:firebase-database:9.4.0' compile 'com.google.android.gms:play-services-maps:9.4.0' compile 'com.android.support:design:25.3.0' compile 'com.google.firebase:firebase-storage:9.4.0' compile 'com.github.bumptech.glide:glide:3.7.0' testCompile 'junit:junit:4.12'}apply plugin: 'com.google.gms.google-services'

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.example.root.projectku">

<!-- The ACCESS_COARSE/FINE_LOCATION permissions are notrequired to use Google Maps Android API v2, but you must specify eithercoarse or fine location permissions for the 'MyLocation' functionality. --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permissionandroid:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permissionandroid:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.SEND_SMS" />

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"

B

Page 3: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"></activity> <activity android:name=".LoginActivity" android:label="Login" /> <activity android:name=".LokasiTokoActivity" android:label="@string/title_activity_toko" /> <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" />

<activity android:name=".ListOrderActivity" /> <activity android:name=".HomeActivity"android:noHistory="true"/> <activity android:name=".LauncherActivity"android:noHistory="true"> <intent-filter> <actionandroid:name="android.intent.action.MAIN" />

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

</manifest>

LoginActivity.java

package com.example.root.client;import android.app.ProgressDialog;import android.content.Intent;import android.os.Bundle;import android.support.annotation.NonNull;import android.support.v7.app.AppCompatActivity;import android.text.TextUtils;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;import com.google.android.gms.tasks.OnCompleteListener;import com.google.android.gms.tasks.Task;import com.google.firebase.auth.AuthResult;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.auth.FirebaseUser;

C

Page 4: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

public class LoginActivity extends AppCompatActivity implementsView.OnClickListener { private Button btSignin; private EditText etEmail; private EditText etPasword; private FirebaseAuth firebaseAuth; private ProgressDialog progressDialog; private FirebaseUser firebaseUser; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); firebaseAuth = FirebaseAuth.getInstance(); if(firebaseAuth.getCurrentUser() != null){ finish(); startActivity(new Intent(getApplicationContext(),MenuActivity.class)); } etEmail = (EditText) findViewById(R.id.etEmail); etPassword = (EditText) findViewById(R.id.etPassword); btSignin = (Button) findViewById(R.id.btSignin); progressDialog = new ProgressDialog(this); btSignin.setOnClickListener(this); } private void userLogin(){ final String email = etEmail.getText().toString().trim(); String password = etPassword.getText().toString().trim(); if (TextUtils.isEmpty(email)) { Toast.makeText(this, "enter email please",Toast.LENGTH_LONG).show(); return; } if (TextUtils.isEmpty(password)) { Toast.makeText(this, "enter password please",Toast.LENGTH_LONG).show(); return; } progressDialog.setMessage("wait.."); progressDialog.show(); firebaseAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, newOnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult>task) { progressDialog.dismiss(); if (task.isSuccessful()) { finish(); startActivity(newIntent(getApplicationContext(), MenuActivity.class)); } }

D

Page 5: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

}); } @Override public void onClick(View view) { if(view == buttonSignIn){ userLogin(); } }}

activity_login.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.projectku.LoginActivity"> <LinearLayout android:layout_centerVertical="true" android:layout_width="368dp" android:layout_height="wrap_content" android:orientation="vertical" tools:layout_editor_absoluteY="0dp" tools:layout_editor_absoluteX="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="User Login" android:id="@+id/textView" android:layout_gravity="center_horizontal" /> <EditText android:id="@+id/etEmail" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter email" android:inputType="textEmailAddress" /> <EditText android:id="@+id/etPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter password" android:inputType="textPassword" /> <Button android:id="@+id/btSignin" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:text="Login" />

E

Page 6: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

</LinearLayout></android.support.constraint.ConstraintLayout>

LauncherActivity.java

package com.example.root.projectku;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.support.v7.app.AppCompatActivity;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.DatabaseReference;public class LauncherActivity extends AppCompatActivity { private FirebaseAuth firebaseAuth; private static final int SPLASH_TIME = 2 * 1000; private DatabaseReference firebaseTable,firebaseSubTable; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); try { new Handler().postDelayed(new Runnable() { public void run() { firebaseAuth = FirebaseAuth.getInstance(); if(firebaseAuth.getCurrentUser() != null){ Intent intent = newIntent(LauncherActivity.this, HomeActivity.class); startActivity(intent); LauncherActivity.this.finish(); } else { Intent intent = newIntent(LauncherActivity.this, MainActivity.class); startActivity(intent); LauncherActivity.this.finish(); } } }, SPLASH_TIME); } catch(Exception e){} } @Override public void onBackPressed() { this.finish(); super.onBackPressed(); }}

activity_launcher.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android"

F

Page 7: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.projectku.LauncherActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Welcome..."/></android.support.constraint.ConstraintLayout>

HomeActivity.java

package com.example.root.projectku;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import com.google.firebase.database.ValueEventListener;public class HomeActivity extends AppCompatActivity { Button btList; Button btBarang; Button btHistory; Button btLogout; private FirebaseAuth firebaseAuth; private DatabaseReference firebaseTable,firebaseSubTable; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); firebaseAuth = FirebaseAuth.getInstance(); btBarang = (Button) findViewById(R.id.btBarang); btList = (Button) findViewById(R.id.btList); btHistory = (Button) findViewById(R.id.btHistory); btLogout = (Button) findViewById(R.id.btLogout); btBarang.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); startActivity(new Intent(getApplicationContext(),LokasiTokoActivity.class)); } }); btList.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { firebaseTable =FirebaseDatabase.getInstance().getReference().child("BarangToko");

G

Page 8: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

firebaseTable.addValueEventListener(newValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { for(DataSnapshot singleSnapshot :snapshot.getChildren()) { if(singleSnapshot.child("Admin").getValue().toString() .equals(firebaseAuth.getCurrentUser().getEmail().replace('.',','))) { ListOrderActivity.KEY_NAMA_TOKO=singleSnapshot.getKey().toString(); finish(); startActivity(newIntent(getApplicationContext(), ListOrderActivity.class)); } } } @Override public void onCancelled(DatabaseErrordatabaseError) { } }); } }); btHistory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { firebaseTable =FirebaseDatabase.getInstance().getReference().child("BarangToko"); firebaseTable.addValueEventListener(newValueEventListener() {//Membaca dan mendengarkan perubahan untuk seluruhkonten jalur. @Override public void onDataChange(DataSnapshot snapshot) { for(DataSnapshot singleSnapshot :snapshot.getChildren()) { if(singleSnapshot.child("Admin").getValue().toString().equals(firebaseAuth.getCurrentUser().getEmail().replace('.',','))) { HistoryOrderActivity.KEY_NAMA_TOKO=singleSnapshot.getKey().toString(); finish(); startActivity(newIntent(getApplicationContext(), HistoryOrderActivity.class)); } } } @Override public void onCancelled(DatabaseErrordatabaseError) { } }); } });

H

Page 9: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

btLogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { firebaseAuth.signOut(); finish(); startActivity(new Intent(getApplicationContext(),LoginActivity.class)); } }); }}

activity_home.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.projectku.HomeActivity"> <Button android:id="@+id/btList" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="List Order" android:layout_marginTop="24dp" android:layout_below="@+id/btBarang" android:layout_centerHorizontal="true" /> <Button android:id="@+id/btBarang" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Update Barang" android:layout_marginTop="21dp" android:layout_alignParentTop="true" android:layout_alignStart="@+id/btHistory" /> <Button android:id="@+id/btHistory" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Delivery Order" android:layout_below="@+id/btList" android:layout_marginTop="21dp" android:layout_centerHorizontal="true" /> <Button android:id="@+id/btLogout" android:layout_width="wrap_content" android:layout_height="wrap_content"

I

Page 10: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_weight="1" android:text="Logout" android:layout_marginTop="21dp" android:layout_below="@+id/btHistory" android:layout_centerHorizontal="true" /></RelativeLayout>

LokasiTokoActivity.java

package com.example.root.projectku;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.Toast;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import java.util.HashMap;import java.util.Map;public class LokasiTokoActivity extends AppCompatActivity { private FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(); private DatabaseReferencefirebaseDatabase=FirebaseDatabase.getInstance().getReference().getRoot(),firebaseTable, firebaseSubTable, firebaseSubSubTable, firebaseRecord; String temp_key_id_toko,temp_key_toko,temp_key_barang; Map<String, Object> map_toko,map_barang; Button btnMenu; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lokasi_toko); btnMenu = (Button) findViewById(R.id.btMenu); firebaseTable = firebaseDatabase.child("BarangToko"); firebaseSubTable=firebaseTable.child("Alfamart Krakatau"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","1@gmail,com"); map_toko.put("Latitude", "-6.987331"); map_toko.put("Longitude", "110.437260"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Aqua Botol 600ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "4500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Krakatau"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Bango Kecap Manis600ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "26000");

J

Page 11: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Krakatau"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Indomilk Susu KentalManis 370gr"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "9500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Krakatau"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Aqua Botol 600ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "4500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Krakatau"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Filma Minyak Goreng2L"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "2500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Labuhan Raya"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","2@gmail,com"); map_toko.put("Latitude", "-6.988187"); map_toko.put("Longitude", "110.436879"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Tango Wafer 300gr"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "21000"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Labuhan Raya"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Sariwangi Teh CelupAsli 25sachet"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "6900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Labuhan Raya"); firebaseSubSubTable=firebaseSubTable.child("Barang");

K

Page 12: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

firebaseRecord=firebaseSubSubTable.child("Rejoice Shampoo Rich320ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "30500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Labuhan Raya"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Sariwangi Teh CelupAsli 25sachet"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "6900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Labuhan Raya"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Nice Facial Tissue NonPerfumed 2Ply 700gr"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "18900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamidi Sidodadi"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","3@gmail,com"); map_toko.put("Latitude", "-6.989611"); map_toko.put("Longitude", "110.434986"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Detol Body Wash AntiBakteri 450ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "30900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamidi Sidodadi"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Nature E HandbodyLotion 245ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "23900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamidi Sidodadi"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Formula Pasta GigiStrong Protector 2x100gr"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "17900");

L

Page 13: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamidi Sidodadi"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Rinso Anti NodaDeterjen 1kg"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "27800"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Point Unika"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","4@gmail,com"); map_toko.put("Latitude", "-7.025296"); map_toko.put("Longitude", "110.404211"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Indomie Mie Goreng"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "2000"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Point Unika"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Lifeboy Shampoo AntiDandruff 170ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "15900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Point Unika"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Close Up Pasta GigiMenthol"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "15000"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Point Unika"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("So Klin SoftergentPowder 800gr"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "14300"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Unika"); map_toko = new HashMap<String, Object>();

M

Page 14: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

map_toko.put("Admin","5@gmail,com"); map_toko.put("Latitude", "-7.024602"); map_toko.put("Longitude", "110.403863"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Mie Sedap KariSpesial"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "3500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Unika"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Pantene Shampo AntiDandruff 170ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "20800"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Unika"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("KRAFT Oreo SelectionBiscuit 352gr"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "40900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Unika"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Garnier Men Acno FightWasabi 100ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","28900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret dan ATM BCATinjomoyo"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","6@gmail,com"); map_toko.put("Latitude", "-7.029462"); map_toko.put("Longitude", "110.408694"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Listerine MouthwashAntiseptic 250ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "19500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang);

N

Page 15: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

firebaseSubTable=firebaseTable.child("Indomaret dan ATM BCATinjomoyo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Nivea Deo Roll OnExtra Whitening"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","16400"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret dan ATM BCATinjomoyo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Minute Maid JuicePulpy 350ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","5500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret dan ATM BCATinjomoyo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Indomaret Beras RamosSuper 5kg"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","59900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Kadirojo"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","7@gmail,com"); map_toko.put("Latitude", "-7.767377"); map_toko.put("Longitude", "110.448636"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Minyak Goreng SaniaRefil 2L"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "23000"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Kadirojo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Sunligh Pencuci Piring800ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","14500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Kadirojo");

O

Page 16: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Vixal Botol Blue800ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","14500"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Kadirojo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("HIT Insektisida SprayOrange 600ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","25900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Kadirojo"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","8@gmail,com"); map_toko.put("Latitude", "-7.764747"); map_toko.put("Longitude", "110.448845"); firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Minyak Goreng FilmaRefil 2L"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "23000"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Kadirojo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Pantene Shampo AntiDandruff 170ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "20800"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Alfamart Kadirojo"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Alfamart Beras RamosSuper 5kg"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","59900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Maluku"); map_toko = new HashMap<String, Object>(); map_toko.put("Admin","9@gmail,com"); map_toko.put("Latitude", "-6.991882"); map_toko.put("Longitude", "110.436643");

P

Page 17: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

firebaseSubTable.updateChildren(map_toko); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Force Magic Lemon600ml"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "23000"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Maluku"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Marjan Boudoin 500mlAll Varian"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga", "18900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); firebaseSubTable=firebaseTable.child("Indomaret Maluku"); firebaseSubSubTable=firebaseSubTable.child("Barang"); firebaseRecord=firebaseSubSubTable.child("Selamat Wafer Kaleng200g"); map_barang = new HashMap<String, Object>(); map_barang.put("Harga","15900"); map_barang.put("Stok", "1000"); map_barang.put("StokMutasi", "0"); firebaseRecord.updateChildren(map_barang); Toast.makeText(getApplicationContext(), "BarangToko Suksesditambahkan", Toast.LENGTH_LONG).show(); btnMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); startActivity(new Intent(getApplicationContext(),HomeActivity.class)); } }); }}

activity_lokasi_toko.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.projectku.LokasiTokoActivity"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" tools:layout_editor_absoluteY="4dp" tools:layout_editor_absoluteX="113dp">

Q

Page 18: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

<Button android:id="@+id/btMenu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="Back to Menu" tools:layout_editor_absoluteX="130dp" tools:layout_editor_absoluteY="0dp" /> </RelativeLayout></android.support.constraint.ConstraintLayout>

ListOrderActivity.java

package com.example.root.projectku;import android.app.AlertDialog;import android.content.DialogInterface;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.AdapterView;import android.widget.Button;import android.widget.ListView;import android.widget.TextView;import android.widget.Toast;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.ChildEventListener;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import com.google.firebase.database.Query;import com.google.firebase.database.ValueEventListener;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;public class ListOrderActivity extends AppCompatActivity { public static String KEY_NAMA_TOKO="1"; public static String KEY_ID_ORDER="2"; public static String KEY_STATUS="3"; public static String KEY_TANGGAL="4"; public static String KEY_TOTAL="5"; public static String KEY_USERNAME="6"; public static String KEY_ORDER_DETAIL="7"; private FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(); private DatabaseReference firebaseDatabase=FirebaseDatabase.getInstance().getReference().getRoot(),firebaseTable,firebaseSubTable, firebaseSubSubTable, firebaseRecord,firebaseRecordDetail; String tabel = "Order"; String NamaBarang = "", Qty = "", Stok="0"; int StokInt; Button btnMenu; ListView listP, mListData;

R

Page 19: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

ListOrderAdapter adapter; ArrayList<HashMap<String, String>> listRow = newArrayList<HashMap<String, String>>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_order); listP = (ListView) findViewById(R.id.listorder); btnMenu = (Button) findViewById(R.id.btMenu); firebaseTable = firebaseDatabase.child(tabel); firebaseSubTable = firebaseTable.child(KEY_NAMA_TOKO); Query query = firebaseSubTable.orderByKey(); query.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String namaToko = ""; String idOrder = ""; String status = ""; String tanggal = ""; String total = ""; String userName = ""; for (DataSnapshot singleSnapshot :dataSnapshot.getChildren()) { HashMap<String, String> map = new HashMap<String,String>(); idOrder = singleSnapshot.getKey().toString(); status =singleSnapshot.child("Status").getValue().toString(); tanggal =singleSnapshot.child("Tanggal").getValue().toString(); total =singleSnapshot.child("Total").getValue().toString(); userName =singleSnapshot.child("Username").getValue().toString().replace(",","."); String orderDetail = ""; for (DataSnapshot singleSnapshot2 :singleSnapshot.child("OrderDetail").getChildren()) { orderDetail = orderDetail +singleSnapshot2.child("NamaBarang").getValue().toString()+"-"+singleSnapshot2.child("Harga").getValue().toString()+"-"+singleSnapshot2.child("Qty").getValue().toString()+"\r\n"; } if(status.equals("Pending")) { map.put(KEY_ID_ORDER, idOrder); map.put(KEY_STATUS, status); map.put(KEY_TANGGAL, tanggal); map.put(KEY_TOTAL, total); map.put(KEY_USERNAME, userName); map.put(KEY_ORDER_DETAIL, orderDetail); listRow.add(map); } } adapter = new ListOrderAdapter(ListOrderActivity.this,listRow); listP.setAdapter(adapter);

S

Page 20: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

} @Override public void onCancelled(DatabaseError databaseError) { } }); listP.setOnItemLongClickListener(newAdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, finalView view, final int position, long id) { new AlertDialog.Builder(ListOrderActivity.this) .setTitle(getResources().getString(R.string.status)) .setMessage(getResources().getString(R.string.status_message)) .setPositiveButton(getResources().getString(R.string.send), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterfacedialog, int which) { TextView idOrderNya = (TextView)view.findViewById(R.id.tvIdOrder); firebaseRecord=firebaseSubTable.child(idOrderNya.getText().toString()); firebaseRecord.child("Status").setValue("Terkirim"); firebaseRecordDetail=firebaseRecord.child("OrderDetail"); firebaseRecordDetail.addChildEventListener(new ChildEventListener() { @Override public voidonChildAdded(DataSnapshot dataSnapshot, String s) { Iterator i =dataSnapshot.getChildren().iterator(); while (i.hasNext()) { i.next(); NamaBarang = (String)((DataSnapshot) i.next()).getValue(); Qty = (String)((DataSnapshot) i.next()).getValue(); DatabaseReferencefirebaseRecordUpdateQty =firebaseDatabase.child("BarangToko").child(KEY_NAMA_TOKO).child("Barang").child(NamaBarang); firebaseRecordUpdateQty.child("StokMutasi").setValue(Qty); } } @Override public voidonChildChanged(DataSnapshot dataSnapshot, String s) { } @Override

T

Page 21: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

public voidonChildRemoved(DataSnapshot dataSnapshot) { } @Override public voidonChildMoved(DataSnapshot dataSnapshot, String s) { } @Override public voidonCancelled(DatabaseError databaseError) { } }); DatabaseReference fbStok =firebaseDatabase.child("BarangToko").child(KEY_NAMA_TOKO).child("Barang"); fbStok.addListenerForSingleValueEvent(new ValueEventListener() { @Override public voidonDataChange(DataSnapshot dataSnapshot) { DatabaseReference fbStok2 =firebaseDatabase.child("BarangToko").child(KEY_NAMA_TOKO).child("Barang").child(dataSnapshot.getKey()); for(DataSnapshotsingleSnapshot1 : dataSnapshot.getChildren()) { String stok =singleSnapshot1.child("Stok").getValue().toString(); String stokmutasi=singleSnapshot1.child("StokMutasi").getValue().toString(); intstokbaru=Integer.parseInt(stok)-Integer.parseInt(stokmutasi); } } @Override public voidonCancelled(DatabaseError databaseError) { } }); Toast.makeText(getApplicationContext(), "Data "+idOrderNya.getText().toString()+" Sukses disimpan",Toast.LENGTH_LONG).show(); finish(); startActivity(newIntent(getApplicationContext(), HomeActivity.class)); } }) .setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterfacedialog, int which) { TextView idOrderNya = (TextView)view.findViewById(R.id.tvIdOrder);

U

Page 22: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

firebaseRecord=firebaseSubTable.child(idOrderNya.getText().toString()); firebaseRecord.child("Status").setValue("Dibatalkan"); Toast.makeText(getApplicationContext(), "Data "+idOrderNya.getText().toString()+" Sukses dicancel (batalkan)",Toast.LENGTH_LONG).show(); finish(); startActivity(newIntent(getApplicationContext(), HomeActivity.class)); } }) .show(); return false; } }); btnMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); startActivity(new Intent(getApplicationContext(),HomeActivity.class)); } }); } public void onBackPressed() { this.finish(); super.onBackPressed(); }}

ListOrderAdapter.java

package com.example.root.projectku;import android.app.Activity;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.TextView;import java.util.ArrayList;import java.util.HashMap;public class ListOrderAdapter extends BaseAdapter { private Activity activity; private ArrayList<HashMap<String, String>> data; private static LayoutInflater inflater = null; public ListOrderAdapter(Activity a, ArrayList<HashMap<String,String>> d) { activity = a; data = d; inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); }

V

Page 23: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroupparent) { View vi = convertView; if (convertView == null) vi = inflater.inflate(R.layout.list_order, null); TextView tvIdOrder= (TextView) vi.findViewById(R.id.tvIdOrder); TextView tvStatus= (TextView) vi.findViewById(R.id.tvStatus); TextView tvTanggal= (TextView) vi.findViewById(R.id.tvTanggal); TextView tvTotal= (TextView) vi.findViewById(R.id.tvTotal); TextView tvUsername= (TextView)vi.findViewById(R.id.tvUsername); TextView tvOrderDetail= (TextView)vi.findViewById(R.id.tvOrderDetail); HashMap<String, String> hasil = new HashMap<String, String>(); hasil = data.get(position); tvIdOrder.setText(hasil.get(ListOrderActivity.KEY_ID_ORDER)); tvStatus.setText(hasil.get(ListOrderActivity.KEY_STATUS)); tvTanggal.setText(hasil.get(ListOrderActivity.KEY_TANGGAL)); tvTotal.setText(hasil.get(ListOrderActivity.KEY_TOTAL)); tvUsername.setText(hasil.get(ListOrderActivity.KEY_USERNAME)); tvOrderDetail.setText(hasil.get(ListOrderActivity.KEY_ORDER_DETAIL)); return vi; }}

activity_list_order.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="368dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:orientation="vertical" tools:layout_editor_absoluteX="8dp" tools:layout_editor_absoluteY="29dp" tools:context="com.example.root.projectku.ListOrderActivity"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <ListView

W

Page 24: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:id="@+id/listorder" android:layout_width="wrap_content" android:layout_height="445dp" android:layout_alignParentStart="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btMenu" android:text="Back to Menu" android:layout_below="@+id/listorder" android:layout_centerHorizontal="true" /> </RelativeLayout></android.support.constraint.ConstraintLayout>

list_order.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ID Order: " /> <TextView android:id="@+id/tvIdOrder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Large Text" android:textAppearance="?android:attr/textAppearanceMedium"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User: " /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"

X

Page 25: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:textAppearance="?android:attr/textAppearanceMedium" android:text="Large Text" android:id="@+id/tvUsername"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tanggal: " /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Large Text" android:id="@+id/tvTanggal"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Total: " /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Large Text" android:id="@+id/tvTotal"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Status: " /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Large Text" android:id="@+id/tvStatus"/> </LinearLayout> <LinearLayout android:layout_width="match_parent"

Y

Page 26: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Barang: " /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="Large Text" android:id="@+id/tvOrderDetail"/> </LinearLayout></LinearLayout>

HistoryOrderActivity.java

package com.example.root.projectku;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.ListView;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import com.google.firebase.database.Query;import com.google.firebase.database.ValueEventListener;import java.util.ArrayList;import java.util.HashMap;public class HistoryOrderActivity extends AppCompatActivity { public static String KEY_NAMA_TOKO="1"; public static String KEY_ID_ORDER="2"; public static String KEY_STATUS="3"; public static String KEY_TANGGAL="4"; public static String KEY_TOTAL="5"; public static String KEY_USERNAME="6"; public static String KEY_ORDER_DETAIL="7"; private FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(); private DatabaseReference firebaseDatabase=FirebaseDatabase.getInstance().getReference().getRoot(),firebaseTable,firebaseSubTable, firebaseSubSubTable, firebaseRecord,firebaseRecordDetail; String tabel = "Order"; String NamaBarang = "", Qty = "", Stok="0"; int StokInt; Button btnMenu; ListView listP, mListData; ListOrderAdapter adapter;

Z

Page 27: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

ArrayList<HashMap<String, String>> listRow = newArrayList<HashMap<String, String>>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_history_order); listP = (ListView) findViewById(R.id.listorder); btnMenu = (Button) findViewById(R.id.btMenu); firebaseTable = firebaseDatabase.child(tabel);// firebaseSubTable = firebaseTable.child(KEY_NAMA_TOKO);// Query query = firebaseSubTable.orderByKey(); query.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String namaToko = ""; String idOrder = ""; String status = ""; String tanggal = ""; String total = ""; String userName = ""; for (DataSnapshot singleSnapshot :dataSnapshot.getChildren()) { HashMap<String, String> map = new HashMap<String,String>(); idOrder = singleSnapshot.getKey().toString(); status =singleSnapshot.child("Status").getValue().toString(); tanggal =singleSnapshot.child("Tanggal").getValue().toString(); total =singleSnapshot.child("Total").getValue().toString(); userName =singleSnapshot.child("Username").getValue().toString().replace(",","."); String orderDetail = ""; for (DataSnapshot singleSnapshot2 :singleSnapshot.child("OrderDetail").getChildren()) { orderDetail = orderDetail +singleSnapshot2.child("NamaBarang").getValue().toString()+"-"+singleSnapshot2.child("Harga").getValue().toString()+"-"+singleSnapshot2.child("Qty").getValue().toString()+"\r\n"; } if(status.equals("Terkirim")) { map.put(KEY_ID_ORDER, idOrder); map.put(KEY_STATUS, status); map.put(KEY_TANGGAL, tanggal); map.put(KEY_TOTAL, total); map.put(KEY_USERNAME, userName); map.put(KEY_ORDER_DETAIL, orderDetail); listRow.add(map); } } adapter = newListOrderAdapter(HistoryOrderActivity.this, listRow); listP.setAdapter(adapter); }

AA

Page 28: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

@Override public void onCancelled(DatabaseError databaseError) { } }); btnMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); startActivity(new Intent(getApplicationContext(),HomeActivity.class)); } }); } public void onBackPressed() { this.finish(); super.onBackPressed(); }}

activity_history_order.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.projectku.HistoryOrderActivity"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <ListView android:id="@+id/listorder" android:layout_width="wrap_content" android:layout_height="445dp" android:layout_alignParentStart="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btMenu" android:text="Back to Menu" android:layout_below="@+id/listorder" android:layout_centerHorizontal="true" /> </RelativeLayout></android.support.constraint.ConstraintLayout>

AB

Page 29: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

Application Customer

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.example.root.client">

<uses-permission android:name="android.permission.INTERNET" /> <uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permissionandroid:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permissionandroid:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.SEND_SMS" />

<application 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/AppTheme">

<!-- The API key for Google Maps-based APIs is defined as a stringresource. (See the file "res/values/google_maps_api.xml"). Note that the API key is linked to the encryption key used tosign the APK. You need a different API key for each encryption key,including the release key that is used to sign the APK for publishing. You can define the keys for the debug and release targets insrc/debug/ and src/release/. --> <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" />

<activity android:name=".MainActivity" android:label="@string/register"> </activity> <activity

AC

Page 30: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:name=".LoginActivity" android:label="@string/login"> <intent-filter> <actionandroid:name="android.intent.action.MAIN" />

<categoryandroid:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MenuActivity" android:label="@string/title_activity_menu" android:theme="@style/AppTheme.NoActionBar" /> <activity android:name=".OrderActivity" /> <activity android:name=".ProductActivity" /> <activity android:name=".ShoppingCartActivity" /> </application>

</manifest>

build.gradle

// Top-level build file where you can add configuration optionscommon to all sub-projects/modules.buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; theybelong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}

app/build.gradle

apply plugin: 'com.android.application'android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig {

AD

Page 31: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

applicationId "com.example.root.client" minSdkVersion 17 targetSdkVersion 25 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 files('libs/android-async-http-1.4.6.jar') compile files('libs/http-core-4.1.jar') compile files('libs/httpclient-4.0.3.jar') compile 'com.android.support:appcompat-v7:25.3.0' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.google.firebase:firebase-auth:9.4.0' compile 'com.google.firebase:firebase-database:9.4.0' compile 'com.google.android.gms:play-services-maps:9.4.0' compile 'com.android.support:design:25.3.0' compile 'com.google.firebase:firebase-storage:9.4.0' compile 'com.github.bumptech.glide:glide:3.7.0' testCompile 'junit:junit:4.12'}apply plugin: 'com.google.gms.google-services'

adapter/CartItemAdapter.java

package com.example.root.projectku.adapter;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.TextView;import com.example.root.projectku.R;import com.example.root.projectku.constant.Constant;import com.example.root.projectku.model.Cart;import com.example.root.projectku.model.CartItem;import com.example.root.projectku.util.CartHelper;import java.math.BigDecimal;import java.text.DecimalFormat;

AE

Page 32: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

import java.text.DecimalFormatSymbols;import java.util.Collections;import java.util.List;import java.util.Locale;public class CartItemAdapter extends BaseAdapter { private static final String TAG = "CartItemAdapter"; private List<CartItem> cartItems = Collections.emptyList(); private final Context context; public CartItemAdapter(Context context) { this.context = context; } public void updateCartItems(List<CartItem> cartItems) { this.cartItems = cartItems; notifyDataSetChanged(); } @Override public int getCount() { return cartItems.size(); } @Override public CartItem getItem(int position) { return cartItems.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroupparent) { TextView tvName; TextView tvUnitPrice; TextView tvQuantity; TextView tvPrice; if (convertView == null) { convertView = LayoutInflater.from(context) .inflate(R.layout.adapter_cart_item, parent,false); tvName = (TextView)convertView.findViewById(R.id.tvCartItemName); tvUnitPrice = (TextView)convertView.findViewById(R.id.tvCartItemUnitPrice); tvQuantity = (TextView)convertView.findViewById(R.id.tvCartItemQuantity); tvPrice = (TextView)convertView.findViewById(R.id.tvCartItemPrice); convertView.setTag(new ViewHolder(tvName, tvUnitPrice,tvQuantity, tvPrice)); } else { ViewHolder viewHolder = (ViewHolder) convertView.getTag(); tvName = viewHolder.tvCartItemName; tvUnitPrice = viewHolder.tvCartItemUnitPrice; tvQuantity = viewHolder.tvCartItemQuantity; tvPrice = viewHolder.tvCartItemPrice;

AF

Page 33: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

} final Cart cart = CartHelper.getCart(); final CartItem cartItem = getItem(position); tvName.setText(cartItem.getProduct().getName()); DecimalFormat df = new DecimalFormat("#,##0",DecimalFormatSymbols.getInstance(Locale.ITALY)); tvUnitPrice.setText(Constant.CURRENCY+String.valueOf(df.format(cartItem.getProduct().getPrice().setScale(0, BigDecimal.ROUND_HALF_UP)))); tvQuantity.setText(String.valueOf(cartItem.getQuantity())); tvPrice.setText(Constant.CURRENCY+String.valueOf(df.format(cart.getCost(cartItem.getProduct()).setScale(0, BigDecimal.ROUND_HALF_UP)))); return convertView; } private static class ViewHolder { public final TextView tvCartItemName; public final TextView tvCartItemUnitPrice; public final TextView tvCartItemQuantity; public final TextView tvCartItemPrice; public ViewHolder(TextView tvCartItemName, TextViewtvCartItemUnitPrice, TextView tvCartItemQuantity, TextViewtvCartItemPrice) { this.tvCartItemName = tvCartItemName; this.tvCartItemUnitPrice = tvCartItemUnitPrice; this.tvCartItemQuantity = tvCartItemQuantity; this.tvCartItemPrice = tvCartItemPrice; } }}

adapter_cart_item.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:minHeight="50dp" android:orientation="horizontal" android:weightSum="1"> <TextView android:id="@+id/tvCartItemName" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.4" android:gravity="center" android:text=""/> <TextView android:id="@+id/tvCartItemUnitPrice" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.2"

AG

Page 34: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:gravity="center" android:text=""/> <TextView android:id="@+id/tvCartItemQuantity" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.15" android:gravity="center"/> <TextView android:id="@+id/tvCartItemPrice" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.25" android:gravity="center" android:text=""/></LinearLayout>

adapter/ProductAdapter.java

package com.example.root.projectku.adapter;import android.content.Context;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.root.projectku.R;import com.example.root.projectku.constant.Constant;import com.example.root.projectku.model.Product;import java.math.BigDecimal;import java.util.ArrayList;import java.util.List;public class ProductAdapter extends BaseAdapter { private static final String TAG = "ProductAdapter"; private List<Product> products = new ArrayList<Product>(); private final Context context; public ProductAdapter(Context context) { this.context = context; } public void updateProducts(List<Product> products) { this.products.addAll(products); notifyDataSetChanged(); } @Override public int getCount() { return products.size(); } @Override public Product getItem(int position) { return products.get(position);

AH

Page 35: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

} @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroupparent) { TextView tvName; TextView tvPrice; ImageView ivImage; if (convertView == null) { convertView = LayoutInflater.from(context) .inflate(R.layout.adapter_product, parent, false); tvName = (TextView)convertView.findViewById(R.id.tvProductName); tvPrice = (TextView)convertView.findViewById(R.id.tvProductPrice); ivImage = (ImageView)convertView.findViewById(R.id.ivProductImage); convertView.setTag(new ViewHolder(tvName, tvPrice,ivImage)); } else { ViewHolder viewHolder = (ViewHolder) convertView.getTag(); tvName = viewHolder.tvProductName; tvPrice = viewHolder.tvProductPrice; ivImage = viewHolder.ivProductImage; } final Product product = getItem(position); tvName.setText(product.getName()); tvPrice.setText(Constant.CURRENCY+String.valueOf(product.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP))); Log.d(TAG, "Context package name: " + context.getPackageName()); ivImage.setImageResource(context.getResources().getIdentifier( product.getImageName(), "drawable",context.getPackageName())); return convertView; } private static class ViewHolder { public final TextView tvProductName; public final TextView tvProductPrice; public final ImageView ivProductImage; public ViewHolder(TextView tvProductName, TextViewtvProductPrice, ImageView ivProductImage) { this.tvProductName = tvProductName; this.tvProductPrice = tvProductPrice; this.ivProductImage = ivProductImage; } }}

AI

Page 36: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

adapter_product.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:minHeight="50dp" android:orientation="horizontal" android:weightSum="1"> <TextView android:id="@+id/tvProductName" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.50" android:textColor="@color/black" android:gravity="center" android:text=""/> <ImageView android:id="@+id/ivProductImage" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.25" android:gravity="center"/> <TextView android:id="@+id/tvProductPrice" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.25" android:textColor="@color/black" android:gravity="center" android:text=""/></LinearLayout>

constant/Constant.java

package com.example.root.projectku.constant;import java.util.ArrayList;import java.util.List;public class Constant { public static final List<Integer> QUANTITY_LIST = newArrayList<Integer>(); public static final String CURRENCY = "Rp. ";}

model/Cart.java

package com.example.root.projectku.model;import java.io.Serializable;import java.math.BigDecimal;import java.util.HashMap;import java.util.Map;

AJ

Page 37: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

import java.util.Map.Entry;import java.util.Set;/** * A representation of shopping cart. * <p/> * A shopping cart has a map of {@link Saleable} products to theircorresponding quantities. */public class Cart implements Serializable { private static final long serialVersionUID = 42L; private Map<Saleable, Integer> cartItemMap = new HashMap<Saleable,Integer>(); private BigDecimal totalPrice = BigDecimal.ZERO; private int totalQuantity = 0; /** * Add a quantity of a certain {@link Saleable} product to thisshopping cart * * @param sellable the product will be added to this shopping cart * @param quantity the amount to be added */ public void add(final Saleable sellable, int quantity) { if (cartItemMap.containsKey(sellable)) { cartItemMap.put(sellable, cartItemMap.get(sellable) +quantity); } else { cartItemMap.put(sellable, quantity); } totalPrice =totalPrice.add(sellable.getPrice().multiply(BigDecimal.valueOf(quantity))); totalQuantity += quantity; } /** * Set new quantity for a {@link Saleable} product in this shoppingcart * * @param sellable the product which quantity will be updated * @param quantity the new quantity will be assigned for the product * @throws ProductNotFoundException if the product is not foundin this shopping cart. * @throws QuantityOutOfRangeException if the quantity is negative */ //throws memberitahu bahwa method yang bersangkutan dapat melempareksepsi dengan tipe yang dideklarasikan public void update(final Saleable sellable, int quantity) throwsProductNotFoundException, QuantityOutOfRangeException { if (!cartItemMap.containsKey(sellable)) throw newProductNotFoundException(); if (quantity < 0) throw new QuantityOutOfRangeException(quantity + " is not avalid quantity. It must be non-negative."); int productQuantity = cartItemMap.get(sellable); BigDecimal productPrice =sellable.getPrice().multiply(BigDecimal.valueOf(productQuantity));

AK

Page 38: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

cartItemMap.put(sellable, quantity); totalQuantity = totalQuantity - productQuantity + quantity; totalPrice =totalPrice.subtract(productPrice).add(sellable.getPrice().multiply(BigDecimal.valueOf(quantity))); } /** * Remove a certain quantity of a {@link Saleable} product from thisshopping cart * * @param sellable the product which will be removed * @param quantity the quantity of product which will be removed * @throws ProductNotFoundException if the product is not foundin this shopping cart * @throws QuantityOutOfRangeException if the quantity is negativeor more than the existing quantity of the product in this shopping cart */ public void remove(final Saleable sellable, int quantity) throwsProductNotFoundException, QuantityOutOfRangeException { if (!cartItemMap.containsKey(sellable)) throw newProductNotFoundException(); int productQuantity = cartItemMap.get(sellable); if (quantity < 0 || quantity > productQuantity) throw new QuantityOutOfRangeException(quantity + " is not avalid quantity. It must be non-negative and less than the currentquantity of the product in the shopping cart."); if (productQuantity == quantity) { cartItemMap.remove(sellable); } else { cartItemMap.put(sellable, productQuantity - quantity); } totalPrice =totalPrice.subtract(sellable.getPrice().multiply(BigDecimal.valueOf(quantity))); totalQuantity -= quantity; } /** * Remove a {@link Saleable} product from this shopping cart totally * * @param sellable the product to be removed * @throws ProductNotFoundException if the product is not found inthis shopping cart */ public void remove(final Saleable sellable) throwsProductNotFoundException { if (!cartItemMap.containsKey(sellable)) throw newProductNotFoundException(); int quantity = cartItemMap.get(sellable); cartItemMap.remove(sellable); totalPrice =totalPrice.subtract(sellable.getPrice().multiply(BigDecimal.valueOf(quantity))); totalQuantity -= quantity; } /**

AL

Page 39: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

* Remove all products from this shopping cart */ public void clear() { cartItemMap.clear(); totalPrice = BigDecimal.ZERO; totalQuantity = 0; } /** * Get quantity of a {@link Saleable} product in this shopping cart * * @param sellable the product of interest which this method willreturn the quantity * @return The product quantity in this shopping cart * @throws ProductNotFoundException if the product is not found inthis shopping cart */ public int getQuantity(final Saleable sellable) throwsProductNotFoundException { if (!cartItemMap.containsKey(sellable)) throw newProductNotFoundException(); return cartItemMap.get(sellable); } /** * Get total cost of a {@link Saleable} product in this shoppingcart * * @param sellable the product of interest which this method willreturn the total cost * @return Total cost of the product * @throws ProductNotFoundException if the product is not found inthis shopping cart */ public BigDecimal getCost(final Saleable sellable) throwsProductNotFoundException { if (!cartItemMap.containsKey(sellable)) throw newProductNotFoundException(); returnsellable.getPrice().multiply(BigDecimal.valueOf(cartItemMap.get(sellable))); } /** * Get total price of all products in this shopping cart * * @return Total price of all products in this shopping cart */ public BigDecimal getTotalPrice() { return totalPrice; } /** * Get total quantity of all products in this shopping cart * * @return Total quantity of all products in this shopping cart */ public int getTotalQuantity() { return totalQuantity;

AM

Page 40: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

} /** * Get set of products in this shopping cart * * @return Set of {@link Saleable} products in this shopping cart */ public Set<Saleable> getProducts() { return cartItemMap.keySet(); } /** * Get a map of products to their quantities in the shopping cart * * @return A map from product to its quantity in this shopping cart */ public Map<Saleable, Integer> getItemWithQuantity() { Map<Saleable, Integer> cartItemMap = new HashMap<Saleable,Integer>(); cartItemMap.putAll(this.cartItemMap); return cartItemMap; } @Override public String toString() { StringBuilder strBuilder = new StringBuilder(); for (Entry<Saleable, Integer> entry : cartItemMap.entrySet()) { strBuilder.append(String.format("Product: %s, Unit Price:%f, Quantity: %d%n", entry.getKey().getName(), entry.getKey().getPrice(),entry.getValue())); } strBuilder.append(String.format("Total Quantity: %d, TotalPrice: %f", totalQuantity, totalPrice)); return strBuilder.toString(); } public class ProductNotFoundException extends RuntimeException { private static final long serialVersionUID = 43L; private static final String DEFAULT_MESSAGE = "Product is notfound in the shopping cart."; public ProductNotFoundException() { super(DEFAULT_MESSAGE); } public ProductNotFoundException(String message) { super(message); } } public class QuantityOutOfRangeException extends RuntimeException { private static final long serialVersionUID = 44L; private static final String DEFAULT_MESSAGE = "Quantity is outof range"; public QuantityOutOfRangeException() { super(DEFAULT_MESSAGE); } public QuantityOutOfRangeException(String message) { super(message); } }

AN

Page 41: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

}

model/CartItem.java

package com.example.root.projectku.model;public class CartItem { private Product product; private int quantity; public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; }}

model/Product.java

package com.example.root.projectku.model;import java.io.Serializable;import java.math.BigDecimal;public class Product implements Saleable, Serializable { private static final long serialVersionUID = -4073256626483275668L; private int pId; private String pName; private BigDecimal pPrice; private String pDescription; private String pImageName; public Product() { super(); } public Product(int pId, String pName, BigDecimal pPrice, StringpDescription, String pImageName) { setId(pId); setName(pName); setPrice(pPrice); setDescription(pDescription); setImageName(pImageName); } @Override public boolean equals(Object o) { if (o == null) return false; if (!(o instanceof Product)) return false; return (this.pId == ((Product) o).getId()); } public int hashCode() { final int prime = 31; int hash = 1;

AO

Page 42: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

hash = hash * prime + pId; hash = hash * prime + (pName == null ? 0 : pName.hashCode()); hash = hash * prime + (pPrice == null ? 0 : pPrice.hashCode()); hash = hash * prime + (pDescription == null ? 0 :pDescription.hashCode()); return hash; } public int getId() { return pId; } public void setId(int id) { this.pId = id; } @Override public BigDecimal getPrice() { return pPrice; } @Override public String getName() { return pName; } public void setPrice(BigDecimal price) { this.pPrice = price; } public void setName(String name) { this.pName = name; } public String getDescription() { return pDescription; } public void setDescription(String pDescription) { this.pDescription = pDescription; } public String getImageName() { return pImageName; } public void setImageName(String imageName) { this.pImageName = imageName; }}

model/Saleable.java

package com.example.root.projectku.model;import java.math.BigDecimal;/** * Implements this interface for any product which can be added toshopping cart */public interface Saleable { BigDecimal getPrice(); String getName(); int getId();}

AP

Page 43: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

model/CartHelper.javapackage com.example.root.projectku.util;import com.example.root.projectku.model.Cart;/** * A helper class to retrieve the static shopping cart. Call {@codegetCart()} to retrieve the shopping cart before you perform any operationon the shopping cart. * * */public class CartHelper { private static Cart cart = new Cart(); /** * Retrieve the shopping cart. Call this before perform anymanipulation on the shopping cart. * * @return the shopping cart */ public static Cart getCart() { if (cart == null) { cart = new Cart(); } return cart; }}

MainActivity.java

package com.example.root.client;import android.app.ProgressDialog;import android.content.Intent;import android.os.Bundle;import android.support.annotation.NonNull;import android.support.v7.app.AppCompatActivity;import android.text.TextUtils;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;import com.google.android.gms.tasks.OnCompleteListener;import com.google.android.gms.tasks.Task;import com.google.firebase.auth.AuthResult;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import java.util.HashMap;import java.util.Map;public class MainActivity extends AppCompatActivity implementsView.OnClickListener { private EditText etEmail; private EditText etPassword; private EditText etNama, etAlamat, etTelp;

AQ

Page 44: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

private Button btSignin; private TextView tvSignin; private ProgressDialog pDialog; private FirebaseAuth firebaseAuth; private DatabaseReference firebaseTable,firebaseSubTable; String tabel_akun="Akun"; Stringtemp_key_akun,temp_key_auth,temp_key_nama,temp_key_alamat,temp_key_telp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); firebaseAuth = FirebaseAuth.getInstance(); if(firebaseAuth.getCurrentUser() != null){ finish(); startActivity(new Intent(getApplicationContext(),MenuActivity.class)); } etEmail = (EditText) findViewById(R.id.etEmail); etPassword = (EditText) findViewById(R.id.etPassword); etNama= (EditText) findViewById(R.id.etNama); etAlamat = (EditText) findViewById(R.id.etAlamat); etTelp = (EditText) findViewById(R.id.etTelp); tvSignin = (TextView) findViewById(R.id.tvSignin); btSignup = (Button) findViewById(R.id.btSignup); pDialog = new ProgressDialog(this); buttonSignup.setOnClickListener(this); textViewSignin.setOnClickListener(this); } private void registerUser(){ String email = etEmail.getText().toString().trim(); String password = etPassword.getText().toString().trim(); if(TextUtils.isEmpty(email)){ Toast.makeText(this,"enter emailplease",Toast.LENGTH_LONG).show(); return; } if(TextUtils.isEmpty(password)){ Toast.makeText(this,"enter passwordplease",Toast.LENGTH_LONG).show(); return; } pDialog.setMessage("Registering Please Wait..."); pDialog.show(); firebaseAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, newOnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult>task) { if(task.isSuccessful()){ firebaseTable =FirebaseDatabase.getInstance().getReference().child(tabel_akun);

AR

Page 45: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

temp_key_akun=editTextEmail.getText().toString().trim().replace('.',','); Map<String, Object> map_user = newHashMap<String, Object>(); map_user.put(temp_key_akun, ""); firebaseTable.updateChildren(map_user); temp_key_auth=firebaseAuth.getCurrentUser().getEmail().replace('.',','); firebaseTable =FirebaseDatabase.getInstance().getReference().child(tabel_akun); firebaseSubTable =firebaseTable.child(temp_key_auth); temp_key_nama=etNama.getText().toString().trim(); temp_key_alamat=etAlamat.getText().toString().trim(); temp_key_telp=etTelp.getText().toString().trim(); Map<String, Object> map_data = newHashMap<String, Object>(); map_data.put("Name", temp_key_nama); map_data.put("Address", temp_key_alamat); map_data.put("Phone", temp_key_telp); firebaseSubTable.updateChildren(map_data); finish(); startActivity(newIntent(getApplicationContext(), MenuActivity.class)); }else{ Toast.makeText(MainActivity.this,"Registration Error",Toast.LENGTH_LONG).show(); } pDialog.dismiss(); } }); } @Override public void onClick(View view) { if(view == btSignup){ registerUser(); } if(view == tvSignin){ startActivity(new Intent(this, LoginActivity.class)); } }}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="368dp"

AS

Page 46: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:orientation="vertical" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="119dp"> <TextView android:id="@+id/textViewRegister" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="User Registration" android:textAlignment="center" tools:layout_editor_absoluteX="8dp" tools:layout_editor_absoluteY="0dp" /> <EditText android:id="@+id/etEmail" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter your email" android:inputType="textEmailAddress" /> <EditText android:id="@+id/etPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter your password" android:inputType="textPassword" /> <EditText android:id="@+id/editTextNama" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter your name" /> <EditText android:id="@+id/etAlamat" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter your address" /> <EditText android:id="@+id/etTelp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter your phone number" android:inputType="number|phone" /> <Button android:id="@+id/btSignup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:text="SignUp" />

AT

Page 47: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

<TextView android:textAlignment="center" android:text="Already Registered? Sign in here" android:id="@+id/textViewSignin" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>

LoginActivity.java

package com.example.root.client;import android.app.ProgressDialog;import android.content.Intent;import android.os.Bundle;import android.support.annotation.NonNull;import android.support.v7.app.AppCompatActivity;import android.text.TextUtils;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;import com.google.android.gms.tasks.OnCompleteListener;import com.google.android.gms.tasks.Task;import com.google.firebase.auth.AuthResult;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.auth.FirebaseUser;public class LoginActivity extends AppCompatActivity implementsView.OnClickListener { private Button btSignin; private EditText etEmail; private EditText etPassword; private TextView tvSignup; private FirebaseAuth firebaseAuth; private ProgressDialog progressDialog; private FirebaseUser firebaseUser;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); firebaseAuth = FirebaseAuth.getInstance(); if(firebaseAuth.getCurrentUser() != null){ finish(); startActivity(new Intent(getApplicationContext(),MenuActivity.class)); } etEmail = (EditText) findViewById(R.id.etEmail); etPassword = (EditText) findViewById(R.id.etPassword); btSignin = (Button) findViewById(R.id.btSignin); tvSignup = (TextView) findViewById(R.id.tvSignup); progressDialog = new ProgressDialog(this); btSignin.setOnClickListener(this);

AU

Page 48: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

tvSignup.setOnClickListener(this); } private void userLogin(){ final String email = etEmail.getText().toString().trim(); String password = etPassword.getText().toString().trim(); if (TextUtils.isEmpty(email)) { Toast.makeText(this, "enter email please",Toast.LENGTH_LONG).show(); return; } if (TextUtils.isEmpty(password)) { Toast.makeText(this, "enter password please",Toast.LENGTH_LONG).show(); return; } progressDialog.setMessage("wait.."); progressDialog.show(); firebaseAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, newOnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult>task) { progressDialog.dismiss(); if (task.isSuccessful()) { finish(); startActivity(newIntent(getApplicationContext(), MenuActivity.class)); } } }); } @Override public void onClick(View view) { if(view == btSignin){ userLogin(); } if(view == tvSignup){ finish(); startActivity(new Intent(this, MainActivity.class)); } }}

activity_login.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_centerVertical="true" android:layout_width="368dp"

AV

Page 49: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_height="wrap_content" android:orientation="vertical" tools:layout_editor_absoluteY="0dp" tools:layout_editor_absoluteX="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="User Login" android:id="@+id/textView" android:layout_gravity="center_horizontal" /> <EditText android:id="@+id/etEmail" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter email" android:inputType="textEmailAddress" /> <EditText android:id="@+id/etPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:hint="Enter password" android:inputType="textPassword" /> <Button android:id="@+id/btSignin" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:text="Login" /> <TextView android:text="Don’t have an account? Signup Here" android:id="@+id/tvSignup" android:textAlignment="center" android:layout_margin="15dp" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>

AppLocationService.java

package com.example.root.client;import android.app.Service;import android.content.Context;import android.content.Intent;import android.location.Location;import android.location.LocationListener;import android.location.LocationManager;import android.os.Bundle;import android.os.IBinder;

AW

Page 50: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

public class AppLocationService extends Service implementsLocationListener { protected LocationManager lm; Location loc; private static final long MIN_DISTANCE_FOR_UPDATE = 10; private static final long MIN_TIME_FOR_UPDATE = 1000 * 60 * 2; public AppLocationService(Context context) { lm = (LocationManager) context .getSystemService(LOCATION_SERVICE); } @SuppressWarnings({"MissingPermission"}) public Location getLocation(String provider) { if (lm.isProviderEnabled(provider)) { lm.requestLocationUpdates(provider,MIN_TIME_FOR_UPDATE,MIN_DISTANCE_FOR_UPDATE, this); if (lm != null) { loc = lm.getLastKnownLocation(provider); return loc; } } return null; } @Override public void onLocationChanged(Location location) { } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundleextras) { } @Override public IBinder onBind(Intent arg0) { return null; }}

MenuActivity.java

package com.example.root.client;import android.app.ProgressDialog;import android.content.Context;import android.content.DialogInterface;import android.content.Intent;import android.content.pm.PackageManager;import android.location.Location;import android.location.LocationManager;import android.os.Bundle;import android.os.StrictMode;import android.provider.Settings;

AX

Page 51: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

import android.support.design.widget.FloatingActionButton;import android.support.design.widget.NavigationView;import android.support.design.widget.Snackbar;import android.support.v4.app.ActivityCompat;import android.support.v4.view.GravityCompat;import android.support.v4.widget.DrawerLayout;import android.support.v7.app.ActionBarDrawerToggle;import android.support.v7.app.AlertDialog;import android.support.v7.app.AppCompatActivity;import android.support.v7.widget.Toolbar;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.LinearLayout;import android.widget.TextView;import android.widget.Toast;import com.google.android.gms.maps.CameraUpdateFactory;import com.google.android.gms.maps.GoogleMap;import com.google.android.gms.maps.OnMapReadyCallback;import com.google.android.gms.maps.SupportMapFragment;import com.google.android.gms.maps.model.LatLng;import com.google.android.gms.maps.model.Marker;import com.google.android.gms.maps.model.MarkerOptions;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.ChildEventListener;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import com.loopj.android.http.AsyncHttpClient;import org.apache.http.HttpResponse;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.impl.client.DefaultHttpClient;import org.json.JSONArray;import org.json.JSONObject;import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.util.HashMap;import java.util.Iterator;import java.util.Map;public class MenuActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,OnMapReadyCallback { private String xResult = ""; private JSONObject jObject; private GoogleMap mMap; private FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(); private DatabaseReferencefirebaseDatabase=FirebaseDatabase.getInstance().getReference().getRoot(),firebaseTable, firebaseSubTable, firebaseSubSubTable, firebaseRecord; String tabel = "LokasiToko"; String temp_key_authuser, temp_key_toko;

AY

Page 52: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

Map<String, Object> map_toko; AsyncHttpClient client = new AsyncHttpClient(); int limitDistance = 1500; int theNearestDistance = 3000000; LatLng lokasiKu, lokasiMiniMarket; String nama = ""; String admin = ""; String barang = ""; String latitude = ""; String longitude = ""; HashMap<String, LatLng> lokasiFiltered = new HashMap<String,LatLng>(); private ProgressDialog pDialog; TextView td; LinearLayout llMap; AppLocationService appLocService; double currentLatitude; double currentLongitude; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu); StrictMode.ThreadPolicy policy = newStrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager() .findFragmentById(R.id.Mapfragment); mapFragment.getMapAsync(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab); fab.setVisibility(View.GONE); 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(); } }); DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open,R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView)findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); td = (TextView) findViewById(R.id.tvDialog); llMap = (LinearLayout) findViewById(R.id.llMap);

AZ

Page 53: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

} private void showSettingsAlert(String provider) { AlertDialog.Builder alertDialog = new AlertDialog.Builder( MenuActivity.this); alertDialog.setTitle(provider + "SETTINGS"); alertDialog.setMessage(provider + "is not enable! Want to go tosettings menu?"); alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, intwhich) { Intent intent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS); MenuActivity.this.startActivity(intent); } }); alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, intwhich) { dialog.cancel(); } }); alertDialog.show(); } @Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, 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); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId();

BA

Page 54: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

if (id == R.id.nav_order) { startActivity(new Intent(getApplicationContext(),MenuActivity.class)); finish(); } if (id == R.id.nav_profile) { startActivity(new Intent(getApplicationContext(),ProfileActivity.class)); } else if (id == R.id.nav_cart) { startActivity(new Intent(getApplicationContext(),ShoppingCartActivity.class)); } else if(id == R.id.nav_logout) { firebaseAuth.signOut(); finish(); startActivity(new Intent(this, MainActivity.class)); } DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setOnInfoWindowClickListener(newGoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { String idc = marker.getTitle(); OrderActivity.NAMA_TOKO = idc; startActivity(new Intent(getApplicationContext(),OrderActivity.class)); } }); appLocService=new AppLocationService(MenuActivity.this); Location gpsLocation = appLocService .getLocation(LocationManager.GPS_PROVIDER); if (gpsLocation != null){ currentLatitude = gpsLocation.getLatitude(); currentLongitude = gpsLocation.getLongitude(); } else { showSettingsAlert("GPS ALERT"); } lokasiKu = new LatLng(currentLatitude, currentLongitude); pDialog = new ProgressDialog(MenuActivity.this); pDialog.setMessage("Getting Data ..."); pDialog.setIndeterminate(false);

BB

Page 55: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

pDialog.setCancelable(true); pDialog.show(); try { firebaseTable =FirebaseDatabase.getInstance().getReference().child("BarangToko"); firebaseTable.addChildEventListener(newChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot,String s) { Iterator i = dataSnapshot.getChildren().iterator(); while (i.hasNext()) { nama = dataSnapshot.getKey(); i.next(); i.next(); latitude = (String) ((DataSnapshot)i.next()).getValue(); longitude = (String) ((DataSnapshot)i.next()).getValue(); try { xResult =getRequestSelect("https://maps.googleapis.com/maps/api/distancematrix/json?origins=" +Double.toString(lokasiKu.latitude) + "," +Double.toString(lokasiKu.longitude) + "&destinations=" + latitude +"," + longitude +"&key=AIzaSyCwm7KFQS2IQiMEdf1A6DzpP5JMx180hZ8", MenuActivity.this); parse(latitude, longitude); } catch (Exception ex) { String dummy = ex.getMessage(); Toast.makeText(getApplicationContext(),"Error: " + dummy, Toast.LENGTH_LONG).show(); } } if(ActivityCompat.checkSelfPermission(MenuActivity.this,android.Manifest.permission.ACCESS_FINE_LOCATION) !=PackageManager.PERMISSION_GRANTED &&ActivityCompat.checkSelfPermission(MenuActivity.this,android.Manifest.permission.ACCESS_COARSE_LOCATION) !=PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions,and then overriding // public voidonRequestPermissionsResult(int requestCode, String[] permissions, //int[] grantResults) // to handle the case where the user grantsthe permission. See the documentation // for ActivityCompat#requestPermissions formore details.

BC

Page 56: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

return; } mMap.setMyLocationEnabled(true); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(lokasiKu, 15)); td.setText("Selesai..."); llMap.setVisibility(View.VISIBLE); } @Override public void onChildChanged(DataSnapshot dataSnapshot,String s) { } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { } @Override public void onChildMoved(DataSnapshot dataSnapshot,String s) { } @Override public void onCancelled(DatabaseError databaseError) { } }); } catch (Exception e) { e.printStackTrace(); } pDialog.dismiss(); } public static String getRequestSelect(String Url, Context ctx) { String sret = ""; HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(Url); try { HttpResponse response = client.execute(request); sret = request(response); } catch (Exception ex) { Toast.makeText(ctx, "Gagal " + ex.getMessage() + ", " + ex.toString(), Toast.LENGTH_LONG).show(); } return sret; } public static String request(HttpResponse response) { String result = ""; try { InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader( new InputStreamReader(in)); StringBuilder str = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { str.append(line + "\n"); } in.close();

BD

Page 57: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

result = str.toString(); } catch (Exception ex) { result = "Error"; } return result; } private void parse(String latitude,String longitude) throwsException { JSONObject object_rows = null; JSONArray array_rows; object_rows = new JSONObject(xResult); array_rows = object_rows.getJSONArray("rows"); for (int i = 0; i < array_rows.length(); i++) { JSONObject object_elements = array_rows.getJSONObject(i); JSONArray array_elements =object_elements.getJSONArray("elements"); for (int ii = 0; ii < array_elements.length(); ii++) { JSONObject object_distance =array_elements.getJSONObject(ii); JSONObject distance_details =object_distance.getJSONObject("distance"); int array_value = distance_details.getInt("value"); theNearestDistance = array_value; if (theNearestDistance <= limitDistance) { lokasiMiniMarket = newLatLng(Double.parseDouble(latitude), Double.parseDouble(longitude)); Marker marker = mMap.addMarker(newMarkerOptions().position(lokasiMiniMarket).title(nama)); marker.showInfoWindow(); } } } }}

activity_menu.xml

<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_menu" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content"

BE

Page 58: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_menu" app:menu="@menu/activity_menu_drawer" /></android.support.v4.widget.DrawerLayout>

OrderActivity.java

package com.example.root.client;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.text.SpannableString;import android.text.style.UnderlineSpan;import android.util.Log;import android.view.View;import android.widget.AdapterView;import android.widget.ListView;import android.widget.TextView;import com.example.root.client.adapter.ProductAdapter;import com.example.root.client.model.Product;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import com.google.firebase.database.Query;import com.google.firebase.database.ValueEventListener;import java.math.BigDecimal;import java.util.ArrayList;import java.util.HashMap;import java.util.List;public class OrderActivity extends AppCompatActivity { public static String NAMA_TOKO = "Jonas"; private static final String TAG = "OrderActivity"; public static List<Product> PRODUCT_LIST = new ArrayList<Product>(); ProductAdapter productAdapter; ListView lvProducts; private DatabaseReferencefirebaseDatabase=FirebaseDatabase.getInstance().getReference().getRoot(),firebaseTable, firebaseSubTable, firebaseSubSubTable, firebaseRecord; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_order); TextView tvViewShoppingCart =(TextView)findViewById(R.id.tvViewShoppingCart); SpannableString content = newSpannableString(getText(R.string.shopping_cart)); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); tvViewShoppingCart.setText(NAMA_TOKO); tvViewShoppingCart.setOnClickListener(new View.OnClickListener(){

BF

Page 59: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

@Override public void onClick(View v) { Intent intent = new Intent(OrderActivity.this,ShoppingCartActivity.class); startActivity(intent); } }); lvProducts = (ListView) findViewById(R.id.lvProducts); lvProducts.addHeaderView(getLayoutInflater().inflate(R.layout.product_list_header, lvProducts, false)); firebaseTable = firebaseDatabase.child("BarangToko"); firebaseSubTable = firebaseTable .child(NAMA_TOKO); try { Query query = firebaseSubTable.orderByKey(); query.addListenerForSingleValueEvent(newValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String idBarang=""; String namaBarang=""; String hargaBarang=""; String deskripsiBarang=""; String fotoBarang=""; productAdapter = newProductAdapter(getApplicationContext()); PRODUCT_LIST.clear(); Product PRODUCT; for(DataSnapshot singleSnapshot :dataSnapshot.getChildren()) { int i=0; for(DataSnapshot singleSnapshot2 :singleSnapshot.getChildren()) { i++; HashMap<String, String> map = newHashMap<String, String>(); idBarang = Integer.toString(i); namaBarang =singleSnapshot2.getKey().toString(); hargaBarang =singleSnapshot2.child("Harga").getValue().toString(); PRODUCT = newProduct(Integer.parseInt(idBarang), namaBarang,BigDecimal.valueOf(Integer.parseInt(hargaBarang)), namaBarang,"noimage"); PRODUCT_LIST.add(PRODUCT);} } productAdapter.updateProducts(PRODUCT_LIST); lvProducts.setAdapter(productAdapter); lvProducts.setOnItemClickListener(newAdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent,View view,

BG

Page 60: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

int position, longid) { Product product =PRODUCT_LIST.get(position - 1); Intent intent = newIntent(OrderActivity.this, ProductActivity.class); Bundle bundle = new Bundle(); bundle.putSerializable("product",product); Log.d(TAG, "View product: " +product.getName()); intent.putExtras(bundle); startActivity(intent); } }); } @Override public void onCancelled(DatabaseError databaseError) { } }); } catch (Exception ex) { } }}

activity_order.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.root.client.OrderActivity"> <TextView android:id="@+id/tvViewShoppingCart" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/blue" android:gravity="center" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:text="@string/shopping_cart" android:textSize="@dimen/small_header_text_size"/> <TextView android:id="@+id/tvProductListHeader" android:layout_width="match_parent"

BH

Page 61: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_height="wrap_content" android:layout_below="@id/tvViewShoppingCart" android:background="@color/green" android:gravity="center" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:text="@string/product_list" android:textAllCaps="true" android:textSize="@dimen/header_text_size" android:textStyle="bold"/> <ListView android:id="@+id/lvProducts" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/tvProductListHeader"/></RelativeLayout>

activity_product.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <TextView android:id="@+id/tvViewShoppingCart" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:textColor="@color/blue" android:gravity="center" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:text="@string/shopping_cart" android:textSize="@dimen/small_header_text_size"/> <TextView android:id="@+id/tvProductName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/tvViewShoppingCart" android:background="@color/green" android:gravity="center" android:padding="@dimen/common_padding" android:textAllCaps="true" android:textSize="@dimen/header_text_size" android:textStyle="bold"/> <TextView android:id="@+id/tvProductDesc" android:layout_width="match_parent"

BI

Page 62: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_height="wrap_content" android:layout_below="@id/tvProductName" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding"/> <ImageView android:id="@+id/ivProductImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_above="@+id/llAction" android:layout_below="@id/tvProductDesc" android:paddingTop="5dp" android:paddingBottom="5dp"/> <LinearLayout android:id="@id/llAction" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="horizontal" android:weightSum="1"> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.25" android:gravity="center_vertical|end" android:text="@string/quantity"/> <Spinner android:id="@+id/spQuantity" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.25"/> <Button android:id="@+id/bOrder" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.5" android:background="@color/orange" android:text="@string/order" android:textAllCaps="true" android:textColor="@android:color/white" android:textStyle="bold"/> </LinearLayout></RelativeLayout>

activity_shopping_cart.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin"

BJ

Page 63: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <TextView android:id="@+id/tvCartHeader" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/green" android:gravity="center" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:text="@string/shopping_cart" android:textAllCaps="true" android:textSize="@dimen/header_text_size" android:textStyle="bold"/> <ListView android:id="@+id/lvCartItems" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/llTotal" android:layout_below="@id/tvCartHeader"/> <LinearLayout android:id="@+id/llTotal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/llBottom" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="5dp" android:weightSum="1"> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.75" android:gravity="center_vertical|end" android:text="@string/total_price" android:textStyle="bold"/> <TextView android:id="@+id/tvTotalPrice" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.25" android:gravity="center" android:text="" android:textStyle="bold"/> </LinearLayout> <LinearLayout android:id="@id/llBottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="horizontal" android:weightSum="1"> <Button android:id="@+id/bHome"

BK

Page 64: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_width="80dp" android:layout_height="wrap_content" android:background="@color/orange" android:text="@string/home" android:textAllCaps="true" android:textColor="@android:color/white" android:textStyle="bold" /> <Button android:id="@+id/bClear" android:layout_width="85dp" android:layout_height="wrap_content" android:background="@color/orange" android:text="@string/clear_cart" android:textAllCaps="true" android:textColor="@android:color/white" android:textStyle="bold" /> <Button android:id="@+id/bShop" android:layout_width="75dp" android:layout_height="wrap_content" android:background="@color/orange" android:text="@string/shop" android:textAllCaps="true" android:textColor="@android:color/white" android:textStyle="bold" /> <Button android:id="@+id/bCO" android:layout_width="90dp" android:layout_height="wrap_content" android:background="@color/orange" android:text="Check Out" android:textAllCaps="true" android:textColor="@android:color/white" android:textStyle="bold" /> </LinearLayout></RelativeLayout>

app_bar_menu.xml

<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.client.MenuActivity"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar"

BL

Page 65: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_menu" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" app:srcCompat="@android:drawable/ic_dialog_email" /></android.support.design.widget.CoordinatorLayout>

cart_footer.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/orange" android:orientation="horizontal" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:weightSum="1"> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.75" android:gravity="end|center_vertical" android:text="@string/total_price" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size" android:textStyle="bold"/> <TextView android:id="@+id/tvTotalPrice" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.25" android:gravity="center" android:text="" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size" android:textStyle="bold"/></LinearLayout>

cart_header.java

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

BM

Page 66: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/powderblue" android:orientation="horizontal" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:weightSum="1"> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.4" android:gravity="center" android:text="@string/name" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size"/> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.2" android:gravity="center" android:text="@string/unit_price" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size"/> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.15" android:gravity="center" android:text="@string/quantity" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size"/> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.25" android:gravity="center" android:text="@string/price" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size"/></LinearLayout>

content_menu.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.root.client.MenuActivity"

BN

Page 67: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

tools:showIn="@layout/app_bar_menu"> <TextView android:id="@+id/tvDialog" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Loading Data..." /> <LinearLayout android:id="@+id/llMap" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:visibility="invisible"> <fragment android:id="@+id/Mapfragment" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="428dp" /> </LinearLayout></LinearLayout>

nav_header_menu.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="@dimen/nav_header_height" android:background="@drawable/side_nav_bar" android:gravity="bottom" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:theme="@style/ThemeOverlay.AppCompat.Dark"> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="@dimen/nav_header_vertical_spacing" android:text="Shopping Nearby Me" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /></LinearLayout>

product_list_header.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

BO

Page 68: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/orange" android:orientation="horizontal" android:paddingBottom="@dimen/common_padding" android:paddingTop="@dimen/common_padding" android:weightSum="1"> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.65" android:gravity="center" android:text="@string/name" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size"/> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.35" android:gravity="center" android:text="@string/unit_price" android:textColor="@android:color/white" android:textSize="@dimen/product_list_header_text_size"/></LinearLayout>

menu/activity_menu_drawer.xml

<?xml version="1.0" encoding="utf-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_order" android:title="Order Barang" /> <item android:id="@+id/nav_cart" android:title="Shopping Cart" /> <item android:id="@+id/nav_profile" android:title="Profile" /> <item android:id="@+id/nav_logout" android:title="Logout" /> </group></menu>

values/google_maps_api.xml

<resources> <!--

BP

Page 69: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

TODO: Before you run your application, you need a Google Maps APIkey. To get one, follow this link, follow the directions and press"Create" at the end: https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=D1:10:EA:9B:77:46:28:7F:A8:C6:59:EA:E3:16:CD:D4:96:A8:E3:F4%3Bcom.example.root.client You can also add your credentials to an existing key, using thesevalues: Package name: D1:10:EA:9B:77:46:28:7F:A8:C6:59:EA:E3:16:CD:D4:96:A8:E3:F4 SHA-1 certificate fingerprint: D1:10:EA:9B:77:46:28:7F:A8:C6:59:EA:E3:16:CD:D4:96:A8:E3:F4 Alternatively, follow the directions here: https://developers.google.com/maps/documentation/android/start#get-key Once you have your key (it starts with "AIza"), replace the"google_maps_key" string in this file. --> <string name="google_maps_key" templateMergeStrategy="preserve"translatable="false"> AIzaSyCwm7KFQS2IQiMEdf1A6DzpP5JMx180hZ8 </string></resources>

values/strings.xml

<resources> <string name="app_name">Client</string> <string name="register">Register</string> <string name="login">Login</string> <string name="profile">Profile</string> <string name="title_activity_menu">Menu</string> <string name="navigation_drawer_open">Open navigationdrawer</string> <string name="navigation_drawer_close">Close navigationdrawer</string> <string name="action_settings">Settings</string> <string name="product_list">Product List</string> <string name="shopping_cart">Shopping Cart</string> <string name="name">Name</string> <string name="unit_price">Unit Price</string> <string name="quantity">Quantity</string> <string name="view">View</string> <string name="action">Action</string> <string name="order">Order</string> <string name="price">Price</string> <string name="total_price">Total Price</string> <string name="remove">Remove</string> <string name="clear_cart">Clear Cart</string> <string name="shop">Shop</string> <string name="delete_item">Delete Item</string>

BQ

Page 70: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

<string name="delete_item_message">Are you sure you want to deletethis item?</string> <string name="yes">Yes</string> <string name="no">No</string> <string name="home">Home</string> <string name="status">Status Pesanan</string> <string name="status_message">Update Status Pesanan?</string> <string name="send">Terkirim</string> <string name="cancel">Cancel</string> <string name="title_activity_maps">Map</string></resources>

values/colors.xml

<? xml version="1.0" encoding="utf-8" ?> <resources> <color name="colorPrimary">#3F51B5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#FF4081</color> <color name="green">#008000</color> <color name="orange">#ff5500</color> <color name="blue">#0000FF</color> <color name="black">#00000F</color> <color name="powderblue">#B0E0E6</color> <color name="grey">#eaeaea</color></resources>

BR

Page 71: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

BS

Page 72: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

BT

Page 73: Application Store Admin build.gradle - Unika Repositoryrepository.unika.ac.id/15357/9/13.02.0049 Jonas Theodore... · 2017-12-04 · APPENDIX Application Store Admin build.gradle

BU