Added audio-video notes activity

This commit is contained in:
Denis 2014-12-23 13:33:25 +02:00
parent b6070c6b0a
commit ae4e3f3837
5 changed files with 91 additions and 15 deletions

View file

@ -128,6 +128,7 @@
<activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation" /> <activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation" /> <activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.routepointsnavigation.RoutePointsActivity" /> <activity android:name="net.osmand.plus.routepointsnavigation.RoutePointsActivity" />
<activity android:name=".dashboard.DashAudioVideoNotesActivity" />
<activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation" /> <activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation" /> <activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation" />

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/main_scroll"
android:background="@color/dashboard_background" >
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="net.osmand.plus.dashboard.DashAudioVideoNotesFragment"
android:layout_marginTop="@dimen/dashCardMargin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</ScrollView>

View file

@ -6,7 +6,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout android:orientation="horizontal" <LinearLayout android:id="@+id/header"
android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight"> android:layout_height="@dimen/dashHeaderHeight">
<TextView android:id="@+id/notes_text" <TextView android:id="@+id/notes_text"

View file

@ -0,0 +1,38 @@
package net.osmand.plus.dashboard;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import net.osmand.plus.R;
import net.osmand.plus.activities.MainMenuActivity;
/**
* Created by Denis on 23.12.2014.
*/
public class DashAudioVideoNotesActivity extends SherlockFragmentActivity {
@Override
protected void onResume() {
super.onResume();
setContentView(R.layout.audio_video_notes_all);
ColorDrawable color = new ColorDrawable(getResources().getColor(R.color.actionbar_color));
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(R.string.audionotes_plugin_name);
actionBar.setBackgroundDrawable(color);
actionBar.setIcon(android.R.color.transparent);
actionBar.setHomeButtonEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
default:
return super.onOptionsItemSelected(item);
}
}
}

View file

@ -1,5 +1,7 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -11,6 +13,7 @@ import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
@ -24,13 +27,17 @@ import java.util.List;
*/ */
public class DashAudioVideoNotesFragment extends DashBaseFragment { public class DashAudioVideoNotesFragment extends DashBaseFragment {
AudioVideoNotesPlugin plugin; AudioVideoNotesPlugin plugin;
boolean allNotes;
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class); plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false); View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
allNotes = getActivity() instanceof DashAudioVideoNotesActivity;
if (allNotes) {
view.findViewById(R.id.header).setVisibility(View.GONE);
} else {
Typeface typeface = FontCache.getRobotoMedium(getActivity()); Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface); ((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface); ((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
@ -38,9 +45,13 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Activity activity = getActivity();
final Intent favorites = new Intent(activity, DashAudioVideoNotesActivity.class);
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites);
} }
}); });
}
return view; return view;
} }
@ -80,7 +91,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.notes); LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.notes);
notesLayout.removeAllViews(); notesLayout.removeAllViews();
if (notes.size() > 3){ if (notes.size() > 3 && !allNotes){
while (notes.size() != 3){ while (notes.size() != 3){
notes.remove(3); notes.remove(3);
} }
@ -95,6 +106,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(getActivity())); ((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(getActivity()));
} else { } else {
((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(getActivity())); ((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(getActivity()));
view.findViewById(R.id.descr).setVisibility(View.GONE);
} }
ImageView icon = (ImageView) view.findViewById(R.id.icon); ImageView icon = (ImageView) view.findViewById(R.id.icon);
@ -105,12 +117,21 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
} else { } else {
icon.setImageResource(R.drawable.ic_type_img); icon.setImageResource(R.drawable.ic_type_img);
} }
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
View.OnClickListener playListener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View v) {
plugin.playRecording(getActivity(), recording); plugin.playRecording(getActivity(), recording);
} }
}); };
if (allNotes){
view.findViewById(R.id.play).setVisibility(View.GONE);
view.setOnClickListener(playListener);
} else {
view.findViewById(R.id.play).setOnClickListener(playListener);
}
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics()); int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);