-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
compileSdk 32 | ||
|
||
defaultConfig { | ||
applicationId "com.mewhpm.mewphotoprism" | ||
minSdk 26 | ||
targetSdk 32 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
apply plugin: 'kotlin-kapt' | ||
|
||
implementation 'androidx.core:core-ktx:1.8.0' | ||
implementation 'androidx.appcompat:appcompat:1.4.2' | ||
implementation 'com.google.android.material:material:1.6.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
|
||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2" | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2" | ||
|
||
implementation 'com.github.thegrizzlylabs:sardine-android:0.8' | ||
implementation 'com.google.code.gson:gson:2.9.0' | ||
|
||
implementation "androidx.room:room-runtime:2.4.2" | ||
kapt "androidx.room:room-compiler:2.4.2" | ||
|
||
implementation 'com.github.bumptech.glide:glide:3.7.0' | ||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0' | ||
implementation 'com.github.ybq:Android-SpinKit:1.4.0' | ||
|
||
// ICONS | ||
// implementation 'ru.ztrap.iconics:core-ktx:1.0.3' | ||
// implementation 'ru.ztrap.iconics:views-ktx:1.0.3' | ||
// implementation 'com.mikepenz:google-material-typeface:3.0.1.3.original@aar' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mewhpm.mewphotoprism | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.mewhpm.mewphotoprism", appContext.packageName) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.mewhpm.mewphotoprism"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
|
||
<application | ||
android:usesCleartextTraffic="true" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.MeWPhotoPrism" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<provider | ||
android:name="androidx.core.content.FileProvider" | ||
android:authorities="${applicationId}.provider" | ||
android:exported="false" | ||
android:grantUriPermissions="true"> | ||
<meta-data | ||
android:name="android.support.FILE_PROVIDER_PATHS" | ||
android:resource="@xml/provider_paths" /> | ||
</provider> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mewhpm.mewphotoprism | ||
|
||
import android.content.Context | ||
import androidx.room.Database | ||
import androidx.room.Room | ||
import androidx.room.RoomDatabase | ||
import com.mewhpm.mewphotoprism.dao.AccountsDAO | ||
import com.mewhpm.mewphotoprism.entity.AccountEntity | ||
|
||
@Database(entities = [AccountEntity::class], version = 1) | ||
abstract class AppDatabase : RoomDatabase() { | ||
abstract fun AccountsDAO() : AccountsDAO | ||
|
||
companion object { | ||
private var db : AppDatabase? = null | ||
@JvmStatic | ||
@Synchronized | ||
fun getDB(context: Context) : AppDatabase { | ||
if (db == null) { | ||
db = Room | ||
.databaseBuilder(context, AppDatabase::class.java, APP_DB_NAME) | ||
.allowMainThreadQueries() | ||
.build() | ||
} | ||
return db!! | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.mewhpm.mewphotoprism | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.Menu | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.mewhpm.mewphotoprism.fragments.AccountsFragment | ||
import com.mewhpm.mewphotoprism.fragments.ImageListFragment | ||
|
||
const val APP_DB_NAME = "mew-pp-database" | ||
const val SHARED_SETTINGS_NAME = "com.mewhpm.mewphotoprism" | ||
const val SHARED_SETTINGS_VAL_UID = "login-uid" | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val settings = getSharedPreferences(SHARED_SETTINGS_NAME, 0) | ||
val accountID = settings.getLong(SHARED_SETTINGS_VAL_UID, -1) | ||
if (accountID >= 0) { | ||
val db = AppDatabase.getDB(this.applicationContext) | ||
val account = db.AccountsDAO().getByUID(accountID) | ||
val transaction = supportFragmentManager.beginTransaction() | ||
transaction.replace(R.id.fragmentHost, ImageListFragment.newInstance(account), "MainFragment") | ||
transaction.commit() | ||
} else { | ||
val transaction = supportFragmentManager.beginTransaction() | ||
transaction.replace(R.id.fragmentHost, AccountsFragment.newInstance(), "MainFragment") | ||
transaction.commit() | ||
} | ||
} | ||
|
||
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | ||
return false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.mewhpm.mewphotoprism.adapters | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.mewhpm.mewphotoprism.R | ||
import com.mewhpm.mewphotoprism.entity.AccountEntity | ||
import com.mewhpm.mewphotoprism.view_holders.ListItemViewHolder | ||
|
||
const val ACTION_LONG_CLICK = 1 | ||
const val ACTION_SHORT_CLICK = 0 | ||
|
||
class AccountsListAdapter( | ||
private val accounts : List<AccountEntity>, | ||
private val onAction : (type : Int, position: Int, item : AccountEntity) -> Unit | ||
) : RecyclerView.Adapter<ListItemViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListItemViewHolder { | ||
val view: View = LayoutInflater | ||
.from(parent.context) | ||
.inflate(R.layout.layout_account_item, parent, false) | ||
return ListItemViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ListItemViewHolder, position: Int) { | ||
val item = accounts[position] | ||
holder.txtHeader.text = item.name | ||
holder.txtText.text = item.url | ||
holder.icon.setImageResource(R.drawable.icon_remote_gallery) | ||
holder.rootView.setOnClickListener { | ||
onAction.invoke(ACTION_SHORT_CLICK, position, item) | ||
} | ||
holder.rootView.setOnLongClickListener { | ||
onAction.invoke(ACTION_LONG_CLICK, position, item) | ||
return@setOnLongClickListener false | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return accounts.size | ||
} | ||
} |