Browse Source

Upgraded to Gradle build system, with full and lite as flavours (rather than usign a library core project). Lib (Torrent Connect) is now integrated directly. Closes #148.

pull/177/head
Eric Kok 10 years ago
parent
commit
bda024f418
  1. 32
      .gitignore
  2. 61
      app/build.gradle
  3. 0
      app/src/full/res/values/bools.xml
  4. 0
      app/src/full/res/values/strings.xml
  5. 0
      app/src/lite/res/values/bools.xml
  6. 0
      app/src/lite/res/values/strings.xml
  7. 10
      app/src/main/AndroidManifest.xml
  8. 0
      app/src/main/java/com/android/internalcopy/http/multipart/BitCometFilePart.java
  9. 0
      app/src/main/java/com/android/internalcopy/http/multipart/ByteArrayPartSource.java
  10. 0
      app/src/main/java/com/android/internalcopy/http/multipart/FilePart.java
  11. 0
      app/src/main/java/com/android/internalcopy/http/multipart/FilePartSource.java
  12. 0
      app/src/main/java/com/android/internalcopy/http/multipart/MultipartEntity.java
  13. 0
      app/src/main/java/com/android/internalcopy/http/multipart/Part.java
  14. 0
      app/src/main/java/com/android/internalcopy/http/multipart/PartBase.java
  15. 0
      app/src/main/java/com/android/internalcopy/http/multipart/PartSource.java
  16. 0
      app/src/main/java/com/android/internalcopy/http/multipart/StringPart.java
  17. 0
      app/src/main/java/com/android/internalcopy/http/multipart/Utf8StringPart.java
  18. 0
      app/src/main/java/de/timroes/axmlrpc/Call.java
  19. 0
      app/src/main/java/de/timroes/axmlrpc/ResponseParser.java
  20. 0
      app/src/main/java/de/timroes/axmlrpc/XMLRPCCallback.java
  21. 0
      app/src/main/java/de/timroes/axmlrpc/XMLRPCClient.java
  22. 0
      app/src/main/java/de/timroes/axmlrpc/XMLRPCException.java
  23. 0
      app/src/main/java/de/timroes/axmlrpc/XMLRPCRuntimeException.java
  24. 0
      app/src/main/java/de/timroes/axmlrpc/XMLRPCServerException.java
  25. 0
      app/src/main/java/de/timroes/axmlrpc/XMLRPCTimeoutException.java
  26. 0
      app/src/main/java/de/timroes/axmlrpc/XMLUtil.java
  27. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/ArraySerializer.java
  28. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/Base64Serializer.java
  29. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/BooleanSerializer.java
  30. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/DateTimeSerializer.java
  31. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/DoubleSerializer.java
  32. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/IntSerializer.java
  33. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/LongSerializer.java
  34. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/NullSerializer.java
  35. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/Serializer.java
  36. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/SerializerHandler.java
  37. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/StringSerializer.java
  38. 0
      app/src/main/java/de/timroes/axmlrpc/serializer/StructSerializer.java
  39. 0
      app/src/main/java/de/timroes/axmlrpc/xmlcreator/SimpleXMLCreator.java
  40. 0
      app/src/main/java/de/timroes/axmlrpc/xmlcreator/XmlElement.java
  41. 0
      app/src/main/java/de/timroes/base64/Base64.java
  42. 8
      app/src/main/java/net/margaritov/preference/colorpicker/AlphaPatternDrawable.java
  43. 38
      app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerDialog.java
  44. 55
      app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerPanelView.java
  45. 251
      app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerPreference.java
  46. 442
      app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerView.java
  47. 0
      app/src/main/java/org/apache/openjpa/lib/util/Base16Encoder.java
  48. 0
      app/src/main/java/org/base64/android/Base64.java
  49. 0
      app/src/main/java/org/transdroid/core/app/search/GoogleWebSearchBarcodeResolver.java
  50. 0
      app/src/main/java/org/transdroid/core/app/search/SearchHelper.java
  51. 0
      app/src/main/java/org/transdroid/core/app/search/SearchResult.java
  52. 0
      app/src/main/java/org/transdroid/core/app/search/SearchSite.java
  53. 0
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  54. 2
      app/src/main/java/org/transdroid/core/app/settings/NotificationSettings.java
  55. 0
      app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java
  56. 0
      app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java
  57. 0
      app/src/main/java/org/transdroid/core/app/settings/SettingsPersistence.java
  58. 0
      app/src/main/java/org/transdroid/core/app/settings/SystemSettings.java
  59. 0
      app/src/main/java/org/transdroid/core/app/settings/WebsearchSetting.java
  60. 2
      app/src/main/java/org/transdroid/core/gui/DetailsActivity.java
  61. 2
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  62. 0
      app/src/main/java/org/transdroid/core/gui/FilterEntryDialog.java
  63. 2
      app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java
  64. 2
      app/src/main/java/org/transdroid/core/gui/ServerStatusView.java
  65. 0
      app/src/main/java/org/transdroid/core/gui/TorrentTasksExecutor.java
  66. 2
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  67. 2
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java
  68. 2
      app/src/main/java/org/transdroid/core/gui/lists/DetailsAdapter.java
  69. 2
      app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java
  70. 0
      app/src/main/java/org/transdroid/core/gui/lists/MergeAdapter.java
  71. 2
      app/src/main/java/org/transdroid/core/gui/lists/NoProgressHeaderTransformer.java
  72. 0
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItem.java
  73. 0
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemAdapter.java
  74. 0
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemSpinnerAdapter.java
  75. 0
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemView.java
  76. 2
      app/src/main/java/org/transdroid/core/gui/lists/SortByListItem.java
  77. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentDetailsView.java
  78. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java
  79. 0
      app/src/main/java/org/transdroid/core/gui/lists/TorrentFileView.java
  80. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentProgressBar.java
  81. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentStatusLayout.java
  82. 0
      app/src/main/java/org/transdroid/core/gui/lists/TorrentView.java
  83. 0
      app/src/main/java/org/transdroid/core/gui/lists/TorrentsAdapter.java
  84. 0
      app/src/main/java/org/transdroid/core/gui/lists/ViewHolderAdapter.java
  85. 0
      app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java
  86. 0
      app/src/main/java/org/transdroid/core/gui/log/ErrorLogEntry.java
  87. 2
      app/src/main/java/org/transdroid/core/gui/log/ErrorLogSender.java
  88. 0
      app/src/main/java/org/transdroid/core/gui/log/Log.java
  89. 0
      app/src/main/java/org/transdroid/core/gui/navigation/DialogHelper.java
  90. 2
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java
  91. 0
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListDropDownAdapter.java
  92. 0
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemAdapter.java
  93. 0
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemView.java
  94. 0
      app/src/main/java/org/transdroid/core/gui/navigation/FilterSeparatorView.java
  95. 0
      app/src/main/java/org/transdroid/core/gui/navigation/Label.java
  96. 0
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationFilter.java
  97. 69
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java
  98. 0
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationSelectionView.java
  99. 0
      app/src/main/java/org/transdroid/core/gui/navigation/RefreshableActivity.java
  100. 0
      app/src/main/java/org/transdroid/core/gui/navigation/SelectionManagerMode.java
  101. Some files were not shown because too many files have changed in this diff Show More

32
.gitignore vendored

@ -1,26 +1,16 @@
# built application files # ignore Gradle files
*.apk .gradle/
*.ap_ build/
# files for the dex VM # local configuration file (sdk path, etc)
*.dex
# Java class files
*.class
# generated files
bin/
gen/
.apt_generated/
# Local configuration file (sdk path, etc)
local.properties local.properties
signing.gradle
# Eclipse project files # IntelliJ
.classpath *.iml
.project *.ipr
.settings/ *.iws
.local.properties .idea
# OS temp files # Mac
.DS_Store .DS_Store

61
app/build.gradle

@ -0,0 +1,61 @@
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply from: '../signing.gradle'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 216
versionName '2.3.0'
resValue "string", "search_history_authority", applicationId + ".search.SearchHistoryProvider"
}
signingConfigs {
release {
storeFile STORE_FILE
storePassword STORE_PASSWORD
keyAlias KEY_ALIAS
keyPassword KEY_PASSWORD
}
}
buildTypes {
release {
runProguard false
signingConfig signingConfigs.release
}
}
productFlavors {
full {
applicationId 'org.transdroid.full'
}
lite {
applicationId 'org.transdroid.lite'
}
}
lintOptions {
disable 'MissingTranslation', 'ExtraTranslation'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.androidannotations:androidannotations-api:3.1'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.8'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.+'
apt "org.androidannotations:androidannotations:3.1"
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'org.transdroid'
//logLevel 'INFO'
//logFile '/Users/erickok/Dev/transdroid/transdroid/app/build/aa-log.txt'
}
}

0
full/res/values/bools.xml → app/src/full/res/values/bools.xml

0
full/res/values/strings.xml → app/src/full/res/values/strings.xml

0
lite/res/values/bools.xml → app/src/lite/res/values/bools.xml

0
lite/res/values/strings.xml → app/src/lite/res/values/strings.xml

10
full/AndroidManifest.xml → app/src/main/AndroidManifest.xml

@ -17,13 +17,9 @@
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="org.transdroid.full" package="org.transdroid" >
android:versionCode="216"
android:versionName="2.3.0" >
<uses-sdk <uses-sdk />
android:minSdkVersion="15"
android:targetSdkVersion="19" />
<supports-screens <supports-screens
android:anyDensity="true" android:anyDensity="true"
@ -229,7 +225,7 @@
<provider <provider
android:name="org.transdroid.core.gui.search.SearchHistoryProvider" android:name="org.transdroid.core.gui.search.SearchHistoryProvider"
android:authorities="org.transdroid.core.gui.search.SearchHistoryProvider" android:authorities="@string/search_history_authority"
android:exported="false" /> android:exported="false" />
<!-- RSS --> <!-- RSS -->

0
lib/src/com/android/internalcopy/http/multipart/BitCometFilePart.java → app/src/main/java/com/android/internalcopy/http/multipart/BitCometFilePart.java

0
lib/src/com/android/internalcopy/http/multipart/ByteArrayPartSource.java → app/src/main/java/com/android/internalcopy/http/multipart/ByteArrayPartSource.java

0
lib/src/com/android/internalcopy/http/multipart/FilePart.java → app/src/main/java/com/android/internalcopy/http/multipart/FilePart.java

0
lib/src/com/android/internalcopy/http/multipart/FilePartSource.java → app/src/main/java/com/android/internalcopy/http/multipart/FilePartSource.java

