Small refactoring

This commit is contained in:
Victor Shcherb 2015-03-23 01:54:51 +01:00
parent 2b1fc9f094
commit 77667270c8
484 changed files with 7474 additions and 725 deletions

View file

@ -296,6 +296,7 @@ repositories {
artifact "ivy/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
}
}
// mavenCentral()
}
dependencies {
@ -309,6 +310,7 @@ dependencies {
"android-support*.jar",
"OsmAndCore_android.jar",
"OsmAndCore_wrapper.jar"])
compile "com.github.ksoichiro:android-observablescrollview:1.5.0"
compile "com.android.support:appcompat-v7:21.0.3"
compile "com.github.shell-software:fab:1.0.5"
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"

View file

@ -1,318 +0,0 @@
apply plugin: 'com.android.application'
// Global Paramers accepted
// APK_NUMBER_VERSION - version number of apk
// APK_VERSION - build number like #9999Z, for dev builds appended to app_version like 2.0.0 in no_translate.xml)
// flavor Z : M=-master, D=-design, B=-Blackberry, MD=-main-default, MQA=-main-qt-arm, MQDA=-main-qt-default-arm, S=-sherpafy
// TARGET_APP_NAME - app name
// APP_EDITION - date stamp of builds
// APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon
// TODO
// 1. Filter fonts
// <unzip src="OsmAndCore_android.aar" dest=".">
// <patternset>
// <include name="assets/**/map/fonts/OpenSans/*"/>
// <include name="assets/**/map/fonts/NotoSans/*"/>
// </patternset>
// </unzip>
// Less important
// 2. fix_apostrophe_issues (replace match="[^=]([^\\])'" replace="\1\\\\'") res/**/strings.xml
// 3. sherpafy/free/paid
// 4. Release signature
// 5. TARGET_APP_NAME, APP_EDITION uses flavor
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
signingConfigs {
development {
storeFile file("../keystores/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
publishing {
storeFile file("osmand_key")
storePassword System.getenv("OSMAND_APK_PASSWORD")
keyAlias "androiddebugkey"
keyPassword System.getenv("OSMAND_APK_PASSWORD")
}
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
//versionName already assigned in code
//versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
}
lintOptions {
lintConfig file("lint.xml")
abortOnError false
warningsAsErrors false
}
// This is from OsmAndCore_android.aar - for some reason it's not inherited
aaptOptions {
// Don't compress any embedded resources
noCompress "qz"
}
dexOptions {
jumboMode = true
}
sourceSets {
main {
manifest.srcFile "AndroidManifest.xml"
jni.srcDirs = []
jniLibs.srcDirs = ["libs"]
aidl.srcDirs = ["src"]
java.srcDirs = ["src"]
resources.srcDirs = ["src"]
renderscript.srcDirs = ["src"]
res.srcDirs = ["res"]
assets.srcDirs = ["assets"]
}
free {
manifest.srcFile "AndroidManifest-free.xml"
}
legacy {
jniLibs.srcDirs = ["libgnustl"]
}
}
flavorDimensions "version", "coreversion", "abi"
productFlavors {
// ABI
armv7 {
flavorDimension "abi"
ndk {
abiFilter "armeabi-v7a"
}
}
armv5 {
flavorDimension "abi"
ndk {
abiFilter "armeabi"
}
}
x86 {
flavorDimension "abi"
ndk {
abiFilter "x86"
}
}
mips {
flavorDimension "abi"
ndk {
abiFilter "mips"
}
}
fat {
flavorDimension "abi"
}
// Version
free {
flavorDimension "version"
applicationId "net.osmand"
}
full {
flavorDimension "version"
applicationId "net.osmand.plus"
}
// CoreVersion
legacy {
flavorDimension "coreversion"
}
qtcore {
flavorDimension "coreversion"
}
qtcoredebug {
flavorDimension "coreversion"
}
}
buildTypes {
debug {
signingConfig signingConfigs.development
}
release {
signingConfig signingConfigs.publishing
}
}
}
def replaceNoTranslate(line) {
if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
}
if (line.contains("\"app_edition\"") && System.getenv("APP_EDITION")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<")
}
if (line.contains("\"app_version\"") && System.getenv("APK_VERSION")) {
// appends build number to version number for dev builds
return line.replaceAll("</", System.getenv("APK_VERSION") + "</")
}
if (line.contains("\"versionFeatures\"") && System.getenv("APP_FEATURES")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_FEATURES") + "<")
}
return line;
}
task updateNoTranslate(type: Copy) {
inputs.property 'appName', System.getenv().get("APP_NAME")
inputs.property 'appEdition', System.getenv().get("APP_EDITION")
inputs.property 'appFeatures', System.getenv().get("APP_FEATURES")
inputs.property 'apkVersion', System.getenv().get("APK_VERSION")
from('.') {
include 'no_translate.xml'
filter {
line -> replaceNoTranslate(line);
}
}
into 'res/values/'
}
task collectVoiceAssets(type: Sync) {
from "../../resources/voice"
into "assets/voice"
include "**/*.p"
}
task collectSpecialPhrasesAssets(type: Sync) {
from "../../resources/specialphrases"
into "assets/specialphrases"
include "*.txt"
}
task collectHelpContentsAssets(type: Sync) {
from "../../help"
into "assets/help"
include "*.html"
include "images/**/*.png"
from "assets/"
into "assets/help"
include "style.css"
}
task collectRoutingResources(type: Sync) {
from "../../resources/routing"
into "src/net/osmand/router"
include "*.xml"
}
task collectMiscResources(type: Copy) {
into "src/net/osmand/osm"
from("../../resources/obf_creation") {
include "rendering_types.xml"
}
from("../../resources/poi") {
include "poi_types.xml"
}
}
task collectRenderingStylesResources(type: Sync) {
from "../../resources/rendering_styles"
into "src/net/osmand/render"
include "*.xml"
}
task collectRegionsInfoResources(type: Copy) {
from "../../resources/countries-info"
into "src/net/osmand/map"
include "regions.ocbf"
}
task copyStyleIcons(type: Copy) {
from "../../resources/rendering_styles/style-icons/"
into "res/"
include "**/*.png"
}
task collectExternalResources << {}
collectExternalResources.dependsOn collectVoiceAssets,
collectSpecialPhrasesAssets,
collectHelpContentsAssets,
collectRoutingResources,
collectRenderingStylesResources,
collectRegionsInfoResources,
collectMiscResources,
copyStyleIcons,
updateNoTranslate
tasks.whenTaskAdded { task ->
if (task.name.startsWith("generate") && task.name.endsWith("Resources")) {
task.dependsOn collectExternalResources
}
}
// Legacy core build
import org.apache.tools.ant.taskdefs.condition.Os
task buildOsmAndCore(type: Exec) {
description "Build Legacy OsmAndCore"
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "bash", file("./old-ndk-build.sh").getAbsolutePath()
} else {
commandLine "cmd", "/c", "echo", "Not supported"
}
}
task cleanupDuplicatesInCore() {
dependsOn buildOsmAndCore
// doesn't work for legacy debug builds
doLast {
file("libgnustl/armeabi").mkdirs()
println file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so"))
file("libgnustl/armeabi-v7a").mkdirs()
println file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so"))
file("libgnustl/mips").mkdirs()
println file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so"))
file("libgnustl/x86").mkdirs()
println file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so"))
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn << [buildOsmAndCore, cleanupDuplicatesInCore]
}
repositories {
ivy {
name = "OsmAndBinariesIvy"
url = "http://builder.osmand.net"
layout "pattern", {
artifact "ivy/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
}
}
}
dependencies {
compile project(path: ":OsmAnd-java", configuration: "android")
compile fileTree(
dir: "libs",
include: ["*.jar"],
exclude: [
"QtAndroid-bundled.jar",
"QtAndroidAccessibility-bundled.jar",
"android-support*.jar",
"OsmAndCore_android.jar",
"OsmAndCore_wrapper.jar"])
compile "com.android.support:appcompat-v7:21.0.3"
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
}

View file

@ -12,5 +12,7 @@ split.density=false
# Project target.
target=android-21
dex.force.jumbo=true
android.library.reference.1=../appcompat
android.library.reference.2=../eclipse-compile/fab
android.library.reference.1=../eclipse-compile/appcompat
android.library.reference.2=../eclipse-compile/observable
android.library.reference.2=../eclipse-compile/observable
android.library.reference.3=../eclipse-compile/fab

View file

@ -35,7 +35,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</net.osmand.plus.dashboard.NotifyingScrollView>
@ -46,13 +45,13 @@
android:layout_gravity="start"
android:visibility="gone" >
<ListView
<com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/dash_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/card_bg"
android:fadeScrollbars="true" >
</ListView>
</com.github.ksoichiro.android.observablescrollview.ObservableListView>
</FrameLayout>
<include

View file

@ -12,11 +12,10 @@
layout="@layout/application_loading"
android:visibility="gone" />
<LinearLayout
<FrameLayout
android:id="@+id/animateContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:layout_height="match_parent" >
<net.osmand.plus.dashboard.NotifyingScrollView
android:id="@+id/main_scroll"
@ -49,14 +48,24 @@
android:layout_height="match_parent"
android:visibility="gone" >
<ListView
<View
android:id="@+id/dash_list_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_bg"/>
<com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/dash_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dashboard_map_top_padding"
android:background="?attr/card_bg"
android:fadeScrollbars="true" >
</ListView>
</com.github.ksoichiro.android.observablescrollview.ObservableListView>
<android.support.v7.widget.Toolbar android:id="@+id/dash_toolbar"
android:background="@color/actionbar_light_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></android.support.v7.widget.Toolbar>
<include
android:id="@+id/map_part_dashboard"
@ -64,6 +73,6 @@
android:layout_height="@dimen/dashboard_map_top_padding"
layout="@layout/map_view_on_dashboard" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
</FrameLayout>

View file

@ -814,7 +814,7 @@ public class MapActivityActions implements DialogProvider {
//////////// Others
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
optionsMenuHelper.item(R.string.shared_string_exit).icon(R.drawable.ic_action_quit_dark )
optionsMenuHelper.item(R.string.shared_string_exit).iconColor(R.drawable.ic_action_quit_dark )
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -1,7 +1,5 @@
package net.osmand.plus.dashboard;
import gnu.trove.map.hash.TIntObjectHashMap;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.LinkedList;
@ -20,16 +18,18 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.DashTrackFragment;
import net.osmand.plus.osmedit.DashOsmEditsFragment;
import net.osmand.plus.osmo.DashOsmoFragment;
import net.osmand.plus.parkingpoint.DashParkingFragment;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
@ -38,7 +38,7 @@ import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
@ -47,13 +47,16 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;
import com.software.shell.fab.ActionButton;
/**
* Created by Denis
* on 03.03.15.
*/
public class DashboardOnMap {
public class DashboardOnMap implements ObservableScrollViewCallbacks {
public static boolean staticVisible = false;
private MapActivity mapActivity;
@ -77,6 +80,8 @@ public class DashboardOnMap {
private NotifyingScrollView scrollView;
private View listViewLayout;
private ListView listView;
private View listBackgroundView;
private int mFlexibleSpaceImageHeight;
public DashboardOnMap(MapActivity ma) {
@ -100,7 +105,34 @@ public class DashboardOnMap {
scrollView = ((NotifyingScrollView) dashboardView.findViewById(R.id.main_scroll));
listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
listView = (ListView) dashboardView.findViewById(R.id.dash_list_view);
// dashboardView.setOnClickListener(listener);
if (listView instanceof ObservableListView) {
((ObservableListView) listView).setScrollViewCallbacks(this);
mFlexibleSpaceImageHeight = mapActivity.getResources().getDimensionPixelSize(
R.dimen.dashboard_map_top_padding);
// Set padding view for ListView. This is the flexible space.
View paddingView = new View(mapActivity);
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
mFlexibleSpaceImageHeight);
paddingView.setLayoutParams(lp);
// This is required to disable header's list selector effect
paddingView.setClickable(true);
paddingView.setOnClickListener(listener);
listView.addHeaderView(paddingView);
Toolbar tb = (Toolbar) mapActivity.findViewById(R.id.dash_toolbar);
tb.setLogo(R.drawable.icon);
listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
contentView.post(new Runnable() {
@Override
public void run() {
// mListBackgroundView's should fill its parent vertically
// but the height of the content view is 0 on 'onCreate'.
// So we should get it with post().
listBackgroundView.getLayoutParams().height = contentView.getHeight();
}
});
}
dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);
@ -127,42 +159,6 @@ public class DashboardOnMap {
}
});
dashboardView.addView(actionButton);
if (ScreenOrientationHelper.isOrientationPortrait(mapActivity)) {
scrollView.setOnScrollChangedListener(onScrollChangedListener);
listView.setOnScrollListener(new OnScrollListener() {
private TIntObjectHashMap<Integer> listViewItemHeights = new TIntObjectHashMap<Integer>();
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// if(listView.getChildCount() == 0) {
// return;
// }
// View c = listView.getChildAt(0);
// int sy = -c.getTop();
// listViewItemHeights.put(listView.getFirstVisiblePosition(), c.getHeight());
// for (int i = 0; i < listView.getFirstVisiblePosition(); ++i) {
// if (listViewItemHeights.get(i) != null) // (this is a sanity check)
// sy += listViewItemHeights.get(i); //add all heights of the views that are gone
// }
// double scale = view.getContext().getResources().getDisplayMetrics().density;
// MarginLayoutParams lp = (MarginLayoutParams) actionButton.getLayoutParams();
// lp.topMargin = (int) Math.max(30 * scale, 160 * scale - sy);
// ((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
// MarginLayoutParams llp = (MarginLayoutParams) listView.getLayoutParams();
// llp.topMargin = (int) Math.max(5 * scale, 160 * scale - sy);
// listView.setLayoutParams(llp);
// listView.getParent().requestLayout();
}
});
}
}
private void switchBtnAction() {
@ -210,7 +206,7 @@ public class DashboardOnMap {
return listAdapterOnClickListener;
}
public void setListAdapter(ArrayAdapter<?> listAdapter, OnItemClickListener optionsMenuOnClickListener) {
public void setListAdapter(ArrayAdapter<?> listAdapter, final OnItemClickListener optionsMenuOnClickListener) {
if(!isVisible()) {
mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(false);
}
@ -218,7 +214,19 @@ public class DashboardOnMap {
this.listAdapterOnClickListener = optionsMenuOnClickListener;
if(this.listView != null) {
listView.setAdapter(listAdapter);
if(listBackgroundView == null) {
listView.setOnItemClickListener(optionsMenuOnClickListener);
} else if (optionsMenuOnClickListener != null) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
optionsMenuOnClickListener.onItemClick(parent, view, position - 1, id);
}
});
} else {
listView.setOnItemClickListener(null);
}
}
setDashboardVisibility(true);
}
@ -533,5 +541,45 @@ public class DashboardOnMap {
}
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
// Translate list background
setTranslationY(listBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));
}
@SuppressLint("NewApi")
private void setTranslationY(View v, int y) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
v.setTranslationY(y);
} else {
TranslateAnimation anim = new TranslateAnimation(0, 0, y, y);
anim.setFillAfter(true);
anim.setDuration(0);
v.startAnimation(anim);
}
}
@Override
public void onDownMotionEvent() {
}
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
// ActionBar ab = getSupportActionBar();
// if (scrollState == ScrollState.UP) {
// if (ab.isShowing()) {
// ab.hide();
// }
// } else if (scrollState == ScrollState.DOWN) {
// if (!ab.isShowing()) {
// ab.show();
// }
// }
}
}

View file

@ -995,12 +995,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
if (osmEditingPlugin != null && osmEditingPlugin.isActive()) {
Drawable exportIcon = getResources().getDrawable(R.drawable.ic_action_export);
if (light) {
exportIcon = exportIcon.mutate();
exportIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
item = optionsMenu.getMenu().add(R.string.shared_string_export).setIcon(exportIcon);
item = optionsMenu.getMenu().add(R.string.shared_string_export).setIcon(getMyApplication().getIconsCache().getActionBarIcon(
R.drawable.ic_action_export, light));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 326 B

View file

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

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