Skip to content

Commit

Permalink
add setting and about view and so on ..
Browse files Browse the repository at this point in the history
  • Loading branch information
lovejjfg committed Sep 5, 2017
1 parent de76080 commit 865f257
Show file tree
Hide file tree
Showing 30 changed files with 889 additions and 239 deletions.
13 changes: 9 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ android {
applicationId "com.lovejjfg.readhub"
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
versionCode project.gitCommitCount
versionName project.gitTag
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//只保留对应的国际化
resConfigs "zh", "en"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
shrinkResources false
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

Expand All @@ -40,6 +42,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-core:11.2.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Expand All @@ -65,3 +68,5 @@ dependencies {

testImplementation 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'
42 changes: 42 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"project_info": {
"project_number": "689745366156",
"firebase_url": "https://readhub-46dc0.firebaseio.com",
"project_id": "readhub-46dc0",
"storage_bucket": "readhub-46dc0.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:689745366156:android:7c480c335dec1735",
"android_client_info": {
"package_name": "com.lovejjfg.readhub"
}
},
"oauth_client": [
{
"client_id": "689745366156-bisjq0200nash35ma70cdk5hol4mhhg9.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCVAQyvtIilb2FsdgqQneeKojWII5L98uI"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
15 changes: 8 additions & 7 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,30 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# okhttp
-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.** { *;}
-keep interface com.squareup.okhttp3.** { *; }
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
-dontwarn okio.**


#retrofit
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
-dontwarn retrofit2.OkHttpCall
#-dontwarn retrofit2.OkHttpCall
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

-dontwarn javax.annotation.**
# keep anotation
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}


-dontwarn rx.**
#rx
#-dontwarn rx.**

# lambda
-dontwarn java.lang.invoke.*
Expand All @@ -61,5 +60,7 @@

-dontwarn com.lovejjfg.**

-keepattributes EnclosingMethod



6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>



<application
android:name=".base.App"
Expand All @@ -24,8 +28,10 @@
</activity>
<activity
android:name=".view.SettingsActivity"
android:theme="@style/AppTheme.ActionBar"
android:label="@string/title_activity_settings">
</activity>
<activity android:name=".view.AboutActivity"/>
</application>

</manifest>
1 change: 1 addition & 0 deletions app/src/main/java/com/lovejjfg/readhub/base/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.lovejjfg.readhub.base

import android.app.Application
import com.google.firebase.analytics.FirebaseAnalytics


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ abstract class RefreshFragment : Fragment() {
})
?.start()
}
if (!isAnimating && dy > 0 && first > 2 && isVisible) {
if (!isAnimating && dy > 0 && isVisible) {
navigation?.animate()
?.translationY(navigation?.height!! + 0.5f)
?.setListener(object : AnimatorListenerAdapter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ package com.lovejjfg.readhub.data

import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName

data class Test(

@field:SerializedName("name")
val name: String? = "xxxxx",

@field:SerializedName("age")
val age: Int? = null
) : Parcelable {
companion object {
@JvmField val CREATOR: Parcelable.Creator<Test> = object : Parcelable.Creator<Test> {
override fun createFromParcel(source: Parcel): Test = Test(source)
override fun newArray(size: Int): Array<Test?> = arrayOfNulls(size)
}
}
/**
* Created by Joe on 2017/3/14.
* Email [email protected]
*/

data class Library(var name: String?, var des: String?, var jumpUrl: String?) : Parcelable {
constructor(source: Parcel) : this(
source.readString(),
source.readValue(Int::class.java.classLoader) as Int?
source.readString(),
source.readString()
)

override fun describeContents() = 0

override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(name)
dest.writeValue(age)
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
writeString(name)
writeString(des)
writeString(jumpUrl)
}

companion object {
@JvmField
val CREATOR: Parcelable.Creator<Library> = object : Parcelable.Creator<Library> {
override fun createFromParcel(source: Parcel): Library = Library(source)
override fun newArray(size: Int): Array<Library?> = arrayOfNulls(size)
}
}
}
}
41 changes: 37 additions & 4 deletions app/src/main/java/com/lovejjfg/readhub/utils/JumpUitl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,53 @@ package com.lovejjfg.readhub.utils

import android.content.Context
import android.content.Intent

import android.net.Uri
import android.os.Bundle
import android.preference.PreferenceManager
import android.text.TextUtils
import com.google.firebase.analytics.FirebaseAnalytics
import com.lovejjfg.readhub.data.Constants
import com.lovejjfg.readhub.view.AboutActivity
import com.lovejjfg.readhub.view.SettingsActivity
import com.lovejjfg.readhub.view.WebActivity


/**
* ReadHub
* Created by Joe at 2017/8/5.
*/

object JumpUitl {

fun jumpWeb(context: Context, url: String) {
val intent = Intent(context, WebActivity::class.java)
intent.putExtra(Constants.URL, url)
fun jumpWeb(context: Context, url: String?) {
if (TextUtils.isEmpty(url)) {
return
}
val bundle = Bundle()
bundle.putString("链接", url)
FirebaseAnalytics.getInstance(context).logEvent("点击", bundle)
val default = PreferenceManager
.getDefaultSharedPreferences(context)
.getBoolean("browser_use", false)

if (!default) {
val intent = Intent(context, WebActivity::class.java)
intent.putExtra(Constants.URL, url)
context.startActivity(intent)
} else {
val uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
context.startActivity(intent)
}
}

fun jumpSetting(context: Context) {
val intent = Intent(context, SettingsActivity::class.java)
context.startActivity(intent)
}

fun jumpAbout(context: Context) {
val intent = Intent(context, AboutActivity::class.java)
context.startActivity(intent)
}
}
109 changes: 109 additions & 0 deletions app/src/main/java/com/lovejjfg/readhub/view/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
*
* Copyright (c) 2017. Joe
*
* 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.lovejjfg.readhub.view

import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.ViewGroup
import com.lovejjfg.powerrecycle.PowerAdapter
import com.lovejjfg.powerrecycle.holder.PowerHolder
import com.lovejjfg.readhub.R
import com.lovejjfg.readhub.data.Library
import com.lovejjfg.readhub.databinding.ActivityAboutBinding
import com.lovejjfg.readhub.databinding.HolderAboutInfoBinding
import com.lovejjfg.readhub.utils.JumpUitl
import java.util.*

/**
* ReadHub
* Created by Joe at 2017/9/5.
*/
class AboutActivity : AppCompatActivity() {
private var aboutAdapter: PowerAdapter<Library>? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val contentView = DataBindingUtil.setContentView<ActivityAboutBinding>(this, R.layout.activity_about)
contentView?.toolbar?.setNavigationOnClickListener({ finish() })
aboutAdapter = AboutAdapter()
val recyclerView = contentView?.recyclerView
recyclerView?.layoutManager = LinearLayoutManager(this)
aboutAdapter?.attachRecyclerView(recyclerView!!)
initData()
aboutAdapter?.setOnItemClickListener({ itemView, position, item ->
JumpUitl.jumpWeb(this, item.jumpUrl)
})
}

private fun initData() {
val libraries = ArrayList<Library>()
libraries.add(Library("Readhub",
"Readhub Android 客户端",
"https://github.com/lovejjfg/Readhub"))
libraries.add(Library("Android support libraries",
"The Android support libraries offer a number of features that are not built into the framework.",
"https://developer.android.com/topic/libraries/support-library"))
libraries.add(Library("OkHttp",
"An HTTP & HTTP/2 client for Android and Java applications.",
"http://square.github.io/okhttp/"))
libraries.add(Library("RxKotlin",
"RxJava bindings for Kotlin.",
"https://github.com/ReactiveX/RxKotlin"))
libraries.add(Library("PowerRecyclerView",
"Easy for RecyclerView to pull refresh and load more.",
"https://github.com/lovejjfg/PowerRecyclerView"))
libraries.add(Library("Retrofit",
"A type-safe HTTP client for Android and Java.",
"http://square.github.io/retrofit/"))
libraries.add(Library("RxAndroid",
"RxJava bindings for Android.",
"https://github.com/ReactiveX/RxAndroid"))
libraries.add(Library("RxJava",
"RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.",
"https://github.com/ReactiveX/RxJava"))
libraries.add(Library("Gson",
"A Java serialization/deserialization library to convert Java Objects into JSON and back",
"https://github.com/google/gson"))

aboutAdapter?.setList(libraries)

}


class AboutAdapter : PowerAdapter<Library>() {
override fun onViewHolderBind(holder: PowerHolder<Library>?, position: Int) {
holder?.onBind(list[position])
}

override fun onViewHolderCreate(parent: ViewGroup, viewType: Int): PowerHolder<Library>? {
val infoBinding = DataBindingUtil.inflate<HolderAboutInfoBinding>(LayoutInflater.from(parent.context), R.layout.holder_about_info, parent, false)
return AboutHolder(infoBinding)
}

}

class AboutHolder(itemView: HolderAboutInfoBinding) : PowerHolder<Library>(itemView.root) {
private var dataBind: HolderAboutInfoBinding? = itemView
override fun onBind(t: Library?) {
dataBind?.lib = t
}
}
}
Loading

0 comments on commit 865f257

Please sign in to comment.