Skip to content

Commit

Permalink
裁剪了一下app的大小
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleydu committed Jul 8, 2021
1 parent 6702f0c commit 383e939
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 472 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ captures/

/gradle.properties
/app/src/main/BrowserFilter-data.xml
/app/debug/
63 changes: 13 additions & 50 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'com.google.gms.google-services' // Google Services plugin
apply plugin: 'com.google.firebase.crashlytics'
Expand All @@ -22,33 +21,9 @@ else {
version = cmdGetTagname.execute().text.trim()
}

def app_id = "ca-app-pub-9990256099942544~3347511713"
def favorite_unit_id = "ca-app-pub-9990256099942544/2247696110"
def history_unit_id = "ca-app-pub-9990256099942544/2247696110"
def download_unit_id = "ca-app-pub-9990256099942544/2247696110"
def local_unit_id = "ca-app-pub-9990256099942544/2247696110"
def search_unit_id = "ca-app-pub-9990256099942544/2247696110"
def banners_id = "ca-app-pub-9990256099942544/6300978111"
def banners_chapter_id = "ca-app-pub-9990256099942544/6300978111"
def banners_search_id = "ca-app-pub-9990256099942544/6300978111"
def insert_home_id = "ca-app-pub-9990256099942544/1033173712"

if(System.getenv("TRAVIS_BUILD_NUMBER") != null){
app_id = System.getenv("ADMOB_APP_ID")
favorite_unit_id = System.getenv("ADMOB_NATIVE_FAVORITE_UNIT_ID")
history_unit_id = System.getenv("ADMOB_NATIVE_HISTORY_UNIT_ID")
download_unit_id = System.getenv("ADMOB_NATIVE_DOWNLOAD_UNIT_ID")
local_unit_id = System.getenv("ADMOB_NATIVE_LOCAL_UNIT_ID")
search_unit_id = System.getenv("ADMOB_NATIVE_SEARCH_UNIT_ID")
banners_id = System.getenv("ADMOB_BANNER_UNIT_ID")
banners_chapter_id = System.getenv("ADMOB_BANNER_CHAPTER_UNIT_ID")
banners_search_id = System.getenv("ADMOB_BANNER_SEARCH_UNIT_ID")
insert_home_id = System.getenv("ADMOB_INSERT_HOME_ID")
}

android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.3'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -58,22 +33,12 @@ android {
defaultConfig {
applicationId "com.haleydu.cimoc"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode buildVersion
versionName version
resConfigs "en", "zh"
multiDexEnabled true

buildConfigField ("String","ADMOB_NATIVE_FAVORITE_UNIT_ID","\""+favorite_unit_id+"\"")
buildConfigField ("String","ADMOB_NATIVE_HISTORY_UNIT_ID","\""+history_unit_id+"\"")
buildConfigField ("String","ADMOB_NATIVE_DOWNLOAD_UNIT_ID","\""+download_unit_id+"\"")
buildConfigField ("String","ADMOB_NATIVE_LOCAL_UNIT_ID","\""+local_unit_id+"\"")
buildConfigField ("String","ADMOB_NATIVE_SEARCH_UNIT_ID","\""+search_unit_id+"\"")
buildConfigField ("String","ADMOB_INSERT_HOME_ID","\""+insert_home_id+"\"")

resValue "string", "ADMOB_BANNER_UNIT_ID", "\""+banners_id+"\""
resValue "string", "ADMOB_BANNER_CHAPTER_UNIT_ID", "\""+banners_chapter_id+"\""
resValue "string", "ADMOB_BANNER_SEARCH_UNIT_ID", "\""+banners_search_id+"\""
}
signingConfigs {
release {
Expand All @@ -96,16 +61,15 @@ android {
shrinkResources true
zipAlignEnabled true
signingConfig signingConfigs.release
manifestPlaceholders=[ADMOB_APP_ID:"$app_id"]
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
shrinkResources false
zipAlignEnabled false
signingConfig signingConfigs.debug
manifestPlaceholders=[ADMOB_APP_ID:"$app_id"]
}

android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "Cimoc_"+version+".apk"
Expand All @@ -122,12 +86,12 @@ greendao {
}

dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'org.greenrobot:greendao:3.3.0'
Expand All @@ -143,12 +107,11 @@ dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.alibaba:fastjson:1.2.62'
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"
implementation 'com.google.firebase:firebase-analytics:17.6.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
implementation 'com.google.firebase:firebase-config:19.2.0'
implementation 'com.google.firebase:firebase-ads:19.5.0'
implementation "androidx.core:core-ktx:1.6.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation 'com.google.firebase:firebase-crashlytics:18.1.0'
implementation 'com.google.firebase:firebase-config:21.0.0'
implementation 'com.king.app:app-updater:1.0.8-androidx'
implementation 'com.king.app:app-dialog:1.0.8-androidx'
implementation 'com.iqiyi.xcrash:xcrash-android-lib:3.0.0'
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths_public" />
</provider>

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="${ADMOB_APP_ID}"/>
</application>

</manifest>
22 changes: 0 additions & 22 deletions app/src/main/java/com/hiroshi/cimoc/ui/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.navigation.NavigationView;
Expand Down Expand Up @@ -205,13 +200,6 @@ protected void initData() {

}

@Override
protected void initAdMob() {
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {}
});
}

