mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Merge branch '566-raise-api-level' into 'master'
Stop supporting Gingerbread Closes #566 See merge request !278
This commit is contained in:
@@ -7,8 +7,7 @@
|
|||||||
android:versionName="0.12">
|
android:versionName="0.12">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="9"
|
android:minSdkVersion="14"
|
||||||
|
|
||||||
android:targetSdkVersion="22"
|
android:targetSdkVersion="22"
|
||||||
tools:overrideLibrary="android.support.v14.preference"
|
tools:overrideLibrary="android.support.v14.preference"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -19,13 +19,9 @@ dependencies {
|
|||||||
compile("com.android.support:appcompat-v7:$supportVersion") {
|
compile("com.android.support:appcompat-v7:$supportVersion") {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
}
|
}
|
||||||
compile("com.android.support:preference-v7:$supportVersion") {
|
|
||||||
exclude module: 'support-v4'
|
|
||||||
}
|
|
||||||
compile("com.android.support:preference-v14:$supportVersion") {
|
compile("com.android.support:preference-v14:$supportVersion") {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
exclude module: 'preference-v7'
|
|
||||||
exclude module: 'recyclerview-v7'
|
|
||||||
}
|
}
|
||||||
compile("com.android.support:design:$supportVersion") {
|
compile("com.android.support:design:$supportVersion") {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
@@ -64,7 +60,6 @@ dependencyVerification {
|
|||||||
'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259',
|
'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259',
|
||||||
'com.android.support:support-v4:81ce890f26d35c75ad17d0f998a7e3230330c3b41e0b629566bc744bee89e448',
|
'com.android.support:support-v4:81ce890f26d35c75ad17d0f998a7e3230330c3b41e0b629566bc744bee89e448',
|
||||||
'com.android.support:appcompat-v7:00f9d93acacd6731f309724054bf51492814b4b2869f16d7d5c0038dcb8c9a0d',
|
'com.android.support:appcompat-v7:00f9d93acacd6731f309724054bf51492814b4b2869f16d7d5c0038dcb8c9a0d',
|
||||||
'com.android.support:preference-v7:775101bd07bd052e455761c5c5d9523d7ad59f2f320e3e8cbde241fd6b1d6025',
|
|
||||||
'com.android.support:preference-v14:44881bb46094e86d0bc2426f205419674a5b4eb514b44b5a4659b5de29f71eb7',
|
'com.android.support:preference-v14:44881bb46094e86d0bc2426f205419674a5b4eb514b44b5a4659b5de29f71eb7',
|
||||||
'com.android.support:design:003e0c0bea0a6891f8b2bc43f20ae7af2a49a17363e5bb10df5ee0bae12fa686',
|
'com.android.support:design:003e0c0bea0a6891f8b2bc43f20ae7af2a49a17363e5bb10df5ee0bae12fa686',
|
||||||
'com.android.support:support-annotations:786ab0d060774fb95cfdaf4878771e14b85733b1af9d72a4aae762dc7c1dff9f',
|
'com.android.support:support-annotations:786ab0d060774fb95cfdaf4878771e14b85733b1af9d72a4aae762dc7c1dff9f',
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
|
|
||||||
<style name="BriarTheme" parent="BriarBaseTheme">
|
|
||||||
<!-- This fixes a UI bug in the support preference library -->
|
|
||||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="BriarButton.Default">
|
|
||||||
<item name="android:textAllCaps">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
|
||||||
@@ -22,6 +22,10 @@
|
|||||||
<item name="elevation">1dp</item>
|
<item name="elevation">1dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="BriarButton.Default">
|
||||||
|
<item name="android:textAllCaps">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="BriarButton" parent="Widget.AppCompat.Button.Colored">
|
<style name="BriarButton" parent="Widget.AppCompat.Button.Colored">
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
@@ -29,8 +33,6 @@
|
|||||||
<item name="android:padding">@dimen/margin_large</item>
|
<item name="android:padding">@dimen/margin_large</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BriarButton.Default"/>
|
|
||||||
|
|
||||||
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
|
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
|
||||||
<item name="android:textColor">@color/briar_button_negative</item>
|
<item name="android:textColor">@color/briar_button_negative</item>
|
||||||
<item name="android:textSize">@dimen/text_size_medium</item>
|
<item name="android:textSize">@dimen/text_size_medium</item>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<style name="BriarThemeNoActionBar.Default"/>
|
<style name="BriarThemeNoActionBar.Default"/>
|
||||||
|
|
||||||
<style name="BriarTheme" parent="BriarBaseTheme">
|
<style name="BriarTheme" parent="BriarBaseTheme">
|
||||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||||
<item name="android:listSeparatorTextViewStyle">@style/BriarTheme.ListSeparatorTextView</item>
|
<item name="android:listSeparatorTextViewStyle">@style/BriarTheme.ListSeparatorTextView</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,8 @@ package im.delight.android.identicons;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -41,12 +39,9 @@ abstract public class IdenticonView extends View {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
protected void init() {
|
protected void init() {
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(byte[] input) {
|
public void show(byte[] input) {
|
||||||
|
|||||||
@@ -76,9 +76,8 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
Intent i = new Intent(this, ExitActivity.class);
|
Intent i = new Intent(this, ExitActivity.class);
|
||||||
i.addFlags(FLAG_ACTIVITY_NEW_TASK
|
i.addFlags(FLAG_ACTIVITY_NEW_TASK
|
||||||
| FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
| FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||||
| FLAG_ACTIVITY_NO_ANIMATION);
|
| FLAG_ACTIVITY_NO_ANIMATION
|
||||||
if (Build.VERSION.SDK_INT >= 11)
|
| FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
i.addFlags(FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ package org.briarproject.android.forum;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ArgbEvaluator;
|
import android.animation.ArgbEvaluator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
@@ -519,14 +517,12 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
List<Integer> indexList =
|
List<Integer> indexList =
|
||||||
getSubTreeIndexes(visiblePos, forumEntry.getLevel());
|
getSubTreeIndexes(visiblePos, forumEntry.getLevel());
|
||||||
if (!indexList.isEmpty()) {
|
if (!indexList.isEmpty()) {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
// stop animating children
|
||||||
// stop animating children
|
for (int index : indexList) {
|
||||||
for (int index : indexList) {
|
ValueAnimator anim =
|
||||||
ValueAnimator anim =
|
animatingEntries.get(forumEntries.get(index));
|
||||||
animatingEntries.get(forumEntries.get(index));
|
if (anim != null && anim.isRunning()) {
|
||||||
if (anim != null && anim.isRunning()) {
|
anim.cancel();
|
||||||
anim.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (indexList.size() == 1) {
|
if (indexList.size() == 1) {
|
||||||
@@ -560,7 +556,6 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(11)
|
|
||||||
private void animateFadeOut(final ForumViewHolder ui,
|
private void animateFadeOut(final ForumViewHolder ui,
|
||||||
final ForumEntry addedEntry) {
|
final ForumEntry addedEntry) {
|
||||||
ui.setIsRecyclable(false);
|
ui.setIsRecyclable(false);
|
||||||
@@ -686,9 +681,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
ui.cell.setBackgroundColor(ContextCompat
|
ui.cell.setBackgroundColor(ContextCompat
|
||||||
.getColor(ForumActivity.this,
|
.getColor(ForumActivity.this,
|
||||||
R.color.forum_cell_highlight));
|
R.color.forum_cell_highlight));
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
animateFadeOut(ui, addedEntry);
|
||||||
animateFadeOut(ui, addedEntry);
|
|
||||||
}
|
|
||||||
addedEntry = null;
|
addedEntry = null;
|
||||||
} else {
|
} else {
|
||||||
ui.cell.setBackgroundColor(ContextCompat
|
ui.cell.setBackgroundColor(ContextCompat
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
package org.briarproject.android.introduction;
|
package org.briarproject.android.introduction;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.ColorFilter;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.PorterDuffColorFilter;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.briarproject.android.contact.ContactListAdapter;
|
import org.briarproject.android.contact.ContactListAdapter;
|
||||||
@@ -47,6 +42,7 @@ public class ContactChooserAdapter extends ContactListAdapter {
|
|||||||
* Set the identity from whose perspective the contact shall be chosen.
|
* Set the identity from whose perspective the contact shall be chosen.
|
||||||
* Contacts that belong to a different author will be shown grayed out,
|
* Contacts that belong to a different author will be shown grayed out,
|
||||||
* but are still clickable.
|
* but are still clickable.
|
||||||
|
*
|
||||||
* @param authorId The ID of the local Author
|
* @param authorId The ID of the local Author
|
||||||
*/
|
*/
|
||||||
public void setLocalAuthor(AuthorId authorId) {
|
public void setLocalAuthor(AuthorId authorId) {
|
||||||
@@ -55,21 +51,12 @@ public class ContactChooserAdapter extends ContactListAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void grayOutItem(final ContactHolder ui) {
|
private void grayOutItem(final ContactHolder ui) {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
float alpha = 0.25f;
|
||||||
float alpha = 0.25f;
|
ui.bulb.setAlpha(alpha);
|
||||||
ui.bulb.setAlpha(alpha);
|
ui.avatar.setAlpha(alpha);
|
||||||
ui.avatar.setAlpha(alpha);
|
ui.name.setAlpha(alpha);
|
||||||
ui.name.setAlpha(alpha);
|
ui.date.setAlpha(alpha);
|
||||||
ui.date.setAlpha(alpha);
|
ui.identity.setAlpha(alpha);
|
||||||
ui.identity.setAlpha(alpha);
|
|
||||||
} else {
|
|
||||||
ColorFilter colorFilter = new PorterDuffColorFilter(Color.GRAY,
|
|
||||||
PorterDuff.Mode.MULTIPLY);
|
|
||||||
ui.bulb.setColorFilter(colorFilter);
|
|
||||||
ui.avatar.setColorFilter(colorFilter);
|
|
||||||
ui.name.setEnabled(false);
|
|
||||||
ui.date.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatDelegate;
|
import android.support.v7.app.AppCompatDelegate;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
@@ -101,11 +100,9 @@ public class DevReportActivity extends BaseCrashReportDialog
|
|||||||
|
|
||||||
SharedPreferences prefs = sharedPreferencesFactory.create();
|
SharedPreferences prefs = sharedPreferencesFactory.create();
|
||||||
excludedFields = new HashSet<>();
|
excludedFields = new HashSet<>();
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
for (String name : prefs.getStringSet(PREF_EXCLUDED_FIELDS,
|
||||||
for (String name : prefs.getStringSet(PREF_EXCLUDED_FIELDS,
|
new HashSet<String>())) {
|
||||||
new HashSet<String>())) {
|
excludedFields.add(ReportField.valueOf(name));
|
||||||
excludedFields.add(ReportField.valueOf(name));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
|
||||||
@@ -367,16 +364,14 @@ public class DevReportActivity extends BaseCrashReportDialog
|
|||||||
protected void onPostExecute(Boolean success) {
|
protected void onPostExecute(Boolean success) {
|
||||||
final SharedPreferences prefs =
|
final SharedPreferences prefs =
|
||||||
sharedPreferencesFactory.create();
|
sharedPreferencesFactory.create();
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
final SharedPreferences.Editor prefEditor =
|
||||||
final SharedPreferences.Editor prefEditor =
|
prefs.edit();
|
||||||
prefs.edit();
|
Set<String> fields = new HashSet<>();
|
||||||
Set<String> fields = new HashSet<>();
|
for (ReportField field : excludedFields) {
|
||||||
for (ReportField field : excludedFields) {
|
fields.add(field.name());
|
||||||
fields.add(field.name());
|
|
||||||
}
|
|
||||||
prefEditor.putStringSet(PREF_EXCLUDED_FIELDS, fields);
|
|
||||||
prefEditor.apply();
|
|
||||||
}
|
}
|
||||||
|
prefEditor.putStringSet(PREF_EXCLUDED_FIELDS, fields);
|
||||||
|
prefEditor.apply();
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
// Retrieve user's comment and email address, if any
|
// Retrieve user's comment and email address, if any
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
package org.briarproject.android.sharing;
|
package org.briarproject.android.sharing;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.ColorFilter;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.PorterDuffColorFilter;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -27,25 +21,10 @@ import static android.view.View.VISIBLE;
|
|||||||
class ContactSelectorAdapter
|
class ContactSelectorAdapter
|
||||||
extends BaseContactListAdapter<ContactSelectorAdapter.SelectableContactHolder> {
|
extends BaseContactListAdapter<ContactSelectorAdapter.SelectableContactHolder> {
|
||||||
|
|
||||||
private final ColorFilter grayColorFilter;
|
|
||||||
|
|
||||||
ContactSelectorAdapter(Context context,
|
ContactSelectorAdapter(Context context,
|
||||||
OnItemClickListener listener) {
|
OnItemClickListener listener) {
|
||||||
|
|
||||||
super(context, listener);
|
super(context, listener);
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
grayColorFilter = null;
|
|
||||||
} else {
|
|
||||||
// Overlay the background colour at 75% opacity
|
|
||||||
int bg = ContextCompat.getColor(context, R.color.window_background);
|
|
||||||
int alpha = (int) (255 * 0.75f);
|
|
||||||
int red = Color.red(bg);
|
|
||||||
int green = Color.green(bg);
|
|
||||||
int blue = Color.blue(bg);
|
|
||||||
bg = Color.argb(alpha, red, green, blue);
|
|
||||||
grayColorFilter = new PorterDuffColorFilter(bg,
|
|
||||||
PorterDuff.Mode.SRC_OVER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,14 +93,9 @@ class ContactSelectorAdapter
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void grayOutItem(SelectableContactHolder ui, boolean gray) {
|
private void grayOutItem(SelectableContactHolder ui, boolean gray) {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
float alpha = gray ? 0.25f : 1f;
|
||||||
float alpha = gray ? 0.25f : 1f;
|
ui.avatar.setAlpha(alpha);
|
||||||
ui.avatar.setAlpha(alpha);
|
ui.name.setAlpha(alpha);
|
||||||
ui.name.setAlpha(alpha);
|
ui.checkBox.setAlpha(alpha);
|
||||||
ui.checkBox.setAlpha(alpha);
|
|
||||||
} else {
|
|
||||||
if (gray) ui.avatar.setColorFilter(grayColorFilter);
|
|
||||||
else ui.avatar.clearColorFilter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package org.briarproject.android.util;
|
package org.briarproject.android.util;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Build;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.RecyclerView.Adapter;
|
import android.support.v7.widget.RecyclerView.Adapter;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -71,7 +69,7 @@ public class BriarRecyclerView extends FrameLayout {
|
|||||||
showProgressBar();
|
showProgressBar();
|
||||||
|
|
||||||
// scroll down when opening keyboard
|
// scroll down when opening keyboard
|
||||||
if (isScrollingToEnd && Build.VERSION.SDK_INT >= 11) {
|
if (isScrollingToEnd) {
|
||||||
addLayoutChangeListener();
|
addLayoutChangeListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +88,6 @@ public class BriarRecyclerView extends FrameLayout {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(11)
|
|
||||||
private void addLayoutChangeListener() {
|
private void addLayoutChangeListener() {
|
||||||
recyclerView.addOnLayoutChangeListener(
|
recyclerView.addOnLayoutChangeListener(
|
||||||
new OnLayoutChangeListener() {
|
new OnLayoutChangeListener() {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import static android.hardware.Camera.Parameters.FOCUS_MODE_EDOF;
|
|||||||
import static android.hardware.Camera.Parameters.FOCUS_MODE_FIXED;
|
import static android.hardware.Camera.Parameters.FOCUS_MODE_FIXED;
|
||||||
import static android.hardware.Camera.Parameters.FOCUS_MODE_MACRO;
|
import static android.hardware.Camera.Parameters.FOCUS_MODE_MACRO;
|
||||||
import static android.hardware.Camera.Parameters.SCENE_MODE_BARCODE;
|
import static android.hardware.Camera.Parameters.SCENE_MODE_BARCODE;
|
||||||
import static android.view.SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS;
|
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
@@ -59,8 +58,6 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
setKeepScreenOn(true);
|
setKeepScreenOn(true);
|
||||||
SurfaceHolder holder = getHolder();
|
SurfaceHolder holder = getHolder();
|
||||||
if (Build.VERSION.SDK_INT < 11)
|
|
||||||
holder.setType(SURFACE_TYPE_PUSH_BUFFERS);
|
|
||||||
holder.addCallback(this);
|
holder.addCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,8 +161,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
LOG.info("Setting scene mode to barcode");
|
LOG.info("Setting scene mode to barcode");
|
||||||
params.setSceneMode(SCENE_MODE_BARCODE);
|
params.setSceneMode(SCENE_MODE_BARCODE);
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 14 &&
|
if (focusModes.contains(FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
||||||
focusModes.contains(FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
|
||||||
LOG.info("Setting focus mode to continuous picture");
|
LOG.info("Setting focus mode to continuous picture");
|
||||||
params.setFocusMode(FOCUS_MODE_CONTINUOUS_PICTURE);
|
params.setFocusMode(FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||||
} else if (focusModes.contains(FOCUS_MODE_CONTINUOUS_VIDEO)) {
|
} else if (focusModes.contains(FOCUS_MODE_CONTINUOUS_VIDEO)) {
|
||||||
@@ -212,12 +208,6 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
+ ", stretch " + stretch + ", pixels " + pixels
|
+ ", stretch " + stretch + ", pixels " + pixels
|
||||||
+ ", score " + score);
|
+ ", score " + score);
|
||||||
}
|
}
|
||||||
// Large preview sizes can crash older devices
|
|
||||||
int maxDimension = Math.max(width, height);
|
|
||||||
if (Build.VERSION.SDK_INT < 14 && maxDimension > screenMax) {
|
|
||||||
LOG.info("Too large for screen");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (bestSize == null || score > bestScore) {
|
if (bestSize == null || score > bestScore) {
|
||||||
bestSize = size;
|
bestSize = size;
|
||||||
bestScore = score;
|
bestScore = score;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.briarproject.android.util;
|
|||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
@@ -12,25 +10,7 @@ import static android.view.View.VISIBLE;
|
|||||||
|
|
||||||
public class CustomAnimations {
|
public class CustomAnimations {
|
||||||
|
|
||||||
public static void animateHeight(ViewGroup viewGroup, boolean isExtending,
|
public static void animateHeight(final ViewGroup viewGroup,
|
||||||
int duration) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
animateHeightPostGingerbread(viewGroup, isExtending, duration);
|
|
||||||
} else {
|
|
||||||
animateHeightGingerbread(viewGroup, isExtending);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void animateHeightGingerbread(ViewGroup viewGroup,
|
|
||||||
boolean isExtending) {
|
|
||||||
// No animations for Gingerbread
|
|
||||||
if (isExtending) viewGroup.setVisibility(VISIBLE);
|
|
||||||
else viewGroup.setVisibility(GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
private static void animateHeightPostGingerbread(final ViewGroup viewGroup,
|
|
||||||
final boolean isExtending, int duration) {
|
final boolean isExtending, int duration) {
|
||||||
ValueAnimator anim;
|
ValueAnimator anim;
|
||||||
if (isExtending) {
|
if (isExtending) {
|
||||||
@@ -74,4 +54,5 @@ public class CustomAnimations {
|
|||||||
anim.setDuration(duration);
|
anim.setDuration(duration);
|
||||||
anim.start();
|
anim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,8 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
// Bind a server socket to accept connections from contacts
|
// Bind a server socket to accept connections from contacts
|
||||||
BluetoothServerSocket ss;
|
BluetoothServerSocket ss;
|
||||||
try {
|
try {
|
||||||
ss = InsecureBluetooth.listen(adapter, "RFCOMM", getUuid());
|
ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
|
||||||
|
"RFCOMM", getUuid());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, e.toString(), e);
|
LOG.log(WARNING, e.toString(), e);
|
||||||
@@ -321,7 +322,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
BluetoothDevice d = adapter.getRemoteDevice(address);
|
BluetoothDevice d = adapter.getRemoteDevice(address);
|
||||||
BluetoothSocket s = null;
|
BluetoothSocket s = null;
|
||||||
try {
|
try {
|
||||||
s = InsecureBluetooth.createSocket(d, u);
|
s = d.createInsecureRfcommSocketToServiceRecord(u);
|
||||||
if (LOG.isLoggable(INFO)) LOG.info("Connecting to " + address);
|
if (LOG.isLoggable(INFO)) LOG.info("Connecting to " + address);
|
||||||
s.connect();
|
s.connect();
|
||||||
if (LOG.isLoggable(INFO)) LOG.info("Connected to " + address);
|
if (LOG.isLoggable(INFO)) LOG.info("Connected to " + address);
|
||||||
@@ -372,7 +373,8 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
// Bind a server socket for receiving invitation connections
|
// Bind a server socket for receiving invitation connections
|
||||||
BluetoothServerSocket ss;
|
BluetoothServerSocket ss;
|
||||||
try {
|
try {
|
||||||
ss = InsecureBluetooth.listen(adapter, "RFCOMM", uuid);
|
ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
|
||||||
|
"RFCOMM", getUuid());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
return null;
|
return null;
|
||||||
@@ -453,7 +455,8 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
// Bind a server socket for receiving invitation connections
|
// Bind a server socket for receiving invitation connections
|
||||||
BluetoothServerSocket ss;
|
BluetoothServerSocket ss;
|
||||||
try {
|
try {
|
||||||
ss = InsecureBluetooth.listen(adapter, "RFCOMM", uuid);
|
ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
|
||||||
|
"RFCOMM", getUuid());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,171 +0,0 @@
|
|||||||
package org.briarproject.plugins.droidtooth;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
|
||||||
import android.bluetooth.BluetoothServerSocket;
|
|
||||||
import android.bluetooth.BluetoothSocket;
|
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.ParcelUuid;
|
|
||||||
|
|
||||||
// Based on http://stanford.edu/~tpurtell/InsecureBluetooth.java by T.J. Purtell
|
|
||||||
class InsecureBluetooth {
|
|
||||||
|
|
||||||
private static final Logger LOG =
|
|
||||||
Logger.getLogger(InsecureBluetooth.class.getName());
|
|
||||||
|
|
||||||
private static final int TYPE_RFCOMM = 1;
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
static BluetoothServerSocket listen(BluetoothAdapter adapter, String name,
|
|
||||||
UUID uuid) throws IOException {
|
|
||||||
if (Build.VERSION.SDK_INT >= 10) {
|
|
||||||
LOG.info("Listening with new API");
|
|
||||||
return adapter.listenUsingInsecureRfcommWithServiceRecord(name,
|
|
||||||
uuid);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
LOG.info("Listening via reflection");
|
|
||||||
// Find an available channel
|
|
||||||
String className = BluetoothAdapter.class.getCanonicalName()
|
|
||||||
+ ".RfcommChannelPicker";
|
|
||||||
Class<?> channelPickerClass = null;
|
|
||||||
Class<?>[] children = BluetoothAdapter.class.getDeclaredClasses();
|
|
||||||
for (Class<?> c : children) {
|
|
||||||
if (c.getCanonicalName().equals(className)) {
|
|
||||||
channelPickerClass = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (channelPickerClass == null)
|
|
||||||
throw new IOException("Can't find channel picker class");
|
|
||||||
Constructor<?> constructor =
|
|
||||||
channelPickerClass.getDeclaredConstructor(UUID.class);
|
|
||||||
constructor.setAccessible(true);
|
|
||||||
Object channelPicker = constructor.newInstance(uuid);
|
|
||||||
Method nextChannel =
|
|
||||||
channelPickerClass.getDeclaredMethod("nextChannel");
|
|
||||||
nextChannel.setAccessible(true);
|
|
||||||
int channel = (Integer) nextChannel.invoke(channelPicker);
|
|
||||||
if (channel == -1) throw new IOException("No available channels");
|
|
||||||
// Listen on the channel
|
|
||||||
BluetoothServerSocket socket = listen(channel);
|
|
||||||
// Add a service record
|
|
||||||
Field f = BluetoothAdapter.class.getDeclaredField("mService");
|
|
||||||
f.setAccessible(true);
|
|
||||||
Object mService = f.get(adapter);
|
|
||||||
Method addRfcommServiceRecord =
|
|
||||||
mService.getClass().getDeclaredMethod(
|
|
||||||
"addRfcommServiceRecord", String.class,
|
|
||||||
ParcelUuid.class, int.class, IBinder.class);
|
|
||||||
addRfcommServiceRecord.setAccessible(true);
|
|
||||||
int handle = (Integer) addRfcommServiceRecord.invoke(mService, name,
|
|
||||||
new ParcelUuid(uuid), channel, new Binder());
|
|
||||||
if (handle == -1) {
|
|
||||||
socket.close();
|
|
||||||
throw new IOException("Can't register SDP record for " + name);
|
|
||||||
}
|
|
||||||
Field f1 = BluetoothAdapter.class.getDeclaredField("mHandler");
|
|
||||||
f1.setAccessible(true);
|
|
||||||
Object mHandler = f1.get(adapter);
|
|
||||||
Method setCloseHandler = socket.getClass().getDeclaredMethod(
|
|
||||||
"setCloseHandler", Handler.class, int.class);
|
|
||||||
setCloseHandler.setAccessible(true);
|
|
||||||
setCloseHandler.invoke(socket, mHandler, handle);
|
|
||||||
return socket;
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
if (e.getCause() instanceof IOException) {
|
|
||||||
throw (IOException) e.getCause();
|
|
||||||
} else {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static BluetoothServerSocket listen(int port) throws IOException {
|
|
||||||
try {
|
|
||||||
Constructor<BluetoothServerSocket> constructor =
|
|
||||||
BluetoothServerSocket.class.getDeclaredConstructor(
|
|
||||||
int.class, boolean.class, boolean.class, int.class);
|
|
||||||
constructor.setAccessible(true);
|
|
||||||
BluetoothServerSocket socket = constructor.newInstance(TYPE_RFCOMM,
|
|
||||||
false, false, port);
|
|
||||||
Field f = BluetoothServerSocket.class.getDeclaredField("mSocket");
|
|
||||||
f.setAccessible(true);
|
|
||||||
Object mSocket = f.get(socket);
|
|
||||||
Method bindListen =
|
|
||||||
mSocket.getClass().getDeclaredMethod("bindListen");
|
|
||||||
bindListen.setAccessible(true);
|
|
||||||
int errno = (Integer) bindListen.invoke(mSocket);
|
|
||||||
if (errno != 0) {
|
|
||||||
socket.close();
|
|
||||||
throw new IOException("Can't bind: errno " + errno);
|
|
||||||
}
|
|
||||||
return socket;
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
if (e.getCause() instanceof IOException) {
|
|
||||||
throw (IOException) e.getCause();
|
|
||||||
} else {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
static BluetoothSocket createSocket(BluetoothDevice device, UUID uuid)
|
|
||||||
throws IOException {
|
|
||||||
if (Build.VERSION.SDK_INT >= 10) {
|
|
||||||
LOG.info("Creating socket with new API");
|
|
||||||
return device.createInsecureRfcommSocketToServiceRecord(uuid);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
LOG.info("Creating socket via reflection");
|
|
||||||
Constructor<BluetoothSocket> constructor =
|
|
||||||
BluetoothSocket.class.getDeclaredConstructor(int.class,
|
|
||||||
int.class, boolean.class, boolean.class,
|
|
||||||
BluetoothDevice.class, int.class, ParcelUuid.class);
|
|
||||||
constructor.setAccessible(true);
|
|
||||||
return constructor.newInstance(TYPE_RFCOMM, -1, false, true, device,
|
|
||||||
-1, new ParcelUuid(uuid));
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
if (e.getCause() instanceof IOException) {
|
|
||||||
throw (IOException) e.getCause();
|
|
||||||
} else {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user