Skip to content

Commit

Permalink
Launching format activity via preference
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Diaz committed Sep 29, 2016
1 parent 5d5abf0 commit 53c607b
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 8 deletions.
15 changes: 13 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,28 @@
/>

<activity
android:name=".app.ui.HomeActivity"
android:name=".app.home.HomeActivity"
android:label="@string/app_name"
android:theme="@style/Snorlax.Activity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity
android:name=".app.rename.RenameActivity"
android:label="@string/format"
android:parentActivityName=".app.home.HomeActivity"
android:theme="@style/Snorlax.Activity"
>
<intent-filter>
<action android:name=".app.rename.RenameActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.icecream.snorlax.app.ui;
package com.icecream.snorlax.app.home;

import java.io.File;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -63,15 +63,15 @@ public class HomeActivity extends AppCompatActivity {
private AlertDialog mAboutDialog;

@Override
protected void onCreate(Bundle savedStateInstanceState) {
super.onCreate(savedStateInstanceState);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_activity);
mUnbinder = ButterKnife.bind(this);

setupToolbar();
setupPreferences();

if (savedStateInstanceState == null) {
if (savedInstanceState == null) {
Observable
.just(SnorlaxApp.isEnabled())
.filter(enabled -> !enabled)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.icecream.snorlax.app.rename;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.icecream.snorlax.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

@SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"})
public class RenameActivity extends AppCompatActivity {

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

private Unbinder mUnbinder;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rename_activity);
mUnbinder = ButterKnife.bind(this);

setupToolbar();
}

private void setupToolbar() {
setSupportActionBar(mToolbar);

if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
}
5 changes: 4 additions & 1 deletion app/src/main/res/layout/home_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".app.ui.HomeActivity"
tools:context=".app.home.HomeActivity"
>

<android.support.design.widget.CoordinatorLayout
Expand All @@ -19,7 +19,10 @@
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="@dimen/evelation_toolbar"
android:stateListAnimator="@null"
android:theme="@style/Snorlax.AppBarOverlay"
tools:ignore="UnusedAttribute"
>

<android.support.v7.widget.Toolbar
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/res/layout/rename_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" ?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".app.home.HomeActivity"
>

<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
>

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="@dimen/evelation_toolbar"
android:stateListAnimator="@null"
android:theme="@style/Snorlax.AppBarOverlay"
tools:ignore="UnusedAttribute"
>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Snorlax.PopupOverlay"
/>

</android.support.design.widget.AppBarLayout>


<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>

</android.support.design.widget.CoordinatorLayout>

</android.support.design.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/menu/menu_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".app.ui.HomeActivity"
tools:context=".app.home.HomeActivity"
>

<item
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<dimen name="margin_fab">16dp</dimen>

<!-- Elevation -->
<dimen name="evelation_toolbar">4dp</dimen>
<dimen name="evelation_normal_fab">6dp</dimen>
<dimen name="evelation_pressed_fab">12dp</dimen>
<dimen name="margin_vertical_dialog">16dp</dimen>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<string name="about">About</string>
<string name="enable">Enable</string>
<string name="format">Format</string>

<string name="about_version">Version %1$s</string>
<string name="about_author">By igoticecream (igoticecream@gmail.com)</string>
Expand Down Expand Up @@ -44,6 +45,10 @@
<string name="preference_rename_enable_title">Enable inventory pokemons stats</string>
<string name="preference_rename_enable_summary">Show inventory pokemons stats on ingame pokemon list</string>

<string name="preference_rename_activity_enable_key">rename_activity_key</string>
<string name="preference_rename_activity_enable_title">Format</string>
<string name="preference_rename_activity_enable_summary">Customize how the stats are going to be displayed on pokemons names</string>

<string name="preference_catch_notification">Catch Notifications</string>
<string name="preference_catch_notification_enable_key">catch_notification_key</string>
<string name="preference_catch_notification_enable_title">Enable catch notifications</string>
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
android:title="@string/preference_rename_enable_title"
/>

<Preference
android:key="@string/preference_rename_activity_enable_key"
android:summary="@string/preference_rename_activity_enable_summary"
android:title="@string/preference_rename_activity_enable_title"
>
<intent
android:action=".app.rename.RenameActivity"
/>

</Preference>

</PreferenceCategory>

<PreferenceCategory
Expand Down

0 comments on commit 53c607b

Please sign in to comment.