--- /dev/null
+1
\ No newline at end of file
--- /dev/null
+2
\ No newline at end of file
--- /dev/null
+3
\ No newline at end of file
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import android.widget.Toast;
import com.google.android.glass.media.Sounds;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
import cz.cvut.fel.dce.qrscanner.pdfviewer.PdfPageView;
import cz.cvut.fel.dce.qrscanner.pdfviewer.PdfViewActivity;
* The name of the PDF file containing the manufacturing guide.
*/
public static final String SKODA_COMP_MANUFACT_GUIDE = "Werkstatt_Einleitung.pdf";
+ /**
+ * The name of the file containing aditional information about the component.
+ */
+ public static final String SKODA_COMPONENT_INFO_NAME = "iteminfo.txt";
/**
* The Key of the Component Identifier value, passed as a data to the activity launch intent.
*/
* Flag signalling whether the PDF page has been loaded.
*/
private boolean mPdfLoaded;
+ /**
+ * The widget showing the value of the components compartment.
+ */
+ private TextView mCompartmentValue;
@Override
protected void onCreate(Bundle savedInstanceState) {
mPdfLoaded = false;
mPreviewImg = (ImageView) findViewById(R.id.imgComponent);
mProgressContainer = (RelativeLayout) findViewById(R.id.progress_container);
+ mCompartmentValue = (TextView) findViewById(R.id.compartment_value);
if (mProgressContainer == null) {
Log.e(TAG, "Progress container not found in the activity layout.");
Log.e(TAG, "ImageView for preview image could not be found in the activity layout.");
finish();
}
+ if (mCompartmentValue == null) {
+ Log.e(TAG, "TextView for compartment value could not be found in the activity layout.");
+ finish();
+ }
mPreviewImgObserver = mPreviewImg.getViewTreeObserver();
Log.d(TAG, "Registering mPreviewImgObserver OnGlobalLayoutListener.");
audio.playSoundEffect(Sounds.ERROR);
finish();
}
+ File infoFile = new File(mComponentRootPath + SKODA_COMPONENT_INFO_NAME);
+ if (!infoFile.exists()) {
+ Log.e(TAG, "Aditional information file " + infoFile.getAbsolutePath() + " does not exist.");
+ Toast toast = Toast.makeText(getApplicationContext(), "Database not complete", Toast.LENGTH_LONG);
+ toast.show();
+ AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ audio.playSoundEffect(Sounds.ERROR);
+ finish();
+ }
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(infoFile));
+ String compartmentLine = br.readLine();
+ if (compartmentLine != null) {
+ mCompartmentValue.setText(compartmentLine);
+ }
+ else {
+ mCompartmentValue.setText("-");
+ }
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "Aditional information file " + infoFile.getAbsolutePath() + " does not exist.");
+ Toast toast = Toast.makeText(getApplicationContext(), "Database not complete", Toast.LENGTH_LONG);
+ toast.show();
+ AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ audio.playSoundEffect(Sounds.ERROR);
+ e.printStackTrace();
+ finish();
+ } catch (IOException e) {
+ Log.e(TAG, "Error while reading the aditional information file " + infoFile.getAbsolutePath());
+ Toast toast = Toast.makeText(getApplicationContext(), "Database reading failed", Toast.LENGTH_LONG);
+ toast.show();
+ AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ audio.playSoundEffect(Sounds.ERROR);
+ e.printStackTrace();
+ finish();
+ }
}
else {
Log.e(TAG, "No component id received.");
android:layout_width="match_parent"
android:layout_height="match_parent">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/imgComponent"
- android:layout_gravity="center_horizontal"
- android:scaleType="center"
- android:contentDescription="@string/preview_content_desc"/>
-
<RelativeLayout
- android:layout_width="73dp"
- android:layout_height="match_parent"
- android:id="@+id/progress_container"
+ android:layout_width="120dp"
+ android:layout_height="fill_parent"
+ android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
- android:layout_alignParentEnd="true"
- android:layout_alignParentStart="true">
+ android:id="@+id/relativeLayout">
- <ProgressBar
- style="?android:attr/progressBarStyleLarge"
+ <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:id="@+id/progressBar2"
- android:layout_centerVertical="true"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/compartment_label"
+ android:id="@+id/textView9"
+ android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/loading_page"
- android:id="@+id/textView5"
- android:layout_below="@+id/progressBar2"
- android:layout_alignStart="@+id/progressBar2"/>
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="1"
+ android:id="@+id/compartment_value"
+ android:layout_centerVertical="true"
+ android:layout_centerHorizontal="true"
+ android:textSize="200dp"/>
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="100dp"
+ android:layout_height="fill_parent"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentEnd="true"
+ android:layout_toEndOf="@+id/relativeLayout">
+
+ <ImageView
+ android:layout_width="100dp"
+ android:layout_height="100dp"
+ android:id="@+id/imgComponent"
+ android:layout_gravity="center_horizontal"
+ android:scaleType="center"
+ android:contentDescription="@string/preview_content_desc"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentStart="true"/>
+
+ <RelativeLayout
+ android:layout_width="73dp"
+ android:layout_height="100dp"
+ android:id="@+id/progress_container"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentStart="true">
+
+ <ProgressBar
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/progressBar2"
+ android:layout_centerVertical="true"
+ android:layout_centerHorizontal="true"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/loading_page"
+ android:id="@+id/textView5"
+ android:layout_below="@+id/progressBar2"
+ android:layout_centerHorizontal="true"/>
+ </RelativeLayout>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<string name="state_scrolling" type="id">scrolling</string>
<string name="preview_content_desc">Component preview image</string>
<string name="skoda_logo_content_desc">Skoda auto logo</string>
+ <string name="compartment_label">Compartment:</string>
</resources>
package cz.cvut.fel.dce.qrscanner;
+import android.content.Context;
import android.content.Intent;
+import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import android.widget.Toast;
import cz.cvut.fel.dce.qrscanner.mupdf.MuPDFActivity;
import cz.cvut.fel.dce.qrscanner.pdfviewer.PdfPageView;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
/**
* An activity for component picture preview with menu for selecting documents to be shown.
* The Key of the Component Identifier value, passed as a data to the activity launch intent.
*/
public static final String COMP_ID_INTENT_KEY = "COMPONENT_ID";
+ /**
+ * The name of the file containing aditional information about the component.
+ */
+ public static final String SKODA_COMPONENT_INFO_NAME = "iteminfo.txt";
/**
* The widget for showing the component preview image.
* Flag signalling whether the PDF page has been loaded.
*/
private boolean mPdfLoaded;
+ /**
+ * The widget showing the value of the components compartment.
+ */
+ private TextView mCompartmentValue;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
mPdfLoaded = false;
mPreviewImg = (ImageView) findViewById(R.id.imgComponent);
mProgressContainer = (RelativeLayout) findViewById(R.id.progress_container);
+ mCompartmentValue = (TextView) findViewById(R.id.compartment_value);
if (mProgressContainer == null) {
Log.e(TAG, "Progress container not found in the activity layout.");
Log.e(TAG, "ImageView for preview image could not be found in the activity layout.");
finish();
}
+ if (mCompartmentValue == null) {
+ Log.e(TAG, "TextView for compartment value could not be found in the activity layout.");
+ finish();
+ }
+
mPreviewImgObserver = mPreviewImg.getViewTreeObserver();
Log.d(TAG, "Registering mPreviewImgObserver OnGlobalLayoutListener.");
Log.e(TAG, "No component id received.");
finish();
}
+ File infoFile = new File(mComponentRootPath + SKODA_COMPONENT_INFO_NAME);
+ if (!infoFile.exists()) {
+ Log.e(TAG, "Aditional information file " + infoFile.getAbsolutePath() + " does not exist.");
+ Toast toast = Toast.makeText(getApplicationContext(), "Database not complete", Toast.LENGTH_LONG);
+ toast.show();
+ finish();
+ }
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(infoFile));
+ String compartmentLine = br.readLine();
+ if (compartmentLine != null) {
+ mCompartmentValue.setText(compartmentLine);
+ }
+ else {
+ mCompartmentValue.setText("-");
+ }
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "Aditional information file " + infoFile.getAbsolutePath() + " does not exist.");
+ Toast toast = Toast.makeText(getApplicationContext(), "Database not complete", Toast.LENGTH_LONG);
+ toast.show();
+ e.printStackTrace();
+ finish();
+ } catch (IOException e) {
+ Log.e(TAG, "Error while reading the aditional information file " + infoFile.getAbsolutePath());
+ Toast toast = Toast.makeText(getApplicationContext(), "Database reading failed", Toast.LENGTH_LONG);
+ toast.show();
+ e.printStackTrace();
+ finish();
+ }
+
}
@Override
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:weightSum="1">
<LinearLayout
android:orientation="vertical"
- android:layout_width="299dp"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:weightSum="1">
+ android:weightSum="1"
+ android:layout_alignParentLeft="true"
+ android:layout_marginLeft="0dp"
+ android:layout_alignParentTop="true"
+ android:layout_marginTop="0dp"
+ android:id="@+id/linearLayout">
<TextView
android:layout_width="wrap_content"
</LinearLayout>
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_marginLeft="27dp"
+ android:layout_marginStart="27dp"
+ android:layout_alignParentTop="true"
+ android:layout_toRightOf="@+id/linearLayout"
+ android:layout_toEndOf="@+id/linearLayout"
+ android:id="@+id/relativeLayout">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/compartment_label"
+ android:id="@+id/textView13"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="1"
+ android:id="@+id/compartment_value"
+ android:textSize="200dp"
+ android:layout_centerVertical="true"
+ android:layout_centerHorizontal="true"/>
+
+ </RelativeLayout>
+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:layout_alignParentTop="true"
+ android:layout_marginTop="0dp"
+ android:layout_toRightOf="@+id/relativeLayout"
+ android:layout_toEndOf="@+id/relativeLayout">
<ImageView
android:layout_width="match_parent"
android:id="@+id/imgComponent"
android:layout_gravity="center_horizontal"
android:scaleType="center"
- android:contentDescription="@string/preview_content_desc"/>
+ android:contentDescription="@string/preview_content_desc"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"/>
<RelativeLayout
android:layout_width="73dp"
android:layout_height="match_parent"
android:id="@+id/progress_container"
android:layout_alignParentTop="true"
+ android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
- android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
- android:layout_alignParentRight="true">
+ android:layout_alignParentStart="true">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:text="@string/loading_page"
android:id="@+id/textView7"
android:layout_below="@+id/progressBar"
- android:layout_alignStart="@+id/progressBar"
- android:layout_alignLeft="@+id/progressBar"/>
+ android:layout_centerHorizontal="true"/>
</RelativeLayout>
+
</RelativeLayout>
-</LinearLayout>
\ No newline at end of file
+</RelativeLayout>
\ No newline at end of file
android:weightSum="1"
android:orientation="vertical">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/previewHeading"
- android:id="@+id/textView"/>
-
- <Button
+ <LinearLayout
+ android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/butManufacturing"
- android:id="@+id/butManufacturing"
- android:onClick="showManufacturing"
- />
+ android:layout_height="wrap_content">
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/butPicturedmanufacturing"
- android:id="@+id/butManufactImages"
- android:onClick="showManufactImages"
- />
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/butManufacturingGuide"
- android:id="@+id/butManufactGuide"
- android:onClick="showManufactGuide"
- />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/previewHeading"
+ android:id="@+id/textView"/>
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/butContacts"
- android:id="@+id/butContacts"
- android:onClick="showContacts"
- />
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/butManufacturing"
+ android:id="@+id/butManufacturing"
+ android:onClick="showManufacturing"
+ />
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/butPicturedmanufacturing"
+ android:id="@+id/butManufactImages"
+ android:onClick="showManufactImages"
+ />
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/butManufacturingGuide"
+ android:id="@+id/butManufactGuide"
+ android:onClick="showManufactGuide"
+ />
+
+ <Button
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/butContacts"
+ android:id="@+id/butContacts"
+ android:onClick="showContacts"
+ />
+
+ </LinearLayout>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="1"
+ android:id="@+id/compartment_value"
+ android:layout_centerVertical="true"
+ android:layout_centerHorizontal="true"
+ android:textSize="200dp"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/compartment_label"
+ android:id="@+id/textView11"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"/>
+
+ </RelativeLayout>
+
+ </LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
<string name="preview_content_desc">Component preview image</string>
<string name="skoda_logo_content_desc">Skoda auto logo</string>
<string name="touch_to_start_scan">Touch the screen to scan the code.</string>
+ <string name="compartment_label">Compartment</string>
</resources>