Skip to content

Commit

Permalink
v2.3.3 released: improve UI, add AD unit on main page.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccjeng committed Feb 24, 2016
1 parent 64e5b7f commit 0b05c69
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ proguard/

# Log Files
*.log

# Constant File
Constant.java

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.oddsoft.buddhavoice2"
minSdkVersion 16
targetSdkVersion 21
versionCode 24
versionName '2.3.2.012316BV'
versionCode 25
versionName '2.3.3.022416BV'
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class BuddhaVoice extends Application {

// Debugging tag for the application
public static final String APPTAG = "BuddhaVoice";
public static final String ADMob_TestDeviceID = "DF9E888CAA233DE54A7FD15B3B1A1522";

public BuddhaVoice() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.mikepenz.aboutlibraries.Libs;
import com.mikepenz.aboutlibraries.LibsBuilder;
Expand All @@ -28,6 +32,7 @@
import com.oddsoft.buddhavoice2.R;
import com.oddsoft.buddhavoice2.utils.Analytics;
import com.oddsoft.buddhavoice2.BuddhaVoice;
import com.oddsoft.buddhavoice2.utils.Constant;

import java.util.Locale;

Expand All @@ -50,6 +55,7 @@ public class MainActivity extends AppCompatActivity {
@Bind(R.id.pager)
ViewPager pager;

private AdView adView;
private Analytics ga;

@Bind(R.id.toolbar)
Expand All @@ -74,7 +80,7 @@ protected void onCreate(Bundle savedInstanceState) {

pager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
tabs.setupWithViewPager(pager);

ADView();
}

private void getPrefs() {
Expand Down Expand Up @@ -242,4 +248,30 @@ public Fragment getItem(int position) {

}

private void ADView() {

LinearLayout adBannerLayout = (LinearLayout) findViewById(R.id.footerLayout);

adView = new AdView(this);
adView.setAdUnitId(Constant.ADMob_BuddhaVoiceMain);
adView.setAdSize(AdSize.SMART_BANNER);
adBannerLayout.addView(adView);

AdRequest adRequest;

if (BuddhaVoice.APPDEBUG) {
//Test Mode
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(Constant.ADMob_TestDeviceID)
.build();
} else {

adRequest = new AdRequest.Builder().build();

}
adView.loadAd(adRequest);

}

}
20 changes: 16 additions & 4 deletions app/src/main/java/com/oddsoft/buddhavoice2/view/VoiceListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.oddsoft.buddhavoice2.R;
import com.oddsoft.buddhavoice2.utils.Analytics;
import com.oddsoft.buddhavoice2.BuddhaVoice;
import com.oddsoft.buddhavoice2.utils.Constant;
import com.pnikosis.materialishprogress.ProgressWheel;

import butterknife.Bind;
Expand Down Expand Up @@ -381,20 +384,29 @@ private void goIntent() {
}

private void ADView() {
adView = (AdView) findViewById(R.id.adView);

LinearLayout adBannerLayout = (LinearLayout) findViewById(R.id.footerLayout);

adView = new AdView(this);
adView.setAdUnitId(Constant.ADMob_BuddhaVoice);
adView.setAdSize(AdSize.SMART_BANNER);
adBannerLayout.addView(adView);

AdRequest adRequest;

if (BuddhaVoice.APPDEBUG) {
//Test Mode
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // 仿真器
.addTestDevice(BuddhaVoice.ADMob_TestDeviceID) // 我的 Galaxy Nexus 測試手機
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(Constant.ADMob_TestDeviceID)
.build();
} else {

adRequest = new AdRequest.Builder().build();
}

}
adView.loadAd(adRequest);

}

private boolean isNetworkAvailable() {
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
android:layout_height="match_parent"
tools:context=".view.MainActivity">

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

<android.support.design.widget.AppBarLayout
android:id="@+id/toolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
Expand All @@ -22,7 +23,6 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
Expand All @@ -37,9 +37,20 @@
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/footerLayout"
android:layout_below="@+id/toolbarLayout"
android:background="@android:color/white" />

</LinearLayout>
<!-- Footer aligned to bottom -->
<LinearLayout
android:id="@+id/footerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:gravity="bottom"/>
</RelativeLayout>

<android.support.design.widget.NavigationView
android:id="@+id/navigation"
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/res/layout/list_item.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="start|center"
Expand All @@ -12,18 +13,14 @@
android:focusable="true"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:id="@+id/cv">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
card_view:cardCornerRadius="2dp"
card_view:cardElevation="2dp">
<TextView
android:id="@+id/row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:background="@android:color/white"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</RelativeLayout>
</android.support.v7.widget.CardView>

</LinearLayout>
10 changes: 1 addition & 9 deletions app/src/main/res/layout/listener.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,7 @@
android:layout_centerHorizontal="true"
android:gravity="bottom"
android:orientation="horizontal"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-6914084100751028/3615464018" />
</LinearLayout>
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</RelativeLayout>

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

0 comments on commit 0b05c69

Please sign in to comment.