Commit aaf6a97c authored by Rneha96's avatar Rneha96

updated

parent a577129b
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.rmal30.housepainter"
minSdkVersion 14
targetSdkVersion 29
versionCode 13
versionName "1.0.12"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
implementation 'com.github.QuadFlask:colorpicker:0.0.15'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\user\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.rmal30.housepainter">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.rmal30.housepainter"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"
tools:replace="android:resource"/>
</provider>
<activity android:name=".Main2Activity"></activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package com.rmal30.housepainter;
import android.os.AsyncTask;
import org.json.JSONObject;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public abstract class CallPostService extends AsyncTask<Void, Void, JSONObject>
{
public JSONObject jObject;
public String url;
public RequestBody body;
public CallPostService(String url, RequestBody body)
{
super();
this.url = url;
this.body = body;
}
@Override
protected JSONObject doInBackground(Void... params)
{
jObject = null;
//MediaType MEDIA_TYPE = MediaType.parse("application/x-www-form-urlencoded");
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(180, TimeUnit.SECONDS)
.writeTimeout(180, TimeUnit.SECONDS)
.readTimeout(180, TimeUnit.SECONDS)
.build();
/*JSONObject postdata = new JSONObject();
try
{
for(int i = 0; i < paramKeys.length; i++)
{
postdata.put(paramKeys[i], paramData[i]);
}
Config.logPrint(Config.TAG + "CallPostService doInBackground() postdata: " + postdata.toString());
}
catch(JSONException e)
{
Config.logPrint(Config.TAG + "CallPostService doInBackground() postdata error: " + e.getMessage());
}*/
//RequestBody body = RequestBody.create(MEDIA_TYPE, postdata.toString());
System.out.println("PaintVisualizer CallPostService doInBackground() postdata: " + body.toString());
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
try
{
Response response = client.newCall(request).execute();
String respond = response.body().string();
jObject = new JSONObject(respond);
}
catch (Exception e)
{
jObject = null;
}
return jObject;
}
@Override
protected void onPostExecute(JSONObject jsonObject)
{
if(jsonObject != null)
{
System.out.println("PaintVisualizer CallPostService onPostExecute() JSONObject: OK");
displayOK(jsonObject);
}
else
{
System.out.println("PaintVisualizer CallPostService onPostExecute() JSONObject: null");
displayError();
}
}
public abstract void displayOK(JSONObject jObject);
public abstract void displayError();
}
package com.rmal30.housepainter;
import android.graphics.Color;
public class Config
{
public static String base64EncodedString = "";
public static final String ip = "192.168.1.102";
public static final String IMAGE_UPLOAD_API = "http://" + ip + "/ColorIdentify/color_identify_service.php";
public static int getRGBCodeFromHex(String hex)
{
int color = (int) Long.parseLong(hex.replace("#", ""), 16);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
return Color.rgb(r, g, b);
}
public static String getRGB(String hex)
{
String rgb;
int color = (int) Long.parseLong(hex.replace("#", ""), 16);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
rgb = r + "," + g + "," + b;
return rgb;
}
}
package com.rmal30.housepainter;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.util.Base64;
import java.io.ByteArrayOutputStream;
public abstract class ConvertBitmapToBase64 extends AsyncTask<Void, Void, String>
{
public final Bitmap bitmap;
public String encodedImage = "";
public ConvertBitmapToBase64(Bitmap bitmap)
{
this.bitmap = bitmap;
}
@Override
protected String doInBackground(Void... voids)
{
String encodedImageString = "";
try
{
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();
encodedImageString = Base64.encodeToString(byteArray, Base64.DEFAULT);
}
catch (Exception e)
{
encodedImageString = "";
System.out.println("PaintVisualizer ConvertBitmapToBase64 doInBackground() error: " + e.getMessage());
}
return encodedImageString;
}
@Override
protected void onPostExecute(String respond)
{
System.out.println("PaintVisualizer ConvertBitmapToBase64 onPostExecute() encoded image length: " + respond.length());
if(respond != null)
{
if(!respond.equals(""))
{
encodedImage = respond;
Config.base64EncodedString = encodedImage;
displayOK();
}
else
{
encodedImage = "";
Config.base64EncodedString = encodedImage;
displayEmpty();
}
}
else
{
encodedImage = "";
Config.base64EncodedString = encodedImage;
displayNull();
}
super.onPostExecute(respond);
}
public abstract void displayOK();
public abstract void displayEmpty();
public abstract void displayNull();
}
package com.rmal30.housepainter;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;
/**
* Created by lakmobile on 12/21/17.
*/
public class CustomProgressDialog
{
public Context ctx;
public Dialog dialog;
public TextView tvMsg;
public CustomProgressDialog(Context context)
{
this.ctx = context;
dialog = new Dialog(ctx);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.custom_progress_layout);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
}
public void showDialog(String msg)
{
tvMsg = (TextView) dialog.findViewById(R.id.tv_progressMsg);
tvMsg.setText(msg);
Point size = new Point();
((Activity)ctx).getWindowManager().getDefaultDisplay().getSize(size);
int w = (int) (size.x*.8);
dialog.getWindow().setLayout(w, ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.show();
}
public void dismissDialog()
{
if(dialog != null)
{
if(dialog.isShowing())
{
dialog.dismiss();
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:thickness="0dp"
android:shape="rectangle">
<corners android:radius="10dp" />
<stroke
android:width="1dp"
android:color="@color/colorPrimary"/>
<solid
android:color="@color/custom_gray"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:thickness="0dp"
android:shape="rectangle">
<corners android:radius="10dp" />
<stroke
android:width="1dp"
android:color="@color/black"/>
<gradient
android:angle="135"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorPrimaryDark"
android:type="linear"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true">
<color android:color="@color/black"/>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:thickness="0dp"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@android:color/black"/>
<solid
android:color="@color/transparent"/>
</shape>
\ No newline at end of file
<?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:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
tools:context="com.rmal30.housepainter.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="takePhoto"
android:src="@android:drawable/ic_menu_camera" />
<ImageButton
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="chooseImage"
android:src="@android:drawable/ic_menu_gallery" />
<ImageButton
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="undo"
android:src="@android:drawable/ic_menu_revert" />
<ImageButton
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="save"
android:src="@android:drawable/ic_menu_save" />
<ImageButton
android:id="@+id/button5"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:onClick="share"
android:src="@android:drawable/ic_menu_share" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="333dp"
android:layout_height="40dp"
android:layout_weight="1"
android:text="Colors:" />
<Button
android:id="@+id/initColor"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@android:color/background_light"
android:onClick="chooseColor"
android:text="Initial"
android:textColor="@android:color/primary_text_light" />
<Button
android:id="@+id/lightColor"
android:text = "Lighting"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_weight="1"
android:onClick="chooseColor"
android:background="@android:color/background_light"
android:textColor = "@android:color/primary_text_light"
/>
<Button
android:id="@+id/paintColor"
android:text="Paint"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@android:color/background_light"
android:onClick="chooseColor"
android:textColor="@android:color/primary_text_light" />
</LinearLayout>
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="0"
android:visibility="gone"
/>
<Button
android:id="@+id/but1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="coat" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
>
<TextView
android:id="@+id/rstr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/red" />
<SeekBar
android:id="@+id/red"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumbTint="@color/red"
android:progressTint="@color/red"
android:max="255" />
<TextView
android:id="@+id/gstr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/green"
android:gravity="center"/>
<SeekBar
android:id="@+id/green"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumbTint="@color/green"
android:progressTint="@color/green"
android:max="255" />
<TextView
android:id="@+id/bstr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/blue"
android:gravity="center"/>
<SeekBar
android:id="@+id/blue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumbTint="@color/blue"
android:progressTint="@color/blue"
android:max="255" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text=""
android:textColor="@color/black"
android:textSize="20sp"
android:background="@color/white">
</CheckedTextView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal">
<com.github.ybq.android.spinkit.SpinKitView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:layout_centerInParent="true"
app:SpinKit_Color="@color/colorPrimary"
style="@style/SpinKitView.Large.FadingCircle"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<TextView
android:id="@+id/tv_progressMsg"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Progress Message"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:gravity="center_horizontal|center_vertical"
android:textSize="20sp"
android:maxLines="2"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text=""
android:textColor="@color/colorPrimary"
android:textSize="20sp"
android:background="@color/white">
</TextView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#9FAAEA</color>
<color name="colorPrimaryDark">#939FEF</color>
<color name="colorAccent">#ff4081</color>
<color name="red">#ff0000</color>
<color name="green">#00ff00</color>
<color name="blue">#0000ff</color>
<color name="transparent">#00FFFFFF</color>
<color name="black">#000000</color>
<color name="white">#ffffff</color>
<color name="dark_gray">#636363</color>
<color name="custom_gray">#cfcfcf</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
<resources>
<string name="app_name">Wall paint visualizer</string>
<string-array name="colors">
<item>Select a color</item>
<item>Red</item>
<item>Orange</item>
<item>Yellow</item>
<item>Green</item>
<item>Blue</item>
<item>Purple</item>
<item>Beige</item>
<item>Off White</item>
</string-array>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_files"
path="." />
</paths>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment