Skip to content

Commit

Permalink
Add about dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilhcem committed May 8, 2013
1 parent 2a54fbb commit dd7d9dd
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 0 deletions.
Binary file added res/drawable-hdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions res/layout/about_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.nilhcem.hostseditor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="10dp" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<!-- Content -->
<com.nilhcem.hostseditor.widget.TypefacedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/about_text"
android:textSize="16sp"
app:typeface="fonts/Roboto-Regular.ttf" />

<!-- GitHub button -->
<com.nilhcem.hostseditor.widget.TypefacedButton
android:id="@+id/aboutGitHub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp"
android:text="@string/about_github_button"
app:typeface="fonts/Roboto-Regular.ttf" />

<!-- Date - Author -->
<com.nilhcem.hostseditor.widget.TypefacedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/about_author"
app:typeface="fonts/Roboto-Italic.ttf" />
</LinearLayout>

</ScrollView>
7 changes: 7 additions & 0 deletions res/menu/list_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@
android:showAsAction="never|withText"
android:title="@string/action_select_all"/>

<!-- About -->
<item
android:id="@+id/action_about"
android:icon="@drawable/ic_menu_info_details"
android:showAsAction="never|withText"
android:title="@string/action_about"/>

</menu>
6 changes: 6 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="action_add_host">Add Host</string>
<string name="action_reload">Reload host entries</string>
<string name="action_select_all">Select all hosts</string>
<string name="action_about">About</string>

<!-- Add/Edit host -->
<string name="add_host_title">Add Hostname</string>
Expand Down Expand Up @@ -58,4 +59,9 @@
<string name="loading_toggle_single">Toggling entry</string>
<string name="loading_toggle_multiple">Toggling entries</string>

<!-- About -->
<string name="about_title">About Hosts Editor</string>
<string name="about_text">This app lets you modify your /etc/hosts file on Android.\nYou might need to reboot to clear your DNS cache after any change.</string>
<string name="about_author">2013 - www.nilhcem.com</string>
<string name="about_github_button">GitHub</string>
</resources>
37 changes: 37 additions & 0 deletions src/com/nilhcem/hostseditor/about/AboutDialogFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.nilhcem.hostseditor.about;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import butterknife.InjectView;
import butterknife.Views;

import com.actionbarsherlock.app.SherlockDialogFragment;
import com.nilhcem.hostseditor.R;

public class AboutDialogFragment extends SherlockDialogFragment implements View.OnClickListener {
public static final String TAG = "AboutDialogFragment";
private static final String GITHUB_URL = "https://github.com/Nilhcem/hosts-editor-android";

@InjectView(R.id.aboutGitHub) Button mGitHubBtn;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.about_dialog, container, false);
Views.inject(this, view);
getDialog().setTitle(R.string.about_title);

mGitHubBtn.setOnClickListener(this);
return view;
}

@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(GITHUB_URL));
startActivity(browserIntent);
}
}
10 changes: 10 additions & 0 deletions src/com/nilhcem/hostseditor/list/ListHostsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView;
import com.nilhcem.hostseditor.R;
import com.nilhcem.hostseditor.about.AboutDialogFragment;
import com.nilhcem.hostseditor.addedit.AddEditHostActivity;
import com.nilhcem.hostseditor.bus.event.LoadingEvent;
import com.nilhcem.hostseditor.bus.event.StartAddEditActivityEvent;
Expand Down Expand Up @@ -120,6 +121,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_select_all:
mFragment.selectAll();
return true;
case R.id.action_about:
displayAboutDialog();
return true;
default:
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -210,4 +214,10 @@ private void setActionBarTitle() {
}
getSupportActionBar().setTitle(titleRes);
}

private void displayAboutDialog() {
FragmentManager fm = getSupportFragmentManager();
AboutDialogFragment dialog = new AboutDialogFragment();
dialog.show(fm, AboutDialogFragment.TAG);
}
}

0 comments on commit dd7d9dd

Please sign in to comment.