-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt more parts from files app [WIP]
Signed-off-by: Tim Krüger <[email protected]>
- Loading branch information
1 parent
0b8c5c9
commit b434278
Showing
16 changed files
with
647 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/nextcloud/talk/adapters/PredefinedStatusClickListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* | ||
* Nextcloud Android client application | ||
* | ||
* @author Tobias Kaminsky | ||
* Copyright (C) 2020 Tobias Kaminsky | ||
* Copyright (C) 2020 Nextcloud GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.nextcloud.talk.adapters | ||
|
||
import com.nextcloud.talk.models.json.status.PredefinedStatus | ||
|
||
interface PredefinedStatusClickListener { | ||
fun onClick(predefinedStatus: PredefinedStatus) | ||
} |
50 changes: 50 additions & 0 deletions
50
app/src/main/java/com/nextcloud/talk/adapters/PredefinedStatusListAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* | ||
* Nextcloud Android client application | ||
* | ||
* @author Tobias Kaminsky | ||
* Copyright (C) 2020 Tobias Kaminsky | ||
* Copyright (C) 2020 Nextcloud GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.nextcloud.talk.adapters | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.nextcloud.talk.databinding.PredefinedStatusBinding | ||
import com.nextcloud.talk.models.json.status.PredefinedStatus | ||
|
||
class PredefinedStatusListAdapter( | ||
private val clickListener: PredefinedStatusClickListener, | ||
val context: Context | ||
) : RecyclerView.Adapter<PredefinedStatusViewHolder>() { | ||
internal var list: List<PredefinedStatus> = emptyList() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PredefinedStatusViewHolder { | ||
val itemBinding = PredefinedStatusBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return PredefinedStatusViewHolder(itemBinding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: PredefinedStatusViewHolder, position: Int) { | ||
holder.bind(list[position], clickListener, context) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return list.size | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/nextcloud/talk/adapters/PredefinedStatusViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* | ||
* Nextcloud Android client application | ||
* | ||
* @author Tobias Kaminsky | ||
* Copyright (C) 2020 Tobias Kaminsky | ||
* Copyright (C) 2020 Nextcloud GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.nextcloud.talk.adapters | ||
|
||
import android.content.Context | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.nextcloud.talk.R | ||
import com.nextcloud.talk.databinding.PredefinedStatusBinding | ||
import com.nextcloud.talk.models.json.status.PredefinedStatus | ||
import com.nextcloud.talk.utils.DisplayUtils | ||
|
||
private const val ONE_SECOND_IN_MILLIS = 1000 | ||
|
||
class PredefinedStatusViewHolder(private val binding: PredefinedStatusBinding) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(status: PredefinedStatus, clickListener: PredefinedStatusClickListener, context: Context) { | ||
binding.root.setOnClickListener { clickListener.onClick(status) } | ||
binding.icon.text = status.icon | ||
binding.name.text = status.message | ||
|
||
if (status.clearAt == null) { | ||
binding.clearAt.text = context.getString(R.string.dontClear) | ||
} else { | ||
val clearAt = status.clearAt!! | ||
if (clearAt.type.equals("period")) { | ||
binding.clearAt.text = DisplayUtils.getRelativeTimestamp( | ||
context, | ||
System.currentTimeMillis() + clearAt.time.toInt() * ONE_SECOND_IN_MILLIS, | ||
true | ||
) | ||
} else { | ||
// end-of | ||
if (clearAt.time.equals("day")) { | ||
binding.clearAt.text = context.getString(R.string.today) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/nextcloud/talk/models/json/status/ClearAt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.nextcloud.talk.models.json.status | ||
|
||
|
||
class ClearAt(val type: String, val time: String) |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/com/nextcloud/talk/models/json/status/PredefinedStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.nextcloud.talk.models.json.status | ||
|
||
class PredefinedStatus(val id: String, val icon: String, val message: String, val clearAt: ClearAt?) |
159 changes: 0 additions & 159 deletions
159
app/src/main/java/com/nextcloud/talk/models/json/status/Status.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.