// public void getUesrInfo() {
// String accessTocken = mPreference.getString(PreferenceManager.PREFERENCES_USER_TOCKEN, null);
Expand Down Expand Up @@ -264,21 +252,11 @@ public void onDrawerClosed(View drawerView) {
private void initNavigation() {
night = mPreference.getBoolean(PreferenceManager.PREF_NIGHT, false);
mNavigationView.getMenu().findItem(R.id.drawer_night).setTitle(night ? R.string.drawer_light : R.string.drawer_night);
// mNavigationView.getMenu().findItem(R.id.user_info)
// .setTitle(
// mPreference.getString(PreferenceManager.PREFERENCES_USER_NAME, "") == "" ?
// getString(R.string.user_login_item) :
// mPreference.getString(PreferenceManager.PREFERENCES_USER_NAME, "User")
// );
mNavigationView.setNavigationItemSelectedListener(this);
View header = mNavigationView.getHeaderView(0);
mLastText = header.findViewById(R.id.drawer_last_title);
mDraweeView = header.findViewById(R.id.drawer_last_cover);

AdView mAdView = header.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

mLastText.setOnClickListener(v -> {
if (mPresenter.checkLocal(mLastId)) {
Intent intent = TaskActivity.createIntent(MainActivity.this, mLastId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdLoader;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.formats.UnifiedNativeAd;
import com.hiroshi.cimoc.App;
import com.hiroshi.cimoc.BuildConfig;
import com.hiroshi.cimoc.R;
import com.hiroshi.cimoc.global.Extra;
import com.hiroshi.cimoc.manager.SourceManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.os.Bundle;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
import androidx.appcompat.widget.AppCompatAutoCompleteTextView;
Expand Down Expand Up @@ -104,10 +102,6 @@ public void afterTextChanged(Editable s) {
mArrayAdapter = new AutoCompleteAdapter(this);
mEditText.setAdapter(mArrayAdapter);
}

AdView mAdView = findViewById(R.id.adView_search);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilderSupplier;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.hiroshi.cimoc.R;
import com.hiroshi.cimoc.model.Chapter;
import com.hiroshi.cimoc.ui.widget.ChapterButton;
Expand Down Expand Up @@ -133,8 +131,12 @@ public void reverse() {
//判断是否分组且当前是否为第一个元素
public boolean isFirst(int position) {
position = position - 1;
if (mDataSet.get(position).getSourceGroup().isEmpty()) return false;
if (position == 0) return true;
if (mDataSet.get(position).getSourceGroup().isEmpty()) {
return false;
}
if (position == 0) {
return true;
}
if (position <= 0) {
return false;
}
Expand Down Expand Up @@ -186,8 +188,6 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
try {
if (position == 0) {
HeaderHolder headerHolder = (HeaderHolder) holder;
AdRequest adRequest = new AdRequest.Builder().build();
headerHolder.mAdView.loadAd(adRequest);
if (title != null) {
if (cover != null) {
headerHolder.mComicImage.setController(mControllerSupplier.get().setUri(cover).build());
Expand Down Expand Up @@ -226,7 +226,9 @@ public void onAttachedToRecyclerView(RecyclerView recyclerView) {
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (position == 0 || isFirst(position)) return manager.getSpanCount();
if (position == 0 || isFirst(position)) {
return manager.getSpanCount();
}

return 1;
}
Expand Down Expand Up @@ -275,8 +277,6 @@ class HeaderHolder extends BaseViewHolder {
TextView mComicUpdate;
@BindView(R.id.item_header_comic_author)
TextView mComicAuthor;
@BindView(R.id.adView_chapter)
AdView mAdView;

HeaderHolder(View view) {
super(view);
Expand Down
Loading

0 comments on commit 383e939

Please sign in to comment.