0
lib/src/com/android/internalcopy/http/multipart/MultipartEntity.java → app/src/main/java/com/android/internalcopy/http/multipart/MultipartEntity.java

0
lib/src/com/android/internalcopy/http/multipart/Part.java → app/src/main/java/com/android/internalcopy/http/multipart/Part.java

0
lib/src/com/android/internalcopy/http/multipart/PartBase.java → app/src/main/java/com/android/internalcopy/http/multipart/PartBase.java

0
lib/src/com/android/internalcopy/http/multipart/PartSource.java → app/src/main/java/com/android/internalcopy/http/multipart/PartSource.java

0
lib/src/com/android/internalcopy/http/multipart/StringPart.java → app/src/main/java/com/android/internalcopy/http/multipart/StringPart.java

0
lib/src/com/android/internalcopy/http/multipart/Utf8StringPart.java → app/src/main/java/com/android/internalcopy/http/multipart/Utf8StringPart.java

0
lib/src/de/timroes/axmlrpc/Call.java → app/src/main/java/de/timroes/axmlrpc/Call.java

0
lib/src/de/timroes/axmlrpc/ResponseParser.java → app/src/main/java/de/timroes/axmlrpc/ResponseParser.java

0
lib/src/de/timroes/axmlrpc/XMLRPCCallback.java → app/src/main/java/de/timroes/axmlrpc/XMLRPCCallback.java

0
lib/src/de/timroes/axmlrpc/XMLRPCClient.java → app/src/main/java/de/timroes/axmlrpc/XMLRPCClient.java

0
lib/src/de/timroes/axmlrpc/XMLRPCException.java → app/src/main/java/de/timroes/axmlrpc/XMLRPCException.java

0
lib/src/de/timroes/axmlrpc/XMLRPCRuntimeException.java → app/src/main/java/de/timroes/axmlrpc/XMLRPCRuntimeException.java

0
lib/src/de/timroes/axmlrpc/XMLRPCServerException.java → app/src/main/java/de/timroes/axmlrpc/XMLRPCServerException.java

0
lib/src/de/timroes/axmlrpc/XMLRPCTimeoutException.java → app/src/main/java/de/timroes/axmlrpc/XMLRPCTimeoutException.java

0
lib/src/de/timroes/axmlrpc/XMLUtil.java → app/src/main/java/de/timroes/axmlrpc/XMLUtil.java

0
lib/src/de/timroes/axmlrpc/serializer/ArraySerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/ArraySerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/Base64Serializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/Base64Serializer.java

0
lib/src/de/timroes/axmlrpc/serializer/BooleanSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/BooleanSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/DateTimeSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/DateTimeSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/DoubleSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/DoubleSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/IntSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/IntSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/LongSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/LongSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/NullSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/NullSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/Serializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/Serializer.java

0
lib/src/de/timroes/axmlrpc/serializer/SerializerHandler.java → app/src/main/java/de/timroes/axmlrpc/serializer/SerializerHandler.java

0
lib/src/de/timroes/axmlrpc/serializer/StringSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/StringSerializer.java

0
lib/src/de/timroes/axmlrpc/serializer/StructSerializer.java → app/src/main/java/de/timroes/axmlrpc/serializer/StructSerializer.java

0
lib/src/de/timroes/axmlrpc/xmlcreator/SimpleXMLCreator.java → app/src/main/java/de/timroes/axmlrpc/xmlcreator/SimpleXMLCreator.java

0
lib/src/de/timroes/axmlrpc/xmlcreator/XmlElement.java → app/src/main/java/de/timroes/axmlrpc/xmlcreator/XmlElement.java

0
lib/src/de/timroes/base64/Base64.java → app/src/main/java/de/timroes/base64/Base64.java

8
external/ColorPickerPreference/src/net/margaritov/preference/colorpicker/AlphaPatternDrawable.java → app/src/main/java/net/margaritov/preference/colorpicker/AlphaPatternDrawable.java

@ -44,7 +44,7 @@ public class AlphaPatternDrawable extends Drawable {
/** /**
* Bitmap in which the pattern will be cahched. * Bitmap in which the pattern will be cahched.
*/ */
private Bitmap mBitmap; private Bitmap mBitmap;
public AlphaPatternDrawable(int rectangleSize) { public AlphaPatternDrawable(int rectangleSize) {
mRectangleSize = rectangleSize; mRectangleSize = rectangleSize;
@ -93,12 +93,12 @@ public class AlphaPatternDrawable extends Drawable {
* recreate it each time draw() is called since it * recreate it each time draw() is called since it
* takes a few milliseconds. * takes a few milliseconds.
*/ */
private void generatePatternBitmap(){ private void generatePatternBitmap() {
if(getBounds().width() <= 0 || getBounds().height() <= 0){ if (getBounds().width() <= 0 || getBounds().height() <= 0) {
return; return;
} }
mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888); mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
Canvas canvas = new Canvas(mBitmap); Canvas canvas = new Canvas(mBitmap);

38
external/ColorPickerPreference/src/net/margaritov/preference/colorpicker/ColorPickerDialog.java → app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerDialog.java

@ -24,12 +24,9 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
public class ColorPickerDialog import org.transdroid.R;
extends
Dialog public class ColorPickerDialog extends Dialog implements ColorPickerView.OnColorChangedListener, View.OnClickListener {
implements
ColorPickerView.OnColorChangedListener,
View.OnClickListener {
private ColorPickerView mColorPicker; private ColorPickerView mColorPicker;
@ -41,7 +38,7 @@ public class ColorPickerDialog
public interface OnColorChangedListener { public interface OnColorChangedListener {
public void onColorChanged(int color); public void onColorChanged(int color);
} }
public ColorPickerDialog(Context context, int initialColor) { public ColorPickerDialog(Context context, int initialColor) {
super(context); super(context);
@ -57,26 +54,23 @@ public class ColorPickerDialog
} }
private void setUp(int color) { private void setUp(int color) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.dialog_color_picker, null); View layout = inflater.inflate(R.layout.dialog_color_picker, null);
setContentView(layout); setContentView(layout);
setTitle(R.string.dialog_color_picker); setTitle(R.string.dialog_color_picker);
mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view); mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel); mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel);
mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel); mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel);
((LinearLayout) mOldColor.getParent()).setPadding( ((LinearLayout) mOldColor.getParent())
Math.round(mColorPicker.getDrawingOffset()), .setPadding(Math.round(mColorPicker.getDrawingOffset()), 0, Math.round(mColorPicker.getDrawingOffset()),
0, 0);
Math.round(mColorPicker.getDrawingOffset()),
0
);
mOldColor.setOnClickListener(this); mOldColor.setOnClickListener(this);
mNewColor.setOnClickListener(this); mNewColor.setOnClickListener(this);
mColorPicker.setOnColorChangedListener(this); mColorPicker.setOnColorChangedListener(this);
@ -101,13 +95,13 @@ public class ColorPickerDialog
public void setAlphaSliderVisible(boolean visible) { public void setAlphaSliderVisible(boolean visible) {
mColorPicker.setAlphaSliderVisible(visible); mColorPicker.setAlphaSliderVisible(visible);
} }
/** /**
* Set a OnColorChangedListener to get notified when the color * Set a OnColorChangedListener to get notified when the color
* selected by the user has changed. * selected by the user has changed.
* @param listener * @param listener
*/ */
public void setOnColorChangedListener(OnColorChangedListener listener){ public void setOnColorChangedListener(OnColorChangedListener listener) {
mListener = listener; mListener = listener;
} }
@ -124,7 +118,7 @@ public class ColorPickerDialog
} }
dismiss(); dismiss();
} }
@Override @Override
public Bundle onSaveInstanceState() { public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState(); Bundle state = super.onSaveInstanceState();
@ -132,7 +126,7 @@ public class ColorPickerDialog
state.putInt("new_color", mNewColor.getColor()); state.putInt("new_color", mNewColor.getColor());
return state; return state;
} }
@Override @Override
public void onRestoreInstanceState(Bundle savedInstanceState) { public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState); super.onRestoreInstanceState(savedInstanceState);

55
external/ColorPickerPreference/src/net/margaritov/preference/colorpicker/ColorPickerPanelView.java → app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerPanelView.java

