Skip to content

Commit

Permalink
help and feedback activity
Browse files Browse the repository at this point in the history
  • Loading branch information
zlsa committed Dec 9, 2016
1 parent e7fa70e commit 162d99a
Show file tree
Hide file tree
Showing 16 changed files with 374 additions and 5 deletions.
9 changes: 8 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@
android:name=".LibraryInfoActivity"
android:label="@string/label_library_info"
android:parentActivityName=".MainActivity" >
>
>
</activity>

<activity
android:name=".HelpFeedbackActivity"
android:label="@string/label_help_feedback"
android:parentActivityName=".MainActivity" >
>
</activity>

<activity
Expand Down
111 changes: 111 additions & 0 deletions app/src/main/java/com/zlsadesign/autogyro/HelpFeedbackActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.zlsadesign.autogyro;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.Toolbar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HelpFeedbackActivity extends Activity {

@BindView(R.id.toolbar)
Toolbar toolbar;

@BindView(R.id.list)
ListView listview;

List<HelpFeedbackItem> items = new ArrayList<HelpFeedbackItem>();


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_help_feedback);

ButterKnife.bind(this);

setActionBar(toolbar);
getActionBar().setDisplayHomeAsUpEnabled(true);

items.add(new HelpFeedbackItem()
.setIcon(R.drawable.ic_notify)
.setPrimary(getString(R.string.app_name))
.setSecondary(BuildConfig.VERSION_NAME)
);

items.add(new HelpFeedbackItem()
.setIcon(R.drawable.ic_link)
.setPrimary(getString(R.string.help_website))
.setSecondary("zlsadesign.com/autogyro")
.setAction(HelpFeedbackItem.ACTION_URI, "http://zlsadesign.com/autogyro/")
);

items.add(new HelpFeedbackItem()
.setIcon(R.drawable.ic_bug_report)
.setPrimary(getString(R.string.help_bug_report))
.setSecondary("github.com/zlsa/autogyro/issues/new")
.setAction(HelpFeedbackItem.ACTION_URI, "https://github.com/zlsa/autogyro/issues/new")
);

items.add(new HelpFeedbackItem()
.setIcon(R.drawable.ic_github)
.setPrimary(getString(R.string.help_repository))
.setSecondary("github.com/zlsa/autogyro")
.setAction(HelpFeedbackItem.ACTION_URI, "https://github.com/zlsa/autogyro")
);

items.add(new HelpFeedbackItem()
.setIcon(R.drawable.ic_email)
.setPrimary(getString(R.string.help_email))
.setSecondary("jonross.zlsa@gmail.com")
.setAction(HelpFeedbackItem.ACTION_EMAIL, "jonross.zlsa@gmail.com")
);

HelpFeedbackItemAdapter customAdapter = new HelpFeedbackItemAdapter(this, R.layout.item_help_feedback, items);

listview.setAdapter(customAdapter);

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

HelpFeedbackItem item = items.get(position);

if(item.action_type == HelpFeedbackItem.ACTION_URI) {
startActivityCheck(new Intent(Intent.ACTION_VIEW, Uri.parse(item.action)), "opening websites");
} else if(item.action_type == HelpFeedbackItem.ACTION_EMAIL) {
Intent intent = new Intent(Intent.ACTION_SEND);

intent.setType("*/*");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{ item.action });
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));

startActivityCheck(intent, "sending emails");
}

}

});

}

private void startActivityCheck(Intent intent, String destination) {
if(intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Toast.makeText(this, "No app available for " + destination, Toast.LENGTH_LONG).show();
}
}
}
41 changes: 41 additions & 0 deletions app/src/main/java/com/zlsadesign/autogyro/HelpFeedbackItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.zlsadesign.autogyro;

import android.graphics.drawable.Drawable;

public class HelpFeedbackItem {

static public int ACTION_NONE = 0;
static public int ACTION_URI = 1;
static public int ACTION_EMAIL = 2;

public String primary = "";
public String secondary = "";

public int icon = 0;

public int action_type = ACTION_NONE;
public String action = "";

public HelpFeedbackItem setPrimary(String primary) {
this.primary = primary;
return this;
}

public HelpFeedbackItem setSecondary(String secondary) {
this.secondary = secondary;
return this;
}

public HelpFeedbackItem setIcon(int icon) {
this.icon = icon;
return this;
}

public HelpFeedbackItem setAction(int action_type, String action) {
this.action_type = action_type;
this.action = action;
return this;
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.zlsadesign.autogyro;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import butterknife.ButterKnife;

public class HelpFeedbackItemAdapter extends ArrayAdapter<HelpFeedbackItem> {

public HelpFeedbackItemAdapter(Context context, int resource, List<HelpFeedbackItem> items) {
super(context, resource, items);
}

@Override
public View getView(int position, View view, ViewGroup parent) {

if(view == null) {
LayoutInflater vi;
vi = LayoutInflater.from(getContext());
view = vi.inflate(R.layout.item_help_feedback, null);
}

HelpFeedbackItem item = getItem(position);

if(item != null) {

if(item.icon != 0) {
((ImageView) ButterKnife.findById(view, R.id.icon)).setImageResource(item.icon);
ButterKnife.findById(view, R.id.icon).setVisibility(View.VISIBLE);
} else {
ButterKnife.findById(view, R.id.icon).setVisibility(View.INVISIBLE);
}

((TextView) ButterKnife.findById(view, R.id.primary)).setText(item.primary);
((TextView) ButterKnife.findById(view, R.id.secondary)).setText(item.secondary);
}

return view;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public void onCreate(Bundle savedInstanceState) {
.setLicense("Apache License, Version 2.0")
);

addLibrary(
new LibraryInfo()
.setName("GitHub circle icon")
.setAuthor("Austin Andrews")
.setLink("https://materialdesignicons.com/icon/github-circle")
.setDescription("From the third-party Material Design Icon set.")
.setLicense("SIL Open Font License")
);

Collections.sort(libraries, new LibraryInfoComparator());

LibraryInfoAdapter customAdapter = new LibraryInfoAdapter(this, R.layout.item_library_info, libraries);
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/zlsadesign/autogyro/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public void onCreate(Bundle savedInstanceState) {
}

setUsedIntroScreen();

startService(new Intent(this, AutogyroService.class));
}

@Override
Expand All @@ -56,7 +58,7 @@ private void openLibraryInfo() {
}

private void openHelpFeedback() {
startActivity(new Intent(this, IntroActivity.class));
startActivity(new Intent(this, HelpFeedbackActivity.class));
}

@Override
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_bug_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_email.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/ic_github.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- drawable/github_circle.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_link.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"/>
</vector>
31 changes: 31 additions & 0 deletions app/src/main/res/layout/activity_help_feedback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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:layout_height="match_parent">

<Toolbar
android:id="@+id/toolbar"
android:background="@color/primary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
>
</Toolbar>

<ListView
android:id="@+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent"

android:divider="@color/light_text_divider"
android:dividerHeight="1dp"

android:footerDividersEnabled="true"
/>

</LinearLayout>
9 changes: 6 additions & 3 deletions app/src/main/res/layout/activity_library_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/light_background"
>

<Toolbar
android:id="@+id/toolbar"
Expand All @@ -27,7 +29,8 @@

android:paddingTop="@dimen/library_info_card_margin_vertical"
android:paddingBottom="@dimen/library_info_card_margin_vertical"
>
</ListView>

android:clipToPadding="false"
/>

</LinearLayout>
Loading

0 comments on commit 162d99a

Please sign in to comment.