Merge pull request #1005 from Bars107/master

Audio video note card.
This commit is contained in:
vshcherb 2014-12-16 11:49:40 +01:00
commit e427aefe79
27 changed files with 207 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -63,6 +63,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="net.osmand.plus.dashboard.DashAudioVideoNotesFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<fragment <fragment
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:name="net.osmand.plus.dashboard.DashPluginsFragment" android:name="net.osmand.plus.dashboard.DashPluginsFragment"

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_notes"
android:background="@drawable/bg_cardui"
android:layout_marginBottom="4dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="40dp">
<TextView android:id="@+id/notes_text"
android:text="@string/map_widget_av_notes"
style="@style/DashboardSubHeader"/>
<Button android:id="@+id/show_all"
android:text="@string/show_all"
style="@style/DashboardGeneralButton"/>
</LinearLayout>
<LinearLayout android:id="@+id/notes"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@drawable/dashboard_button"
android:layout_height="50dp">
<View android:layout_width="match_parent"
android:background="@color/dashboard_divider"
android:layout_height="1dp"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="@+id/icon"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="28dp"
android:layout_height="28dp"/>
<LinearLayout android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView android:id="@+id/name"
android:textSize="16sp"
android:lines="1"
android:ellipsize="end"
android:textColor="@color/dashboard_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/descr"
android:textSize="12sp"
android:lines="1"
android:ellipsize="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ImageButton android:id="@+id/play"
android:src="@drawable/ic_play_light"
android:background="@drawable/dashboard_button"
android:layout_marginLeft="12dp"
android:layout_width="50dp"
android:layout_height="50dp"/>
</LinearLayout>
</LinearLayout>

View file

@ -37,6 +37,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="net.osmand.plus.dashboard.DashAudioVideoNotesFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<fragment <fragment
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:name="net.osmand.plus.dashboard.DashUpdatesFragment" android:name="net.osmand.plus.dashboard.DashUpdatesFragment"

View file

@ -16,13 +16,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask; import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.dashboard.DashDownloadMapsFragment; import net.osmand.plus.dashboard.*;
import net.osmand.plus.dashboard.DashErrorFragment;
import net.osmand.plus.dashboard.DashFavoritesFragment;
import net.osmand.plus.dashboard.DashMapFragment;
import net.osmand.plus.dashboard.DashPluginsFragment;
import net.osmand.plus.dashboard.DashSearchFragment;
import net.osmand.plus.dashboard.DashUpdatesFragment;
import net.osmand.plus.download.BaseDownloadActivity; import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
@ -447,6 +441,9 @@ public class MainMenuActivity extends BaseDownloadActivity {
((DashDownloadMapsFragment) f).refreshData(); ((DashDownloadMapsFragment) f).refreshData();
} }
} }
if(f instanceof DashAudioVideoNotesFragment && !f.isDetached()){
((DashAudioVideoNotesFragment) f).setupNotes();
}
} }
} }
} }

View file

@ -0,0 +1,115 @@
package net.osmand.plus.dashboard;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.helpers.FontCache;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Denis on 15.12.2014.
*/
public class DashAudioVideoNotesFragment extends DashBaseFragment {
AudioVideoNotesPlugin plugin;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
if (plugin == null) {
return super.onCreateView(inflater, container, savedInstanceState);
}
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
return view;
}
@Override
public void onResume() {
super.onResume();
setupNotes();
}
@Override
public void onPause() {
super.onPause();
}
public void setupNotes() {
View mainView = getView();
List<AudioVideoNotesPlugin.Recording> notes = new ArrayList<AudioVideoNotesPlugin.Recording>(plugin.getAllRecordings());
if (notes.size() == 0){
(mainView.findViewById(R.id.main_notes)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_notes)).setVisibility(View.VISIBLE);
}
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.notes);
notesLayout.removeAllViews();
if (notes.size() > 3){
while (notes.size() != 3){
notes.remove(3);
}
}
for (final AudioVideoNotesPlugin.Recording recording : notes){
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_note_item, null, false);
if (recording.name != null){
((TextView) view.findViewById(R.id.name)).setText(recording.name);
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(getActivity()));
} else {
((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(getActivity()));
}
ImageView icon = (ImageView) view.findViewById(R.id.icon);
if (recording.isAudio()){
icon.setImageResource(R.drawable.ic_type_audio);
} else if (recording.isVideo()){
icon.setImageResource(R.drawable.ic_type_video);
} else {
icon.setImageResource(R.drawable.ic_type_img);
}
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
plugin.playRecording(getActivity(), recording);
}
});
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
view.setLayoutParams(lp);
notesLayout.addView(view);
}
}
}

View file

@ -59,8 +59,6 @@ public class DashFavoritesFragment extends DashBaseFragment implements OsmAndLoc
} }
}); });
return view; return view;
} }