Skip to content

Instantly share code, notes, and snippets.

@asafstr2
Created July 9, 2018 21:02
Show Gist options
  • Save asafstr2/ba2ef7ff8b132ec68549c23e71a26ab9 to your computer and use it in GitHub Desktop.
Save asafstr2/ba2ef7ff8b132ec68549c23e71a26ab9 to your computer and use it in GitHub Desktop.
inventory app finel
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-main-apk-res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.android.support:transition-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.10.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:recyclerview-v7-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-1.1.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core-3.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:design-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:monitor-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource-3.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.2@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.1.0" level="project" />
</component>
</module>
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.android.inventory2"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'org.jsoup:jsoup:1.10.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:27.1.1'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.android.inventory2"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".CatalogActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".EditorActivity"
android:theme="@style/EditorTheme"
android:parentActivityName=".CatalogActivity" >
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".CatalogActivity" />
</activity>
<provider
android:name=".data.StoreProvider"
android:authorities="com.example.android.inventory2"
android:exported="false" />
</application>
</manifest>
package com.example.android.inventory2;
import android.app.LoaderManager;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import com.example.android.inventory2.data.StoreContract.ProductEntry;
import com.example.android.inventory2.data.StoreDbHelper;
public class CatalogActivity extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<Cursor> {
private static final int PRODUCT_LOADER = 0;
StoreCursorAdapter mCursorAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_catalog);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);
startActivity(intent);
}
});
ListView petListView = findViewById(R.id.list);
View emptyView = findViewById(R.id.empty_view);
petListView.setEmptyView(emptyView);
mCursorAdapter = new StoreCursorAdapter(this, null);
petListView.setAdapter(mCursorAdapter);
petListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);
Uri currentproductUri = ContentUris.withAppendedId(ProductEntry.CONTENT_URI, id);
intent.setData(currentproductUri);
startActivity(intent);
}
});
getLoaderManager().initLoader(PRODUCT_LOADER, null, this);
SwipeRefreshLayout swipe = findViewById(R.id.swiperefresh);
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
SwipeRefreshLayout swipe = findViewById(R.id.swiperefresh);
getLoaderManager().initLoader(PRODUCT_LOADER, null, CatalogActivity.this);
Toast.makeText(getApplicationContext(), R.string.refreshed_successfully, Toast.LENGTH_LONG).show();
swipe.setRefreshing(false);
}
}
);
}
private void insertPet() {
ContentValues values = new ContentValues();
values.put(ProductEntry.COLUMN_PRODUCT_NAME, "earphones");
values.put(ProductEntry.COLUMN_PRICE, 10);
values.put(ProductEntry.COLUMN_SUPPLIER_NAME, "JBL");
values.put(ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER, "0549012568");
values.put(ProductEntry.COLUMN_QUANTITY, 7);
getContentResolver().insert(ProductEntry.CONTENT_URI, values);
}
private void deleteAllProducts() {
StoreDbHelper mDbHelper;
mDbHelper = new StoreDbHelper(this);
mDbHelper.delete();
mCursorAdapter.swapCursor(null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_catalog, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_insert_dummy_data:
insertPet();
return true;
case R.id.action_delete_all_entries:
deleteAllProducts();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
String[] projection = {
ProductEntry._ID,
ProductEntry.COLUMN_PRODUCT_NAME,
ProductEntry.COLUMN_SUPPLIER_NAME,
ProductEntry.COLUMN_QUANTITY,
ProductEntry.COLUMN_PRICE,
ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER
};
return new CursorLoader(this, // Parent activity context
ProductEntry.CONTENT_URI, // Provider content URI to query
projection, // Columns to include in the resulting Cursor
null, // No selection clause
null, // No selection arguments
null); // Default sort order
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mCursorAdapter.swapCursor(data);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
mCursorAdapter.swapCursor(null);
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.inventory2.data;
import android.content.ContentResolver;
import android.net.Uri;
import android.provider.BaseColumns;
public final class StoreContract {
private StoreContract() {
}
public static final class ProductEntry implements BaseColumns {
public static final String CONTENT_AUTHORITY = "com.example.android.inventory2";
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
public static final String PATH_STORE = "inventory";
public static final Uri CONTENT_URI = Uri.withAppendedPath(BASE_CONTENT_URI, PATH_STORE);
public static final String CONTENT_LIST_TYPE =
ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_STORE;
public static final String CONTENT_ITEM_TYPE =
ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_STORE;
public final static String TABLE_NAME = "inventory";
public final static String _ID = BaseColumns._ID;
public final static String COLUMN_PRODUCT_NAME = "product_name";
public final static String COLUMN_SUPPLIER_NAME = "supplier_name";
public final static String COLUMN_SUPPLIER_PHONE_NUMBER = "supplier_phone_number";
public final static String COLUMN_QUANTITY = "quantity";
public final static String COLUMN_PRICE = "price";
public static final String DELETE = " DROP TABLE " + TABLE_NAME;
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.inventory2.data;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.example.android.inventory2.data.StoreContract.ProductEntry;
public class StoreDbHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "store.db";
private static final int DATABASE_VERSION = 1;
public StoreDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String SQL_CREATE_INVENTORY_TABLE = "CREATE TABLE " + ProductEntry.TABLE_NAME + " ("
+ ProductEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ ProductEntry.COLUMN_PRODUCT_NAME + " TEXT NOT NULL, "
+ ProductEntry.COLUMN_SUPPLIER_NAME + " TEXT NOT NULL, "
+ ProductEntry.COLUMN_QUANTITY + " INTEGER NOT NULL, "
+ ProductEntry.COLUMN_PRICE + " INTEGER NOT NULL, "
+ ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER + " TEXT NOT NULL );";
db.execSQL(SQL_CREATE_INVENTORY_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(ProductEntry.DELETE);
onCreate(db);
}
public void delete() {
SQLiteDatabase db = getWritableDatabase();
db.execSQL(ProductEntry.DELETE);
onCreate(db);
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.inventory2.data;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.example.android.inventory2.R;
import com.example.android.inventory2.data.StoreContract.ProductEntry;
import java.util.Objects;
/**
* {@link ContentProvider} for Pets app.
*/
public class StoreProvider extends ContentProvider {
public static final String LOG_TAG = StoreProvider.class.getSimpleName();
private static final int INVENTORY = 100;
private static final int INVENTORY_ID = 101;
private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
private StoreDbHelper mDbHelper;
static {
sUriMatcher.addURI(StoreContract.ProductEntry.CONTENT_AUTHORITY, StoreContract.ProductEntry.PATH_STORE, INVENTORY);
sUriMatcher.addURI(StoreContract.ProductEntry.CONTENT_AUTHORITY, StoreContract.ProductEntry.PATH_STORE + "/#", INVENTORY_ID);
}
@Override
public boolean onCreate() {
mDbHelper = new StoreDbHelper(getContext());
return true;
}
//gets URI ,projection(returning list of all column chosen in it), selection+selection args for returning specifeid raw,null,null,null) returning courser of the data specified if URI contains selection of ID will auto qurry for it
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteDatabase database = mDbHelper.getReadableDatabase();
Cursor cursor;
int match = sUriMatcher.match(uri);
switch (match) {
case INVENTORY:
cursor = database.query(StoreContract.ProductEntry.TABLE_NAME, projection, selection, selectionArgs,
null, null, sortOrder);
break;
case INVENTORY_ID:
selection = StoreContract.ProductEntry._ID + "=?";
selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
cursor = database.query(ProductEntry.TABLE_NAME, projection, selection, selectionArgs,
null, null, sortOrder);
break;
default:
throw new IllegalArgumentException("Cannot query unknown URI " + uri);
}
cursor.setNotificationUri(Objects.requireNonNull(getContext()).getContentResolver(), uri);
return cursor;
}
//since new input no need to check for ID in selection+selection args
@Override
public Uri insert(@NonNull Uri uri, ContentValues contentValues) {
final int match = sUriMatcher.match(uri);
switch (match) {
case INVENTORY:
return insertInventory(uri, contentValues);
default:
throw new IllegalArgumentException("Insertion is not supported for " + uri);
}
}
private Uri insertInventory(Uri uri, ContentValues values) {
String product_name = values.getAsString(StoreContract.ProductEntry.COLUMN_PRODUCT_NAME);
if (product_name == null|| TextUtils.isEmpty(product_name)) {
Toast.makeText(getContext(), R.string.name_is_required, Toast.LENGTH_SHORT).show();
return null;
}
String supplier_name = values.getAsString(ProductEntry.COLUMN_SUPPLIER_NAME);
if (supplier_name == null|| TextUtils.isEmpty(supplier_name)) {
Toast.makeText(getContext(), R.string.supplier_is_required, Toast.LENGTH_SHORT).show();
return null; }
Integer supplier_phone_number = values.getAsInteger(StoreContract.ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER);
if (supplier_phone_number == null ) {
Toast.makeText(getContext(), R.string.phone_is_required, Toast.LENGTH_SHORT).show();
return null; }
Integer quantity = values.getAsInteger(StoreContract.ProductEntry.COLUMN_QUANTITY);
if (quantity != null && quantity < 0) {
Toast.makeText(getContext(), R.string.requires_valid_quantity, Toast.LENGTH_SHORT).show();
return null;
}
Integer price = values.getAsInteger(ProductEntry.COLUMN_PRICE);
if (price != null && price < 0) {
Toast.makeText(getContext(), R.string.requires_valid_price, Toast.LENGTH_SHORT).show();
return null;
}
SQLiteDatabase database = mDbHelper.getWritableDatabase();
long id = database.insert(StoreContract.ProductEntry.TABLE_NAME, null, values);
if (id == -1) {
Log.e(LOG_TAG, "Failed to insert row for " + uri);
return null;
}
Objects.requireNonNull(getContext()).getContentResolver().notifyChange(uri, null);
return ContentUris.withAppendedId(uri, id);
}
@Override
public int update(@NonNull Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) {
Log.d("TAG1", " Store provider URI : "+uri.toString()+"\n");
final int match = sUriMatcher.match(uri);
switch (match) {
case INVENTORY:
return updateProduct(uri, contentValues, selection, selectionArgs);
case INVENTORY_ID:
selection = StoreContract.ProductEntry._ID + "=?";
selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
return updateProduct(uri, contentValues, selection, selectionArgs);
default:
throw new IllegalArgumentException("Update is not supported for " + uri);
}
}
private int updateProduct(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
if (values.containsKey(StoreContract.ProductEntry.COLUMN_PRODUCT_NAME)) {
String name = values.getAsString(StoreContract.ProductEntry.COLUMN_PRODUCT_NAME);
if (name == null) {
throw new IllegalArgumentException(" requires a name");
}
}
if (values.containsKey(ProductEntry.COLUMN_SUPPLIER_NAME)) {
String supllierName = values.getAsString(ProductEntry.COLUMN_SUPPLIER_NAME);
if (supllierName == null ) {
throw new IllegalArgumentException(" requires valid phone number");
}
}
if (values.containsKey(StoreContract.ProductEntry.COLUMN_QUANTITY)) {
Integer quantity = values.getAsInteger(StoreContract.ProductEntry.COLUMN_QUANTITY);
Log.d("TAG1", " Store provider quantity : "+quantity.toString()+"\n");
if (quantity < 0) {
throw new IllegalArgumentException("requires valid quantity");
}
}
if (values.containsKey(ProductEntry.COLUMN_PRICE)) {
Integer price = values.getAsInteger(ProductEntry.COLUMN_PRICE);
if (price != null && price < 0) {
throw new IllegalArgumentException("requires valid quantity");
}
}
if (values.containsKey(ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER)) {
Integer supllierPhoneNumber = values.getAsInteger(ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER);
if (supllierPhoneNumber != null && supllierPhoneNumber < 0) {
throw new IllegalArgumentException("requires valid quantity");
}
}
if (values.size() == 0) {
return 0;
}
SQLiteDatabase database = mDbHelper.getWritableDatabase();
database.update(StoreContract.ProductEntry.TABLE_NAME, values, selection, selectionArgs);
if (values.size() != 0) {
Objects.requireNonNull(getContext()).getContentResolver().notifyChange(uri, null);
}
return values.size();
}
@Override
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
// Get writeable database
SQLiteDatabase database = mDbHelper.getWritableDatabase();
// Track the number of rows that were deleted
int rowsDeleted;
final int match = sUriMatcher.match(uri);
switch (match) {
case INVENTORY:
// Delete all rows that match the selection and selection args
rowsDeleted = database.delete(StoreContract.ProductEntry.TABLE_NAME, selection, selectionArgs);
break;
case INVENTORY_ID:
// Delete a single row given by the ID in the URI
selection = StoreContract.ProductEntry._ID + "=?";
selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
rowsDeleted = database.delete(StoreContract.ProductEntry.TABLE_NAME, selection, selectionArgs);
break;
default:
throw new IllegalArgumentException("Deletion is not supported for " + uri);
}
// If 1 or more rows were deleted, then notify all listeners that the data at the
// given URI has changed
if (rowsDeleted != 0) {
Objects.requireNonNull(getContext()).getContentResolver().notifyChange(uri, null);
}
// Return the number of rows deleted
return rowsDeleted;
}
@Override
public String getType(@NonNull Uri uri) {
final int match = sUriMatcher.match(uri);
switch (match) {
case INVENTORY:
return StoreContract.ProductEntry.CONTENT_LIST_TYPE;
case INVENTORY_ID:
return ProductEntry.CONTENT_ITEM_TYPE;
default:
throw new IllegalStateException("Unknown URI " + uri + " with match " + match);
}
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.inventory2;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.LoaderManager;
import android.content.ContentValues;
import android.content.CursorLoader;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
import com.example.android.inventory2.data.StoreContract;
import com.example.android.inventory2.data.StoreContract.ProductEntry;
public class EditorActivity extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<Cursor> {
private static final int EXISTING_PRODUCT_LOADER = 0;
private Uri mCurrentProductUri;
private EditText mProductNameEditText;
private EditText mSupplierNmaeEditText;
private EditText mQuantityText;
private EditText mPrice;
private EditText mSupllierPhonenumber;
private boolean mProductHasChanged = false;
private View.OnTouchListener mTouchListener = new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
mProductHasChanged = true;
return false;
}
};
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_editor);
Intent intent = getIntent();
mCurrentProductUri = intent.getData();
if (mCurrentProductUri == null) {
setTitle(getString(R.string.editor_activity_title_new_item));
invalidateOptionsMenu();
} else {
setTitle(getString(R.string.editor_activity_title_edit_product));
getLoaderManager().initLoader(EXISTING_PRODUCT_LOADER, null, this);
}
mProductNameEditText = findViewById(R.id.product_name_edit);
mSupplierNmaeEditText = findViewById(R.id.supplier_name_edit);
mQuantityText = findViewById(R.id.quantity_edit);
mPrice = findViewById(R.id.price_edit);
mSupllierPhonenumber = findViewById(R.id.supplier_phone_number_edit);
final Button increse = findViewById(R.id.increse);
final ImageButton dialer = findViewById(R.id.supplier_phone_number_button);
final Button decrese = findViewById(R.id.decrese);
dialer.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialContactPhone();
}
});
increse.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
increase();
}
});
decrese.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
decrese();
}
});
mProductNameEditText.setOnTouchListener(mTouchListener);
mSupplierNmaeEditText.setOnTouchListener(mTouchListener);
mQuantityText.setOnTouchListener(mTouchListener);
mPrice.setOnTouchListener(mTouchListener);
mSupllierPhonenumber.setOnTouchListener(mTouchListener);
increse.setOnTouchListener(mTouchListener);
decrese.setOnTouchListener(mTouchListener);
}
private void saveProduct() {
String productName = mProductNameEditText.getText().toString().trim();
String supplierName = mSupplierNmaeEditText.getText().toString().trim();
String quantity = mQuantityText.getText().toString().trim();
String price = mPrice.getText().toString().trim();
String supplierPhoneNumber = mSupllierPhonenumber.getText().toString().trim();
if (mCurrentProductUri == null && TextUtils.isEmpty(productName) && TextUtils.isEmpty(supplierName) &&
TextUtils.isEmpty(quantity) && TextUtils.isEmpty(price) && TextUtils.isEmpty(supplierPhoneNumber)) {
return;
}
ContentValues values = new ContentValues();
values.put(StoreContract.ProductEntry.COLUMN_PRODUCT_NAME, productName);
values.put(StoreContract.ProductEntry.COLUMN_SUPPLIER_NAME, supplierName);
values.put(ProductEntry.COLUMN_QUANTITY, quantity);
values.put(ProductEntry.COLUMN_PRICE, price);
values.put(ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER, supplierPhoneNumber);
if (mCurrentProductUri == null) {
Uri newUri = getContentResolver().insert(ProductEntry.CONTENT_URI, values);
if (newUri == null) {
Toast.makeText(this, getString(R.string.editor_insert_product_failed),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, getString(R.string.editor_insert_product_successful),
Toast.LENGTH_SHORT).show();
}
} else {
int rowsAffected = getContentResolver().update(mCurrentProductUri, values, null, null);
if (rowsAffected == 0) {
Toast.makeText(this, getString(R.string.editor_update_product_failed),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, getString(R.string.editor_update_product_successful),
Toast.LENGTH_SHORT).show();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_editor, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
if (mCurrentProductUri == null) {
MenuItem menuItem = menu.findItem(R.id.action_delete);
menuItem.setVisible(false);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_save:
saveProduct();
finish();
return true;
case R.id.action_delete:
showDeleteConfirmationDialog();
return true;
case android.R.id.home:
if (!mProductHasChanged) {
NavUtils.navigateUpFromSameTask(EditorActivity.this);
return true;
}
DialogInterface.OnClickListener discardButtonClickListener =
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
NavUtils.navigateUpFromSameTask(EditorActivity.this);
}
};
showUnsavedChangesDialog(discardButtonClickListener);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
if (!mProductHasChanged) {
super.onBackPressed();
return;
}
DialogInterface.OnClickListener discardButtonClickListener =
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
};
showUnsavedChangesDialog(discardButtonClickListener);
}
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
return new CursorLoader(this, mCurrentProductUri, null, null, null, null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
if (cursor == null || cursor.getCount() < 1) {
return;
}
if (cursor.moveToFirst()) {
int productNameColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_PRODUCT_NAME);
int supllierNameColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_SUPPLIER_NAME);
int quantityColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_QUANTITY);
int priceColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_PRICE);
int supplierPhonenumberColumnIndex = cursor.getColumnIndex(ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER);
String productName = cursor.getString(productNameColumnIndex);
String supplierName = cursor.getString(supllierNameColumnIndex);
String quantity = cursor.getString(quantityColumnIndex);
String price = cursor.getString(priceColumnIndex);
String supplierPhoneNumber = cursor.getString(supplierPhonenumberColumnIndex);
mProductNameEditText.setText(productName);
mSupplierNmaeEditText.setText(supplierName);
mQuantityText.setText(quantity);
mPrice.setText(price);
mSupllierPhonenumber.setText(supplierPhoneNumber);
}
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
mProductNameEditText.setText("");
mSupplierNmaeEditText.setText("");
mQuantityText.setText("");
mPrice.setText("");
mSupllierPhonenumber.setText("");
}
private void showUnsavedChangesDialog(
DialogInterface.OnClickListener discardButtonClickListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.unsaved_changes_dialog_msg);
builder.setPositiveButton(R.string.discard, discardButtonClickListener);
builder.setNegativeButton(R.string.keep_editing, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (dialog != null) {
dialog.dismiss();
}
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
private void showDeleteConfirmationDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.delete_dialog_msg);
builder.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
deleteProduct();
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (dialog != null) {
dialog.dismiss();
}
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
private void deleteProduct() {
if (mCurrentProductUri != null) {
int rowsDeleted = getContentResolver().delete(mCurrentProductUri, null, null);
if (rowsDeleted == 0) {
Toast.makeText(this, getString(R.string.editor_delete_product_failed),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, getString(R.string.editor_delete_product_successful),
Toast.LENGTH_SHORT).show();
}
}
finish();
}
public void dialContactPhone() {
String supplierPhoneNumber = mSupllierPhonenumber.getText().toString().trim();
startActivity(new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", supplierPhoneNumber, null)));
}
@SuppressLint("SetTextI18n")
public void increase() {
String quantity2 = mQuantityText.getText().toString();
if (!TextUtils.isEmpty(quantity2)) {
int quantity = Integer.parseInt(mQuantityText.getText().toString());
quantity++;
mQuantityText.setText(Integer.toString(quantity));
} else {
Toast.makeText(this, getString(R.string.plaese_enter_value), Toast.LENGTH_SHORT).show();
}
}
@SuppressLint("SetTextI18n")
public void decrese() {
String quantity2 = mQuantityText.getText().toString();
if (!TextUtils.isEmpty(quantity2)) {
int quantity = Integer.parseInt(mQuantityText.getText().toString());
if (quantity > 0 && mQuantityText != null) {
quantity--;
mQuantityText.setText(Integer.toString(quantity));
} else {
Toast.makeText(this, getString(R.string.cant_be_under_0), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, getString(R.string.plaese_enter_value), Toast.LENGTH_SHORT).show();
}
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.inventory2;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.example.android.inventory2.data.StoreContract;
public class StoreCursorAdapter extends CursorAdapter {
StoreCursorAdapter(Context context, Cursor c) {
super(context, c, 0 );
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
}
@Override
public void bindView(View view, final Context context, Cursor cursor) {
TextView productNameTextView = view.findViewById(R.id.product_name);
TextView supplierNameTextView = view.findViewById(R.id.supplier_name);
TextView supplierPhoneNumberTextView = view.findViewById(R.id.supplier_phone_number);
TextView quantityTextView = view.findViewById(R.id.quantity);
TextView priceTextView = view.findViewById(R.id.price);
final Button sale = view.findViewById(R.id.sale);
int storeProductColumnIndex = cursor.getColumnIndex(StoreContract.ProductEntry.COLUMN_PRODUCT_NAME);
int supplierNameColumnIndex = cursor.getColumnIndex(StoreContract.ProductEntry.COLUMN_SUPPLIER_NAME);
int supplierPhoneNumberColumnIndex = cursor.getColumnIndex(StoreContract.ProductEntry.COLUMN_SUPPLIER_PHONE_NUMBER);
final int quantityColumnIndex = cursor.getColumnIndex(StoreContract.ProductEntry.COLUMN_QUANTITY);
int priceColumnIndex = cursor.getColumnIndex(StoreContract.ProductEntry.COLUMN_PRICE);
int idColumnIndex = cursor.getColumnIndex(StoreContract.ProductEntry._ID);
String currentProductName = cursor.getString(storeProductColumnIndex);
String currentSupplierName = cursor.getString(supplierNameColumnIndex);
String currentSupplierPhoneNumber = cursor.getString(supplierPhoneNumberColumnIndex);
final int currentQuantity = cursor.getInt(quantityColumnIndex);
String currentprice = cursor.getString(priceColumnIndex);
final int currentId = cursor.getInt(idColumnIndex);
productNameTextView.setText(currentProductName);
supplierNameTextView.setText(currentSupplierName);
supplierPhoneNumberTextView.setText(currentSupplierPhoneNumber);
quantityTextView.setText(Integer.toString(currentQuantity));
priceTextView.setText(currentprice);
sale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (currentQuantity > 0) {
final Uri mCurrentProductUri = ContentUris.withAppendedId(StoreContract.ProductEntry.CONTENT_URI, currentId);
int mid = currentQuantity;
mid--;
ContentValues values = new ContentValues();
values.put(StoreContract.ProductEntry.COLUMN_QUANTITY, mid);
context.getContentResolver().update(mCurrentProductUri, values, null, null);
} else {
Toast.makeText(context, R.string.product_out_of_stock, Toast.LENGTH_SHORT).show();
}
}
});
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Layout for the list of inventory -->
<RelativeLayout
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="match_parent"
android:layout_height="match_parent"
android:background="@color/yellow_editor"
tools:context=".CatalogActivity">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
<!-- Empty view for the list -->
<RelativeLayout
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/yellow"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/empty_shelter_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/productempty"
android:contentDescription="@string/image_for_empty_page" />
<TextView
android:id="@+id/empty_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/empty_shelter_image"
android:layout_centerHorizontal="true"
android:fontFamily="sans-serif-medium"
android:paddingTop="16dp"
android:text="@string/empty_view_title_text"
android:textAppearance="?android:textAppearanceMedium"/>
<TextView
android:id="@+id/empty_subtitle_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/empty_title_text"
android:layout_centerHorizontal="true"
android:fontFamily="sans-serif"
android:paddingTop="8dp"
android:text="@string/empty_view_subtitle_text"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#A2AAB0"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/productfab"
app:backgroundTint="@android:color/holo_blue_bright" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="@color/yellow_editor"
android:orientation="vertical"
android:padding="@dimen/activity_margin"
tools:context=".EditorActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/producttop"
tools:ignore="product top"
android:contentDescription="@string/product_top" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/CategoryStyle"
android:text="@string/product_name" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
android:paddingStart="4dp"
tools:ignore="RtlSymmetry">
<EditText
android:id="@+id/product_name_edit"
style="@style/EditorFieldStyle"
android:inputType="textCapWords"
android:hint="@string/please_enter_product_name"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/CategoryStyle"
android:text="@string/supplier_name" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
android:paddingStart="4dp"
tools:ignore="RtlSymmetry">
<EditText
android:id="@+id/supplier_name_edit"
style="@style/EditorFieldStyle"
android:hint="@string/please_enter_supplier_name"
android:inputType="textCapSentences" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/CategoryStyle"
android:text="@string/quantity" />
<Button
android:id="@+id/increse"
android:layout_width="40dp"
android:layout_height="40dp"
android:text="+" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
android:paddingStart="4dp"
tools:ignore="RtlSymmetry">
<EditText
android:id="@+id/quantity_edit"
style="@style/EditorFieldStyle"
android:inputType="number"
android:text="@string/_0"
android:hint="@string/please_enter_quantity"
/>
</LinearLayout>
<Button
android:id="@+id/decrese"
android:layout_width="40dp"
android:layout_height="40dp"
android:text="-" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/CategoryStyle"
android:text="@string/price" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
android:paddingStart="4dp"
tools:ignore="RtlSymmetry">
<EditText
android:id="@+id/price_edit"
style="@style/EditorFieldStyle"
android:inputType="number"
android:hint="@string/please_enter_price"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/CategoryStyle"
android:text="@string/supplier_phone_number" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
android:paddingStart="4dp"
tools:ignore="RtlSymmetry">
<EditText
android:id="@+id/supplier_phone_number_edit"
style="@style/EditorFieldStyle"
android:inputType="phone"
android:hint="@string/please_enter_supplier_phone_number"
/>
</LinearLayout>
<ImageButton
android:id="@+id/supplier_phone_number_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerCrop"
android:src="@drawable/dailer"
android:text="@string/contact_supplier"
android:contentDescription="@string/contact_supplier" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/producteditorimage"
android:contentDescription="@string/product_editor_image" />
</LinearLayout>
<?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:descendantFocusability="blocksDescendants"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<TextView
android:id="@+id/product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#2B3D4D"
/>
<TextView
android:id="@+id/supplier_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#AEB6BD"
/>
<TextView
android:id="@+id/supplier_phone_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#AEB6BD"
/>
<TextView
android:id="@+id/quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#AEB6BD"
/>
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#AEB6BD"
/>
</LinearLayout>
<Button
android:id="@+id/sale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="#AEB6BD"
android:text="sale"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<menu 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"
tools:context=".CatalogActivity">
<item
android:id="@+id/action_insert_dummy_data"
android:title="@string/action_insert_dummy_data"
app:showAsAction="always" />
<item
android:id="@+id/action_delete_all_entries"
android:title="@string/action_delete_all_entries"
app:showAsAction="never" />
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu 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"
tools:context=".EditorActivity">
<item
android:id="@+id/action_save"
android:title="@string/action_save"
android:icon="@drawable/ic_done"
app:showAsAction="always" />
<item
android:id="@+id/action_delete"
android:title="@string/action_delete"
app:showAsAction="never" />
</menu>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#F0514B</color>
<color name="colorPrimaryDark">#C0403C</color>
<color name="colorAccent">#F0514B</color>
<color name="editorColorPrimary">#2D3640</color>
<color name="editorColorPrimaryDark">#394450</color>
<color name="yellow">#f0cd6e</color>
<color name="yellow_editor">#7bf0cd6e</color>
</resources>
<resources>
<dimen name="fab_margin">16dp</dimen>
<dimen name="activity_margin">16dp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">products</string>
<string name="action_insert_dummy_data">Insert Dummy Data</string>
<string name="action_delete_all_entries">Delete All products</string>
<string name="empty_view_title_text">It\'s a bit lonely here…</string>
<string name="empty_view_subtitle_text">Get started by adding a product</string>
<string name="editor_activity_title_new_item">Add product</string>
<string name="editor_activity_title_edit_product">Edit product</string>
<string name="action_save">Save</string>
<string name="action_delete">Delete</string>
<string name="editor_insert_product_successful">product saved</string>
<string name="editor_insert_product_failed">Error with saving product</string>
<string name="editor_update_product_successful">product updated</string>
<string name="editor_update_product_failed">Error with updating product</string>
<string name="unsaved_changes_dialog_msg">Discard your changes and quit editing?</string>
<string name="discard">Discard</string>
<string name="keep_editing">Keep Editing</string>
<string name="editor_delete_product_successful">product deleted</string>
<string name="editor_delete_product_failed">Error with deleting product</string>
<string name="delete_dialog_msg">Delete this product?</string>
<string name="delete">Delete</string>
<string name="cancel">Cancel</string>
<string name="refreshed_successfully">refreshed successfully</string>
<string name="quantity_zero">quantity is zero</string>
<string name="product_out_of_stock">product can\'t be zero need to add some more</string>
<string name="cant_be_under_0">can\'t be under 0</string>
<string name="name_is_required">Name is required</string>
<string name="number_is_required">Number is required</string>
<string name="phone_is_required">phone is required</string>
<string name="supplier_is_required">supplier is required</string>
<string name="requires_valid_quantity">requires valid quantity</string>
<string name="requires_valid_price"> requires valid price</string>
<string name="plaese_enter_value">plaese enter value</string>
<string name="quantity">quantity</string>
<string name="product_name">product name</string>
<string name="supplier_name">supplier name</string>
<string name="supplier_phone_number">supplier phone number</string>
<string name="product_top">product top</string>
<string name="product_editor_image">product editor image</string>
<string name="contact_supplier">contact supplier</string>
<string name="_0">0</string>
<string name="please_enter_product_name">please enter product name</string>
<string name="please_enter_supplier_name">please enter supplier name</string>
<string name="please_enter_quantity">please enter quantity</string>
<string name="price">price</string>
<string name="please_enter_price">please enter price</string>
<string name="please_enter_supplier_phone_number">please enter supplier phone number</string>
<string name="image_for_empty_page">image for empty page</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- Theme of the editor -->
<style name="EditorTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/editorColorPrimary</item>
<item name="colorPrimaryDark">@color/editorColorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- Style for a category in the editor -->
<style name="CategoryStyle">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:paddingTop">16dp</item>
<item name="android:textColor">@color/colorAccent</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textAppearance">?android:textAppearanceSmall</item>
</style>
<!-- Style for an EditText field in the editor -->
<style name="EditorFieldStyle">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
<item name="android:fontFamily">sans-serif-light</item>
<item name="android:textAppearance">?android:textAppearanceMedium</item>
</style>
<!-- Style for the measurement units for an EditText field in the editor -->
<style name="EditorUnitsStyle">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:paddingRight">16dp</item>
<item name="android:paddingTop">16dp</item>
<item name="android:textAppearance">?android:textAppearanceSmall</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment