Browse Source

增加 TileService

liuyuqi-dellpc 4 years ago
parent
commit
6cd2342e1d

+ 20 - 5
app/src/main/AndroidManifest.xml

@@ -3,7 +3,7 @@
     package="me.yoqi.qrcode"
     android:installLocation="auto"
     android:versionCode="2"
-    android:versionName="1.0.1" >
+    android:versionName="1.0.2">
 
     <uses-permission android:name="android.permission.CAMERA" />
    <!-- <uses-permission android:name="android.permission.INTERNET" />-->
@@ -49,15 +49,17 @@
         android:allowBackup="true"
         android:icon="@drawable/logo2"
         android:label="@string/app_name"
-        android:theme="@style/AppTheme" >
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
         <activity
             android:name="me.yoqi.qrcode.CaptureActivity"
             android:clearTaskOnLaunch="true"
             android:configChanges="orientation|keyboardHidden"
+            android:launchMode="singleTop"
             android:screenOrientation="portrait"
             android:stateNotNeeded="true"
-            android:theme="@android:style/Theme.NoTitleBar"
-            android:windowSoftInputMode="stateAlwaysHidden" >
+            android:theme="@style/Theme.AppCompat.Light.NoActionBar"
+            android:windowSoftInputMode="stateAlwaysHidden">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -117,7 +119,20 @@
                     android:scheme="zxing" />
             </intent-filter>
         </activity>
-        <activity android:name="me.yoqi.qrcode.ResultActivity"/>
+        <activity android:name="me.yoqi.qrcode.ResultActivity" />
+
+        <service
+            android:name=".service.QuickStartService"
+            android:icon="@android:drawable/btn_star"
+            android:label="@string/app_name"
+            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
+            <intent-filter>
+                <action android:name="android.service.quicksettings.action.QS_TILE" />
+            </intent-filter>
+            <meta-data
+                android:name="android.service.quicksettings.ACTIVE_TILE"
+                android:value="true" />
+        </service>
     </application>
 
 </manifest>

+ 293 - 298
app/src/main/java/me/yoqi/qrcode/CaptureActivity.java

@@ -1,7 +1,6 @@
 package me.yoqi.qrcode;
 
 import android.Manifest;
-import android.app.Activity;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
@@ -40,307 +39,303 @@ import java.util.Collection;
 
 /**
  * 识别二维码 CaptureActivity
- * 
- * @author liuyuqi
  *
+ * @author liuyuqi
  */
 public final class CaptureActivity extends AppCompatActivity implements SurfaceHolder.Callback {
 
-	private static final String TAG = CaptureActivity.class.getSimpleName();
-
-	private CameraManager cameraManager;
-	private CaptureActivityHandler handler;
-	private Result savedResultToShow;
-	private ViewfinderView viewfinderView;
-	private boolean hasSurface;
-	private Collection<BarcodeFormat> decodeFormats;
-	private InactivityTimer inactivityTimer;
-	private String characterSet;
-	private BeepManager beepManager;
-
-	ImageView opreateView;
-
-	ViewfinderView getViewfinderView() {
-		return viewfinderView;
-	}
-
-	public Handler getHandler() {
-		return handler;
-	}
-
-	public CameraManager getCameraManager() {
-		return cameraManager;
-	}
-
-	@Override
-	public void onCreate(Bundle icicle) {
-		super.onCreate(icicle);
-
-		Window window = getWindow();
-		window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-		setContentView(R.layout.capture);
-
-		hasSurface = false;
-		inactivityTimer = new InactivityTimer(this);
-		beepManager = new BeepManager(this);
-		opreateView = (ImageView) findViewById(R.id.button_openorcloseClick);
-
-		opreateView.setOnClickListener(new OnClickListener() {
-
-			@Override
-			public void onClick(View v) {
-				if (cameraManager != null) {
-					Config.KEY_FRONT_LIGHT = !Config.KEY_FRONT_LIGHT;
-					if (Config.KEY_FRONT_LIGHT == true) {
-						opreateView
-								.setImageResource(R.drawable.mzw_camera_close);
-					} else {
-						opreateView
-								.setImageResource(R.drawable.mzw_camera_open);
-					}
-					cameraManager.getConfigManager().initializeTorch(
-							cameraManager.getCamera().getParameters(), false);
-					onPause();
-					onResume();
-				}
-			}
-		});
-	}
-
-	@Override
-	protected void onResume() {
-		super.onResume();
-
-		// CameraManager must be initialized here, not in onCreate(). This is
-		// necessary because we don't
-		// want to open the camera driver and measure the screen size if we're
-		// going to show the help on
-		// first launch. That led to bugs where the scanning rectangle was the
-		// wrong size and partially
-		// off screen.
-		cameraManager = new CameraManager(getApplication());
-
-		viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
-		viewfinderView.setCameraManager(cameraManager);
-
-		handler = null;
-		SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
-		SurfaceHolder surfaceHolder = surfaceView.getHolder();
-		if (hasSurface) {
-			// The activity was paused but not stopped, so the surface still
-			// exists. Therefore
-			// surfaceCreated() won't be called, so init the camera here.
-			initCamera(surfaceHolder);
-		} else {
-			// Install the callback and wait for surfaceCreated() to init the
-			// camera.
-			surfaceHolder.addCallback(this);
-			surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
-		}
-
-		beepManager.updatePrefs();
-
-		inactivityTimer.onResume();
-	}
-
-	@Override
-	protected void onPause() {
-		if (handler != null) {
-			handler.quitSynchronously();
-			handler = null;
-		}
-		inactivityTimer.onPause();
-		cameraManager.closeDriver();
-		if (!hasSurface) {
-			SurfaceView surfaceView = findViewById(R.id.preview_view);
-			SurfaceHolder surfaceHolder = surfaceView.getHolder();
-			surfaceHolder.removeCallback(this);
-		}
-		super.onPause();
-	}
-
-	@Override
-	protected void onDestroy() {
-		inactivityTimer.shutdown();
-		super.onDestroy();
-	}
-
-	@Override
-	public boolean onKeyDown(int keyCode, KeyEvent event) {
-		switch (keyCode) {
-		case KeyEvent.KEYCODE_BACK:
-			// restartPreviewAfterDelay(0L);
-			return super.onKeyDown(keyCode, event);
-		case KeyEvent.KEYCODE_FOCUS:
-		case KeyEvent.KEYCODE_CAMERA:
-			// Handle these events so they don't launch the Camera app
-			return true;
-			// Use volume up/down to turn on light
-		case KeyEvent.KEYCODE_VOLUME_DOWN:
-			cameraManager.setTorch(false);
-			return true;
-		case KeyEvent.KEYCODE_VOLUME_UP:
-			cameraManager.setTorch(true);
-			return true;
-		}
-		return super.onKeyDown(keyCode, event);
-	}
-
-	private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) {
-		// Bitmap isn't used yet -- will be used soon
-		if (handler == null) {
-			savedResultToShow = result;
-		} else {
-			if (result != null) {
-				savedResultToShow = result;
-			}
-			if (savedResultToShow != null) {
-				Message message = Message.obtain(handler,
-						R.id.decode_succeeded, savedResultToShow);
-				handler.sendMessage(message);
-			}
-			savedResultToShow = null;
-		}
-	}
-
-	@Override
-	public void surfaceCreated(SurfaceHolder holder) {
-		if (holder == null) {
-			Log.e(TAG,
-					"*** WARNING *** surfaceCreated() gave us a null surface!");
-		}
-		if (!hasSurface) {
-			hasSurface = true;
-			initCamera(holder);
-		}
-	}
-
-	@Override
-	public void surfaceDestroyed(SurfaceHolder holder) {
-		hasSurface = false;
-	}
-
-	@Override
-	public void surfaceChanged(SurfaceHolder holder, int format, int width,
-			int height) {
-
-	}
-
-	/**
-	 * A valid barcode has been found, so give an indication of success and show
-	 * the results.
-	 * 
-	 * @param rawResult
-	 *            The contents of the barcode.
-	 * @param barcode
-	 *            A greyscale bitmap of the camera data which was decoded.
-	 */
-	public void handleDecode(Result rawResult, Bitmap barcode) {
-		inactivityTimer.onActivity();
-		ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(
-				this, rawResult);
-
-		boolean fromLiveScan = barcode != null;
-		if (fromLiveScan) {
-			// Then not from history, so beep/vibrate and we have an image to
-			// draw on
-			beepManager.playBeepSoundAndVibrate();
-			// drawResultPoints(barcode, rawResult);
-			viewfinderView.drawResultBitmap(barcode);
-		}
-
-		String text = rawResult.getText();
-		Intent intent = new Intent(this, ResultActivity.class);
-		intent.putExtra("text", text);
-		startActivity(intent);
+    private static final String TAG = CaptureActivity.class.getSimpleName();
+
+    private CameraManager cameraManager;
+    private CaptureActivityHandler handler;
+    private Result savedResultToShow;
+    private ViewfinderView viewfinderView;
+    private boolean hasSurface;
+    private Collection<BarcodeFormat> decodeFormats;
+    private InactivityTimer inactivityTimer;
+    private String characterSet;
+    private BeepManager beepManager;
+
+    ImageView opreateView;
+
+    ViewfinderView getViewfinderView() {
+        return viewfinderView;
+    }
+
+    public Handler getHandler() {
+        return handler;
+    }
+
+    public CameraManager getCameraManager() {
+        return cameraManager;
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        Window window = getWindow();
+        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+        setContentView(R.layout.capture);
+
+        hasSurface = false;
+        inactivityTimer = new InactivityTimer(this);
+        beepManager = new BeepManager(this);
+        opreateView = (ImageView) findViewById(R.id.button_openorcloseClick);
+
+        opreateView.setOnClickListener(new OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                if (cameraManager != null) {
+                    Config.KEY_FRONT_LIGHT = !Config.KEY_FRONT_LIGHT;
+                    if (Config.KEY_FRONT_LIGHT == true) {
+                        opreateView
+                                .setImageResource(R.drawable.mzw_camera_close);
+                    } else {
+                        opreateView
+                                .setImageResource(R.drawable.mzw_camera_open);
+                    }
+                    cameraManager.getConfigManager().initializeTorch(
+                            cameraManager.getCamera().getParameters(), false);
+                    onPause();
+                    onResume();
+                }
+            }
+        });
+
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        // CameraManager must be initialized here, not in onCreate(). This is
+        // necessary because we don't
+        // want to open the camera driver and measure the screen size if we're
+        // going to show the help on
+        // first launch. That led to bugs where the scanning rectangle was the
+        // wrong size and partially
+        // off screen.
+        cameraManager = new CameraManager(getApplication());
+
+        viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
+        viewfinderView.setCameraManager(cameraManager);
+
+        handler = null;
+        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
+        SurfaceHolder surfaceHolder = surfaceView.getHolder();
+        if (hasSurface) {
+            // The activity was paused but not stopped, so the surface still
+            // exists. Therefore
+            // surfaceCreated() won't be called, so init the camera here.
+            initCamera(surfaceHolder);
+        } else {
+            // Install the callback and wait for surfaceCreated() to init the
+            // camera.
+            surfaceHolder.addCallback(this);
+            surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+        }
+
+        beepManager.updatePrefs();
+
+        inactivityTimer.onResume();
+    }
+
+    @Override
+    protected void onPause() {
+        if (handler != null) {
+            handler.quitSynchronously();
+            handler = null;
+        }
+        inactivityTimer.onPause();
+        cameraManager.closeDriver();
+        if (!hasSurface) {
+            SurfaceView surfaceView = findViewById(R.id.preview_view);
+            SurfaceHolder surfaceHolder = surfaceView.getHolder();
+            surfaceHolder.removeCallback(this);
+        }
+        super.onPause();
+    }
+
+    @Override
+    protected void onDestroy() {
+        inactivityTimer.shutdown();
+        super.onDestroy();
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_BACK:
+                // restartPreviewAfterDelay(0L);
+                return super.onKeyDown(keyCode, event);
+            case KeyEvent.KEYCODE_FOCUS:
+            case KeyEvent.KEYCODE_CAMERA:
+                // Handle these events so they don't launch the Camera app
+                return true;
+            // Use volume up/down to turn on light
+            case KeyEvent.KEYCODE_VOLUME_DOWN:
+                cameraManager.setTorch(false);
+                return true;
+            case KeyEvent.KEYCODE_VOLUME_UP:
+                cameraManager.setTorch(true);
+                return true;
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) {
+        // Bitmap isn't used yet -- will be used soon
+        if (handler == null) {
+            savedResultToShow = result;
+        } else {
+            if (result != null) {
+                savedResultToShow = result;
+            }
+            if (savedResultToShow != null) {
+                Message message = Message.obtain(handler,
+                        R.id.decode_succeeded, savedResultToShow);
+                handler.sendMessage(message);
+            }
+            savedResultToShow = null;
+        }
+    }
+
+    @Override
+    public void surfaceCreated(SurfaceHolder holder) {
+        if (holder == null) {
+            Log.e(TAG,
+                    "*** WARNING *** surfaceCreated() gave us a null surface!");
+        }
+        if (!hasSurface) {
+            hasSurface = true;
+            initCamera(holder);
+        }
+    }
+
+    @Override
+    public void surfaceDestroyed(SurfaceHolder holder) {
+        hasSurface = false;
+    }
+
+    @Override
+    public void surfaceChanged(SurfaceHolder holder, int format, int width,
+                               int height) {
+
+    }
+
+    /**
+     * A valid barcode has been found, so give an indication of success and show
+     * the results.
+     *
+     * @param rawResult The contents of the barcode.
+     * @param barcode   A greyscale bitmap of the camera data which was decoded.
+     */
+    public void handleDecode(Result rawResult, Bitmap barcode) {
+        inactivityTimer.onActivity();
+        ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(
+                this, rawResult);
+
+        boolean fromLiveScan = barcode != null;
+        if (fromLiveScan) {
+            // Then not from history, so beep/vibrate and we have an image to
+            // draw on
+            beepManager.playBeepSoundAndVibrate();
+            // drawResultPoints(barcode, rawResult);
+            viewfinderView.drawResultBitmap(barcode);
+        }
+
+        String text = rawResult.getText();
+        Intent intent = new Intent(this, ResultActivity.class);
+        intent.putExtra("text", text);
+        startActivity(intent);
 //		Toast.makeText(this, "扫描结果:" + text, Toast.LENGTH_LONG).show();
 //		Log.d(TAG, "result-->" + text);
-	}
-
-	/**
-	 * Superimpose a line for 1D or dots for 2D to highlight the key features of
-	 * the barcode.
-	 * 
-	 * @param barcode
-	 *            A bitmap of the captured image.
-	 * @param rawResult
-	 *            The decoded results which contains the points to draw.
-	 */
-	private void drawResultPoints(Bitmap barcode, Result rawResult) {
-		ResultPoint[] points = rawResult.getResultPoints();
-		if (points != null && points.length > 0) {
-			Canvas canvas = new Canvas(barcode);
-			Paint paint = new Paint();
-			paint.setColor(getResources().getColor(R.color.result_points));
-			if (points.length == 2) {
-				paint.setStrokeWidth(4.0f);
-				drawLine(canvas, paint, points[0], points[1]);
-			} else if (points.length == 4
-					&& (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult
-							.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
-				// Hacky special case -- draw two lines, for the barcode and
-				// metadata
-				drawLine(canvas, paint, points[0], points[1]);
-				drawLine(canvas, paint, points[2], points[3]);
-			} else {
-				paint.setStrokeWidth(10.0f);
-				for (ResultPoint point : points) {
-					canvas.drawPoint(point.getX(), point.getY(), paint);
-				}
-			}
-		}
-	}
-
-	private static void drawLine(Canvas canvas, Paint paint, ResultPoint a,
-			ResultPoint b) {
-		canvas.drawLine(a.getX(), a.getY(), b.getX(), b.getY(), paint);
-	}
-
-	private void initCamera(SurfaceHolder surfaceHolder) {
-		//		权限检测
-		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-			if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
-				requestPermissions(new String[]{Manifest.permission.CAMERA}, 1);
-			}
-		}
-		if (surfaceHolder == null) {
-			throw new IllegalStateException("No SurfaceHolder provided");
-		}
-		if (cameraManager.isOpen()) {
-			Log.w(TAG,
-					"initCamera() while already open -- late SurfaceView callback?");
-			return;
-		}
-		try {
-			cameraManager.openDriver(surfaceHolder);
-			// Creating the handler starts the preview, which can also throw a
-			// RuntimeException.
-			if (handler == null) {
-				handler = new CaptureActivityHandler(this, viewfinderView,
-						decodeFormats, characterSet, cameraManager);
-			}
-			decodeOrStoreSavedBitmap(null, null);
-		} catch (IOException ioe) {
-			Log.w(TAG, ioe);
-			Toast.makeText(this, R.string.camera_problem, Toast.LENGTH_SHORT)
-					.show();
-			finish();
-		} catch (RuntimeException e) {
-			// Barcode Scanner has seen crashes in the wild of this variety:
-			// java.?lang.?RuntimeException: Fail to connect to camera service
-			Log.w(TAG, "Unexpected error initializing camera", e);
-			Toast.makeText(this, R.string.framwork_problem, Toast.LENGTH_SHORT)
-					.show();
-		}
-	}
-
-	public void restartPreviewAfterDelay(long delayMS) {
-		if (handler != null) {
-			handler.sendEmptyMessageDelayed(R.id.restart_preview, delayMS);
-		}
-	}
-
-	public void drawViewfinder() {
-		viewfinderView.drawViewfinder();
-	}
+    }
+
+    /**
+     * Superimpose a line for 1D or dots for 2D to highlight the key features of
+     * the barcode.
+     *
+     * @param barcode   A bitmap of the captured image.
+     * @param rawResult The decoded results which contains the points to draw.
+     */
+    private void drawResultPoints(Bitmap barcode, Result rawResult) {
+        ResultPoint[] points = rawResult.getResultPoints();
+        if (points != null && points.length > 0) {
+            Canvas canvas = new Canvas(barcode);
+            Paint paint = new Paint();
+            paint.setColor(getResources().getColor(R.color.result_points));
+            if (points.length == 2) {
+                paint.setStrokeWidth(4.0f);
+                drawLine(canvas, paint, points[0], points[1]);
+            } else if (points.length == 4
+                    && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult
+                    .getBarcodeFormat() == BarcodeFormat.EAN_13)) {
+                // Hacky special case -- draw two lines, for the barcode and
+                // metadata
+                drawLine(canvas, paint, points[0], points[1]);
+                drawLine(canvas, paint, points[2], points[3]);
+            } else {
+                paint.setStrokeWidth(10.0f);
+                for (ResultPoint point : points) {
+                    canvas.drawPoint(point.getX(), point.getY(), paint);
+                }
+            }
+        }
+    }
+
+    private static void drawLine(Canvas canvas, Paint paint, ResultPoint a,
+                                 ResultPoint b) {
+        canvas.drawLine(a.getX(), a.getY(), b.getX(), b.getY(), paint);
+    }
+
+    private void initCamera(SurfaceHolder surfaceHolder) {
+        //		权限检测
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
+                requestPermissions(new String[]{Manifest.permission.CAMERA}, 1);
+            }
+        }
+        if (surfaceHolder == null) {
+            throw new IllegalStateException("No SurfaceHolder provided");
+        }
+        if (cameraManager.isOpen()) {
+            Log.w(TAG,
+                    "initCamera() while already open -- late SurfaceView callback?");
+            return;
+        }
+        try {
+            cameraManager.openDriver(surfaceHolder);
+            // Creating the handler starts the preview, which can also throw a
+            // RuntimeException.
+            if (handler == null) {
+                handler = new CaptureActivityHandler(this, viewfinderView,
+                        decodeFormats, characterSet, cameraManager);
+            }
+            decodeOrStoreSavedBitmap(null, null);
+        } catch (IOException ioe) {
+            Log.w(TAG, ioe);
+            Toast.makeText(this, R.string.camera_problem, Toast.LENGTH_SHORT)
+                    .show();
+            finish();
+        } catch (RuntimeException e) {
+            // Barcode Scanner has seen crashes in the wild of this variety:
+            // java.?lang.?RuntimeException: Fail to connect to camera service
+            Log.w(TAG, "Unexpected error initializing camera", e);
+            Toast.makeText(this, R.string.framwork_problem, Toast.LENGTH_SHORT)
+                    .show();
+        }
+    }
+
+    public void restartPreviewAfterDelay(long delayMS) {
+        if (handler != null) {
+            handler.sendEmptyMessageDelayed(R.id.restart_preview, delayMS);
+        }
+    }
+
+    public void drawViewfinder() {
+        viewfinderView.drawViewfinder();
+    }
 }