@ -28,7 +28,6 @@ import android.view.View;
* It can be used to show the currently selected color which you will get from * It can be used to show the currently selected color which you will get from
* the {@link ColorPickerView}. * the {@link ColorPickerView}.
* @author Daniel Nilsson * @author Daniel Nilsson
*
*/ */
public class ColorPickerPanelView extends View { public class ColorPickerPanelView extends View {
@ -36,27 +35,27 @@ public class ColorPickerPanelView extends View {
* The width in pixels of the border * The width in pixels of the border
* surrounding the color panel. * surrounding the color panel.
*/ */
private final static float BORDER_WIDTH_PX = 1; private final static float BORDER_WIDTH_PX = 1;
private float mDensity = 1f; private float mDensity = 1f;
private int mBorderColor = 0xff6E6E6E; private int mBorderColor = 0xff6E6E6E;
private int mColor = 0xff000000; private int mColor = 0xff000000;
private Paint mBorderPaint; private Paint mBorderPaint;
private Paint mColorPaint; private Paint mColorPaint;
private RectF mDrawingRect; private RectF mDrawingRect;
private RectF mColorRect; private RectF mColorRect;
private AlphaPatternDrawable mAlphaPattern; private AlphaPatternDrawable mAlphaPattern;
public ColorPickerPanelView(Context context){ public ColorPickerPanelView(Context context) {
this(context, null); this(context, null);
} }
public ColorPickerPanelView(Context context, AttributeSet attrs){ public ColorPickerPanelView(Context context, AttributeSet attrs) {
this(context, attrs, 0); this(context, attrs, 0);
} }
@ -65,7 +64,7 @@ public class ColorPickerPanelView extends View {
init(); init();
} }
private void init(){ private void init() {
mBorderPaint = new Paint(); mBorderPaint = new Paint();
mColorPaint = new Paint(); mColorPaint = new Paint();
mDensity = getContext().getResources().getDisplayMetrics().density; mDensity = getContext().getResources().getDisplayMetrics().density;
@ -75,14 +74,14 @@ public class ColorPickerPanelView extends View {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
final RectF rect = mColorRect; final RectF rect = mColorRect;
if(BORDER_WIDTH_PX > 0){ if (BORDER_WIDTH_PX > 0) {
mBorderPaint.setColor(mBorderColor); mBorderPaint.setColor(mBorderColor);
canvas.drawRect(mDrawingRect, mBorderPaint); canvas.drawRect(mDrawingRect, mBorderPaint);
} }
if(mAlphaPattern != null){ if (mAlphaPattern != null) {
mAlphaPattern.draw(canvas); mAlphaPattern.draw(canvas);
} }
@ -105,8 +104,8 @@ public class ColorPickerPanelView extends View {
super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh);
mDrawingRect = new RectF(); mDrawingRect = new RectF();
mDrawingRect.left = getPaddingLeft(); mDrawingRect.left = getPaddingLeft();
mDrawingRect.right = w - getPaddingRight(); mDrawingRect.right = w - getPaddingRight();
mDrawingRect.top = getPaddingTop(); mDrawingRect.top = getPaddingTop();
mDrawingRect.bottom = h - getPaddingBottom(); mDrawingRect.bottom = h - getPaddingBottom();
@ -114,24 +113,20 @@ public class ColorPickerPanelView extends View {
} }
private void setUpColorRect(){ private void setUpColorRect() {
final RectF dRect = mDrawingRect; final RectF dRect = mDrawingRect;
float left = dRect.left + BORDER_WIDTH_PX; float left = dRect.left + BORDER_WIDTH_PX;
float top = dRect.top + BORDER_WIDTH_PX; float top = dRect.top + BORDER_WIDTH_PX;
float bottom = dRect.bottom - BORDER_WIDTH_PX; float bottom = dRect.bottom - BORDER_WIDTH_PX;
float right = dRect.right - BORDER_WIDTH_PX; float right = dRect.right - BORDER_WIDTH_PX;
mColorRect = new RectF(left,top, right, bottom); mColorRect = new RectF(left, top, right, bottom);
mAlphaPattern = new AlphaPatternDrawable((int)(5 * mDensity)); mAlphaPattern = new AlphaPatternDrawable((int) (5 * mDensity));
mAlphaPattern.setBounds( mAlphaPattern.setBounds(Math.round(mColorRect.left), Math.round(mColorRect.top), Math.round(mColorRect.right),
Math.round(mColorRect.left), Math.round(mColorRect.bottom));
Math.round(mColorRect.top),
Math.round(mColorRect.right),
Math.round(mColorRect.bottom)
);
} }
@ -139,7 +134,7 @@ public class ColorPickerPanelView extends View {
* Set the color that should be shown by this view. * Set the color that should be shown by this view.
* @param color * @param color
*/ */
public void setColor(int color){ public void setColor(int color) {
mColor = color; mColor = color;
invalidate(); invalidate();
} }
@ -148,7 +143,7 @@ public class ColorPickerPanelView extends View {
* Get the color currently show by this view. * Get the color currently show by this view.
* @return * @return
*/ */
public int getColor(){ public int getColor() {
return mColor; return mColor;
} }
@ -156,7 +151,7 @@ public class ColorPickerPanelView extends View {
* Set the color of the border surrounding the panel. * Set the color of the border surrounding the panel.
* @param color * @param color
*/ */
public void setBorderColor(int color){ public void setBorderColor(int color) {
mBorderColor = color; mBorderColor = color;
invalidate(); invalidate();
} }
@ -164,7 +159,7 @@ public class ColorPickerPanelView extends View {
/** /**
* Get the color of the border surrounding the panel. * Get the color of the border surrounding the panel.
*/ */
public int getBorderColor(){ public int getBorderColor() {
return mBorderColor; return mBorderColor;
} }

251
external/ColorPickerPreference/src/net/margaritov/preference/colorpicker/ColorPickerPreference.java → app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerPreference.java

@ -34,12 +34,8 @@ import android.widget.LinearLayout;
* A preference type that allows a user to choose a time * A preference type that allows a user to choose a time
* @author Sergey Margaritov * @author Sergey Margaritov
*/ */
public class ColorPickerPreference public class ColorPickerPreference extends Preference
extends implements Preference.OnPreferenceClickListener, ColorPickerDialog.OnColorChangedListener {
Preference
implements
Preference.OnPreferenceClickListener,
ColorPickerDialog.OnColorChangedListener {
View mView; View mView;
ColorPickerDialog mDialog; ColorPickerDialog mDialog;
@ -88,17 +84,18 @@ public class ColorPickerPreference
} }
private void setPreviewColor() { private void setPreviewColor() {
if (mView == null) return; if (mView == null) {
return;
}
ImageView iView = new ImageView(getContext()); ImageView iView = new ImageView(getContext());
LinearLayout widgetFrameView = ((LinearLayout)mView.findViewById(android.R.id.widget_frame)); LinearLayout widgetFrameView = ((LinearLayout) mView.findViewById(android.R.id.widget_frame));
if (widgetFrameView == null) return; if (widgetFrameView == null) {
return;
}
widgetFrameView.setVisibility(View.VISIBLE); widgetFrameView.setVisibility(View.VISIBLE);
widgetFrameView.setPadding( widgetFrameView
widgetFrameView.getPaddingLeft(), .setPadding(widgetFrameView.getPaddingLeft(), widgetFrameView.getPaddingTop(), (int) (mDensity * 8),
widgetFrameView.getPaddingTop(), widgetFrameView.getPaddingBottom());
(int)(mDensity * 8),
widgetFrameView.getPaddingBottom()
);
// remove already create preview image // remove already create preview image
int count = widgetFrameView.getChildCount(); int count = widgetFrameView.getChildCount();
if (count > 0) { if (count > 0) {
@ -106,7 +103,7 @@ public class ColorPickerPreference
} }
widgetFrameView.addView(iView); widgetFrameView.addView(iView);
widgetFrameView.setMinimumWidth(0); widgetFrameView.setMinimumWidth(0);
iView.setBackgroundDrawable(new AlphaPatternDrawable((int)(5 * mDensity))); iView.setBackgroundDrawable(new AlphaPatternDrawable((int) (5 * mDensity)));
iView.setImageBitmap(getPreviewBitmap()); iView.setImageBitmap(getPreviewBitmap());
} }
@ -119,7 +116,7 @@ public class ColorPickerPreference
int c = color; int c = color;
for (int i = 0; i < w; i++) { for (int i = 0; i < w; i++) {
for (int j = i; j < h; j++) { for (int j = i; j < h; j++) {
c = (i <= 1 || j <= 1 || i >= w-2 || j >= h-2) ? Color.GRAY : color; c = (i <= 1 || j <= 1 || i >= w - 2 || j >= h - 2) ? Color.GRAY : color;
bm.setPixel(i, j, c); bm.setPixel(i, j, c);
if (i != j) { if (i != j) {
bm.setPixel(j, i, c); bm.setPixel(j, i, c);
@ -148,7 +145,7 @@ public class ColorPickerPreference
showDialog(null); showDialog(null);
return false; return false;
} }
protected void showDialog(Bundle state) { protected void showDialog(Bundle state) {
mDialog = new ColorPickerDialog(getContext(), mValue); mDialog = new ColorPickerDialog(getContext(), mValue);
mDialog.setOnColorChangedListener(this); mDialog.setOnColorChangedListener(this);
@ -174,114 +171,112 @@ public class ColorPickerPreference
* @param color * @param color
* @author Unknown * @author Unknown
*/ */
public static String convertToARGB(int color) { public static String convertToARGB(int color) {
String alpha = Integer.toHexString(Color.alpha(color)); String alpha = Integer.toHexString(Color.alpha(color));
String red = Integer.toHexString(Color.red(color)); String red = Integer.toHexString(Color.red(color));
String green = Integer.toHexString(Color.green(color)); String green = Integer.toHexString(Color.green(color));
String blue = Integer.toHexString(Color.blue(color)); String blue = Integer.toHexString(Color.blue(color));
if (alpha.length() == 1) { if (alpha.length() == 1) {
alpha = "0" + alpha; alpha = "0" + alpha;
} }
if (red.length() == 1) { if (red.length() == 1) {
red = "0" + red; red = "0" + red;
} }
if (green.length() == 1) { if (green.length() == 1) {
green = "0" + green; green = "0" + green;
} }
if (blue.length() == 1) { if (blue.length() == 1) {
blue = "0" + blue; blue = "0" + blue;
} }
return "#" + alpha + red + green + blue; return "#" + alpha + red + green + blue;
} }
/** /**
* For custom purposes. Not used by ColorPickerPreferrence * For custom purposes. Not used by ColorPickerPreferrence
* @param argb * @param argb
* @throws NumberFormatException * @throws NumberFormatException
* @author Unknown * @author Unknown
*/ */
public static int convertToColorInt(String argb) throws NumberFormatException { public static int convertToColorInt(String argb) throws NumberFormatException {
if (argb.startsWith("#")) { if (argb.startsWith("#")) {
argb = argb.replace("#", ""); argb = argb.replace("#", "");
} }
int alpha = -1, red = -1, green = -1, blue = -1; int alpha = -1, red = -1, green = -1, blue = -1;
if (argb.length() == 8) { if (argb.length() == 8) {
alpha = Integer.parseInt(argb.substring(0, 2), 16); alpha = Integer.parseInt(argb.substring(0, 2), 16);
red = Integer.parseInt(argb.substring(2, 4), 16); red = Integer.parseInt(argb.substring(2, 4), 16);
green = Integer.parseInt(argb.substring(4, 6), 16); green = Integer.parseInt(argb.substring(4, 6), 16);
blue = Integer.parseInt(argb.substring(6, 8), 16); blue = Integer.parseInt(argb.substring(6, 8), 16);
} } else if (argb.length() == 6) {
else if (argb.length() == 6) { alpha = 255;
alpha = 255; red = Integer.parseInt(argb.substring(0, 2), 16);
red = Integer.parseInt(argb.substring(0, 2), 16); green = Integer.parseInt(argb.substring(2, 4), 16);
green = Integer.parseInt(argb.substring(2, 4), 16); blue = Integer.parseInt(argb.substring(4, 6), 16);
blue = Integer.parseInt(argb.substring(4, 6), 16); }
}
return Color.argb(alpha, red, green, blue);
return Color.argb(alpha, red, green, blue); }
}
@Override
@Override protected Parcelable onSaveInstanceState() {
protected Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState();
final Parcelable superState = super.onSaveInstanceState(); if (mDialog == null || !mDialog.isShowing()) {
if (mDialog == null || !mDialog.isShowing()) { return superState;
return superState; }
}
final SavedState myState = new SavedState(superState);
final SavedState myState = new SavedState(superState); myState.dialogBundle = mDialog.onSaveInstanceState();
myState.dialogBundle = mDialog.onSaveInstanceState(); return myState;
return myState; }
}
@Override
@Override protected void onRestoreInstanceState(Parcelable state) {
protected void onRestoreInstanceState(Parcelable state) { if (state == null || !(state instanceof SavedState)) {
if (state == null || !(state instanceof SavedState)) { // Didn't save state for us in onSaveInstanceState
// Didn't save state for us in onSaveInstanceState super.onRestoreInstanceState(state);
super.onRestoreInstanceState(state); return;
return; }
}
SavedState myState = (SavedState) state;
SavedState myState = (SavedState) state; super.onRestoreInstanceState(myState.getSuperState());
super.onRestoreInstanceState(myState.getSuperState()); showDialog(myState.dialogBundle);
showDialog(myState.dialogBundle); }
}
private static class SavedState extends BaseSavedState {
private static class SavedState extends BaseSavedState { Bundle dialogBundle;
Bundle dialogBundle;
public SavedState(Parcel source) {
public SavedState(Parcel source) { super(source);
super(source); dialogBundle = source.readBundle();
dialogBundle = source.readBundle(); }
}
@Override
@Override public void writeToParcel(Parcel dest, int flags) {
public void writeToParcel(Parcel dest, int flags) { super.writeToParcel(dest, flags);
super.writeToParcel(dest, flags); dest.writeBundle(dialogBundle);
dest.writeBundle(dialogBundle); }
}
public SavedState(Parcelable superState) {
public SavedState(Parcelable superState) { super(superState);
super(superState); }
}
@SuppressWarnings("unused")
@SuppressWarnings("unused") public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
public static final Parcelable.Creator<SavedState> CREATOR = public SavedState createFromParcel(Parcel in) {
new Parcelable.Creator<SavedState>() { return new SavedState(in);
public SavedState createFromParcel(Parcel in) { }
return new SavedState(in);
} public SavedState[] newArray(int size) {
return new SavedState[size];
public SavedState[] newArray(int size) { }
return new SavedState[size]; };
} }
};
}
} }

442
external/ColorPickerPreference/src/net/margaritov/preference/colorpicker/ColorPickerView.java → app/src/main/java/net/margaritov/preference/colorpicker/ColorPickerView.java

@ -22,12 +22,12 @@ import android.graphics.Color;
import android.graphics.ComposeShader; import android.graphics.ComposeShader;
import android.graphics.LinearGradient; import android.graphics.LinearGradient;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.Shader; import android.graphics.Shader;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Shader.TileMode; import android.graphics.Shader.TileMode;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -42,103 +42,103 @@ import android.view.View;
*/ */
public class ColorPickerView extends View { public class ColorPickerView extends View {
private final static int PANEL_SAT_VAL = 0; private final static int PANEL_SAT_VAL = 0;
private final static int PANEL_HUE = 1; private final static int PANEL_HUE = 1;
private final static int PANEL_ALPHA = 2; private final static int PANEL_ALPHA = 2;
/** /**
* The width in pixels of the border * The width in pixels of the border
* surrounding all color panels. * surrounding all color panels.
*/ */
private final static float BORDER_WIDTH_PX = 1; private final static float BORDER_WIDTH_PX = 1;
/** /**
* The width in dp of the hue panel. * The width in dp of the hue panel.
*/ */
private float HUE_PANEL_WIDTH = 30f; private float HUE_PANEL_WIDTH = 30f;
/** /**
* The height in dp of the alpha panel * The height in dp of the alpha panel
*/ */
private float ALPHA_PANEL_HEIGHT = 20f; private float ALPHA_PANEL_HEIGHT = 20f;
/** /**
* The distance in dp between the different * The distance in dp between the different
* color panels. * color panels.
*/ */
private float PANEL_SPACING = 10f; private float PANEL_SPACING = 10f;
/** /**
* The radius in dp of the color palette tracker circle. * The radius in dp of the color palette tracker circle.
*/ */
private float PALETTE_CIRCLE_TRACKER_RADIUS = 5f; private float PALETTE_CIRCLE_TRACKER_RADIUS = 5f;
/** /**
* The dp which the tracker of the hue or alpha panel * The dp which the tracker of the hue or alpha panel
* will extend outside of its bounds. * will extend outside of its bounds.
*/ */
private float RECTANGLE_TRACKER_OFFSET = 2f; private float RECTANGLE_TRACKER_OFFSET = 2f;
private float mDensity = 1f; private float mDensity = 1f;
private OnColorChangedListener mListener; private OnColorChangedListener mListener;
private Paint mSatValPaint; private Paint mSatValPaint;
private Paint mSatValTrackerPaint; private Paint mSatValTrackerPaint;
private Paint mHuePaint; private Paint mHuePaint;
private Paint mHueTrackerPaint; private Paint mHueTrackerPaint;
private Paint mAlphaPaint; private Paint mAlphaPaint;
private Paint mAlphaTextPaint; private Paint mAlphaTextPaint;
private Paint mBorderPaint; private Paint mBorderPaint;
private Shader mValShader; private Shader mValShader;
private Shader mSatShader; private Shader mSatShader;
private Shader mHueShader; private Shader mHueShader;
private Shader mAlphaShader; private Shader mAlphaShader;
private int mAlpha = 0xff; private int mAlpha = 0xff;
private float mHue = 360f; private float mHue = 360f;
private float mSat = 0f; private float mSat = 0f;
private float mVal = 0f; private float mVal = 0f;
private String mAlphaSliderText = ""; private String mAlphaSliderText = "";
private int mSliderTrackerColor = 0xff1c1c1c; private int mSliderTrackerColor = 0xff1c1c1c;
private int mBorderColor = 0xff6E6E6E; private int mBorderColor = 0xff6E6E6E;
private boolean mShowAlphaPanel = false; private boolean mShowAlphaPanel = false;
/* /*
* To remember which panel that has the "focus" when * To remember which panel that has the "focus" when
* processing hardware button data. * processing hardware button data.
*/ */
private int mLastTouchedPanel = PANEL_SAT_VAL; private int mLastTouchedPanel = PANEL_SAT_VAL;
/** /**
* Offset from the edge we must have or else * Offset from the edge we must have or else
* the finger tracker will get clipped when * the finger tracker will get clipped when
* it is drawn outside of the view. * it is drawn outside of the view.
*/ */
private float mDrawingOffset; private float mDrawingOffset;
/* /*
* Distance form the edges of the view * Distance form the edges of the view
* of where we are allowed to draw. * of where we are allowed to draw.
*/ */
private RectF mDrawingRect; private RectF mDrawingRect;
private RectF mSatValRect; private RectF mSatValRect;
private RectF mHueRect; private RectF mHueRect;
private RectF mAlphaRect; private RectF mAlphaRect;
private AlphaPatternDrawable mAlphaPattern; private AlphaPatternDrawable mAlphaPattern;
private Point mStartTouchPoint = null; private Point mStartTouchPoint = null;
public interface OnColorChangedListener { public interface OnColorChangedListener {
public void onColorChanged(int color); public void onColorChanged(int color);
} }
public ColorPickerView(Context context){ public ColorPickerView(Context context) {
this(context, null); this(context, null);
} }
@ -151,7 +151,7 @@ public class ColorPickerView extends View {
init(); init();
} }
private void init(){ private void init() {
mDensity = getContext().getResources().getDisplayMetrics().density; mDensity = getContext().getResources().getDisplayMetrics().density;
PALETTE_CIRCLE_TRACKER_RADIUS *= mDensity; PALETTE_CIRCLE_TRACKER_RADIUS *= mDensity;
RECTANGLE_TRACKER_OFFSET *= mDensity; RECTANGLE_TRACKER_OFFSET *= mDensity;
@ -168,7 +168,7 @@ public class ColorPickerView extends View {
setFocusableInTouchMode(true); setFocusableInTouchMode(true);
} }
private void initPaintTools(){ private void initPaintTools() {
mSatValPaint = new Paint(); mSatValPaint = new Paint();
mSatValTrackerPaint = new Paint(); mSatValTrackerPaint = new Paint();
@ -197,19 +197,19 @@ public class ColorPickerView extends View {
} }
private float calculateRequiredOffset(){ private float calculateRequiredOffset() {
float offset = Math.max(PALETTE_CIRCLE_TRACKER_RADIUS, RECTANGLE_TRACKER_OFFSET); float offset = Math.max(PALETTE_CIRCLE_TRACKER_RADIUS, RECTANGLE_TRACKER_OFFSET);
offset = Math.max(offset, BORDER_WIDTH_PX * mDensity); offset = Math.max(offset, BORDER_WIDTH_PX * mDensity);
return offset * 1.5f; return offset * 1.5f;
} }
private int[] buildHueColorArray(){ private int[] buildHueColorArray() {
int[] hue = new int[361]; int[] hue = new int[361];
int count = 0; int count = 0;
for(int i = hue.length -1; i >= 0; i--, count++){ for (int i = hue.length - 1; i >= 0; i--, count++) {
hue[count] = Color.HSVToColor(new float[]{i, 1f, 1f}); hue[count] = Color.HSVToColor(new float[]{i, 1f, 1f});
} }
@ -220,7 +220,9 @@ public class ColorPickerView extends View {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
if(mDrawingRect.width() <= 0 || mDrawingRect.height() <= 0) return; if (mDrawingRect.width() <= 0 || mDrawingRect.height() <= 0) {
return;
}
drawSatValPanel(canvas); drawSatValPanel(canvas);
drawHuePanel(canvas); drawHuePanel(canvas);
@ -228,24 +230,24 @@ public class ColorPickerView extends View {
} }
private void drawSatValPanel(Canvas canvas){ private void drawSatValPanel(Canvas canvas) {
final RectF rect = mSatValRect; final RectF rect = mSatValRect;
if(BORDER_WIDTH_PX > 0){ if (BORDER_WIDTH_PX > 0) {
mBorderPaint.setColor(mBorderColor); mBorderPaint.setColor(mBorderColor);
canvas.drawRect(mDrawingRect.left, mDrawingRect.top, rect.right + BORDER_WIDTH_PX, rect.bottom + BORDER_WIDTH_PX, mBorderPaint); canvas.drawRect(mDrawingRect.left, mDrawingRect.top, rect.right + BORDER_WIDTH_PX,
rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
} }
if (mValShader == null) { if (mValShader == null) {
mValShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, mValShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, 0xffffffff, 0xff000000,
0xffffffff, 0xff000000, TileMode.CLAMP); TileMode.CLAMP);
} }
int rgb = Color.HSVToColor(new float[]{mHue,1f,1f}); int rgb = Color.HSVToColor(new float[]{mHue, 1f, 1f});
mSatShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top, mSatShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top, 0xffffffff, rgb, TileMode.CLAMP);
0xffffffff, rgb, TileMode.CLAMP);
ComposeShader mShader = new ComposeShader(mValShader, mSatShader, PorterDuff.Mode.MULTIPLY); ComposeShader mShader = new ComposeShader(mValShader, mSatShader, PorterDuff.Mode.MULTIPLY);
mSatValPaint.setShader(mShader); mSatValPaint.setShader(mShader);
@ -261,21 +263,19 @@ public class ColorPickerView extends View {
} }
private void drawHuePanel(Canvas canvas){ private void drawHuePanel(Canvas canvas) {
final RectF rect = mHueRect; final RectF rect = mHueRect;
if(BORDER_WIDTH_PX > 0){ if (BORDER_WIDTH_PX > 0) {
mBorderPaint.setColor(mBorderColor); mBorderPaint.setColor(mBorderColor);
canvas.drawRect(rect.left - BORDER_WIDTH_PX, canvas.drawRect(rect.left - BORDER_WIDTH_PX, rect.top - BORDER_WIDTH_PX, rect.right + BORDER_WIDTH_PX,
rect.top - BORDER_WIDTH_PX, rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
rect.right + BORDER_WIDTH_PX,
rect.bottom + BORDER_WIDTH_PX,
mBorderPaint);
} }
if (mHueShader == null) { if (mHueShader == null) {
mHueShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, buildHueColorArray(), null, TileMode.CLAMP); mHueShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, buildHueColorArray(), null,
TileMode.CLAMP);
mHuePaint.setShader(mHueShader); mHuePaint.setShader(mHueShader);
} }
@ -296,37 +296,35 @@ public class ColorPickerView extends View {
} }
private void drawAlphaPanel(Canvas canvas){ private void drawAlphaPanel(Canvas canvas) {
if(!mShowAlphaPanel || mAlphaRect == null || mAlphaPattern == null) return; if (!mShowAlphaPanel || mAlphaRect == null || mAlphaPattern == null) {
return;
}
final RectF rect = mAlphaRect; final RectF rect = mAlphaRect;
if(BORDER_WIDTH_PX > 0){ if (BORDER_WIDTH_PX > 0) {
mBorderPaint.setColor(mBorderColor); mBorderPaint.setColor(mBorderColor);
canvas.drawRect(rect.left - BORDER_WIDTH_PX, canvas.drawRect(rect.left - BORDER_WIDTH_PX, rect.top - BORDER_WIDTH_PX, rect.right + BORDER_WIDTH_PX,
rect.top - BORDER_WIDTH_PX, rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
rect.right + BORDER_WIDTH_PX,
rect.bottom + BORDER_WIDTH_PX,
mBorderPaint);
} }
mAlphaPattern.draw(canvas); mAlphaPattern.draw(canvas);
float[] hsv = new float[]{mHue,mSat,mVal}; float[] hsv = new float[]{mHue, mSat, mVal};
int color = Color.HSVToColor(hsv); int color = Color.HSVToColor(hsv);
int acolor = Color.HSVToColor(0, hsv); int acolor = Color.HSVToColor(0, hsv);
mAlphaShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top, mAlphaShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top, color, acolor, TileMode.CLAMP);
color, acolor, TileMode.CLAMP);
mAlphaPaint.setShader(mAlphaShader); mAlphaPaint.setShader(mAlphaShader);
canvas.drawRect(rect, mAlphaPaint); canvas.drawRect(rect, mAlphaPaint);
if(mAlphaSliderText != null && mAlphaSliderText!= ""){ if (mAlphaSliderText != null && mAlphaSliderText != "") {
canvas.drawText(mAlphaSliderText, rect.centerX(), rect.centerY() + 4 * mDensity, mAlphaTextPaint); canvas.drawText(mAlphaSliderText, rect.centerX(), rect.centerY() + 4 * mDensity, mAlphaTextPaint);
} }
@ -345,7 +343,7 @@ public class ColorPickerView extends View {
} }
private Point hueToPoint(float hue){ private Point hueToPoint(float hue) {
final RectF rect = mHueRect; final RectF rect = mHueRect;
final float height = rect.height(); final float height = rect.height();
@ -358,7 +356,7 @@ public class ColorPickerView extends View {
return p; return p;
} }
private Point satValToPoint(float sat, float val){ private Point satValToPoint(float sat, float val) {
final RectF rect = mSatValRect; final RectF rect = mSatValRect;
final float height = rect.height(); final float height = rect.height();
@ -372,7 +370,7 @@ public class ColorPickerView extends View {
return p; return p;
} }
private Point alphaToPoint(int alpha){ private Point alphaToPoint(int alpha) {
final RectF rect = mAlphaRect; final RectF rect = mAlphaRect;
final float width = rect.width(); final float width = rect.width();
@ -386,7 +384,7 @@ public class ColorPickerView extends View {
} }
private float[] pointToSatVal(float x, float y){ private float[] pointToSatVal(float x, float y) {
final RectF rect = mSatValRect; final RectF rect = mSatValRect;
float[] result = new float[2]; float[] result = new float[2];
@ -394,23 +392,19 @@ public class ColorPickerView extends View {
float width = rect.width(); float width = rect.width();
float height = rect.height(); float height = rect.height();
if (x < rect.left){ if (x < rect.left) {
x = 0f; x = 0f;
} } else if (x > rect.right) {
else if(x > rect.right){
x = width; x = width;
} } else {
else{
x = x - rect.left; x = x - rect.left;
} }
if (y < rect.top){ if (y < rect.top) {
y = 0f; y = 0f;
} } else if (y > rect.bottom) {
else if(y > rect.bottom){
y = height; y = height;
} } else {
else{
y = y - rect.top; y = y - rect.top;
} }
@ -421,38 +415,34 @@ public class ColorPickerView extends View {
return result; return result;
} }
private float pointToHue(float y){ private float pointToHue(float y) {
final RectF rect = mHueRect; final RectF rect = mHueRect;
float height = rect.height(); float height = rect.height();
if (y < rect.top){ if (y < rect.top) {
y = 0f; y = 0f;
} } else if (y > rect.bottom) {
else if(y > rect.bottom){
y = height; y = height;
} } else {
else{
y = y - rect.top; y = y - rect.top;
} }
return 360f - (y * 360f / height); return 360f - (y * 360f / height);
} }
private int pointToAlpha(int x){ private int pointToAlpha(int x) {
final RectF rect = mAlphaRect; final RectF rect = mAlphaRect;
final int width = (int) rect.width(); final int width = (int) rect.width();
if(x < rect.left){ if (x < rect.left) {
x = 0; x = 0;
} } else if (x > rect.right) {
else if(x > rect.right){
x = width; x = width;
} } else {
else{ x = x - (int) rect.left;
x = x - (int)rect.left;
} }
return 0xff - (x * 0xff / width); return 0xff - (x * 0xff / width);
@ -469,87 +459,82 @@ public class ColorPickerView extends View {
boolean update = false; boolean update = false;
if(event.getAction() == MotionEvent.ACTION_MOVE){ if (event.getAction() == MotionEvent.ACTION_MOVE) {
switch(mLastTouchedPanel){ switch (mLastTouchedPanel) {
case PANEL_SAT_VAL: case PANEL_SAT_VAL:
float sat, val; float sat, val;
sat = mSat + x/50f; sat = mSat + x / 50f;
val = mVal - y/50f; val = mVal - y / 50f;
if(sat < 0f){ if (sat < 0f) {
sat = 0f; sat = 0f;
} } else if (sat > 1f) {
else if(sat > 1f){ sat = 1f;
sat = 1f; }
}
if(val < 0f){ if (val < 0f) {
val = 0f; val = 0f;
} } else if (val > 1f) {
else if(val > 1f){ val = 1f;
val = 1f; }
}
mSat = sat; mSat = sat;
mVal = val; mVal = val;
update = true; update = true;
break; break;
case PANEL_HUE: case PANEL_HUE:
float hue = mHue - y * 10f; float hue = mHue - y * 10f;
if(hue < 0f){ if (hue < 0f) {
hue = 0f; hue = 0f;
} } else if (hue > 360f) {
else if(hue > 360f){ hue = 360f;
hue = 360f; }
}
mHue = hue; mHue = hue;
update = true; update = true;
break; break;
case PANEL_ALPHA: case PANEL_ALPHA:
if(!mShowAlphaPanel || mAlphaRect == null){ if (!mShowAlphaPanel || mAlphaRect == null) {
update = false; update = false;
} } else {
else{
int alpha = (int) (mAlpha - x*10); int alpha = (int) (mAlpha - x * 10);
if(alpha < 0){ if (alpha < 0) {
alpha = 0; alpha = 0;
} } else if (alpha > 0xff) {
else if(alpha > 0xff){ alpha = 0xff;
alpha = 0xff; }
}
mAlpha = alpha; mAlpha = alpha;
update = true; update = true;
} }
break; break;
} }
} }
if(update){ if (update) {
if(mListener != null){ if (mListener != null) {
mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal})); mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));
} }
@ -566,35 +551,35 @@ public class ColorPickerView extends View {
boolean update = false; boolean update = false;
switch(event.getAction()){ switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
mStartTouchPoint = new Point((int)event.getX(), (int)event.getY()); mStartTouchPoint = new Point((int) event.getX(), (int) event.getY());
update = moveTrackersIfNeeded(event); update = moveTrackersIfNeeded(event);
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
update = moveTrackersIfNeeded(event); update = moveTrackersIfNeeded(event);
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
mStartTouchPoint = null; mStartTouchPoint = null;
update = moveTrackersIfNeeded(event); update = moveTrackersIfNeeded(event);
break; break;
} }
if(update){ if (update) {
if(mListener != null){ if (mListener != null) {
mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal})); mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));
} }
@ -606,9 +591,11 @@ public class ColorPickerView extends View {
return super.onTouchEvent(event); return super.onTouchEvent(event);
} }
private boolean moveTrackersIfNeeded(MotionEvent event){ private boolean moveTrackersIfNeeded(MotionEvent event) {
if(mStartTouchPoint == null) return false; if (mStartTouchPoint == null) {
return false;
}
boolean update = false; boolean update = false;
@ -616,14 +603,13 @@ public class ColorPickerView extends View {
int startY = mStartTouchPoint.y; int startY = mStartTouchPoint.y;
if(mHueRect.contains(startX, startY)){ if (mHueRect.contains(startX, startY)) {
mLastTouchedPanel = PANEL_HUE; mLastTouchedPanel = PANEL_HUE;
mHue = pointToHue(event.getY()); mHue = pointToHue(event.getY());
update = true; update = true;
} } else if (mSatValRect.contains(startX, startY)) {
else if(mSatValRect.contains(startX, startY)){
mLastTouchedPanel = PANEL_SAT_VAL; mLastTouchedPanel = PANEL_SAT_VAL;
@ -633,12 +619,11 @@ public class ColorPickerView extends View {
mVal = result[1]; mVal = result[1];
update = true; update = true;
} } else if (mAlphaRect != null && mAlphaRect.contains(startX, startY)) {
else if(mAlphaRect != null && mAlphaRect.contains(startX, startY)){
mLastTouchedPanel = PANEL_ALPHA; mLastTouchedPanel = PANEL_ALPHA;
mAlpha = pointToAlpha((int)event.getX()); mAlpha = pointToAlpha((int) event.getX());
update = true; update = true;
} }
@ -652,47 +637,44 @@ public class ColorPickerView extends View {
int width = 0; int width = 0;
int height = 0; int height = 0;
int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int widthAllowed = MeasureSpec.getSize(widthMeasureSpec); int widthAllowed = MeasureSpec.getSize(widthMeasureSpec);
int heightAllowed = MeasureSpec.getSize(heightMeasureSpec); int heightAllowed = MeasureSpec.getSize(heightMeasureSpec);
widthAllowed = chooseWidth(widthMode, widthAllowed); widthAllowed = chooseWidth(widthMode, widthAllowed);
heightAllowed = chooseHeight(heightMode, heightAllowed); heightAllowed = chooseHeight(heightMode, heightAllowed);
if(!mShowAlphaPanel){ if (!mShowAlphaPanel) {
height = (int) (widthAllowed - PANEL_SPACING - HUE_PANEL_WIDTH); height = (int) (widthAllowed - PANEL_SPACING - HUE_PANEL_WIDTH);
//If calculated height (based on the width) is more than the allowed height. //If calculated height (based on the width) is more than the allowed height.
if(height > heightAllowed || getTag().equals("landscape")) { if (height > heightAllowed || getTag().equals("landscape")) {
height = heightAllowed; height = heightAllowed;
width = (int) (height + PANEL_SPACING + HUE_PANEL_WIDTH); width = (int) (height + PANEL_SPACING + HUE_PANEL_WIDTH);
} } else {
else{
width = widthAllowed; width = widthAllowed;
} }
} } else {
else{
width = (int) (heightAllowed - ALPHA_PANEL_HEIGHT + HUE_PANEL_WIDTH); width = (int) (heightAllowed - ALPHA_PANEL_HEIGHT + HUE_PANEL_WIDTH);
if(width > widthAllowed){ if (width > widthAllowed) {
width = widthAllowed; width = widthAllowed;
height = (int) (widthAllowed - HUE_PANEL_WIDTH + ALPHA_PANEL_HEIGHT); height = (int) (widthAllowed - HUE_PANEL_WIDTH + ALPHA_PANEL_HEIGHT);
} } else {
else{
height = heightAllowed; height = heightAllowed;
} }
} }
setMeasuredDimension(width, height); setMeasuredDimension(width, height);
} }
private int chooseWidth(int mode, int size){ private int chooseWidth(int mode, int size) {
if (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) { if (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) {
return size; return size;
} else { // (mode == MeasureSpec.UNSPECIFIED) } else { // (mode == MeasureSpec.UNSPECIFIED)
@ -700,7 +682,7 @@ public class ColorPickerView extends View {
} }
} }
private int chooseHeight(int mode, int size){ private int chooseHeight(int mode, int size) {
if (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) { if (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) {
return size; return size;
} else { // (mode == MeasureSpec.UNSPECIFIED) } else { // (mode == MeasureSpec.UNSPECIFIED)
@ -708,11 +690,11 @@ public class ColorPickerView extends View {
} }
} }
private int getPrefferedWidth(){ private int getPrefferedWidth() {
int width = getPrefferedHeight(); int width = getPrefferedHeight();
if(mShowAlphaPanel){ if (mShowAlphaPanel) {
width -= (PANEL_SPACING + ALPHA_PANEL_HEIGHT); width -= (PANEL_SPACING + ALPHA_PANEL_HEIGHT);
} }
@ -721,11 +703,11 @@ public class ColorPickerView extends View {
} }
private int getPrefferedHeight(){ private int getPrefferedHeight() {
int height = (int)(200 * mDensity); int height = (int) (200 * mDensity);
if(mShowAlphaPanel){ if (mShowAlphaPanel) {
height += PANEL_SPACING + ALPHA_PANEL_HEIGHT; height += PANEL_SPACING + ALPHA_PANEL_HEIGHT;
} }
@ -733,14 +715,13 @@ public class ColorPickerView extends View {
} }
@Override @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) { protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh);
mDrawingRect = new RectF(); mDrawingRect = new RectF();
mDrawingRect.left = mDrawingOffset + getPaddingLeft(); mDrawingRect.left = mDrawingOffset + getPaddingLeft();
mDrawingRect.right = w - mDrawingOffset - getPaddingRight(); mDrawingRect.right = w - mDrawingOffset - getPaddingRight();
mDrawingRect.top = mDrawingOffset + getPaddingTop(); mDrawingRect.top = mDrawingOffset + getPaddingTop();
mDrawingRect.bottom = h - mDrawingOffset - getPaddingBottom(); mDrawingRect.bottom = h - mDrawingOffset - getPaddingBottom();
@ -749,12 +730,12 @@ public class ColorPickerView extends View {
setUpAlphaRect(); setUpAlphaRect();
} }
private void setUpSatValRect(){ private void setUpSatValRect() {
final RectF dRect = mDrawingRect; final RectF dRect = mDrawingRect;
float panelSide = dRect.height() - BORDER_WIDTH_PX * 2; float panelSide = dRect.height() - BORDER_WIDTH_PX * 2;
if(mShowAlphaPanel){ if (mShowAlphaPanel) {
panelSide -= PANEL_SPACING + ALPHA_PANEL_HEIGHT; panelSide -= PANEL_SPACING + ALPHA_PANEL_HEIGHT;
} }
@ -763,11 +744,11 @@ public class ColorPickerView extends View {
float bottom = top + panelSide; float bottom = top + panelSide;
float right = left + panelSide; float right = left + panelSide;
mSatValRect = new RectF(left,top, right, bottom); mSatValRect = new RectF(left, top, right, bottom);
} }
private void setUpHueRect(){ private void setUpHueRect() {
final RectF dRect = mDrawingRect; final RectF dRect = mDrawingRect;
float left = dRect.right - HUE_PANEL_WIDTH + BORDER_WIDTH_PX; float left = dRect.right - HUE_PANEL_WIDTH + BORDER_WIDTH_PX;
float top = dRect.top + BORDER_WIDTH_PX; float top = dRect.top + BORDER_WIDTH_PX;
@ -779,9 +760,11 @@ public class ColorPickerView extends View {
private void setUpAlphaRect() { private void setUpAlphaRect() {
if(!mShowAlphaPanel) return; if (!mShowAlphaPanel) {
return;
}
final RectF dRect = mDrawingRect; final RectF dRect = mDrawingRect;
float left = dRect.left + BORDER_WIDTH_PX; float left = dRect.left + BORDER_WIDTH_PX;
float top = dRect.bottom - ALPHA_PANEL_HEIGHT + BORDER_WIDTH_PX; float top = dRect.bottom - ALPHA_PANEL_HEIGHT + BORDER_WIDTH_PX;
@ -791,12 +774,8 @@ public class ColorPickerView extends View {
mAlphaRect = new RectF(left, top, right, bottom); mAlphaRect = new RectF(left, top, right, bottom);
mAlphaPattern = new AlphaPatternDrawable((int) (5 * mDensity)); mAlphaPattern = new AlphaPatternDrawable((int) (5 * mDensity));
mAlphaPattern.setBounds( mAlphaPattern.setBounds(Math.round(mAlphaRect.left), Math.round(mAlphaRect.top), Math.round(mAlphaRect.right),
Math.round(mAlphaRect.left), Math.round(mAlphaRect.bottom));
Math.round(mAlphaRect.top),
Math.round(mAlphaRect.right),
Math.round(mAlphaRect.bottom)
);
} }
@ -806,7 +785,7 @@ public class ColorPickerView extends View {
* selected by the user has changed. * selected by the user has changed.
* @param listener * @param listener
*/ */
public void setOnColorChangedListener(OnColorChangedListener listener){ public void setOnColorChangedListener(OnColorChangedListener listener) {
mListener = listener; mListener = listener;
} }
@ -814,7 +793,7 @@ public class ColorPickerView extends View {
* Set the color of the border surrounding all panels. * Set the color of the border surrounding all panels.
* @param color * @param color
*/ */
public void setBorderColor(int color){ public void setBorderColor(int color) {
mBorderColor = color; mBorderColor = color;
invalidate(); invalidate();
} }
@ -822,7 +801,7 @@ public class ColorPickerView extends View {
/** /**
* Get the color of the border surrounding all panels. * Get the color of the border surrounding all panels.
*/ */
public int getBorderColor(){ public int getBorderColor() {
return mBorderColor; return mBorderColor;
} }
@ -830,15 +809,15 @@ public class ColorPickerView extends View {
* Get the current color this view is showing. * Get the current color this view is showing.
* @return the current color. * @return the current color.
*/ */
public int getColor(){ public int getColor() {
return Color.HSVToColor(mAlpha, new float[]{mHue,mSat,mVal}); return Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal});
} }
/** /**
* Set the color the view should show. * Set the color the view should show.
* @param color The color that should be selected. * @param color The color that should be selected.
*/ */
public void setColor(int color){ public void setColor(int color) {
setColor(color, false); setColor(color, false);
} }
@ -848,7 +827,7 @@ public class ColorPickerView extends View {
* @param callback If you want to get a callback to * @param callback If you want to get a callback to
* your OnColorChangedListener. * your OnColorChangedListener.
*/ */
public void setColor(int color, boolean callback){ public void setColor(int color, boolean callback) {
int alpha = Color.alpha(color); int alpha = Color.alpha(color);
int red = Color.red(color); int red = Color.red(color);
@ -864,7 +843,7 @@ public class ColorPickerView extends View {
mSat = hsv[1]; mSat = hsv[1];
mVal = hsv[2]; mVal = hsv[2];
if(callback && mListener != null){ if (callback && mListener != null) {
mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal})); mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));
} }
@ -879,7 +858,7 @@ public class ColorPickerView extends View {
* the currently selected color and want to align it perfectly. * the currently selected color and want to align it perfectly.
* @return The offset in pixels. * @return The offset in pixels.
*/ */
public float getDrawingOffset(){ public float getDrawingOffset() {
return mDrawingOffset; return mDrawingOffset;
} }
@ -888,9 +867,9 @@ public class ColorPickerView extends View {
* If it is set to false no alpha will be set. * If it is set to false no alpha will be set.
* @param visible * @param visible
*/ */
public void setAlphaSliderVisible(boolean visible){ public void setAlphaSliderVisible(boolean visible) {
if(mShowAlphaPanel != visible){ if (mShowAlphaPanel != visible) {
mShowAlphaPanel = visible; mShowAlphaPanel = visible;
/* /*
@ -901,14 +880,15 @@ public class ColorPickerView extends View {
mValShader = null; mValShader = null;
mSatShader = null; mSatShader = null;
mHueShader = null; mHueShader = null;
mAlphaShader = null;; mAlphaShader = null;
;
requestLayout(); requestLayout();
} }
} }
public void setSliderTrackerColor(int color){ public void setSliderTrackerColor(int color) {
mSliderTrackerColor = color; mSliderTrackerColor = color;
mHueTrackerPaint.setColor(mSliderTrackerColor); mHueTrackerPaint.setColor(mSliderTrackerColor);
@ -916,7 +896,7 @@ public class ColorPickerView extends View {
invalidate(); invalidate();
} }
public int getSliderTrackerColor(){ public int getSliderTrackerColor() {
return mSliderTrackerColor; return mSliderTrackerColor;
} }
@ -925,7 +905,7 @@ public class ColorPickerView extends View {
* alpha slider. Set to null to disable text. * alpha slider. Set to null to disable text.
* @param res string resource id. * @param res string resource id.
*/ */
public void setAlphaSliderText(int res){ public void setAlphaSliderText(int res) {
String text = getContext().getString(res); String text = getContext().getString(res);
setAlphaSliderText(text); setAlphaSliderText(text);
} }
@ -935,7 +915,7 @@ public class ColorPickerView extends View {
* alpha slider. Set to null to disable text. * alpha slider. Set to null to disable text.
* @param text Text that should be shown. * @param text Text that should be shown.
*/ */
public void setAlphaSliderText(String text){ public void setAlphaSliderText(String text) {
mAlphaSliderText = text; mAlphaSliderText = text;
invalidate(); invalidate();
} }
@ -946,7 +926,7 @@ public class ColorPickerView extends View {
* slider. * slider.
* @return * @return
*/ */
public String getAlphaSliderText(){ public String getAlphaSliderText() {
return mAlphaSliderText; return mAlphaSliderText;
} }
} }

0
lib/src/org/apache/openjpa/lib/util/Base16Encoder.java → app/src/main/java/org/apache/openjpa/lib/util/Base16Encoder.java

0
lib/src/org/base64/android/Base64.java → app/src/main/java/org/base64/android/Base64.java

0
core/src/org/transdroid/core/app/search/GoogleWebSearchBarcodeResolver.java → app/src/main/java/org/transdroid/core/app/search/GoogleWebSearchBarcodeResolver.java

0
core/src/org/transdroid/core/app/search/SearchHelper.java → app/src/main/java/org/transdroid/core/app/search/SearchHelper.java

0
core/src/org/transdroid/core/app/search/SearchResult.java → app/src/main/java/org/transdroid/core/app/search/SearchResult.java

0
core/src/org/transdroid/core/app/search/SearchSite.java → app/src/main/java/org/transdroid/core/app/search/SearchSite.java

0
core/src/org/transdroid/core/app/settings/ApplicationSettings.java → app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

2
core/src/org/transdroid/core/app/settings/NotificationSettings.java → app/src/main/java/org/transdroid/core/app/settings/NotificationSettings.java

@ -19,7 +19,7 @@ package org.transdroid.core.app.settings;
import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.EBean.Scope; import org.androidannotations.annotations.EBean.Scope;
import org.androidannotations.annotations.RootContext; import org.androidannotations.annotations.RootContext;
import org.transdroid.core.R; import org.transdroid.R;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;

0
core/src/org/transdroid/core/app/settings/RssfeedSetting.java → app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java

0
core/src/org/transdroid/core/app/settings/ServerSetting.java → app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java

0
core/src/org/transdroid/core/app/settings/SettingsPersistence.java → app/src/main/java/org/transdroid/core/app/settings/SettingsPersistence.java

0
core/src/org/transdroid/core/app/settings/SystemSettings.java → app/src/main/java/org/transdroid/core/app/settings/SystemSettings.java

0
core/src/org/transdroid/core/app/settings/WebsearchSetting.java → app/src/main/java/org/transdroid/core/app/settings/WebsearchSetting.java

2
core/src/org/transdroid/core/gui/DetailsActivity.java → app/src/main/java/org/transdroid/core/gui/DetailsActivity.java

@ -29,7 +29,7 @@ import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.UiThread; import org.androidannotations.annotations.UiThread;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.lists.LocalTorrent; import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer; import org.transdroid.core.gui.lists.NoProgressHeaderTransformer;

2
core/src/org/transdroid/core/gui/DetailsFragment.java → app/src/main/java/org/transdroid/core/gui/DetailsFragment.java

@ -28,7 +28,7 @@ import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings_; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.lists.DetailsAdapter; import org.transdroid.core.gui.lists.DetailsAdapter;

0
core/src/org/transdroid/core/gui/FilterEntryDialog.java → app/src/main/java/org/transdroid/core/gui/FilterEntryDialog.java

2
core/src/org/transdroid/core/gui/ServerPickerDialog.java → app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java

@ -2,7 +2,7 @@ package org.transdroid.core.gui;
import java.util.List; import java.util.List;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import android.app.AlertDialog; import android.app.AlertDialog;

2
core/src/org/transdroid/core/gui/ServerStatusView.java → app/src/main/java/org/transdroid/core/gui/ServerStatusView.java

@ -20,7 +20,7 @@ import java.util.List;
import org.androidannotations.annotations.EViewGroup; import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.SetTransferRatesDialog; import org.transdroid.core.gui.navigation.SetTransferRatesDialog;
import org.transdroid.core.gui.navigation.SetTransferRatesDialog.OnRatesPickedListener; import org.transdroid.core.gui.navigation.SetTransferRatesDialog.OnRatesPickedListener;

0
core/src/org/transdroid/core/gui/TorrentTasksExecutor.java → app/src/main/java/org/transdroid/core/gui/TorrentTasksExecutor.java

2
core/src/org/transdroid/core/gui/TorrentsActivity.java → app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

@ -43,7 +43,7 @@ import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.impl.cookie.BasicClientCookie;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.search.*; import org.transdroid.core.app.search.*;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.lists.LocalTorrent; import org.transdroid.core.gui.lists.LocalTorrent;

2
core/src/org/transdroid/core/gui/TorrentsFragment.java → app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java

@ -28,7 +28,7 @@ import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.InstanceState; import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick; import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ApplicationSettings; import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.SystemSettings; import org.transdroid.core.app.settings.SystemSettings;
import org.transdroid.core.gui.lists.TorrentsAdapter; import org.transdroid.core.gui.lists.TorrentsAdapter;

2
core/src/org/transdroid/core/gui/lists/DetailsAdapter.java → app/src/main/java/org/transdroid/core/gui/lists/DetailsAdapter.java

@ -19,7 +19,7 @@ package org.transdroid.core.gui.lists;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.gui.navigation.FilterSeparatorView_; import org.transdroid.core.gui.navigation.FilterSeparatorView_;
import org.transdroid.daemon.Torrent; import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentFile; import org.transdroid.daemon.TorrentFile;

2
core/src/org/transdroid/core/gui/lists/LocalTorrent.java → app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java

@ -18,7 +18,7 @@ package org.transdroid.core.gui.lists;
import java.util.Locale; import java.util.Locale;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.daemon.DaemonException; import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.Torrent; import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentStatus; import org.transdroid.daemon.TorrentStatus;

0
core/src/org/transdroid/core/gui/lists/MergeAdapter.java → app/src/main/java/org/transdroid/core/gui/lists/MergeAdapter.java

2
core/src/org/transdroid/core/gui/lists/NoProgressHeaderTransformer.java → app/src/main/java/org/transdroid/core/gui/lists/NoProgressHeaderTransformer.java

@ -1,6 +1,6 @@
package org.transdroid.core.gui.lists; package org.transdroid.core.gui.lists;
import org.transdroid.core.R; import org.transdroid.R;
import uk.co.senab.actionbarpulltorefresh.library.DefaultHeaderTransformer; import uk.co.senab.actionbarpulltorefresh.library.DefaultHeaderTransformer;
import android.app.Activity; import android.app.Activity;

0
core/src/org/transdroid/core/gui/lists/SimpleListItem.java → app/src/main/java/org/transdroid/core/gui/lists/SimpleListItem.java

0
core/src/org/transdroid/core/gui/lists/SimpleListItemAdapter.java → app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemAdapter.java

0
core/src/org/transdroid/core/gui/lists/SimpleListItemSpinnerAdapter.java → app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemSpinnerAdapter.java

0
core/src/org/transdroid/core/gui/lists/SimpleListItemView.java → app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemView.java

2
core/src/org/transdroid/core/gui/lists/SortByListItem.java → app/src/main/java/org/transdroid/core/gui/lists/SortByListItem.java

@ -16,7 +16,7 @@
*/ */
package org.transdroid.core.gui.lists; package org.transdroid.core.gui.lists;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.daemon.TorrentsSortBy; import org.transdroid.daemon.TorrentsSortBy;
import android.content.Context; import android.content.Context;

2
core/src/org/transdroid/core/gui/lists/TorrentDetailsView.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentDetailsView.java

@ -18,7 +18,7 @@ package org.transdroid.core.gui.lists;
import org.androidannotations.annotations.EViewGroup; import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.Torrent; import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.util.FileSizeConverter; import org.transdroid.daemon.util.FileSizeConverter;

2
core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java

@ -16,7 +16,7 @@
*/ */
package org.transdroid.core.gui.lists; package org.transdroid.core.gui.lists;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.daemon.Priority; import org.transdroid.daemon.Priority;
import android.content.Context; import android.content.Context;

0
core/src/org/transdroid/core/gui/lists/TorrentFileView.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentFileView.java

2
core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentProgressBar.java

@ -16,7 +16,7 @@
*/ */
package org.transdroid.core.gui.lists; package org.transdroid.core.gui.lists;
import org.transdroid.core.R; import org.transdroid.R;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;

2
core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentStatusLayout.java

@ -16,7 +16,7 @@
*/ */
package org.transdroid.core.gui.lists; package org.transdroid.core.gui.lists;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.daemon.TorrentStatus; import org.transdroid.daemon.TorrentStatus;
import android.content.Context; import android.content.Context;

0
core/src/org/transdroid/core/gui/lists/TorrentView.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentView.java

0
core/src/org/transdroid/core/gui/lists/TorrentsAdapter.java → app/src/main/java/org/transdroid/core/gui/lists/TorrentsAdapter.java

0
core/src/org/transdroid/core/gui/lists/ViewHolderAdapter.java → app/src/main/java/org/transdroid/core/gui/lists/ViewHolderAdapter.java

0
core/src/org/transdroid/core/gui/log/DatabaseHelper.java → app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java

0
core/src/org/transdroid/core/gui/log/ErrorLogEntry.java → app/src/main/java/org/transdroid/core/gui/log/ErrorLogEntry.java

2
core/src/org/transdroid/core/gui/log/ErrorLogSender.java → app/src/main/java/org/transdroid/core/gui/log/ErrorLogSender.java

@ -22,7 +22,7 @@ import java.util.List;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.OrmLiteDao; import org.androidannotations.annotations.OrmLiteDao;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;

0
core/src/org/transdroid/core/gui/log/Log.java → app/src/main/java/org/transdroid/core/gui/log/Log.java

0
core/src/org/transdroid/core/gui/navigation/DialogHelper.java → app/src/main/java/org/transdroid/core/gui/navigation/DialogHelper.java

2
core/src/org/transdroid/core/gui/navigation/FilterListAdapter.java → app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java

@ -20,7 +20,7 @@ import java.util.List;
import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext; import org.androidannotations.annotations.RootContext;
import org.transdroid.core.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.lists.MergeAdapter; import org.transdroid.core.gui.lists.MergeAdapter;
import org.transdroid.core.gui.lists.ViewHolderAdapter; import org.transdroid.core.gui.lists.ViewHolderAdapter;

0
core/src/org/transdroid/core/gui/navigation/FilterListDropDownAdapter.java → app/src/main/java/org/transdroid/core/gui/navigation/FilterListDropDownAdapter.java

0
core/src/org/transdroid/core/gui/navigation/FilterListItemAdapter.java → app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemAdapter.java

0
core/src/org/transdroid/core/gui/navigation/FilterListItemView.java → app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemView.java

0
core/src/org/transdroid/core/gui/navigation/FilterSeparatorView.java → app/src/main/java/org/transdroid/core/gui/navigation/FilterSeparatorView.java

0
core/src/org/transdroid/core/gui/navigation/Label.java → app/src/main/java/org/transdroid/core/gui/navigation/Label.java

0
core/src/org/transdroid/core/gui/navigation/NavigationFilter.java → app/src/main/java/org/transdroid/core/gui/navigation/NavigationFilter.java

69
core/src/org/transdroid/core/gui/navigation/NavigationHelper.java → app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -16,10 +16,6 @@
*/ */
package org.transdroid.core.gui.navigation; package org.transdroid.core.gui.navigation;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.transdroid.core.R;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
@ -30,7 +26,7 @@ import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.style.TypefaceSpan; import android.text.style.TypefaceSpan;
import com.nostra13.universalimageloader.cache.disc.impl.FileCountLimitedDiscCache; import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache; import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.DisplayImageOptions;
@ -38,6 +34,12 @@ import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder;
import com.nostra13.universalimageloader.core.assist.ImageScaleType; import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.transdroid.R;
import java.io.IOException;
import de.keyboardsurfer.android.widget.crouton.Crouton; import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style; import de.keyboardsurfer.android.widget.crouton.Style;
@ -58,14 +60,14 @@ public class NavigationHelper {
/** /**
* Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display error messages. * Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display error messages.
*/ */
public static Style CROUTON_ERROR_STYLE = new Style.Builder().setBackgroundColor(R.color.crouton_error) public static Style CROUTON_ERROR_STYLE =
.setTextSize(13).build(); new Style.Builder().setBackgroundColor(R.color.crouton_error).setTextSize(13).build();
/** /**
* Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display info messages. * Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display info messages.
*/ */
public static Style CROUTON_INFO_STYLE = new Style.Builder().setBackgroundColor(R.color.crouton_info) public static Style CROUTON_INFO_STYLE =
.setTextSize(13).build(); new Style.Builder().setBackgroundColor(R.color.crouton_info).setTextSize(13).build();
/** /**
* Returns (and initialises, if needed) an image cache that uses memory and (1MB) local storage. * Returns (and initialises, if needed) an image cache that uses memory and (1MB) local storage.
@ -73,22 +75,25 @@ public class NavigationHelper {
*/ */
public ImageLoader getImageCache() { public ImageLoader getImageCache() {
if (imageCache == null) { if (imageCache == null) {
// @formatter:off
imageCache = ImageLoader.getInstance(); imageCache = ImageLoader.getInstance();
Builder imageCacheBuilder = new Builder(context) try {
.defaultDisplayImageOptions( LruDiscCache diskCache =
new DisplayImageOptions.Builder() new LruDiscCache(context.getCacheDir(), null, new Md5FileNameGenerator(), 640000, 25);
.cacheInMemory() // @formatter:off
.cacheOnDisc() Builder imageCacheBuilder = new Builder(context)
.imageScaleType(ImageScaleType.IN_SAMPLE_INT) .defaultDisplayImageOptions(
.showImageForEmptyUri(R.drawable.ic_launcher) new DisplayImageOptions.Builder()
.build()) .cacheInMemory()
.memoryCache( .cacheOnDisc()
new UsingFreqLimitedMemoryCache(1024 * 1024)) .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
.discCache( .showImageForEmptyUri(R.drawable.ic_launcher).build())
new FileCountLimitedDiscCache(context.getCacheDir(), new Md5FileNameGenerator(), 25)); .memoryCache(new UsingFreqLimitedMemoryCache(1024 * 1024))
imageCache.init(imageCacheBuilder.build()); .discCache(diskCache);
imageCache.init(imageCacheBuilder.build());
// @formatter:on // @formatter:on
} catch (IOException e) {
// The cache directory is always available on Android; ignore this exception
}
} }
return imageCache; return imageCache;
} }
@ -154,7 +159,7 @@ public class NavigationHelper {
} }
/** /**
* Returns whether any seedbox-related components should be shown in the interface; specifically the option to add * Returns whether any seedbox-related components should be shown in the interface; specifically the option to add
* server settings via easy seedbox-specific screens. * server settings via easy seedbox-specific screens.
* @return True if seedbox settings should be shown, false otherwise * @return True if seedbox settings should be shown, false otherwise
*/ */
@ -165,7 +170,7 @@ public class NavigationHelper {
/** /**
* Whether the custom app update checker should be used to check for new app and search module versions. * Whether the custom app update checker should be used to check for new app and search module versions.
* @return True if it should be checked against transdroid.org if there are app updates (as opposed to using the * @return True if it should be checked against transdroid.org if there are app updates (as opposed to using the
* Play Store for updates, for example), false otherwise * Play Store for updates, for example), false otherwise
*/ */
public boolean enableUpdateChecker() { public boolean enableUpdateChecker() {
return context.getResources().getBoolean(R.bool.updatecheck_available); return context.getResources().getBoolean(R.bool.updatecheck_available);
@ -175,11 +180,12 @@ public class NavigationHelper {
* Converts a string into a {@link Spannable} that displays the string in the Roboto Condensed font * Converts a string into a {@link Spannable} that displays the string in the Roboto Condensed font
* @param string A plain text {@link String} * @param string A plain text {@link String}
* @return A {@link Spannable} that can be applied to supporting views (such as the action bar title) so that the * @return A {@link Spannable} that can be applied to supporting views (such as the action bar title) so that the
* input string will be displayed using the Roboto Condensed font (if the OS has this) * input string will be displayed using the Roboto Condensed font (if the OS has this)
*/ */
public static SpannableString buildCondensedFontString(String string) { public static SpannableString buildCondensedFontString(String string) {
if (string == null) if (string == null) {
return null; return null;
}
SpannableString s = new SpannableString(string); SpannableString s = new SpannableString(string);
s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s; return s;
@ -200,19 +206,22 @@ public class NavigationHelper {
if (rawTorrentUri.getScheme().equals("magnet")) { if (rawTorrentUri.getScheme().equals("magnet")) {
// Magnet links might have a dn (display name) parameter // Magnet links might have a dn (display name) parameter
String dn = getQueryParameter(rawTorrentUri, "dn"); String dn = getQueryParameter(rawTorrentUri, "dn");
if (dn != null && !dn.equals("")) if (dn != null && !dn.equals("")) {
return dn; return dn;
}
// If not, try to return the hash that is specified as xt (exact topci) // If not, try to return the hash that is specified as xt (exact topci)
String xt = getQueryParameter(rawTorrentUri, "xt"); String xt = getQueryParameter(rawTorrentUri, "xt");
if (xt != null && !xt.equals("")) if (xt != null && !xt.equals("")) {
return xt; return xt;
}
} }
if (rawTorrentUri.isHierarchical()) { if (rawTorrentUri.isHierarchical()) {
String path = rawTorrentUri.getPath(); String path = rawTorrentUri.getPath();
if (path != null) { if (path != null) {
if (path.contains("/")) if (path.contains("/")) {
path = path.substring(path.lastIndexOf("/")); path = path.substring(path.lastIndexOf("/"));
}
return path; return path;
} }
} }

0
core/src/org/transdroid/core/gui/navigation/NavigationSelectionView.java → app/src/main/java/org/transdroid/core/gui/navigation/NavigationSelectionView.java

0
core/src/org/transdroid/core/gui/navigation/RefreshableActivity.java → app/src/main/java/org/transdroid/core/gui/navigation/RefreshableActivity.java

0
core/src/org/transdroid/core/gui/navigation/SelectionManagerMode.java → app/src/main/java/org/transdroid/core/gui/navigation/SelectionManagerMode.java

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save