+ 48 - 0
app/src/main/java/me/yoqi/qrcode/service/QuickStartService.java

@@ -0,0 +1,48 @@
+package me.yoqi.qrcode.service;
+
+import android.content.Intent;
+import android.os.Build;
+import android.service.quicksettings.TileService;
+
+import androidx.annotation.RequiresApi;
+
+import me.yoqi.qrcode.CaptureActivity;
+
+/**
+ * 下拉快速启动
+ *
+ * @author liuyuqi.gov@msn.cn
+ * @createTime 2020-10-14
+ */
+@RequiresApi(api = Build.VERSION_CODES.N)
+public class QuickStartService extends TileService {
+
+    /**
+     * 当用户从Edit栏添加到快速设置中调用
+     */
+    @Override
+    public void onTileAdded() {
+        super.onTileAdded();
+        //添加成功
+    }
+
+    @Override
+    public void onTileRemoved() {
+        super.onTileRemoved();
+        //移除成功
+    }
+
+    @Override
+    public void onClick() {
+        super.onClick();
+        int state = getQsTile().getState();
+        Intent intent = new Intent(this, CaptureActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        startActivityAndCollapse(intent);
+    }
+
+    @Override
+    public void onStartListening() {
+        super.onStartListening();
+    }
+}

+ 16 - 27
app/src/main/res/values/colors.xml

@@ -1,30 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2008 ZXing authors
-
- 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>
-  <color name="contents_text">#ff000000</color>
-  <color name="encode_view">#ffffffff</color>
-  <color name="possible_result_points">#c0ffbd21</color> <!-- Android standard ICS color -->
-  <color name="result_minor_text">#ffc0c0c0</color>
-  <color name="result_points">#c099cc00</color> <!-- Android standard ICS color -->
-  <color name="result_text">#ffffffff</color>
-  <color name="result_view">#b0000000</color>
-  <color name="status_text">#ffffffff</color>
-  <color name="transparent">#00000000</color>
-  <color name="viewfinder_laser">#ffcc0000</color> <!-- Android standard ICS color -->
-  <color name="viewfinder_mask">#60000000</color>
-  <color name="viewfinder_frame">#ff88ae00</color>
+    <color name="contents_text">#ff000000</color>
+    <color name="encode_view">#ffffffff</color>
+    <color name="possible_result_points">#c0ffbd21</color> <!-- Android standard ICS color -->
+    <color name="result_minor_text">#ffc0c0c0</color>
+    <color name="result_points">#c099cc00</color> <!-- Android standard ICS color -->
+    <color name="result_text">#ffffffff</color>
+    <color name="result_view">#b0000000</color>
+    <color name="status_text">#ffffffff</color>
+    <color name="transparent">#00000000</color>
+    <color name="viewfinder_laser">#ffcc0000</color> <!-- Android standard ICS color -->
+    <color name="viewfinder_mask">#60000000</color>
+    <color name="viewfinder_frame">#ff88ae00</color>
+<!--    basetheme-->
+    <color name="colorPrimary">#6200EE</color>
+    <color name="colorPrimaryDark">#3700B3</color>
+    <color name="colorAccent">#03DAC5</color>
 </resources>

+ 6 - 17
app/src/main/res/values/styles.xml

@@ -1,20 +1,9 @@
 <resources>
-
-    <!--
-        Base application theme, dependent on API level. This theme is replaced
-        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-    -->
-    <style name="AppBaseTheme" parent="android:Theme.Light">
-        <!--
-            Theme customizations available in newer API levels can go in
-            res/values-vXX/styles.xml, while customizations related to
-            backward-compatibility can go here.
-        -->
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
     </style>
-
-    <!-- Application theme. -->
-    <style name="AppTheme" parent="AppBaseTheme">
-        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
-    </style>
-
 </resources>